toc-ocra 0.3.1 → 0.3.2
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/README.md +6 -0
- package/dist/cli/cli.mjs +3267 -1621
- package/dist/service/agent.mjs +3190 -1544
- package/dist/src/acp/agent-process.d.ts +34 -0
- package/dist/src/acp/agent-process.js +90 -0
- package/dist/src/acp/agent-process.js.map +1 -0
- package/dist/src/acp/chat-agents.d.ts +53 -0
- package/dist/src/acp/chat-agents.js +120 -0
- package/dist/src/acp/chat-agents.js.map +1 -0
- package/dist/src/acp/chat-forwarder.d.ts +30 -0
- package/dist/src/acp/chat-forwarder.js +101 -0
- package/dist/src/acp/chat-forwarder.js.map +1 -0
- package/dist/src/acp/chat-host.d.ts +28 -0
- package/dist/src/acp/chat-host.js +102 -0
- package/dist/src/acp/chat-host.js.map +1 -0
- package/dist/src/acp/chat-session.d.ts +112 -0
- package/dist/src/acp/chat-session.js +465 -0
- package/dist/src/acp/chat-session.js.map +1 -0
- package/dist/src/acp/connection.d.ts +77 -0
- package/dist/src/acp/connection.js +204 -0
- package/dist/src/acp/connection.js.map +1 -0
- package/dist/src/acp/rpc.d.ts +40 -0
- package/dist/src/acp/rpc.js +137 -0
- package/dist/src/acp/rpc.js.map +1 -0
- package/dist/src/acp/transcript.d.ts +39 -0
- package/dist/src/acp/transcript.js +273 -0
- package/dist/src/acp/transcript.js.map +1 -0
- package/dist/src/acp/vendor.d.ts +21 -0
- package/dist/src/acp/vendor.js +137 -0
- package/dist/src/acp/vendor.js.map +1 -0
- package/dist/src/providers/acp/acp-agents.d.ts +9 -0
- package/dist/src/providers/acp/acp-agents.js +8 -8
- package/dist/src/providers/acp/acp-agents.js.map +1 -1
- package/dist/src/providers/acp/acp-driver.d.ts +1 -1
- package/dist/src/providers/acp/acp-driver.js +9 -3
- package/dist/src/providers/acp/acp-driver.js.map +1 -1
- package/dist/src/providers/chat/codex-app-server.js +5 -3
- package/dist/src/providers/chat/codex-app-server.js.map +1 -1
- package/dist/src/providers/chat/codex-goal.js +5 -6
- package/dist/src/providers/chat/codex-goal.js.map +1 -1
- package/dist/src/providers/cli/claude.js +19 -5
- package/dist/src/providers/cli/claude.js.map +1 -1
- package/dist/src/providers/cli/codex.d.ts +12 -1
- package/dist/src/providers/cli/codex.js +33 -2
- package/dist/src/providers/cli/codex.js.map +1 -1
- package/dist/src/providers/cli/kiro.js +3 -2
- package/dist/src/providers/cli/kiro.js.map +1 -1
- package/dist/src/providers/provider.d.ts +29 -0
- package/dist/src/providers/provider.js +19 -0
- package/dist/src/providers/provider.js.map +1 -1
- package/dist/src/providers/registry.d.ts +6 -1
- package/dist/src/providers/registry.js +24 -8
- package/dist/src/providers/registry.js.map +1 -1
- package/dist/src/runs/run-supervisor.d.ts +41 -0
- package/dist/src/runs/run-supervisor.js +229 -40
- package/dist/src/runs/run-supervisor.js.map +1 -1
- package/dist/src/runtime/agent-runtime.js +17 -2
- package/dist/src/runtime/agent-runtime.js.map +1 -1
- package/dist/src/session/terminal-line-sanitizer.d.ts +5 -0
- package/dist/src/session/terminal-line-sanitizer.js +18 -0
- package/dist/src/session/terminal-line-sanitizer.js.map +1 -1
- package/dist/src/types/protocol.d.ts +9 -0
- package/dist/src/types/protocol.js +16 -0
- package/dist/src/types/protocol.js.map +1 -1
- package/package.json +4 -2
- package/vendor/acp/claude/LICENSE +191 -0
- package/vendor/acp/claude/index.mjs +167 -0
- package/vendor/acp/claude/runtime.json +7 -0
- package/vendor/acp/codex/LICENSE +190 -0
- package/vendor/acp/codex/index.mjs +158 -0
- package/vendor/acp/codex/runtime.json +3 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire as hI}from"module";import{spawn as Op}from"node:child_process";import{createRequire as UI}from"node:module";import{readFileSync as jI,writeFileSync as LI}from"node:fs";import xl from"node:path";import{StringDecoder as qI}from"node:string_decoder";import{finished as ZI,Readable as WI}from"node:stream";import xm from"node:fs";import rP from"node:path";import{randomUUID as K8}from"node:crypto";import*as Ob from"node:path";import{randomUUID as R2}from"node:crypto";import{randomUUID as O2}from"node:crypto";import Eg from"node:path";import{AsyncLocalStorage as Qz}from"node:async_hooks";import zS from"node:fs";import Qe from"node:path";import ec from"node:path";import{pathToFileURL as ZO}from"node:url";import{randomUUID as $N}from"node:crypto";import{randomUUID as PN}from"node:crypto";import{realpath as NN}from"node:fs/promises";import Ad from"node:path";import{createHash as UN}from"node:crypto";import{realpath as jN}from"node:fs/promises";import Cp from"node:path";import iD from"node:process";import yp from"node:path";import{fileURLToPath as WN}from"node:url";import GN from"node:child_process";import VN,{constants as HN}from"node:fs/promises";import JN from"node:path";import{promisify as KN}from"node:util";import XN from"node:child_process";import bd,{constants as uD}from"node:fs/promises";import sD from"node:process";import YN from"node:os";import lc from"node:fs";import QN from"node:fs";import oD from"node:fs";import Qg from"node:process";import{Buffer as iM}from"node:buffer";import{promisify as uM}from"node:util";import sM from"node:child_process";import{promisify as yM}from"node:util";import hc from"node:process";import{execFile as EM}from"node:child_process";import{promisify as wM}from"node:util";import _M from"node:process";import{execFile as AM}from"node:child_process";import DM from"node:process";import{promisify as IM}from"node:util";import{execFile as $M}from"node:child_process";import t4 from"node:process";import{promisify as FM}from"node:util";import{execFile as PM}from"node:child_process";import fc from"node:process";import Dd from"node:path";import Qr from"node:path";import{createHash as XM}from"node:crypto";import{statSync as h4}from"node:fs";import{readFile as Rj}from"node:fs/promises";import D4 from"node:path";import{types as T4}from"node:util";import{randomUUID as wc}from"node:crypto";import GL from"node:path";import wt from"node:fs";import he from"node:path";import Rq from"node:fs/promises";import{randomUUID as jq}from"node:crypto";import Lq from"node:path";import gn from"node:fs";import Zr from"node:path";import to from"node:fs";import qq from"node:path";import{spawn as wv}from"node:child_process";import{createRequire as xZ}from"node:module";var Rr=hI(import.meta.url),fI=Object.create,Kd=Object.defineProperty,pI=Object.getOwnPropertyDescriptor,$v=Object.getOwnPropertyNames,mI=Object.getPrototypeOf,gI=Object.prototype.hasOwnProperty,Ct=(e=>typeof Rr<"u"?Rr:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof Rr<"u"?Rr:t)[n]}):e)(function(e){if(typeof Rr<"u")return Rr.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),we=(e,t)=>function(){try{return t||(0,e[$v(e)[0]])((t={exports:{}}).exports,t),t.exports}catch(i){throw t=0,i}},bn=(e,t)=>{for(var n in t)Kd(e,n,{get:t[n],enumerable:!0})},vI=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of $v(t))!gI.call(e,r)&&r!==n&&Kd(e,r,{get:()=>t[r],enumerable:!(i=pI(t,r))||i.enumerable});return e},Sn=(e,t,n)=>(n=e!=null?fI(mI(e)):{},vI(t||!e||!e.__esModule?Kd(n,"default",{value:e,enumerable:!0}):n,e)),yu=we({"node_modules/vscode-jsonrpc/lib/common/is.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.boolean=t,e.string=n,e.number=i,e.error=r,e.func=u,e.array=s,e.stringArray=o;function t(a){return a===!0||a===!1}function n(a){return typeof a=="string"||a instanceof String}function i(a){return typeof a=="number"||a instanceof Number}function r(a){return a instanceof Error}function u(a){return typeof a=="function"}function s(a){return Array.isArray(a)}function o(a){return s(a)&&a.every(l=>n(l))}}}),Bv=we({"node_modules/vscode-jsonrpc/lib/common/messages.js"(e){"use strict";var t=e&&e.__createBinding||(Object.create?(function(x,$,P,N){N===void 0&&(N=P);var F=Object.getOwnPropertyDescriptor($,P);(!F||("get"in F?!$.__esModule:F.writable||F.configurable))&&(F={enumerable:!0,get:function(){return $[P]}}),Object.defineProperty(x,N,F)}):(function(x,$,P,N){N===void 0&&(N=P),x[N]=$[P]})),n=e&&e.__setModuleDefault||(Object.create?(function(x,$){Object.defineProperty(x,"default",{enumerable:!0,value:$})}):function(x,$){x.default=$}),i=e&&e.__importStar||(function(){var x=function($){return x=Object.getOwnPropertyNames||function(P){var N=[];for(var F in P)Object.prototype.hasOwnProperty.call(P,F)&&(N[N.length]=F);return N},x($)};return function($){if($&&$.__esModule)return $;var P={};if($!=null)for(var N=x($),F=0;F<N.length;F++)N[F]!=="default"&&t(P,$,N[F]);return n(P,$),P}})();Object.defineProperty(e,"__esModule",{value:!0}),e.Message=e.NotificationType9=e.NotificationType8=e.NotificationType7=e.NotificationType6=e.NotificationType5=e.NotificationType4=e.NotificationType3=e.NotificationType2=e.NotificationType1=e.NotificationType0=e.NotificationType=e.RequestType9=e.RequestType8=e.RequestType7=e.RequestType6=e.RequestType5=e.RequestType4=e.RequestType3=e.RequestType2=e.RequestType1=e.RequestType=e.RequestType0=e.AbstractMessageSignature=e.ParameterStructures=e.ResponseError=e.ErrorCodes=void 0;var r=i(yu()),u;(function(x){x.ParseError=-32700,x.InvalidRequest=-32600,x.MethodNotFound=-32601,x.InvalidParams=-32602,x.InternalError=-32603,x.jsonrpcReservedErrorRangeStart=-32099,x.serverErrorStart=-32099,x.MessageWriteError=-32099,x.MessageReadError=-32098,x.PendingResponseRejected=-32097,x.ConnectionInactive=-32096,x.ServerNotInitialized=-32002,x.UnknownErrorCode=-32001,x.jsonrpcReservedErrorRangeEnd=-32e3,x.serverErrorEnd=-32e3})(u||(e.ErrorCodes=u={}));var s=class kv extends Error{code;data;constructor($,P,N){super(P),this.code=r.number($)?$:u.UnknownErrorCode,this.data=N,Object.setPrototypeOf(this,kv.prototype)}toJson(){let $={code:this.code,message:this.message};return this.data!==void 0&&($.data=this.data),$}};e.ResponseError=s;var o=class sr{kind;static auto=new sr("auto");static byPosition=new sr("byPosition");static byName=new sr("byName");constructor($){this.kind=$}static is($){return $===sr.auto||$===sr.byName||$===sr.byPosition}toString(){return this.kind}};e.ParameterStructures=o;var a=class{method;numberOfParams;constructor(x,$){this.method=x,this.numberOfParams=$}get parameterStructures(){return o.auto}};e.AbstractMessageSignature=a;var l=class extends a{_;constructor(x){super(x,0)}};e.RequestType0=l;var c=class extends a{_parameterStructures;_;constructor(x,$=o.auto){super(x,1),this._parameterStructures=$}get parameterStructures(){return this._parameterStructures}};e.RequestType=c;var m=class extends a{_parameterStructures;_;constructor(x,$=o.auto){super(x,1),this._parameterStructures=$}get parameterStructures(){return this._parameterStructures}};e.RequestType1=m;var p=class extends a{_;constructor(x){super(x,2)}};e.RequestType2=p;var v=class extends a{_;constructor(x){super(x,3)}};e.RequestType3=v;var g=class extends a{_;constructor(x){super(x,4)}};e.RequestType4=g;var C=class extends a{_;constructor(x){super(x,5)}};e.RequestType5=C;var y=class extends a{_;constructor(x){super(x,6)}};e.RequestType6=y;var b=class extends a{_;constructor(x){super(x,7)}};e.RequestType7=b;var A=class extends a{_;constructor(x){super(x,8)}};e.RequestType8=A;var S=class extends a{_;constructor(x){super(x,9)}};e.RequestType9=S;var z=class extends a{_parameterStructures;_;constructor(x,$=o.auto){super(x,1),this._parameterStructures=$}get parameterStructures(){return this._parameterStructures}};e.NotificationType=z;var M=class extends a{_;constructor(x){super(x,0)}};e.NotificationType0=M;var T=class extends a{_parameterStructures;_;constructor(x,$=o.auto){super(x,1),this._parameterStructures=$}get parameterStructures(){return this._parameterStructures}};e.NotificationType1=T;var G=class extends a{_;constructor(x){super(x,2)}};e.NotificationType2=G;var re=class extends a{_;constructor(x){super(x,3)}};e.NotificationType3=re;var Z=class extends a{_;constructor(x){super(x,4)}};e.NotificationType4=Z;var oe=class extends a{_;constructor(x){super(x,5)}};e.NotificationType5=oe;var te=class extends a{_;constructor(x){super(x,6)}};e.NotificationType6=te;var ye=class extends a{_;constructor(x){super(x,7)}};e.NotificationType7=ye;var Ne=class extends a{_;constructor(x){super(x,8)}};e.NotificationType8=Ne;var At=class extends a{_;constructor(x){super(x,9)}};e.NotificationType9=At;var j;(function(x){function $(F){let H=F;return H&&r.string(H.method)&&(r.string(H.id)||r.number(H.id))}x.isRequest=$;function P(F){let H=F;return H&&r.string(H.method)&&F.id===void 0}x.isNotification=P;function N(F){let H=F;return H&&(H.result!==void 0||!!H.error)&&(r.string(H.id)||r.number(H.id)||H.id===null)}x.isResponse=N})(j||(e.Message=j={}))}}),xv=we({"node_modules/vscode-jsonrpc/lib/common/linkedMap.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LRUCache=e.LinkedMap=e.Touch=void 0;var t;(function(r){r.None=0,r.First=1,r.AsOld=r.First,r.Last=2,r.AsNew=r.Last})(t||(e.Touch=t={}));var n=class{[Symbol.toStringTag]="LinkedMap";_map;_head;_tail;_size;_state;constructor(){this._map=new Map,this._head=void 0,this._tail=void 0,this._size=0,this._state=0}clear(){this._map.clear(),this._head=void 0,this._tail=void 0,this._size=0,this._state++}isEmpty(){return!this._head&&!this._tail}get size(){return this._size}get first(){return this._head?.value}get last(){return this._tail?.value}before(r){let u=this._map.get(r);return u?u.previous?.value:void 0}after(r){let u=this._map.get(r);return u?u.next?.value:void 0}has(r){return this._map.has(r)}get(r,u=t.None){let s=this._map.get(r);if(s)return u!==t.None&&this.touch(s,u),s.value}set(r,u,s=t.None){let o=this._map.get(r);if(o)o.value=u,s!==t.None&&this.touch(o,s);else{switch(o={key:r,value:u,next:void 0,previous:void 0},s){case t.None:this.addItemLast(o);break;case t.First:this.addItemFirst(o);break;case t.Last:this.addItemLast(o);break;default:this.addItemLast(o);break}this._map.set(r,o),this._size++}return this}delete(r){return!!this.remove(r)}remove(r){let u=this._map.get(r);if(u)return this._map.delete(r),this.removeItem(u),this._size--,u.value}shift(){if(!this._head&&!this._tail)return;if(!this._head||!this._tail)throw new Error("Invalid list");let r=this._head;return this._map.delete(r.key),this.removeItem(r),this._size--,r.value}forEach(r,u){let s=this._state,o=this._head;for(;o;){if(u?r.bind(u)(o.value,o.key,this):r(o.value,o.key,this),this._state!==s)throw new Error("LinkedMap got modified during iteration.");o=o.next}}keys(){let r=this._state,u=this._head,s={[Symbol.iterator]:()=>s,next:()=>{if(this._state!==r)throw new Error("LinkedMap got modified during iteration.");if(u){let o={value:u.key,done:!1};return u=u.next,o}else return{value:void 0,done:!0}}};return s}values(){let r=this._state,u=this._head,s={[Symbol.iterator]:()=>s,next:()=>{if(this._state!==r)throw new Error("LinkedMap got modified during iteration.");if(u){let o={value:u.value,done:!1};return u=u.next,o}else return{value:void 0,done:!0}}};return s}entries(){let r=this._state,u=this._head,s={[Symbol.iterator]:()=>s,next:()=>{if(this._state!==r)throw new Error("LinkedMap got modified during iteration.");if(u){let o={value:[u.key,u.value],done:!1};return u=u.next,o}else return{value:void 0,done:!0}}};return s}[Symbol.iterator](){return this.entries()}trimOld(r){if(r>=this.size)return;if(r===0){this.clear();return}let u=this._head,s=this.size;for(;u&&s>r;)this._map.delete(u.key),u=u.next,s--;this._head=u,this._size=s,u&&(u.previous=void 0),this._state++}addItemFirst(r){if(!this._head&&!this._tail)this._tail=r;else if(this._head)r.next=this._head,this._head.previous=r;else throw new Error("Invalid list");this._head=r,this._state++}addItemLast(r){if(!this._head&&!this._tail)this._head=r;else if(this._tail)r.previous=this._tail,this._tail.next=r;else throw new Error("Invalid list");this._tail=r,this._state++}removeItem(r){if(r===this._head&&r===this._tail)this._head=void 0,this._tail=void 0;else if(r===this._head){if(!r.next)throw new Error("Invalid list");r.next.previous=void 0,this._head=r.next}else if(r===this._tail){if(!r.previous)throw new Error("Invalid list");r.previous.next=void 0,this._tail=r.previous}else{let u=r.next,s=r.previous;if(!u||!s)throw new Error("Invalid list");u.previous=s,s.next=u}r.next=void 0,r.previous=void 0,this._state++}touch(r,u){if(!this._head||!this._tail)throw new Error("Invalid list");if(!(u!==t.First&&u!==t.Last)){if(u===t.First){if(r===this._head)return;let s=r.next,o=r.previous;r===this._tail?(o.next=void 0,this._tail=o):(s.previous=o,o.next=s),r.previous=void 0,r.next=this._head,this._head.previous=r,this._head=r,this._state++}else if(u===t.Last){if(r===this._tail)return;let s=r.next,o=r.previous;r===this._head?(s.previous=void 0,this._head=s):(s.previous=o,o.next=s),r.next=void 0,r.previous=this._tail,this._tail.next=r,this._tail=r,this._state++}}}toJSON(){let r=[];return this.forEach((u,s)=>{r.push([s,u])}),r}fromJSON(r){this.clear();for(let[u,s]of r)this.set(u,s)}};e.LinkedMap=n;var i=class extends n{_limit;_ratio;constructor(r,u=1){super(),this._limit=r,this._ratio=Math.min(Math.max(0,u),1)}get limit(){return this._limit}set limit(r){this._limit=r,this.checkTrim()}get ratio(){return this._ratio}set ratio(r){this._ratio=Math.min(Math.max(0,r),1),this.checkTrim()}get(r,u=t.AsNew){return super.get(r,u)}peek(r){return super.get(r,t.None)}set(r,u){return super.set(r,u,t.Last),this.checkTrim(),this}checkTrim(){this.size>this._limit&&this.trimOld(Math.round(this._limit*this._ratio))}};e.LRUCache=i}}),CI=we({"node_modules/vscode-jsonrpc/lib/common/disposable.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Disposable=void 0;var t;(function(n){function i(r){return{dispose:r}}n.create=i})(t||(e.Disposable=t={}))}}),br=we({"node_modules/vscode-jsonrpc/lib/common/ral.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t;function n(){if(t===void 0)throw new Error("No runtime abstraction layer installed");return t}(function(i){function r(u){if(u===void 0)throw new Error("No runtime abstraction layer provided");t=u}i.install=r})(n||(n={})),e.default=n}}),Eu=we({"node_modules/vscode-jsonrpc/lib/common/events.js"(e){"use strict";var t=e&&e.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(e,"__esModule",{value:!0}),e.Emitter=e.Event=void 0;var n=t(br()),i;(function(s){let o={dispose(){}};s.None=function(){return o}})(i||(e.Event=i={}));var r=class{_callbacks;_contexts;add(s,o=null,a){this._callbacks||(this._callbacks=[],this._contexts=[]),this._callbacks.push(s),this._contexts.push(o),Array.isArray(a)&&a.push({dispose:()=>this.remove(s,o)})}remove(s,o=null){if(!this._callbacks)return;let a=!1;for(let l=0,c=this._callbacks.length;l<c;l++)if(this._callbacks[l]===s)if(this._contexts[l]===o){this._callbacks.splice(l,1),this._contexts.splice(l,1);return}else a=!0;if(a)throw new Error("When adding a listener with a context, you should remove it with the same context")}invoke(...s){if(!this._callbacks)return[];let o=[],a=this._callbacks.slice(0),l=this._contexts.slice(0);for(let c=0,m=a.length;c<m;c++)try{o.push(a[c].apply(l[c],s))}catch(p){(0,n.default)().console.error(p)}return o}isEmpty(){return!this._callbacks||this._callbacks.length===0}dispose(){this._callbacks=void 0,this._contexts=void 0}},u=class Tv{_options;static _noop=function(){};_event;_callbacks;constructor(o){this._options=o}get event(){return this._event||(this._event=(o,a,l)=>{this._callbacks||(this._callbacks=new r),this._options&&this._options.onFirstListenerAdd&&this._callbacks.isEmpty()&&this._options.onFirstListenerAdd(this),this._callbacks.add(o,a);let c={dispose:()=>{this._callbacks&&(this._callbacks.remove(o,a),c.dispose=Tv._noop,this._options&&this._options.onLastListenerRemove&&this._callbacks.isEmpty()&&this._options.onLastListenerRemove(this))}};return Array.isArray(l)&&l.push(c),c}),this._event}fire(o){this._callbacks&&this._callbacks.invoke.call(this._callbacks,o)}dispose(){this._callbacks&&(this._callbacks.dispose(),this._callbacks=void 0)}};e.Emitter=u}}),Xd=we({"node_modules/vscode-jsonrpc/lib/common/cancellation.js"(e){"use strict";var t=e&&e.__createBinding||(Object.create?(function(p,v,g,C){C===void 0&&(C=g);var y=Object.getOwnPropertyDescriptor(v,g);(!y||("get"in y?!v.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return v[g]}}),Object.defineProperty(p,C,y)}):(function(p,v,g,C){C===void 0&&(C=g),p[C]=v[g]})),n=e&&e.__setModuleDefault||(Object.create?(function(p,v){Object.defineProperty(p,"default",{enumerable:!0,value:v})}):function(p,v){p.default=v}),i=e&&e.__importStar||(function(){var p=function(v){return p=Object.getOwnPropertyNames||function(g){var C=[];for(var y in g)Object.prototype.hasOwnProperty.call(g,y)&&(C[C.length]=y);return C},p(v)};return function(v){if(v&&v.__esModule)return v;var g={};if(v!=null)for(var C=p(v),y=0;y<C.length;y++)C[y]!=="default"&&t(g,v,C[y]);return n(g,v),g}})(),r=e&&e.__importDefault||function(p){return p&&p.__esModule?p:{default:p}};Object.defineProperty(e,"__esModule",{value:!0}),e.CancellationTokenSource=e.CancellationToken=void 0;var u=r(br()),s=i(yu()),o=Eu(),a;(function(p){p.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:o.Event.None}),p.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:o.Event.None});function v(g){let C=g;return C&&(C===p.None||C===p.Cancelled||s.boolean(C.isCancellationRequested)&&!!C.onCancellationRequested)}p.is=v})(a||(e.CancellationToken=a={}));var l=Object.freeze(function(p,v){let g=(0,u.default)().timer.setTimeout(p.bind(v),0);return{dispose(){g.dispose()}}}),c=class{_isCancelled=!1;_emitter;cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?l:(this._emitter||(this._emitter=new o.Emitter),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=void 0)}},m=class{_token;get token(){return this._token||(this._token=new c),this._token}cancel(){this._token?this._token.cancel():this._token=a.Cancelled}dispose(){this._token?this._token instanceof c&&this._token.dispose():this._token=a.None}};e.CancellationTokenSource=m}}),yI=we({"node_modules/vscode-jsonrpc/lib/common/sharedArrayCancellation.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SharedArrayReceiverStrategy=e.SharedArraySenderStrategy=void 0;var t=Xd(),n;(function(o){o.Continue=0,o.Cancelled=1})(n||(n={}));var i=class{buffers;constructor(){this.buffers=new Map}enableCancellation(o){if(o.id===null)return;let a=new SharedArrayBuffer(4),l=new Int32Array(a,0,1);l[0]=n.Continue,this.buffers.set(o.id,a),o.$cancellationData=a}async sendCancellation(o,a){let l=this.buffers.get(a);if(l===void 0)return;let c=new Int32Array(l,0,1);Atomics.store(c,0,n.Cancelled)}cleanup(o){this.buffers.delete(o)}dispose(){this.buffers.clear()}};e.SharedArraySenderStrategy=i;var r=class{data;constructor(o){this.data=new Int32Array(o,0,1)}get isCancellationRequested(){return Atomics.load(this.data,0)===n.Cancelled}get onCancellationRequested(){throw new Error("Cancellation over SharedArrayBuffer doesn't support cancellation events")}},u=class{token;constructor(o){this.token=new r(o)}cancel(){}dispose(){}},s=class{kind="request";createCancellationTokenSource(o){let a=o.$cancellationData;return a===void 0?new t.CancellationTokenSource:new u(a)}};e.SharedArrayReceiverStrategy=s}}),Fv=we({"node_modules/vscode-jsonrpc/lib/common/semaphore.js"(e){"use strict";var t=e&&e.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(e,"__esModule",{value:!0}),e.Semaphore=void 0;var n=t(br()),i=class{_capacity;_active;_waiting;constructor(r=1){if(r<=0)throw new Error("Capacity must be greater than 0");this._capacity=r,this._active=0,this._waiting=[]}lock(r){return new Promise((u,s)=>{this._waiting.push({thunk:r,resolve:u,reject:s}),this.runNext()})}get active(){return this._active}runNext(){this._waiting.length===0||this._active===this._capacity||(0,n.default)().timer.setImmediate(()=>this.doRunNext())}doRunNext(){if(this._waiting.length===0||this._active===this._capacity)return;let r=this._waiting.shift();if(this._active++,this._active>this._capacity)throw new Error("Too many thunks active");try{let u=r.thunk();u instanceof Promise?u.then(s=>{this._active--,r.resolve(s),this.runNext()},s=>{this._active--,r.reject(s),this.runNext()}):(this._active--,r.resolve(u),this.runNext())}catch(u){this._active--,r.reject(u),this.runNext()}}};e.Semaphore=i}}),EI=we({"node_modules/vscode-jsonrpc/lib/common/messageReader.js"(e){"use strict";var t=e&&e.__createBinding||(Object.create?(function(v,g,C,y){y===void 0&&(y=C);var b=Object.getOwnPropertyDescriptor(g,C);(!b||("get"in b?!g.__esModule:b.writable||b.configurable))&&(b={enumerable:!0,get:function(){return g[C]}}),Object.defineProperty(v,y,b)}):(function(v,g,C,y){y===void 0&&(y=C),v[y]=g[C]})),n=e&&e.__setModuleDefault||(Object.create?(function(v,g){Object.defineProperty(v,"default",{enumerable:!0,value:g})}):function(v,g){v.default=g}),i=e&&e.__importStar||(function(){var v=function(g){return v=Object.getOwnPropertyNames||function(C){var y=[];for(var b in C)Object.prototype.hasOwnProperty.call(C,b)&&(y[y.length]=b);return y},v(g)};return function(g){if(g&&g.__esModule)return g;var C={};if(g!=null)for(var y=v(g),b=0;b<y.length;b++)y[b]!=="default"&&t(C,g,y[b]);return n(C,g),C}})(),r=e&&e.__importDefault||function(v){return v&&v.__esModule?v:{default:v}};Object.defineProperty(e,"__esModule",{value:!0}),e.ReadableStreamMessageReader=e.AbstractMessageReader=e.MessageReader=void 0;var u=r(br()),s=i(yu()),o=Eu(),a=Fv(),l;(function(v){function g(C){let y=C;return y&&s.func(y.listen)&&s.func(y.dispose)&&s.func(y.onError)&&s.func(y.onClose)&&s.func(y.onPartialMessage)}v.is=g})(l||(e.MessageReader=l={}));var c=class{errorEmitter;closeEmitter;partialMessageEmitter;constructor(){this.errorEmitter=new o.Emitter,this.closeEmitter=new o.Emitter,this.partialMessageEmitter=new o.Emitter}dispose(){this.errorEmitter.dispose(),this.closeEmitter.dispose(),this.partialMessageEmitter.dispose()}get onError(){return this.errorEmitter.event}fireError(v){this.errorEmitter.fire(this.asError(v))}get onClose(){return this.closeEmitter.event}fireClose(){this.closeEmitter.fire(void 0)}get onPartialMessage(){return this.partialMessageEmitter.event}firePartialMessage(v){this.partialMessageEmitter.fire(v)}asError(v){return v instanceof Error?v:new Error(`Reader received error. Reason: ${s.string(v.message)?v.message:"unknown"}`)}};e.AbstractMessageReader=c;var m;(function(v){function g(C){let y,b,A,S=new Map,z,M=new Map;if(C===void 0||typeof C=="string")y=C??"utf-8";else{if(y=C.charset??"utf-8",C.contentDecoder!==void 0&&(A=C.contentDecoder,S.set(A.name,A)),C.contentDecoders!==void 0)for(let T of C.contentDecoders)S.set(T.name,T);if(C.contentTypeDecoder!==void 0&&(z=C.contentTypeDecoder,M.set(z.name,z)),C.contentTypeDecoders!==void 0)for(let T of C.contentTypeDecoders)M.set(T.name,T)}return z===void 0&&(z=(0,u.default)().applicationJson.decoder,M.set(z.name,z)),{charset:y,contentDecoder:A,contentDecoders:S,contentTypeDecoder:z,contentTypeDecoders:M}}v.fromOptions=g})(m||(m={}));var p=class extends c{readable;options;callback;nextMessageLength;messageToken;buffer;partialMessageTimer;_partialMessageTimeout;readSemaphore;constructor(v,g){super(),this.readable=v,this.options=m.fromOptions(g),this.buffer=(0,u.default)().messageBuffer.create(this.options.charset),this._partialMessageTimeout=1e4,this.nextMessageLength=-1,this.messageToken=0,this.readSemaphore=new a.Semaphore(1)}set partialMessageTimeout(v){this._partialMessageTimeout=v}get partialMessageTimeout(){return this._partialMessageTimeout}listen(v){this.nextMessageLength=-1,this.messageToken=0,this.partialMessageTimer=void 0,this.callback=v;let g=this.readable.onData(C=>{this.onData(C)});return this.readable.onError(C=>this.fireError(C)),this.readable.onClose(()=>this.fireClose()),g}onData(v){try{for(this.buffer.append(v);;){if(this.nextMessageLength===-1){let C=this.buffer.tryReadHeaders(!0);if(!C)return;let y=C.get("content-length");if(!y){this.fireError(new Error(`Header must provide a Content-Length property.
|
|
3
|
+
${JSON.stringify(Object.fromEntries(C))}`));return}let b=parseInt(y);if(isNaN(b)){this.fireError(new Error(`Content-Length value must be a number. Got ${y}`));return}this.nextMessageLength=b}let g=this.buffer.tryReadBody(this.nextMessageLength);if(g===void 0){this.setPartialMessageTimer();return}this.clearPartialMessageTimer(),this.nextMessageLength=-1,this.readSemaphore.lock(async()=>{let C=this.options.contentDecoder!==void 0?await this.options.contentDecoder.decode(g):g,y=await this.options.contentTypeDecoder.decode(C,this.options);this.callback(y)}).catch(C=>{this.fireError(C)})}}catch(g){this.fireError(g)}}clearPartialMessageTimer(){this.partialMessageTimer&&(this.partialMessageTimer.dispose(),this.partialMessageTimer=void 0)}setPartialMessageTimer(){this.clearPartialMessageTimer(),!(this._partialMessageTimeout<=0)&&(this.partialMessageTimer=(0,u.default)().timer.setTimeout((v,g)=>{this.partialMessageTimer=void 0,v===this.messageToken&&(this.firePartialMessage({messageToken:v,waitingTime:g}),this.setPartialMessageTimer())},this._partialMessageTimeout,this.messageToken,this._partialMessageTimeout))}};e.ReadableStreamMessageReader=p}}),wI=we({"node_modules/vscode-jsonrpc/lib/common/messageWriter.js"(e){"use strict";var t=e&&e.__createBinding||(Object.create?(function(C,y,b,A){A===void 0&&(A=b);var S=Object.getOwnPropertyDescriptor(y,b);(!S||("get"in S?!y.__esModule:S.writable||S.configurable))&&(S={enumerable:!0,get:function(){return y[b]}}),Object.defineProperty(C,A,S)}):(function(C,y,b,A){A===void 0&&(A=b),C[A]=y[b]})),n=e&&e.__setModuleDefault||(Object.create?(function(C,y){Object.defineProperty(C,"default",{enumerable:!0,value:y})}):function(C,y){C.default=y}),i=e&&e.__importStar||(function(){var C=function(y){return C=Object.getOwnPropertyNames||function(b){var A=[];for(var S in b)Object.prototype.hasOwnProperty.call(b,S)&&(A[A.length]=S);return A},C(y)};return function(y){if(y&&y.__esModule)return y;var b={};if(y!=null)for(var A=C(y),S=0;S<A.length;S++)A[S]!=="default"&&t(b,y,A[S]);return n(b,y),b}})(),r=e&&e.__importDefault||function(C){return C&&C.__esModule?C:{default:C}};Object.defineProperty(e,"__esModule",{value:!0}),e.WriteableStreamMessageWriter=e.AbstractMessageWriter=e.MessageWriter=void 0;var u=r(br()),s=i(yu()),o=Fv(),a=Eu(),l="Content-Length: ",c=`\r
|
|
4
|
+
`,m;(function(C){function y(b){let A=b;return A&&s.func(A.dispose)&&s.func(A.onClose)&&s.func(A.onError)&&s.func(A.write)}C.is=y})(m||(e.MessageWriter=m={}));var p=class{errorEmitter;closeEmitter;constructor(){this.errorEmitter=new a.Emitter,this.closeEmitter=new a.Emitter}dispose(){this.errorEmitter.dispose(),this.closeEmitter.dispose()}get onError(){return this.errorEmitter.event}fireError(C,y,b){this.errorEmitter.fire([this.asError(C),y,b])}get onClose(){return this.closeEmitter.event}fireClose(){this.closeEmitter.fire(void 0)}asError(C){return C instanceof Error?C:new Error(`Writer received error. Reason: ${s.string(C.message)?C.message:"unknown"}`)}};e.AbstractMessageWriter=p;var v;(function(C){function y(b){return b===void 0||typeof b=="string"?{charset:b??"utf-8",contentTypeEncoder:(0,u.default)().applicationJson.encoder}:{charset:b.charset??"utf-8",contentEncoder:b.contentEncoder,contentTypeEncoder:b.contentTypeEncoder??(0,u.default)().applicationJson.encoder}}C.fromOptions=y})(v||(v={}));var g=class extends p{writable;options;errorCount;writeSemaphore;constructor(C,y){super(),this.writable=C,this.options=v.fromOptions(y),this.errorCount=0,this.writeSemaphore=new o.Semaphore(1),this.writable.onError(b=>this.fireError(b)),this.writable.onClose(()=>this.fireClose())}async write(C){return this.writeSemaphore.lock(async()=>this.options.contentTypeEncoder.encode(C,this.options).then(b=>this.options.contentEncoder!==void 0?this.options.contentEncoder.encode(b):b).then(b=>{let A=[];return A.push(l,b.byteLength.toString(),c),A.push(c),this.doWrite(C,A,b)},b=>{throw this.fireError(b),b}))}async doWrite(C,y,b){try{return await this.writable.write(y.join(""),"ascii"),this.writable.write(b)}catch(A){return this.handleError(A,C),Promise.reject(A)}}handleError(C,y){this.errorCount++,this.fireError(C,y,this.errorCount)}end(){this.writable.end()}};e.WriteableStreamMessageWriter=g}}),_I=we({"node_modules/vscode-jsonrpc/lib/common/messageBuffer.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AbstractMessageBuffer=void 0;var t=13,n=10,i=`\r
|
|
5
|
+
`,r=class{_encoding;_chunks;_totalLength;constructor(u="utf-8"){this._encoding=u,this._chunks=[],this._totalLength=0}get encoding(){return this._encoding}append(u){let s=typeof u=="string"?this.fromString(u,this._encoding):u;this._chunks.push(s),this._totalLength+=s.byteLength}tryReadHeaders(u=!1){if(this._chunks.length===0)return;let s=0,o=0,a=0,l=0;e:for(;o<this._chunks.length;){let v=this._chunks[o];for(a=0;a<v.length;){switch(v[a]){case t:switch(s){case 0:s=1;break;case 2:s=3;break;default:s=0}break;case n:switch(s){case 1:s=2;break;case 3:s=4,a++;break e;default:s=0}break;default:s=0}a++}l+=v.byteLength,o++}if(s!==4)return;let c=this._read(l+a),m=new Map,p=this.toString(c,"ascii").split(i);if(p.length<2)return m;for(let v=0;v<p.length-2;v++){let g=p[v],C=g.indexOf(":");if(C===-1)throw new Error(`Message header must separate key and value using ':'
|
|
6
|
+
${g}`);let y=g.substr(0,C),b=g.substr(C+1).trim();m.set(u?y.toLowerCase():y,b)}return m}tryReadBody(u){if(!(this._totalLength<u))return this._read(u)}get numberOfBytes(){return this._totalLength}_read(u){if(u===0)return this.emptyBuffer();if(u>this._totalLength)throw new Error("Cannot read so many bytes!");if(this._chunks[0].byteLength===u){let l=this._chunks[0];return this._chunks.shift(),this._totalLength-=u,this.asNative(l)}if(this._chunks[0].byteLength>u){let l=this._chunks[0],c=this.asNative(l,u);return this._chunks[0]=l.slice(u),this._totalLength-=u,c}let s=this.allocNative(u),o=0,a=0;for(;u>0;){let l=this._chunks[a];if(l.byteLength>u){let c=l.slice(0,u);s.set(c,o),o+=u,this._chunks[a]=l.slice(u),this._totalLength-=u,u-=u}else s.set(l,o),o+=l.byteLength,this._chunks.shift(),this._totalLength-=l.byteLength,u-=l.byteLength}return s}};e.AbstractMessageBuffer=r}}),AI=we({"node_modules/vscode-jsonrpc/lib/common/connection.js"(e){"use strict";var t=e&&e.__createBinding||(Object.create?(function($,P,N,F){F===void 0&&(F=N);var H=Object.getOwnPropertyDescriptor(P,N);(!H||("get"in H?!P.__esModule:H.writable||H.configurable))&&(H={enumerable:!0,get:function(){return P[N]}}),Object.defineProperty($,F,H)}):(function($,P,N,F){F===void 0&&(F=N),$[F]=P[N]})),n=e&&e.__setModuleDefault||(Object.create?(function($,P){Object.defineProperty($,"default",{enumerable:!0,value:P})}):function($,P){$.default=P}),i=e&&e.__importStar||(function(){var $=function(P){return $=Object.getOwnPropertyNames||function(N){var F=[];for(var H in N)Object.prototype.hasOwnProperty.call(N,H)&&(F[F.length]=H);return F},$(P)};return function(P){if(P&&P.__esModule)return P;var N={};if(P!=null)for(var F=$(P),H=0;H<F.length;H++)F[H]!=="default"&&t(N,P,F[H]);return n(N,P),N}})(),r=e&&e.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(e,"__esModule",{value:!0}),e.ConnectionOptions=e.MessageStrategy=e.CancellationStrategy=e.CancellationSenderStrategy=e.CancellationReceiverStrategy=e.RequestCancellationReceiverStrategy=e.IdCancellationReceiverStrategy=e.ConnectionStrategy=e.ConnectionError=e.ConnectionErrors=e.LogTraceNotification=e.SetTraceNotification=e.TraceFormat=e.TraceValues=e.TraceValue=e.Trace=e.NullLogger=e.ProgressType=e.ProgressToken=void 0,e.createMessageConnection=x;var u=r(br()),s=i(yu()),o=Bv(),a=xv(),l=Eu(),c=Xd(),m;(function($){$.type=new o.NotificationType("$/cancelRequest")})(m||(m={}));var p;(function($){function P(N){return typeof N=="string"||typeof N=="number"}$.is=P})(p||(e.ProgressToken=p={}));var v;(function($){$.type=new o.NotificationType("$/progress")})(v||(v={}));var g=class{__;_pr;constructor(){}};e.ProgressType=g;var C;(function($){function P(N){return s.func(N)}$.is=P})(C||(C={})),e.NullLogger=Object.freeze({error:()=>{},warn:()=>{},info:()=>{},log:()=>{}});var y;(function($){$[$.Off=0]="Off",$[$.Messages=1]="Messages",$[$.Compact=2]="Compact",$[$.Verbose=3]="Verbose"})(y||(e.Trace=y={}));var b;(function($){$.Off="off",$.Messages="messages",$.Compact="compact",$.Verbose="verbose"})(b||(e.TraceValue=b={})),e.TraceValues=b,(function($){function P(F){if(!s.string(F))return $.Off;switch(F=F.toLowerCase(),F){case"off":return $.Off;case"messages":return $.Messages;case"compact":return $.Compact;case"verbose":return $.Verbose;default:return $.Off}}$.fromString=P;function N(F){switch(F){case $.Off:return"off";case $.Messages:return"messages";case $.Compact:return"compact";case $.Verbose:return"verbose";default:return"off"}}$.toString=N})(y||(e.Trace=y={}));var A;(function($){$.Text="text",$.JSON="json"})(A||(e.TraceFormat=A={})),(function($){function P(N){return s.string(N)?(N=N.toLowerCase(),N==="json"?$.JSON:$.Text):$.Text}$.fromString=P})(A||(e.TraceFormat=A={}));var S;(function($){$.type=new o.NotificationType("$/setTrace")})(S||(e.SetTraceNotification=S={}));var z;(function($){$.type=new o.NotificationType("$/logTrace")})(z||(e.LogTraceNotification=z={}));var M;(function($){$[$.Closed=1]="Closed",$[$.Disposed=2]="Disposed",$[$.AlreadyListening=3]="AlreadyListening"})(M||(e.ConnectionErrors=M={}));var T=class Pv extends Error{code;constructor(P,N){super(N),this.code=P,Object.setPrototypeOf(this,Pv.prototype)}};e.ConnectionError=T;var G;(function($){function P(N){let F=N;return F&&s.func(F.cancelUndispatched)}$.is=P})(G||(e.ConnectionStrategy=G={}));var re;(function($){function P(N){let F=N;return F&&(F.kind===void 0||F.kind==="id")&&s.func(F.createCancellationTokenSource)&&(F.dispose===void 0||s.func(F.dispose))}$.is=P})(re||(e.IdCancellationReceiverStrategy=re={}));var Z;(function($){function P(N){let F=N;return F&&F.kind==="request"&&s.func(F.createCancellationTokenSource)&&(F.dispose===void 0||s.func(F.dispose))}$.is=P})(Z||(e.RequestCancellationReceiverStrategy=Z={}));var oe;(function($){$.Message=Object.freeze({createCancellationTokenSource(N){return new c.CancellationTokenSource}});function P(N){return re.is(N)||Z.is(N)}$.is=P})(oe||(e.CancellationReceiverStrategy=oe={}));var te;(function($){$.Message=Object.freeze({sendCancellation(N,F){return N.sendNotification(m.type,{id:F})},cleanup(N){}});function P(N){let F=N;return F&&s.func(F.sendCancellation)&&s.func(F.cleanup)}$.is=P})(te||(e.CancellationSenderStrategy=te={}));var ye;(function($){$.Message=Object.freeze({receiver:oe.Message,sender:te.Message});function P(N){let F=N;return F&&oe.is(F.receiver)&&te.is(F.sender)}$.is=P})(ye||(e.CancellationStrategy=ye={}));var Ne;(function($){function P(N){let F=N;return F&&s.func(F.handleMessage)}$.is=P})(Ne||(e.MessageStrategy=Ne={}));var At;(function($){function P(N){let F=N;return F&&(ye.is(F.cancellationStrategy)||G.is(F.connectionStrategy)||Ne.is(F.messageStrategy)||s.number(F.maxParallelism))}$.is=P})(At||(e.ConnectionOptions=At={}));var j;(function($){$[$.New=1]="New",$[$.Listening=2]="Listening",$[$.Closed=3]="Closed",$[$.Disposed=4]="Disposed"})(j||(j={}));function x($,P,N,F){let H=N!==void 0?N:e.NullLogger,Ye=0,In=0,Tr=0,$n="2.0",Bn=F?.maxParallelism??-1,kn=0,cn,xn=new Map,Me,Qn=new Map,Qt=new Map,Bi,Zt=new a.LinkedMap,Wt=new Map,er=new Set,Tn=new Map,be=y.Off,ve=A.Text,Je,Gt=j.New,Fr=new l.Emitter,ki=new l.Emitter,ls=new l.Emitter,V=new l.Emitter,xe=new l.Emitter,Ie=F&&F.cancellationStrategy?F.cancellationStrategy:ye.Message;function zt(I){}function xi(){return Gt===j.Listening}function cs(){return Gt===j.Closed}function dn(){return Gt===j.Disposed}function Ti(){(Gt===j.New||Gt===j.Listening)&&(Gt=j.Closed,ki.fire(void 0))}function tr(I){Fr.fire([I,void 0,void 0])}function ds(I){Fr.fire(I)}$.onClose(Ti),$.onError(tr),P.onClose(Ti),P.onError(ds);function xp(I){if(I===null)throw new Error("Can't send requests with id null since the response can't be correlated.");return"req-"+I.toString()}function YD(I){return I===null?"res-unknown-"+(++Tr).toString():"res-"+I.toString()}function QD(){return"not-"+(++In).toString()}function eI(I,O){o.Message.isRequest(O)?I.set(xp(O.id),O):o.Message.isResponse(O)?Bn===-1?I.set(YD(O.id),O):Fp(O):I.set(QD(),O)}function Il(){Bi||Zt.size===0||Bn!==-1&&kn>=Bn||(Bi=(0,u.default)().timer.setImmediate(async()=>{if(Bi=void 0,Zt.size===0||Bn!==-1&&kn>=Bn)return;let I=Zt.shift(),O;try{kn++;let q=F?.messageStrategy;Ne.is(q)?O=q.handleMessage(I,Tp):O=Tp(I)}catch(q){H.error(`Processing message queue failed: ${q.toString()}`)}finally{O instanceof Promise?O.then(()=>{kn--,Il()}).catch(q=>{H.error(`Processing message queue failed: ${q.toString()}`)}):kn--,Il()}}))}async function Tp(I){return o.Message.isRequest(I)?nI(I):o.Message.isNotification(I)?rI(I):o.Message.isResponse(I)?Fp(I):iI(I)}let tI=I=>{try{if(o.Message.isNotification(I)&&I.method===m.type.method){let O=I.params.id,q=xp(O),X=Zt.get(q);if(o.Message.isRequest(X)){let Ze=F?.connectionStrategy,Se=Ze&&Ze.cancelUndispatched?Ze.cancelUndispatched(X,zt):void 0;if(Se&&(Se.error!==void 0||Se.result!==void 0)){Zt.delete(q),Tn.delete(O),Se.id=X.id,$l(Se,I.method,Date.now()),P.write(Se).catch(()=>H.error("Sending response for canceled message failed."));return}}let Ce=Tn.get(O);if(Ce!==void 0){Ce.cancel(),Bl(I);return}else er.add(O)}eI(Zt,I)}finally{Il()}};async function nI(I){if(dn())return Promise.resolve();function O(et,ct,We){let Ge={jsonrpc:$n,id:I.id};return et instanceof o.ResponseError?Ge.error=et.toJson():Ge.result=et===void 0?null:et,$l(Ge,ct,We),P.write(Ge)}function q(et,ct,We){let Ge={jsonrpc:$n,id:I.id,error:et.toJson()};return $l(Ge,ct,We),P.write(Ge)}oI(I);let X=xn.get(I.method),Ce,Ze;X&&(Ce=X.type,Ze=X.handler);let Se=Date.now();if(Ze||cn){let et=I.id??String(Date.now()),ct=re.is(Ie.receiver)?Ie.receiver.createCancellationTokenSource(et):Ie.receiver.createCancellationTokenSource(I);I.id!==null&&er.has(I.id)&&ct.cancel(),I.id!==null&&Tn.set(et,ct);try{let We;if(Ze)if(I.params===void 0){if(Ce!==void 0&&Ce.numberOfParams!==0)return q(new o.ResponseError(o.ErrorCodes.InvalidParams,`Request ${I.method} defines ${Ce.numberOfParams} params but received none.`),I.method,Se);We=Ze(ct.token)}else if(Array.isArray(I.params)){if(Ce!==void 0&&Ce.parameterStructures===o.ParameterStructures.byName)return q(new o.ResponseError(o.ErrorCodes.InvalidParams,`Request ${I.method} defines parameters by name but received parameters by position`),I.method,Se);We=Ze(...I.params,ct.token)}else{if(Ce!==void 0&&Ce.parameterStructures===o.ParameterStructures.byPosition)return q(new o.ResponseError(o.ErrorCodes.InvalidParams,`Request ${I.method} defines parameters by position but received parameters by name`),I.method,Se);We=Ze(I.params,ct.token)}else cn&&(We=cn(I.method,I.params,ct.token));let Ge=await We;await O(Ge,I.method,Se)}catch(We){We instanceof o.ResponseError?await O(We,I.method,Se):We&&s.string(We.message)?await q(new o.ResponseError(o.ErrorCodes.InternalError,`Request ${I.method} failed with message: ${We.message}`),I.method,Se):await q(new o.ResponseError(o.ErrorCodes.InternalError,`Request ${I.method} failed unexpectedly without providing any details.`),I.method,Se)}finally{Tn.delete(et)}}else await q(new o.ResponseError(o.ErrorCodes.MethodNotFound,`Unhandled method ${I.method}`),I.method,Se)}function Fp(I){if(!dn())if(I.id===null)I.error?H.error(`Received response message without id: Error is:
|
|
7
|
+
${JSON.stringify(I.error,void 0,4)}`):H.error("Received response message without id. No further error information provided.");else{let O=I.id,q=Wt.get(O);if(aI(I,q),q!==void 0){Wt.delete(O);try{if(I.error){let X=I.error;q.reject(new o.ResponseError(X.code,X.message,X.data))}else if(I.result!==void 0)q.resolve(I.result);else throw new Error("Should never happen.")}catch(X){X.message?H.error(`Response handler '${q.method}' failed with message: ${X.message}`):H.error(`Response handler '${q.method}' failed unexpectedly.`)}}}}async function rI(I){if(dn())return;let O,q;if(I.method===m.type.method){let X=I.params.id;er.delete(X),Bl(I);return}else{let X=Qn.get(I.method);X&&(q=X.handler,O=X.type)}if(q||Me)try{if(Bl(I),q)if(I.params===void 0)O!==void 0&&O.numberOfParams!==0&&O.parameterStructures!==o.ParameterStructures.byName&&H.error(`Notification ${I.method} defines ${O.numberOfParams} params but received none.`),await q();else if(Array.isArray(I.params)){let X=I.params;I.method===v.type.method&&X.length===2&&p.is(X[0])?await q({token:X[0],value:X[1]}):(O!==void 0&&(O.parameterStructures===o.ParameterStructures.byName&&H.error(`Notification ${I.method} defines parameters by name but received parameters by position`),O.numberOfParams!==I.params.length&&H.error(`Notification ${I.method} defines ${O.numberOfParams} params but received ${X.length} arguments`)),await q(...X))}else O!==void 0&&O.parameterStructures===o.ParameterStructures.byPosition&&H.error(`Notification ${I.method} defines parameters by position but received parameters by name`),await q(I.params);else Me&&await Me(I.method,I.params)}catch(X){X.message?H.error(`Notification handler '${I.method}' failed with message: ${X.message}`):H.error(`Notification handler '${I.method}' failed unexpectedly.`)}else ls.fire(I)}function iI(I){if(!I){H.error("Received empty message.");return}H.error(`Received message which is neither a response nor a notification message:
|
|
8
|
+
${JSON.stringify(I,null,4)}`);let O=I;if(s.string(O.id)||s.number(O.id)){let q=O.id,X=Wt.get(q);X&&X.reject(new Error("The received response has neither a result nor an error property."))}}function Fn(I){if(I!=null)switch(be){case y.Verbose:return JSON.stringify(I,null,4);case y.Compact:return JSON.stringify(I);default:return}}function uI(I){if(!(be===y.Off||!Je))if(ve===A.Text){let O;(be===y.Verbose||be===y.Compact)&&I.params&&(O=`Params: ${Fn(I.params)}`),Je.log(`Sending request '${I.method} - (${I.id})'.`,O)}else Pr("send-request",I)}function sI(I){if(!(be===y.Off||!Je))if(ve===A.Text){let O;(be===y.Verbose||be===y.Compact)&&(I.params?O=`Params: ${Fn(I.params)}`:O="No parameters provided."),Je.log(`Sending notification '${I.method}'.`,O)}else Pr("send-notification",I)}function $l(I,O,q){if(!(be===y.Off||!Je))if(ve===A.Text){let X;(be===y.Verbose||be===y.Compact)&&(I.error&&I.error.data?X=`Error data: ${Fn(I.error.data)}`:I.result?X=`Result: ${Fn(I.result)}`:I.error===void 0&&(X="No result returned."));let Ce=I.error?` Request failed: ${I.error.message} (${I.error.code}).`:"";Je.log(`Sending response '${O} - (${I.id})'. Processing request took ${Date.now()-q}ms.${Ce}`,X)}else Pr("send-response",I)}function oI(I){if(!(be===y.Off||!Je))if(ve===A.Text){let O;(be===y.Verbose||be===y.Compact)&&I.params&&(O=`Params: ${Fn(I.params)}`),Je.log(`Received request '${I.method} - (${I.id})'.`,O)}else Pr("receive-request",I)}function Bl(I){if(!(be===y.Off||!Je||I.method===z.type.method))if(ve===A.Text){let O;(be===y.Verbose||be===y.Compact)&&(I.params?O=`Params: ${Fn(I.params)}`:O="No parameters provided."),Je.log(`Received notification '${I.method}'.`,O)}else Pr("receive-notification",I)}function aI(I,O){if(!(be===y.Off||!Je))if(ve===A.Text){let q;if((be===y.Verbose||be===y.Compact)&&(I.error&&I.error.data?q=`Error data: ${Fn(I.error.data)}`:I.result?q=`Result: ${Fn(I.result)}`:I.error===void 0&&(q="No result returned.")),O){let X=I.error?` Request failed: ${I.error.message} (${I.error.code}).`:"";Je.log(`Received response '${O.method} - (${I.id})' in ${Date.now()-O.timerStart}ms.${X}`,q)}else Je.log(`Received response ${I.id} without active response promise.`,q)}else Pr("receive-response",I)}function Pr(I,O){if(!Je||be===y.Off)return;let q={isLSPMessage:!0,type:I,message:O,timestamp:Date.now()};Je.log(q)}function Fi(){if(cs())throw new T(M.Closed,"Connection is closed.");if(dn())throw new T(M.Disposed,"Connection is disposed.")}function lI(){if(xi())throw new T(M.AlreadyListening,"Connection is already listening")}function cI(){if(!xi())throw new Error("Call listen() first.")}function Pi(I){return I===void 0?null:I}function Pp(I){if(I!==null)return I}function Rp(I){return I!=null&&!Array.isArray(I)&&typeof I=="object"}function kl(I,O){switch(I){case o.ParameterStructures.auto:return Rp(O)?Pp(O):[Pi(O)];case o.ParameterStructures.byName:if(!Rp(O))throw new Error("Received parameters by name but param is not an object literal.");return Pp(O);case o.ParameterStructures.byPosition:return[Pi(O)];default:throw new Error(`Unknown parameter structure ${I.toString()}`)}}function zp(I,O){let q,X=I.numberOfParams;switch(X){case 0:q=void 0;break;case 1:q=kl(I.parameterStructures,O[0]);break;default:q=[];for(let Ce=0;Ce<O.length&&Ce<X;Ce++)q.push(Pi(O[Ce]));if(O.length<X)for(let Ce=O.length;Ce<X;Ce++)q.push(null);break}return q}let nr={sendNotification:(I,...O)=>{Fi();let q,X;if(s.string(I)){q=I;let Ze=O[0],Se=0,et=o.ParameterStructures.auto;o.ParameterStructures.is(Ze)&&(Se=1,et=Ze);let ct=O.length,We=ct-Se;switch(We){case 0:X=void 0;break;case 1:X=kl(et,O[Se]);break;default:if(et===o.ParameterStructures.byName)throw new Error(`Received ${We} parameters for 'by Name' notification parameter structure.`);X=O.slice(Se,ct).map(Ge=>Pi(Ge));break}}else{let Ze=O;q=I.method,X=zp(I,Ze)}let Ce={jsonrpc:$n,method:q,params:X};return sI(Ce),P.write(Ce).catch(Ze=>{throw H.error("Sending notification failed."),Ze})},onNotification:(I,O)=>{Fi();let q;return s.func(I)?Me=I:O&&(s.string(I)?(q=I,Qn.set(I,{type:void 0,handler:O})):(q=I.method,Qn.set(I.method,{type:I,handler:O}))),{dispose:()=>{q!==void 0?Qn.get(q)?.handler===O&&Qn.delete(q):Me===I&&(Me=void 0)}}},onProgress:(I,O,q)=>{if(Qt.has(O))throw new Error(`Progress handler for token ${O} already registered`);return Qt.set(O,q),{dispose:()=>{Qt.get(O)===q&&Qt.delete(O)}}},sendProgress:(I,O,q)=>nr.sendNotification(v.type,{token:O,value:q}),onUnhandledProgress:V.event,sendRequest:(I,...O)=>{Fi(),cI();function q(Ge,Vt){let hn=Ie.sender.sendCancellation(Ge,Vt);hn===void 0?H.log(`Received no promise from cancellation strategy when cancelling id ${Vt}`):hn.catch(()=>{H.log(`Sending cancellation messages for id ${Vt} failed.`)})}let X,Ce,Ze;if(s.string(I)){X=I;let Ge=O[0],Vt=O[O.length-1],hn=0,Ri=o.ParameterStructures.auto;o.ParameterStructures.is(Ge)&&(hn=1,Ri=Ge);let rr=O.length;c.CancellationToken.is(Vt)&&(rr=rr-1,Ze=Vt);let fn=rr-hn;switch(fn){case 0:Ce=void 0;break;case 1:Ce=kl(Ri,O[hn]);break;default:if(Ri===o.ParameterStructures.byName)throw new Error(`Received ${fn} parameters for 'by Name' request parameter structure.`);Ce=O.slice(hn,rr).map(dI=>Pi(dI));break}}else{let Ge=O;X=I.method,Ce=zp(I,Ge);let Vt=I.numberOfParams;Ze=c.CancellationToken.is(Ge[Vt])?Ge[Vt]:void 0}let Se=Ye++,et,ct=!1;Ze!==void 0&&(Ze.isCancellationRequested?ct=!0:et=Ze.onCancellationRequested(()=>{q(nr,Se)}));let We={jsonrpc:$n,id:Se,method:X,params:Ce};return uI(We),typeof Ie.sender.enableCancellation=="function"&&Ie.sender.enableCancellation(We),new Promise(async(Ge,Vt)=>{let hn=fn=>{Ge(fn),Ie.sender.cleanup(Se),et?.dispose()},Ri=fn=>{Vt(fn),Ie.sender.cleanup(Se),et?.dispose()},rr={method:X,timerStart:Date.now(),resolve:hn,reject:Ri};try{Wt.set(Se,rr),await P.write(We),ct&&q(nr,Se)}catch(fn){Wt.delete(Se),rr.reject(new o.ResponseError(o.ErrorCodes.MessageWriteError,fn.message?fn.message:"Unknown reason")),H.error("Sending request failed.")}})},onRequest:(I,O)=>{Fi();let q=null;return C.is(I)?(q=void 0,cn=I):s.string(I)?(q=null,O!==void 0&&(q=I,xn.set(I,{handler:O,type:void 0}))):O!==void 0&&(q=I.method,xn.set(I.method,{type:I,handler:O})),{dispose:()=>{q!==null&&(q!==void 0?xn.get(q)?.handler===O&&xn.delete(q):cn===I&&(cn=void 0))}}},hasPendingResponse:()=>Wt.size>0,trace:async(I,O,q)=>{let X=!1,Ce=A.Text;q!==void 0&&(s.boolean(q)?X=q:(X=q.sendNotification||!1,Ce=q.traceFormat||A.Text)),be=I,ve=Ce,be===y.Off?Je=void 0:Je=O,X&&!cs()&&!dn()&&await nr.sendNotification(S.type,{value:y.toString(I)})},onError:Fr.event,onClose:ki.event,onUnhandledNotification:ls.event,onDispose:xe.event,end:()=>{P.end()},dispose:()=>{if(dn())return;Gt=j.Disposed,xe.fire(void 0);let I=new o.ResponseError(o.ErrorCodes.PendingResponseRejected,"Pending response rejected since connection got disposed");for(let O of Wt.values())O.reject(I);Wt=new Map,Tn=new Map,er=new Set,Zt=new a.LinkedMap,s.func(P.dispose)&&P.dispose(),s.func($.dispose)&&$.dispose()},listen:()=>{Fi(),lI(),Gt=j.Listening,$.listen(tI)},inspect:()=>{(0,u.default)().console.log("inspect")}};return nr.onNotification(z.type,I=>{if(be===y.Off||!Je)return;let O=be===y.Verbose||be===y.Compact;Je.log(I.message,O?I.verbose:void 0)}),nr.onNotification(v.type,async I=>{let O=Qt.get(I.token);O?await O(I.value):V.fire(I)}),nr}}}),ro=we({"node_modules/vscode-jsonrpc/lib/common/api.js"(e){"use strict";var t=e&&e.__importDefault||function(v){return v&&v.__esModule?v:{default:v}};Object.defineProperty(e,"__esModule",{value:!0}),e.ProgressType=e.ProgressToken=e.createMessageConnection=e.NullLogger=e.ConnectionOptions=e.ConnectionStrategy=e.AbstractMessageBuffer=e.WriteableStreamMessageWriter=e.AbstractMessageWriter=e.MessageWriter=e.ReadableStreamMessageReader=e.AbstractMessageReader=e.MessageReader=e.SharedArrayReceiverStrategy=e.SharedArraySenderStrategy=e.CancellationToken=e.CancellationTokenSource=e.Emitter=e.Event=e.Disposable=e.LRUCache=e.Touch=e.LinkedMap=e.ParameterStructures=e.NotificationType9=e.NotificationType8=e.NotificationType7=e.NotificationType6=e.NotificationType5=e.NotificationType4=e.NotificationType3=e.NotificationType2=e.NotificationType1=e.NotificationType0=e.NotificationType=e.ErrorCodes=e.ResponseError=e.RequestType9=e.RequestType8=e.RequestType7=e.RequestType6=e.RequestType5=e.RequestType4=e.RequestType3=e.RequestType2=e.RequestType1=e.RequestType0=e.RequestType=e.Message=e.RAL=void 0,e.MessageStrategy=e.CancellationStrategy=e.CancellationSenderStrategy=e.RequestCancellationReceiverStrategy=e.IdCancellationReceiverStrategy=e.CancellationReceiverStrategy=e.ConnectionError=e.ConnectionErrors=e.LogTraceNotification=e.SetTraceNotification=e.TraceFormat=e.TraceValues=e.TraceValue=e.Trace=void 0;var n=Bv();Object.defineProperty(e,"Message",{enumerable:!0,get:function(){return n.Message}}),Object.defineProperty(e,"RequestType",{enumerable:!0,get:function(){return n.RequestType}}),Object.defineProperty(e,"RequestType0",{enumerable:!0,get:function(){return n.RequestType0}}),Object.defineProperty(e,"RequestType1",{enumerable:!0,get:function(){return n.RequestType1}}),Object.defineProperty(e,"RequestType2",{enumerable:!0,get:function(){return n.RequestType2}}),Object.defineProperty(e,"RequestType3",{enumerable:!0,get:function(){return n.RequestType3}}),Object.defineProperty(e,"RequestType4",{enumerable:!0,get:function(){return n.RequestType4}}),Object.defineProperty(e,"RequestType5",{enumerable:!0,get:function(){return n.RequestType5}}),Object.defineProperty(e,"RequestType6",{enumerable:!0,get:function(){return n.RequestType6}}),Object.defineProperty(e,"RequestType7",{enumerable:!0,get:function(){return n.RequestType7}}),Object.defineProperty(e,"RequestType8",{enumerable:!0,get:function(){return n.RequestType8}}),Object.defineProperty(e,"RequestType9",{enumerable:!0,get:function(){return n.RequestType9}}),Object.defineProperty(e,"ResponseError",{enumerable:!0,get:function(){return n.ResponseError}}),Object.defineProperty(e,"ErrorCodes",{enumerable:!0,get:function(){return n.ErrorCodes}}),Object.defineProperty(e,"NotificationType",{enumerable:!0,get:function(){return n.NotificationType}}),Object.defineProperty(e,"NotificationType0",{enumerable:!0,get:function(){return n.NotificationType0}}),Object.defineProperty(e,"NotificationType1",{enumerable:!0,get:function(){return n.NotificationType1}}),Object.defineProperty(e,"NotificationType2",{enumerable:!0,get:function(){return n.NotificationType2}}),Object.defineProperty(e,"NotificationType3",{enumerable:!0,get:function(){return n.NotificationType3}}),Object.defineProperty(e,"NotificationType4",{enumerable:!0,get:function(){return n.NotificationType4}}),Object.defineProperty(e,"NotificationType5",{enumerable:!0,get:function(){return n.NotificationType5}}),Object.defineProperty(e,"NotificationType6",{enumerable:!0,get:function(){return n.NotificationType6}}),Object.defineProperty(e,"NotificationType7",{enumerable:!0,get:function(){return n.NotificationType7}}),Object.defineProperty(e,"NotificationType8",{enumerable:!0,get:function(){return n.NotificationType8}}),Object.defineProperty(e,"NotificationType9",{enumerable:!0,get:function(){return n.NotificationType9}}),Object.defineProperty(e,"ParameterStructures",{enumerable:!0,get:function(){return n.ParameterStructures}});var i=xv();Object.defineProperty(e,"LinkedMap",{enumerable:!0,get:function(){return i.LinkedMap}}),Object.defineProperty(e,"LRUCache",{enumerable:!0,get:function(){return i.LRUCache}}),Object.defineProperty(e,"Touch",{enumerable:!0,get:function(){return i.Touch}});var r=CI();Object.defineProperty(e,"Disposable",{enumerable:!0,get:function(){return r.Disposable}});var u=Eu();Object.defineProperty(e,"Event",{enumerable:!0,get:function(){return u.Event}}),Object.defineProperty(e,"Emitter",{enumerable:!0,get:function(){return u.Emitter}});var s=Xd();Object.defineProperty(e,"CancellationTokenSource",{enumerable:!0,get:function(){return s.CancellationTokenSource}}),Object.defineProperty(e,"CancellationToken",{enumerable:!0,get:function(){return s.CancellationToken}});var o=yI();Object.defineProperty(e,"SharedArraySenderStrategy",{enumerable:!0,get:function(){return o.SharedArraySenderStrategy}}),Object.defineProperty(e,"SharedArrayReceiverStrategy",{enumerable:!0,get:function(){return o.SharedArrayReceiverStrategy}});var a=EI();Object.defineProperty(e,"MessageReader",{enumerable:!0,get:function(){return a.MessageReader}}),Object.defineProperty(e,"AbstractMessageReader",{enumerable:!0,get:function(){return a.AbstractMessageReader}}),Object.defineProperty(e,"ReadableStreamMessageReader",{enumerable:!0,get:function(){return a.ReadableStreamMessageReader}});var l=wI();Object.defineProperty(e,"MessageWriter",{enumerable:!0,get:function(){return l.MessageWriter}}),Object.defineProperty(e,"AbstractMessageWriter",{enumerable:!0,get:function(){return l.AbstractMessageWriter}}),Object.defineProperty(e,"WriteableStreamMessageWriter",{enumerable:!0,get:function(){return l.WriteableStreamMessageWriter}});var c=_I();Object.defineProperty(e,"AbstractMessageBuffer",{enumerable:!0,get:function(){return c.AbstractMessageBuffer}});var m=AI();Object.defineProperty(e,"ConnectionStrategy",{enumerable:!0,get:function(){return m.ConnectionStrategy}}),Object.defineProperty(e,"ConnectionOptions",{enumerable:!0,get:function(){return m.ConnectionOptions}}),Object.defineProperty(e,"NullLogger",{enumerable:!0,get:function(){return m.NullLogger}}),Object.defineProperty(e,"createMessageConnection",{enumerable:!0,get:function(){return m.createMessageConnection}}),Object.defineProperty(e,"ProgressToken",{enumerable:!0,get:function(){return m.ProgressToken}}),Object.defineProperty(e,"ProgressType",{enumerable:!0,get:function(){return m.ProgressType}}),Object.defineProperty(e,"Trace",{enumerable:!0,get:function(){return m.Trace}}),Object.defineProperty(e,"TraceValue",{enumerable:!0,get:function(){return m.TraceValue}}),Object.defineProperty(e,"TraceFormat",{enumerable:!0,get:function(){return m.TraceFormat}}),Object.defineProperty(e,"SetTraceNotification",{enumerable:!0,get:function(){return m.SetTraceNotification}}),Object.defineProperty(e,"LogTraceNotification",{enumerable:!0,get:function(){return m.LogTraceNotification}}),Object.defineProperty(e,"ConnectionErrors",{enumerable:!0,get:function(){return m.ConnectionErrors}}),Object.defineProperty(e,"ConnectionError",{enumerable:!0,get:function(){return m.ConnectionError}}),Object.defineProperty(e,"CancellationReceiverStrategy",{enumerable:!0,get:function(){return m.CancellationReceiverStrategy}}),Object.defineProperty(e,"IdCancellationReceiverStrategy",{enumerable:!0,get:function(){return m.IdCancellationReceiverStrategy}}),Object.defineProperty(e,"RequestCancellationReceiverStrategy",{enumerable:!0,get:function(){return m.RequestCancellationReceiverStrategy}}),Object.defineProperty(e,"CancellationSenderStrategy",{enumerable:!0,get:function(){return m.CancellationSenderStrategy}}),Object.defineProperty(e,"CancellationStrategy",{enumerable:!0,get:function(){return m.CancellationStrategy}}),Object.defineProperty(e,"MessageStrategy",{enumerable:!0,get:function(){return m.MessageStrategy}}),Object.defineProperty(e,"TraceValues",{enumerable:!0,get:function(){return m.TraceValues}});var p=t(br());e.RAL=p.default}}),bI=we({"node_modules/vscode-jsonrpc/lib/node/ril.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=Ct("util"),n=ro(),i=class Rv extends n.AbstractMessageBuffer{static emptyBuffer=Buffer.allocUnsafe(0);constructor(l="utf-8"){super(l)}emptyBuffer(){return Rv.emptyBuffer}fromString(l,c){return Buffer.from(l,c)}toString(l,c){return l instanceof Buffer?l.toString(c):new t.TextDecoder(c).decode(l)}asNative(l,c){return c===void 0?l instanceof Buffer?l:Buffer.from(l):l instanceof Buffer?l.slice(0,c):Buffer.from(l,0,c)}allocNative(l){return Buffer.allocUnsafe(l)}},r=class{stream;constructor(a){this.stream=a}onClose(a){return this.stream.on("close",a),n.Disposable.create(()=>this.stream.off("close",a))}onError(a){return this.stream.on("error",a),n.Disposable.create(()=>this.stream.off("error",a))}onEnd(a){return this.stream.on("end",a),n.Disposable.create(()=>this.stream.off("end",a))}onData(a){return this.stream.on("data",a),n.Disposable.create(()=>this.stream.off("data",a))}},u=class{stream;constructor(a){this.stream=a}onClose(a){return this.stream.on("close",a),n.Disposable.create(()=>this.stream.off("close",a))}onError(a){return this.stream.on("error",a),n.Disposable.create(()=>this.stream.off("error",a))}onEnd(a){return this.stream.on("end",a),n.Disposable.create(()=>this.stream.off("end",a))}write(a,l){return new Promise((c,m)=>{let p=v=>{v==null?c():m(v)};typeof a=="string"?this.stream.write(a,l,p):this.stream.write(a,p)})}end(){this.stream.end()}},s=Object.freeze({messageBuffer:Object.freeze({create:a=>new i(a)}),applicationJson:Object.freeze({encoder:Object.freeze({name:"application/json",encode:(a,l)=>{try{return Promise.resolve(Buffer.from(JSON.stringify(a,void 0,0),l.charset))}catch(c){return Promise.reject(c)}}}),decoder:Object.freeze({name:"application/json",decode:(a,l)=>{try{return a instanceof Buffer?Promise.resolve(JSON.parse(a.toString(l.charset))):Promise.resolve(JSON.parse(new t.TextDecoder(l.charset).decode(a)))}catch(c){return Promise.reject(c)}}})}),stream:Object.freeze({asReadableStream:a=>new r(a),asWritableStream:a=>new u(a)}),console,timer:Object.freeze({setTimeout(a,l,...c){let m=setTimeout(a,l,...c);return{dispose:()=>clearTimeout(m)}},setImmediate(a,...l){let c=setImmediate(a,...l);return{dispose:()=>clearImmediate(c)}},setInterval(a,l,...c){let m=setInterval(a,l,...c);return{dispose:()=>clearInterval(m)}}})});function o(){return s}(function(a){function l(){n.RAL.install(s)}a.install=l})(o||(o={})),e.default=o}}),Sr=we({"node_modules/vscode-jsonrpc/lib/node/main.js"(e){"use strict";var t=e&&e.__createBinding||(Object.create?(function(j,x,$,P){P===void 0&&(P=$);var N=Object.getOwnPropertyDescriptor(x,$);(!N||("get"in N?!x.__esModule:N.writable||N.configurable))&&(N={enumerable:!0,get:function(){return x[$]}}),Object.defineProperty(j,P,N)}):(function(j,x,$,P){P===void 0&&(P=$),j[P]=x[$]})),n=e&&e.__setModuleDefault||(Object.create?(function(j,x){Object.defineProperty(j,"default",{enumerable:!0,value:x})}):function(j,x){j.default=x}),i=e&&e.__importStar||(function(){var j=function(x){return j=Object.getOwnPropertyNames||function($){var P=[];for(var N in $)Object.prototype.hasOwnProperty.call($,N)&&(P[P.length]=N);return P},j(x)};return function(x){if(x&&x.__esModule)return x;var $={};if(x!=null)for(var P=j(x),N=0;N<P.length;N++)P[N]!=="default"&&t($,x,P[N]);return n($,x),$}})(),r=e&&e.__exportStar||function(j,x){for(var $ in j)$!=="default"&&!Object.prototype.hasOwnProperty.call(x,$)&&t(x,j,$)},u=e&&e.__importDefault||function(j){return j&&j.__esModule?j:{default:j}};Object.defineProperty(e,"__esModule",{value:!0}),e.StreamMessageWriter=e.StreamMessageReader=e.SocketMessageWriter=e.SocketMessageReader=e.PortMessageWriter=e.PortMessageReader=e.IPCMessageWriter=e.IPCMessageReader=void 0,e.generateRandomPipeName=G,e.createClientPipeTransport=re,e.createServerPipeTransport=Z,e.createClientSocketTransport=oe,e.createServerSocketTransport=te,e.createMessageConnection=At;var s=u(bI());s.default.install();var o=i(Ct("path")),a=i(Ct("os")),l=i(Ct("fs")),c=Ct("crypto"),m=Ct("net"),p=ro();r(ro(),e);var v=class extends p.AbstractMessageReader{process;constructor(j){super(),this.process=j;let x=this.process;x.on("error",$=>this.fireError($)),x.on("close",()=>this.fireClose())}listen(j){return this.process.on("message",j),p.Disposable.create(()=>this.process.off("message",j))}};e.IPCMessageReader=v;var g=class extends p.AbstractMessageWriter{process;errorCount;constructor(j){super(),this.process=j,this.errorCount=0;let x=this.process;x.on("error",$=>this.fireError($)),x.on("close",()=>this.fireClose)}write(j){try{return typeof this.process.send=="function"&&this.process.send(j,void 0,void 0,x=>{x?(this.errorCount++,this.handleError(x,j)):this.errorCount=0}),Promise.resolve()}catch(x){return this.handleError(x,j),Promise.reject(x)}}handleError(j,x){this.errorCount++,this.fireError(j,x,this.errorCount)}end(){}};e.IPCMessageWriter=g;var C=class extends p.AbstractMessageReader{onData;constructor(j){super(),this.onData=new p.Emitter,j.on("close",()=>this.fireClose),j.on("error",x=>this.fireError(x)),j.on("message",x=>{this.onData.fire(x)})}listen(j){return this.onData.event(j)}};e.PortMessageReader=C;var y=class extends p.AbstractMessageWriter{port;errorCount;constructor(j){super(),this.port=j,this.errorCount=0,j.on("close",()=>this.fireClose()),j.on("error",x=>this.fireError(x))}write(j){try{return this.port.postMessage(j),Promise.resolve()}catch(x){return this.handleError(x,j),Promise.reject(x)}}handleError(j,x){this.errorCount++,this.fireError(j,x,this.errorCount)}end(){}};e.PortMessageWriter=y;var b=class extends p.ReadableStreamMessageReader{constructor(j,x="utf-8"){super((0,s.default)().stream.asReadableStream(j),x)}};e.SocketMessageReader=b;var A=class extends p.WriteableStreamMessageWriter{socket;constructor(j,x){super((0,s.default)().stream.asWritableStream(j),x),this.socket=j}dispose(){super.dispose(),this.socket.destroy()}};e.SocketMessageWriter=A;var S=class extends p.ReadableStreamMessageReader{constructor(j,x){super((0,s.default)().stream.asReadableStream(j),x)}};e.StreamMessageReader=S;var z=class extends p.WriteableStreamMessageWriter{constructor(j,x){super((0,s.default)().stream.asWritableStream(j),x)}};e.StreamMessageWriter=z;var M=process.env.XDG_RUNTIME_DIR,T=new Map([["linux",107],["darwin",102]]);function G(){if(process.platform==="win32")return`\\\\.\\pipe\\lsp-${(0,c.randomBytes)(16).toString("hex")}-sock`;let j=32,x=10,$=l.realpathSync(M??a.tmpdir()),P=T.get(process.platform);if(P!==void 0&&(j=Math.min(P-$.length-x,j)),j<16)throw new Error(`Unable to generate a random pipe name with ${j} characters.`);let N=(0,c.randomBytes)(Math.floor(j/2)).toString("hex");return o.join($,`lsp-${N}.sock`)}function re(j,x="utf-8"){let $,P=new Promise((N,F)=>{$=N});return new Promise((N,F)=>{let H=(0,m.createServer)(Ye=>{H.close(),$([new b(Ye,x),new A(Ye,x)])});H.on("error",F),H.listen(j,()=>{H.removeListener("error",F),N({onConnected:()=>P})})})}function Z(j,x="utf-8"){let $=(0,m.createConnection)(j);return[new b($,x),new A($,x)]}function oe(j,x="utf-8"){let $,P=new Promise((N,F)=>{$=N});return new Promise((N,F)=>{let H=(0,m.createServer)(Ye=>{H.close(),$([new b(Ye,x),new A(Ye,x)])});H.on("error",F),H.listen(j,"127.0.0.1",()=>{H.removeListener("error",F);let Ye=H.address();if(Ye===null||typeof Ye=="string"){F(new Error(`Unexpected server address: ${Ye}`));return}let In=Ye.port;N({port:()=>In,onConnected:()=>P})})})}function te(j,x="utf-8"){let $=(0,m.createConnection)(j,"127.0.0.1");return[new b($,x),new A($,x)]}function ye(j){let x=j;return x.read!==void 0&&x.addListener!==void 0}function Ne(j){let x=j;return x.write!==void 0&&x.addListener!==void 0}function At(j,x,$,P){$||($=p.NullLogger);let N=ye(j)?new S(j):j,F=Ne(x)?new z(x):x;return p.ConnectionStrategy.is(P)&&(P={connectionStrategy:P}),(0,p.createMessageConnection)(N,F,$,P)}}}),SI=we({"node_modules/isexe/windows.js"(e,t){t.exports=u,u.sync=s;var n=Ct("fs");function i(o,a){var l=a.pathExt!==void 0?a.pathExt:process.env.PATHEXT;if(!l||(l=l.split(";"),l.indexOf("")!==-1))return!0;for(var c=0;c<l.length;c++){var m=l[c].toLowerCase();if(m&&o.substr(-m.length).toLowerCase()===m)return!0}return!1}function r(o,a,l){return!o.isSymbolicLink()&&!o.isFile()?!1:i(a,l)}function u(o,a,l){n.stat(o,function(c,m){l(c,c?!1:r(m,o,a))})}function s(o,a){return r(n.statSync(o),o,a)}}}),DI=we({"node_modules/isexe/mode.js"(e,t){t.exports=i,i.sync=r;var n=Ct("fs");function i(o,a,l){n.stat(o,function(c,m){l(c,c?!1:u(m,a))})}function r(o,a){return u(n.statSync(o),a)}function u(o,a){return o.isFile()&&s(o,a)}function s(o,a){var l=o.mode,c=o.uid,m=o.gid,p=a.uid!==void 0?a.uid:process.getuid&&process.getuid(),v=a.gid!==void 0?a.gid:process.getgid&&process.getgid(),g=parseInt("100",8),C=parseInt("010",8),y=parseInt("001",8),b=g|C,A=l&y||l&C&&m===v||l&g&&c===p||l&b&&p===0;return A}}}),II=we({"node_modules/isexe/index.js"(e,t){var n=Ct("fs"),i;process.platform==="win32"||global.TESTING_WINDOWS?i=SI():i=DI(),t.exports=r,r.sync=u;function r(s,o,a){if(typeof o=="function"&&(a=o,o={}),!a){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(l,c){r(s,o||{},function(m,p){m?c(m):l(p)})})}i(s,o||{},function(l,c){l&&(l.code==="EACCES"||o&&o.ignoreErrors)&&(l=null,c=!1),a(l,c)})}function u(s,o){try{return i.sync(s,o||{})}catch(a){if(o&&o.ignoreErrors||a.code==="EACCES")return!1;throw a}}}}),$I=we({"node_modules/which/which.js"(e,t){var n=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",i=Ct("path"),r=n?";":":",u=II(),s=c=>Object.assign(new Error(`not found: ${c}`),{code:"ENOENT"}),o=(c,m)=>{let p=m.colon||r,v=c.match(/\//)||n&&c.match(/\\/)?[""]:[...n?[process.cwd()]:[],...(m.path||process.env.PATH||"").split(p)],g=n?m.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",C=n?g.split(p):[""];return n&&c.indexOf(".")!==-1&&C[0]!==""&&C.unshift(""),{pathEnv:v,pathExt:C,pathExtExe:g}},a=(c,m,p)=>{typeof m=="function"&&(p=m,m={}),m||(m={});let{pathEnv:v,pathExt:g,pathExtExe:C}=o(c,m),y=[],b=S=>new Promise((z,M)=>{if(S===v.length)return m.all&&y.length?z(y):M(s(c));let T=v[S],G=/^".*"$/.test(T)?T.slice(1,-1):T,re=i.join(G,c),Z=!G&&/^\.[\\\/]/.test(c)?c.slice(0,2)+re:re;z(A(Z,S,0))}),A=(S,z,M)=>new Promise((T,G)=>{if(M===g.length)return T(b(z+1));let re=g[M];u(S+re,{pathExt:C},(Z,oe)=>{if(!Z&&oe)if(m.all)y.push(S+re);else return T(S+re);return T(A(S,z,M+1))})});return p?b(0).then(S=>p(null,S),p):b(0)},l=(c,m)=>{m=m||{};let{pathEnv:p,pathExt:v,pathExtExe:g}=o(c,m),C=[];for(let y=0;y<p.length;y++){let b=p[y],A=/^".*"$/.test(b)?b.slice(1,-1):b,S=i.join(A,c),z=!A&&/^\.[\\\/]/.test(c)?c.slice(0,2)+S:S;for(let M=0;M<v.length;M++){let T=z+v[M];try{if(u.sync(T,{pathExt:g}))if(m.all)C.push(T);else return T}catch{}}}if(m.all&&C.length)return C;if(m.nothrow)return null;throw s(c)};t.exports=a,a.sync=l}}),BI=we({"node_modules/path-key/index.js"(e,t){"use strict";var n=(i={})=>{let r=i.env||process.env;return(i.platform||process.platform)!=="win32"?"PATH":Object.keys(r).reverse().find(s=>s.toUpperCase()==="PATH")||"Path"};t.exports=n,t.exports.default=n}}),kI=we({"node_modules/cross-spawn/lib/util/resolveCommand.js"(e,t){"use strict";var n=Ct("path"),i=$I(),r=BI();function u(o,a){let l=o.options.env||process.env,c=process.cwd(),m=o.options.cwd!=null,p=m&&process.chdir!==void 0&&!process.chdir.disabled;if(p)try{process.chdir(o.options.cwd)}catch{}let v;try{v=i.sync(o.command,{path:l[r({env:l})],pathExt:a?n.delimiter:void 0})}catch{}finally{p&&process.chdir(c)}return v&&(v=n.resolve(m?o.options.cwd:"",v)),v}function s(o){return u(o)||u(o,!0)}t.exports=s}}),xI=we({"node_modules/cross-spawn/lib/util/escape.js"(e,t){"use strict";var n=/([()\][%!^"`<>&|;, *?])/g;function i(u){return u=u.replace(n,"^$1"),u}function r(u,s){return u=`${u}`,u=u.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),u=u.replace(/(?=(\\+?)?)\1$/,"$1$1"),u=`"${u}"`,u=u.replace(n,"^$1"),s&&(u=u.replace(n,"^$1")),u}t.exports.command=i,t.exports.argument=r}}),TI=we({"node_modules/shebang-regex/index.js"(e,t){"use strict";t.exports=/^#!(.*)/}}),FI=we({"node_modules/shebang-command/index.js"(e,t){"use strict";var n=TI();t.exports=(i="")=>{let r=i.match(n);if(!r)return null;let[u,s]=r[0].replace(/#! ?/,"").split(" "),o=u.split("/").pop();return o==="env"?s:s?`${o} ${s}`:o}}}),PI=we({"node_modules/cross-spawn/lib/util/readShebang.js"(e,t){"use strict";var n=Ct("fs"),i=FI();function r(u){let o=Buffer.alloc(150),a;try{a=n.openSync(u,"r"),n.readSync(a,o,0,150,0),n.closeSync(a)}catch{}return i(o.toString())}t.exports=r}}),RI=we({"node_modules/cross-spawn/lib/parse.js"(e,t){"use strict";var n=Ct("path"),i=kI(),r=xI(),u=PI(),s=process.platform==="win32",o=/\.(?:com|exe)$/i,a=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function l(p){p.file=i(p);let v=p.file&&u(p.file);return v?(p.args.unshift(p.file),p.command=v,i(p)):p.file}function c(p){if(!s)return p;let v=l(p),g=!o.test(v);if(p.options.forceShell||g){let C=a.test(v);p.command=n.normalize(p.command),p.command=r.command(p.command),p.args=p.args.map(b=>r.argument(b,C));let y=[p.command].concat(p.args).join(" ");p.args=["/d","/s","/c",`"${y}"`],p.command=process.env.comspec||"cmd.exe",p.options.windowsVerbatimArguments=!0}return p}function m(p,v,g){v&&!Array.isArray(v)&&(g=v,v=null),v=v?v.slice(0):[],g=Object.assign({},g);let C={command:p,args:v,options:g,file:void 0,original:{command:p,args:v}};return g.shell?C:c(C)}t.exports=m}}),zI=we({"node_modules/cross-spawn/lib/enoent.js"(e,t){"use strict";var n=process.platform==="win32";function i(o,a){return Object.assign(new Error(`${a} ${o.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${a} ${o.command}`,path:o.command,spawnargs:o.args})}function r(o,a){if(!n)return;let l=o.emit;o.emit=function(c,m){if(c==="exit"){let p=u(m,a);if(p)return l.call(o,"error",p)}return l.apply(o,arguments)}}function u(o,a){return n&&o===1&&!a.file?i(a.original,"spawn"):null}function s(o,a){return n&&o===1&&!a.file?i(a.original,"spawnSync"):null}t.exports={hookChildProcess:r,verifyENOENT:u,verifyENOENTSync:s,notFoundError:i}}}),OI=we({"node_modules/cross-spawn/index.js"(e,t){"use strict";var n=Ct("child_process"),i=RI(),r=zI();function u(o,a,l){let c=i(o,a,l),m=n.spawn(c.command,c.args,c.options);return r.hookChildProcess(m,c),m}function s(o,a,l){let c=i(o,a,l),m=n.spawnSync(c.command,c.args,c.options);return m.error=m.error||r.verifyENOENTSync(m.status,c),m}t.exports=u,t.exports.spawn=u,t.exports.sync=s,t.exports._parse=i,t.exports._enoent=r}}),NI=Sn(Sr(),1),MI=Sn(OI(),1),Vi=Sn(Sr(),1),pe={initialize:"initialize",authenticate:"authenticate",providers_list:"providers/list",providers_set:"providers/set",providers_disable:"providers/disable",session_new:"session/new",session_load:"session/load",session_set_mode:"session/set_mode",session_set_config_option:"session/set_config_option",session_prompt:"session/prompt",session_cancel:"session/cancel",mcp_message:"mcp/message",session_list:"session/list",session_delete:"session/delete",session_fork:"session/fork",session_resume:"session/resume",session_close:"session/close",logout:"logout"},De={session_request_permission:"session/request_permission",session_update:"session/update",fs_write_text_file:"fs/write_text_file",fs_read_text_file:"fs/read_text_file",terminal_create:"terminal/create",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit",terminal_kill:"terminal/kill",mcp_message:"mcp/message",elicitation_create:"elicitation/create",elicitation_complete:"elicitation/complete"},GI={cancel_request:"$/cancel_request"},VI=1,Q={};bn(Q,{$brand:()=>Kv,$input:()=>$3,$output:()=>I3,INVALID:()=>_t,NEVER:()=>na,TimePrecision:()=>M3,ZodAny:()=>Lh,ZodArray:()=>Gh,ZodBase64:()=>Ua,ZodBase64URL:()=>ja,ZodBigInt:()=>Lu,ZodBigIntFormat:()=>Za,ZodBoolean:()=>ju,ZodCIDRv4:()=>Na,ZodCIDRv6:()=>Ma,ZodCUID:()=>xa,ZodCUID2:()=>Ta,ZodCatch:()=>hf,ZodCodec:()=>Vu,ZodCompileAsyncError:()=>Ln,ZodCompileUnsupportedError:()=>ge,ZodCreditCard:()=>Oh,ZodCustom:()=>Hu,ZodCustomStringFormat:()=>Ir,ZodDate:()=>Ga,ZodDefault:()=>sf,ZodDiscriminatedUnion:()=>Hh,ZodE164:()=>La,ZodEmail:()=>Ia,ZodEmoji:()=>Ba,ZodEnum:()=>ci,ZodError:()=>yx,ZodExactOptional:()=>Ka,ZodFile:()=>tf,ZodFirstPartyTypeKind:()=>Mc,ZodFunction:()=>_f,ZodGUID:()=>$a,ZodIBAN:()=>Nh,ZodIPv4:()=>za,ZodIPv6:()=>Oa,ZodISODate:()=>zu,ZodISODateTime:()=>Ru,ZodISODuration:()=>Nu,ZodISOTime:()=>Ou,ZodInstanceOf:()=>Sf,ZodIntersection:()=>Jh,ZodIssueCode:()=>wx,ZodJWT:()=>qa,ZodKSUID:()=>Ra,ZodLazy:()=>yf,ZodLiteral:()=>ef,ZodMAC:()=>zh,ZodMap:()=>Yh,ZodNaN:()=>pf,ZodNanoID:()=>ka,ZodNever:()=>Zh,ZodNonOptional:()=>Xa,ZodNull:()=>jh,ZodNullable:()=>uf,ZodNumber:()=>Uu,ZodNumberFormat:()=>$r,ZodObject:()=>qu,ZodOptional:()=>Wu,ZodPipe:()=>Gu,ZodPrefault:()=>af,ZodPreprocess:()=>mf,ZodPromise:()=>wf,ZodReadonly:()=>gf,ZodRealError:()=>Pt,ZodRecord:()=>li,ZodSet:()=>Qh,ZodString:()=>Pu,ZodStringFormat:()=>Ae,ZodSuccess:()=>df,ZodSymbol:()=>Mh,ZodTemplateLiteral:()=>Cf,ZodTransform:()=>nf,ZodTuple:()=>Kh,ZodType:()=>ce,ZodULID:()=>Fa,ZodURL:()=>Mu,ZodUUID:()=>sn,ZodUndefined:()=>Uh,ZodUnion:()=>Zu,ZodUnknown:()=>qh,ZodVoid:()=>Wh,ZodXID:()=>Pa,ZodXor:()=>Vh,_ZodString:()=>Da,_default:()=>of,_function:()=>go,any:()=>d1,array:()=>Y,base64:()=>Ww,base64url:()=>Gw,bigint:()=>s1,boolean:()=>ke,catch:()=>ff,check:()=>x1,cidrv4:()=>qw,cidrv6:()=>Zw,clone:()=>je,codec:()=>I1,coerce:()=>U1,compile:()=>k3,config:()=>at,core:()=>zv,creditCard:()=>Hw,cuid:()=>Rw,cuid2:()=>zw,currencyCode:()=>e1,custom:()=>T1,date:()=>f1,decode:()=>yw,decodeAsync:()=>ww,deepPartial:()=>Nx,describe:()=>F1,discriminatedUnion:()=>v1,e164:()=>Vw,email:()=>Dw,emoji:()=>Fw,encode:()=>Cw,encodeAsync:()=>Ew,endsWith:()=>Ca,enum:()=>Ha,exactOptional:()=>rf,file:()=>A1,flattenError:()=>o0,float32:()=>n1,float64:()=>r1,formatError:()=>a0,fromJSONSchema:()=>Ox,function:()=>go,getDiscriminatedOption:()=>Ky,getErrorMap:()=>Ax,globalRegistry:()=>Mt,gt:()=>Zn,gte:()=>Lt,guid:()=>Iw,hash:()=>t1,hex:()=>Qw,hostname:()=>Yw,httpUrl:()=>Tw,iban:()=>Jw,includes:()=>ga,input:()=>jx,instanceof:()=>R1,int:()=>Ke,int32:()=>i1,int64:()=>o1,intersection:()=>Xe,invertCodec:()=>$1,ipv4:()=>Uw,ipv6:()=>Lw,iso:()=>Ai,json:()=>O1,jwt:()=>Kw,keyof:()=>p1,ksuid:()=>Mw,lazy:()=>Ef,length:()=>Fu,literal:()=>E,locales:()=>Y0,looseObject:()=>Va,looseRecord:()=>y1,lowercase:()=>pa,lt:()=>qn,lte:()=>jt,mac:()=>jw,map:()=>E1,maxLength:()=>Tu,maxSize:()=>wi,memoizer:()=>K0,meta:()=>P1,mime:()=>Ea,minLength:()=>_r,minSize:()=>Wn,multipleOf:()=>ri,nan:()=>D1,nanoid:()=>Pw,nativeEnum:()=>_1,negative:()=>Bh,never:()=>Wa,nonnegative:()=>xh,nonoptional:()=>cf,nonpositive:()=>kh,normalize:()=>wa,null:()=>Br,nullable:()=>lu,nullish:()=>b1,number:()=>se,object:()=>d,optional:()=>di,output:()=>Lx,overwrite:()=>Dn,parse:()=>pw,parseAsync:()=>mw,partialRecord:()=>C1,pipe:()=>mo,positive:()=>$h,prefault:()=>lf,preprocess:()=>Df,prettifyError:()=>tC,promise:()=>k1,properties:()=>ya,property:()=>Th,readonly:()=>vf,record:()=>_,refine:()=>Af,regex:()=>fa,regexes:()=>ua,registry:()=>Q0,safeDecode:()=>Aw,safeDecodeAsync:()=>Sw,safeEncode:()=>_w,safeEncodeAsync:()=>bw,safeParse:()=>gw,safeParseAsync:()=>vw,set:()=>w1,setErrorMap:()=>_x,size:()=>xu,slugify:()=>Sa,startsWith:()=>va,strictObject:()=>m1,string:()=>h,stringFormat:()=>Xw,stringbool:()=>z1,success:()=>S1,superRefine:()=>bf,symbol:()=>l1,templateLiteral:()=>B1,toJSONSchema:()=>cw,toLowerCase:()=>Aa,toUpperCase:()=>ba,toZod:()=>Yd,transform:()=>Ja,treeifyError:()=>Qv,trim:()=>_a,tuple:()=>Xh,uint32:()=>u1,uint64:()=>a1,ulid:()=>Ow,undefined:()=>c1,union:()=>U,unknown:()=>w,uppercase:()=>ma,url:()=>Rt,util:()=>ne,uuid:()=>$w,uuidv4:()=>Bw,uuidv6:()=>kw,uuidv7:()=>xw,validate:()=>l0,validateAsync:()=>c0,void:()=>h1,withParser:()=>eh,xid:()=>Nw,xor:()=>g1});var zv={};bn(zv,{$ZodAny:()=>My,$ZodArray:()=>Zy,$ZodAsyncError:()=>Cn,$ZodBase64:()=>Iy,$ZodBase64URL:()=>$y,$ZodBigInt:()=>L0,$ZodBigIntFormat:()=>Ry,$ZodBoolean:()=>j0,$ZodCIDRv4:()=>Sy,$ZodCIDRv6:()=>Dy,$ZodCUID:()=>fy,$ZodCUID2:()=>py,$ZodCatch:()=>f3,$ZodCheck:()=>Re,$ZodCheckBigIntFormat:()=>jC,$ZodCheckEndsWith:()=>QC,$ZodCheckGreaterThan:()=>D0,$ZodCheckIncludes:()=>XC,$ZodCheckLengthEquals:()=>VC,$ZodCheckLessThan:()=>S0,$ZodCheckLowerCase:()=>JC,$ZodCheckMaxLength:()=>WC,$ZodCheckMaxSize:()=>LC,$ZodCheckMimeType:()=>ny,$ZodCheckMinLength:()=>GC,$ZodCheckMinSize:()=>qC,$ZodCheckMultipleOf:()=>MC,$ZodCheckNumberFormat:()=>UC,$ZodCheckOverwrite:()=>ry,$ZodCheckProperties:()=>ty,$ZodCheckProperty:()=>ey,$ZodCheckRegex:()=>HC,$ZodCheckSizeEquals:()=>ZC,$ZodCheckStartsWith:()=>YC,$ZodCheckStringFormat:()=>Bu,$ZodCheckUpperCase:()=>KC,$ZodCodec:()=>V0,$ZodCreditCard:()=>ky,$ZodCustom:()=>E3,$ZodCustomStringFormat:()=>Fy,$ZodCyclicError:()=>w3,$ZodDate:()=>qy,$ZodDefault:()=>l3,$ZodDiscriminatedUnion:()=>Yy,$ZodE164:()=>By,$ZodEmail:()=>ay,$ZodEmoji:()=>dy,$ZodEncodeError:()=>ra,$ZodEnum:()=>r3,$ZodError:()=>Yv,$ZodExactOptional:()=>o3,$ZodFile:()=>u3,$ZodFunction:()=>C3,$ZodGUID:()=>sy,$ZodIBAN:()=>xy,$ZodIPv4:()=>_y,$ZodIPv6:()=>Ay,$ZodISODate:()=>yy,$ZodISODateTime:()=>Cy,$ZodISODuration:()=>wy,$ZodISOTime:()=>Ey,$ZodIntersection:()=>Qy,$ZodJWT:()=>Ty,$ZodKSUID:()=>vy,$ZodLazy:()=>H0,$ZodLiteral:()=>i3,$ZodMAC:()=>by,$ZodMap:()=>t3,$ZodNaN:()=>p3,$ZodNanoID:()=>hy,$ZodNever:()=>jy,$ZodNonOptional:()=>d3,$ZodNull:()=>Ny,$ZodNullable:()=>a3,$ZodNumber:()=>U0,$ZodNumberFormat:()=>Py,$ZodObject:()=>Vy,$ZodObjectJIT:()=>Hy,$ZodOptional:()=>W0,$ZodPipe:()=>G0,$ZodPrefault:()=>c3,$ZodPreprocess:()=>m3,$ZodPromise:()=>y3,$ZodReadonly:()=>g3,$ZodRealError:()=>Ft,$ZodRecord:()=>e3,$ZodRegistry:()=>B3,$ZodSet:()=>n3,$ZodString:()=>ku,$ZodStringFormat:()=>_e,$ZodSuccess:()=>h3,$ZodSymbol:()=>zy,$ZodTemplateLiteral:()=>v3,$ZodTransform:()=>s3,$ZodTuple:()=>Z0,$ZodType:()=>le,$ZodULID:()=>my,$ZodURL:()=>cy,$ZodUUID:()=>oy,$ZodUndefined:()=>Oy,$ZodUnion:()=>la,$ZodUnknown:()=>Uy,$ZodVoid:()=>Ly,$ZodXID:()=>gy,$ZodXor:()=>Jy,$brand:()=>Kv,$constructor:()=>B,$input:()=>$3,$output:()=>I3,Doc:()=>I0,INVALID:()=>_t,JSONSchema:()=>Cx,JSONSchemaGenerator:()=>vx,NEVER:()=>na,TimePrecision:()=>M3,URL_BAD_FORMAT:()=>B0,URL_UNPARSEABLE:()=>uu,ZodCompileAsyncError:()=>Ln,ZodCompileUnsupportedError:()=>ge,_any:()=>nE,_array:()=>lE,_base64:()=>Eh,_base64url:()=>wh,_bigint:()=>J3,_boolean:()=>V3,_catch:()=>sx,_check:()=>pE,_cidrv4:()=>Ch,_cidrv6:()=>yh,_coercedBigint:()=>K3,_coercedBoolean:()=>H3,_coercedDate:()=>oE,_coercedNumber:()=>j3,_coercedString:()=>R3,_creditCard:()=>O3,_cuid:()=>dh,_cuid2:()=>hh,_custom:()=>dE,_date:()=>sE,_decode:()=>h0,_decodeAsync:()=>p0,_default:()=>rx,_discriminatedUnion:()=>Wk,_e164:()=>_h,_email:()=>rh,_emoji:()=>lh,_encode:()=>d0,_encodeAsync:()=>f0,_endsWith:()=>Ca,_enum:()=>Xk,_file:()=>cE,_float32:()=>q3,_float64:()=>Z3,_gt:()=>Zn,_gte:()=>Lt,_guid:()=>ih,_iban:()=>N3,_includes:()=>ga,_int:()=>L3,_int32:()=>W3,_int64:()=>X3,_intersection:()=>Gk,_ipv4:()=>gh,_ipv6:()=>vh,_isoDate:()=>Sh,_isoDateTime:()=>bh,_isoDuration:()=>Ih,_isoTime:()=>Dh,_jwt:()=>Ah,_ksuid:()=>mh,_lazy:()=>cx,_length:()=>Fu,_literal:()=>Qk,_lowercase:()=>pa,_lt:()=>qn,_lte:()=>jt,_mac:()=>z3,_map:()=>Jk,_max:()=>jt,_maxLength:()=>Tu,_maxSize:()=>wi,_mime:()=>Ea,_min:()=>Lt,_minLength:()=>_r,_minSize:()=>Wn,_multipleOf:()=>ri,_nan:()=>aE,_nanoid:()=>ch,_nativeEnum:()=>Yk,_negative:()=>Bh,_never:()=>iE,_nonnegative:()=>xh,_nonoptional:()=>ix,_nonpositive:()=>kh,_normalize:()=>wa,_null:()=>tE,_nullable:()=>nx,_number:()=>U3,_optional:()=>tx,_overwrite:()=>Dn,_parse:()=>Au,_parseAsync:()=>bu,_pipe:()=>ox,_positive:()=>$h,_promise:()=>dx,_properties:()=>ya,_property:()=>Th,_readonly:()=>ax,_record:()=>Hk,_refine:()=>hE,_regex:()=>fa,_safeDecode:()=>g0,_safeDecodeAsync:()=>C0,_safeEncode:()=>m0,_safeEncodeAsync:()=>v0,_safeParse:()=>Su,_safeParseAsync:()=>Du,_set:()=>Kk,_size:()=>xu,_slugify:()=>Sa,_startsWith:()=>va,_string:()=>P3,_stringFormat:()=>_i,_stringbool:()=>vE,_success:()=>ux,_superRefine:()=>fE,_symbol:()=>Q3,_templateLiteral:()=>lx,_toLowerCase:()=>Aa,_toUpperCase:()=>ba,_transform:()=>ex,_trim:()=>_a,_tuple:()=>Vk,_uint32:()=>G3,_uint64:()=>Y3,_ulid:()=>fh,_undefined:()=>eE,_union:()=>qk,_unknown:()=>rE,_uppercase:()=>ma,_url:()=>ha,_uuid:()=>uh,_uuidv4:()=>sh,_uuidv6:()=>oh,_uuidv7:()=>ah,_void:()=>uE,_xid:()=>ph,_xor:()=>Zk,base64Charset:()=>R0,base64urlCharset:()=>aa,canParseURL:()=>k0,clone:()=>je,compile:()=>k3,compileFn:()=>ca,config:()=>at,createStandardJSONSchemaMethod:()=>ou,createToJSONSchemaMethod:()=>EE,decode:()=>M5,decodeAsync:()=>j5,describe:()=>mE,encode:()=>N5,encodeAsync:()=>U5,extractDefs:()=>ui,finalize:()=>si,flattenError:()=>o0,formatError:()=>a0,getDiscriminatedOption:()=>Ky,globalConfig:()=>gt,globalRegistry:()=>Mt,handleUnrepresentable:()=>it,initializeContext:()=>ii,isBackEdge:()=>X0,isRecursiveSchema:()=>J0,isValidBase64:()=>oa,isValidBase64URL:()=>z0,isValidCIDRv6:()=>P0,isValidCreditCard:()=>O0,isValidIBAN:()=>N0,isValidIPv6:()=>sa,isValidJWT:()=>M0,locales:()=>Y0,memoizer:()=>K0,mergeValues:()=>su,meta:()=>gE,parse:()=>$c,parseAsync:()=>Bc,parseURLObject:()=>ly,prettifyError:()=>tC,process:()=>Ee,processSchema:()=>Ee,regexes:()=>ua,registry:()=>Q0,safeDecode:()=>q5,safeDecodeAsync:()=>W5,safeEncode:()=>L5,safeEncodeAsync:()=>Z5,safeParse:()=>F5,safeParseAsync:()=>P5,standardProps:()=>$0,stripTabAndNewline:()=>fo,toDotPath:()=>eC,toJSONSchema:()=>cw,toZod:()=>Yd,treeifyError:()=>Qv,urlHostnameOk:()=>T0,urlProtocolOk:()=>F0,util:()=>ne,validate:()=>l0,validateAsync:()=>c0,validateURL:()=>x0,version:()=>iy,withParser:()=>eh});var ne={};bn(ne,{BIGINT_FORMAT_RANGES:()=>i0,CONSTANT_CATCH:()=>s0,Class:()=>_5,NUMBER_FORMAT_RANGES:()=>r0,aborted:()=>yt,allowsEval:()=>jv,assert:()=>YI,assertEqual:()=>HI,assertIs:()=>KI,assertNever:()=>XI,assertNotEqual:()=>JI,assignProp:()=>Tt,attachSchema:()=>ao,base64ToUint8Array:()=>Gv,base64urlToUint8Array:()=>C5,cached:()=>wu,captureStackTrace:()=>t0,cleanEnum:()=>v5,cleanRegex:()=>Mn,clone:()=>je,cloneDef:()=>n5,codePointLength:()=>_u,constantCatch:()=>Jv,createTransparentProxy:()=>a5,defineLazy:()=>Ov,defineLazyInternal:()=>fe,derived:()=>A5,esc:()=>$t,escapeRegex:()=>An,explicitlyAborted:()=>Wv,extend:()=>d5,finalizeIssue:()=>qt,floatSafeRemainder:()=>e0,getElementAtPath:()=>r5,getEnumValues:()=>io,getLengthableOrigin:()=>ta,getParsedType:()=>o5,getSizableOrigin:()=>ea,hexToUint8Array:()=>E5,hide:()=>u0,installLazyProp:()=>I5,isObject:()=>ti,isPlainObject:()=>_n,issue:()=>lo,joinValues:()=>R,jsonStringifyReplacer:()=>uo,members:()=>Hv,merge:()=>f5,mergeDefs:()=>an,normalizeParams:()=>L,nullish:()=>Qd,numKeys:()=>s5,objectClone:()=>e5,omit:()=>c5,optionalKeys:()=>qv,own:()=>yr,parsedType:()=>K,partial:()=>p5,pick:()=>l5,prefixIssues:()=>Nt,primitiveTypes:()=>Lv,promiseAllObject:()=>i5,propertyKeyTypes:()=>so,randomString:()=>u5,rawShape:()=>Yo,required:()=>m5,safeExtend:()=>h5,shallowClone:()=>n0,sizeCaps:()=>oo,slugify:()=>Uv,stringifyPrimitive:()=>J,toZod:()=>Yd,uint8ArrayToBase64:()=>Vv,uint8ArrayToBase64url:()=>y5,uint8ArrayToHex:()=>w5,unwrapMessage:()=>Mr});function HI(e){return e}function JI(e){return e}function Yd(){return e=>e}function KI(e){}function XI(e){throw new Error("Unexpected value in exhaustive check")}function YI(e){}function io(e){let t=Object.values(e).filter(i=>typeof i=="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function R(e,t="|"){return e.map(n=>J(n)).join(t)}function uo(e,t){return typeof t=="bigint"?t.toString():t}var QI=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function wu(e){return new QI(e)}function Qd(e){return e==null}function Mn(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function e0(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-i)<r?0:n-i}var Np=Symbol("evaluating");function Ov(e,t,n){let i;Object.defineProperty(e,t,{get(){if(i!==Np)return i===void 0&&(i=Np,i=n()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function e5(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Tt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Yo(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function wn(e){return Yo(e._zod.def)??e._zod.def.shape}function Nv(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Tt(this,t,i),i},enumerable:!0,configurable:!0})}function Mv(e,t,n){t in e?Tt(e,t,n):e[t]=n}function Cr(e,t,n,i){let r=wn(t);for(let u of n){let s=Object.getOwnPropertyDescriptor(r,u);s.enumerable&&(s.get?Nv(e,u,()=>{let o=t._zod.def.shape[u];return i?i(o,u):o}):Mv(e,u,i?i(s.value,u):s.value))}}function t5(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);i.enumerable&&(i.get?Nv(e,n,()=>t[n]):Mv(e,n,i.value))}}function an(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function n5(e){return an(e._zod.def)}function r5(e,t){return t?t.reduce((n,i)=>n?.[i],e):e}function i5(e){let t=Object.keys(e),n=t.map(i=>e[i]);return Promise.all(n).then(i=>{let r={};for(let u=0;u<t.length;u++)r[t[u]]=i[u];return r})}function u5(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let i=0;i<e;i++)n+=t[Math.floor(Math.random()*t.length)];return n}function $t(e){return JSON.stringify(e)}function Uv(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var t0="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ti(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var jv=wu(()=>{if(gt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function _n(e){if(ti(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(ti(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function n0(e){return _n(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function s5(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}var o5=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},so=new Set(["string","number","symbol"]),Lv=new Set(["string","number","bigint","boolean","symbol","undefined"]);function An(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function je(e,t,n){let i=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(i._zod.parent=e),i}function L(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function a5(e){let t;return new Proxy({},{get(n,i,r){return t??(t=e()),Reflect.get(t,i,r)},set(n,i,r,u){return t??(t=e()),Reflect.set(t,i,r,u)},has(n,i){return t??(t=e()),Reflect.has(t,i)},deleteProperty(n,i){return t??(t=e()),Reflect.deleteProperty(t,i)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,i){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,i)},defineProperty(n,i,r){return t??(t=e()),Reflect.defineProperty(t,i,r)}})}function J(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function qv(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var r0={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},i0={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function l5(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let u={};return Cr(u,e,Qo(e,t)),je(e,an(n,{shape:u,checks:[]}))}function Qo(e,t){let n=wn(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw new Error(`Unrecognized key: "${String(r)}"`);t[r]&&i.push(r)}return i}function c5(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let u=new Set(Qo(e,t)),s={};return Cr(s,e,Reflect.ownKeys(wn(e)).filter(o=>!u.has(o))),je(e,an(n,{shape:s,checks:[]}))}function d5(e,t){if(!_n(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=wn(e);for(let u of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,u)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return je(e,an(e._zod.def,{shape:Zv(e,t)}))}function Zv(e,t){let n={};return Cr(n,e,Reflect.ownKeys(wn(e))),t5(n,t),n}function h5(e,t){if(!_n(t))throw new Error("Invalid input to safeExtend: expected a plain object");return je(e,an(e._zod.def,{shape:Zv(e,t)}))}function f5(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Cr(n,e,Reflect.ownKeys(wn(e))),Cr(n,t,Reflect.ownKeys(wn(t)));let i=an(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return je(e,i)}function p5(e,t,n,i="partial"){let u=t._zod.def.checks;if(u&&u.length>0)throw new Error(`.${i}() cannot be used on object schemas containing refinements`);let o=n?new Set(Qo(t,n)):void 0,a={};return Cr(a,t,Reflect.ownKeys(wn(t)),e&&((l,c)=>o&&!o.has(c)?l:new e({type:"optional",innerType:l}))),je(t,an(t._zod.def,{shape:a,checks:[]}))}function m5(e,t,n){let i=n?new Set(Qo(t,n)):void 0,r={};return Cr(r,t,Reflect.ownKeys(wn(t)),(u,s)=>i&&!i.has(s)?u:new e({type:"nonoptional",innerType:u})),je(t,an(t._zod.def,{shape:r}))}function yt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Wv(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Nt(e,t){return t.map(n=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Mr(e){return typeof e=="string"?e:e?.message}function oo(e){let t=[];for(let n of e??[]){let i=n._zod.def;if(!/_(length|size)$|_equals$/.test(i.check))break;let r=i.maximum??i.length??i.size;r>=0&&t.push([r,n])}return t}function ao(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function qt(e,t,n){var i;let r=e.inst?._zod?.traits;r?.has("$ZodType")&&(r.has("$ZodCheck")?(i=e).schema??(i.schema=e.inst):e.schema=e.inst);let u=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:Mr(e.inst?._zod.def?.error?.(e))??Mr(u?.(e))??Mr(t?.error?.(e))??Mr(n.customError?.(e))??Mr(n.localeError?.(e))??"Invalid input",o={};for(let a of Object.keys(e))a==="inst"||a==="schema"||a==="continue"||a==="input"||a==="__proto__"||(o[a]=e[a]);return o.path??(o.path=[]),o.message=s,t?.reportInput&&(o.input=e.input),o}function ea(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var g5=/[\uD800-\uDBFF]/;function _u(e){let t=e.length;if(!g5.test(e))return t;let n=t;for(let i=0;i<t-1;i++)(e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320&&(n--,i++);return n}function ta(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function K(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function lo(...e){let[t,n,i]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:i}:{...t}}function v5(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Gv(e){let t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}function Vv(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function C5(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return Gv(t+n)}function y5(e){return Vv(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function E5(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(t.length/2);for(let i=0;i<t.length;i+=2)n[i/2]=Number.parseInt(t.slice(i,i+2),16);return n}function w5(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var _5=class{constructor(...e){}};function Hv(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);i.get?Object.defineProperty(e,n,{...i,enumerable:!1}):b5(e,n,i.value)}}function yr(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function u0(e,t,n){return yr(e,t,n,!1)}function A5(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return yr(this,n,i(this))},set(r){yr(this,n,r)}})}return t}function b5(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:yr(this,t,n.bind(this))},set(i){yr(this,t,i)}})}function S5(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Tl,Pn=!1,D5={configurable:!0,get(){Pn=!0}};function fe(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&Tl!==e._zod){Tl=void 0;return}Tl=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,D5);let r=Pn;Pn=!1;try{let u=n(this);return Pn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:u}),Pn=Pn||r,u}catch(u){throw delete this[t],Pn=Pn||r,u}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function I5(e,t,n,i){let r=S5(e,t);r&&Object.defineProperty(r,t,{configurable:!0,get(){let u={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,u),u.value=n(this),Object.defineProperty(this,t,u),u.value},set(u){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:u})}})}var s0="~constantCatch";function Jv(e){let t=()=>e;return t[s0]=!0,t}var Mp,na=Object.freeze({status:"aborted"}),Fl={value:void 0,enumerable:!1},Up="captureStackTrace"in Error?Error:null;function $5(e){let t=Up;if(t){let n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return Up=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function B(e,t,n,i){let r={};function u(p){this.def=p,this.constr=m,this.traits=new Set}u.prototype=r;let s=n,o=s&&new WeakSet;function a(p,v){if(p._zod){if(p._zod.traits.has(e))return}else{Fl.value=new u(v);try{Object.defineProperty(p,"_zod",Fl)}finally{Fl.value=void 0}}if(p._zod.traits.add(e),t(p,v),o){let C=Object.getPrototypeOf(p),y=p._zod.constr.prototype,b=C;for(;b&&b!==y;)b=Object.getPrototypeOf(b);let A=b??C;o.has(A)||(o.add(A),Hv(A,s))}let g=m.prototype;for(let C in g)Object.prototype.hasOwnProperty.call(g,C)&&(C in p||(p[C]=g[C].bind(p)))}let l=i?.Parent??Object;class c extends l{}Object.defineProperty(c,"name",{value:e});function m(p){let v=i?.Parent?$5(c):this;a(v,p);let g=v._zod.deferred;if(g){for(let y of g)y();v._zod.deferred=void 0}let C=globalThis.__zod_globalConfig?.postProcessor;return C&&C(v),v}return Object.defineProperty(m,"init",{value:a}),Object.defineProperty(m,Symbol.hasInstance,{value:p=>i?.Parent&&p instanceof i.Parent?!0:p?._zod?.traits?.has(e)}),Object.defineProperty(m,"name",{value:e}),m}var Kv=Symbol("zod_brand"),Cn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},ra=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(Mp=globalThis).__zod_globalConfig??(Mp.__zod_globalConfig={});var gt=globalThis.__zod_globalConfig;function at(e){return e&&Object.assign(gt,e),gt}function B5(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,uo,2)),e.message}function k5(e){this._zod.message=e}var x5={get:B5,set:k5,enumerable:!0,configurable:!0},Pl={value:void 0,enumerable:!1},jp=new WeakSet([Object.prototype,Error.prototype]),Xv=(e,t)=>{e.name="$ZodError",Pl.value=t,Object.defineProperty(e,"issues",Pl),Pl.value=void 0,Object.defineProperty(e,"message",x5);let n=Object.getPrototypeOf(e);jp.has(n)||(jp.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}}))},Yv=B("$ZodError",Xv),Ft=B("$ZodError",Xv,void 0,{Parent:Error});function T5(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function o0(e,t=n=>n.message){let n={},i=[];for(let r of e.issues)r.path.length>0?T5(n,r.path[0],()=>[]).push(t(r)):i.push(t(r));return{formErrors:i,fieldErrors:n}}function a0(e,t=n=>n.message){let n={_errors:[]},i=(r,u=[])=>{for(let s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>i({issues:o},[...u,...s.path]));else if(s.code==="invalid_key")i({issues:s.issues},[...u,...s.path]);else if(s.code==="invalid_element")i({issues:s.issues},[...u,...s.path]);else{let o=[...u,...s.path];if(o.length===0)n._errors.push(t(s));else{let a=n,l=0;for(;l<o.length;){let c=o[l],m=l===o.length-1;if(c==="_errors"){m&&a._errors.push(t(s)),l++;continue}Object.prototype.hasOwnProperty.call(a,c)||Object.defineProperty(a,c,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let p=a[c];m&&p._errors.push(t(s)),a=p,l++}}}};return i(e),n}function Qv(e,t=n=>n.message){let n={errors:[]},i=(r,u=[])=>{var s;for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(a=>i({issues:a},[...u,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...u,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...u,...o.path]);else{let a=[...u,...o.path];if(a.length===0){n.errors.push(t(o));continue}let l=n,c=0;for(;c<a.length;){let m=a[c],p=c===a.length-1;typeof m=="string"?(l.properties??(l.properties={}),Object.prototype.hasOwnProperty.call(l.properties,m)||Object.defineProperty(l.properties,m,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),l=l.properties[m]):(l.items??(l.items=[]),(s=l.items)[m]??(s[m]={errors:[]}),l=l.items[m]),p&&l.errors.push(t(o)),c++}}};return i(e),n}function eC(e){let t=[],n=e.map(i=>typeof i=="object"?i.key:i);for(let i of n)typeof i=="number"?t.push(`[${i}]`):typeof i=="symbol"?t.push(`[${JSON.stringify(String(i))}]`):/[^\w$]/.test(i)?t.push(`[${JSON.stringify(i)}]`):(t.length&&t.push("."),t.push(i));return t.join("")}function tC(e){let t=[],n=[...e.issues].sort((i,r)=>(i.path??[]).length-(r.path??[]).length);for(let i of n)t.push(`\u2716 ${i.message}`),i.path?.length&&t.push(` \u2192 at ${eC(i.path)}`);return t.join(`
|
|
9
|
+
`)}function ia(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Au=e=>{let t=(n,i,r,u)=>{let s=r?{...r,async:!1}:{async:!1},o=n._zod.run({value:i,issues:[]},s);if(o instanceof Promise)throw new Cn;if(o.issues.length){let a=new(u?.Err??e)(o.issues.map(l=>qt(l,s,at())));throw t0(a,u?.callee??t),a}return o.value};return t},$c=Au(Ft),bu=e=>{let t=async(n,i,r,u)=>{let s=r?{...r,async:!0}:{async:!0},o=n._zod.run({value:i,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){let a=new(u?.Err??e)(o.issues.map(l=>qt(l,s,at())));throw t0(a,u?.callee??t),a}return o.value};return t},Bc=bu(Ft),Su=e=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},u=t._zod.run({value:n,issues:[]},r);if(u instanceof Promise)throw new Cn;return u.issues.length?nC(e,u.issues,r):{success:!0,data:u.value}},F5=Su(Ft);function nC(e,t,n){let i;return{success:!1,get error(){return i||(i=new e(t.map(r=>qt(r,n,at()))),t=void 0,n=void 0),i},set error(r){i=r,t=void 0,n=void 0}}}var Du=e=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},u=t._zod.run({value:n,issues:[]},r);return u instanceof Promise&&(u=await u),u.issues.length?nC(e,u.issues,r):{success:!0,data:u.value}},P5=Du(Ft),R5=Symbol.for("zod.compile.invalid"),z5=Symbol.for("zod.compile.fallback"),l0=((e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==R5)return!0;if(i.definite===!0&&n===void 0)return!1}return O5(e,t,n)});function O5(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,u;if(r?(i[z5]=!0,u=r({value:t,issues:[]},i)):u=e._zod.run({value:t,issues:[]},i),u instanceof Promise)throw new Cn;return u.issues.length===0}var c0=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);return r instanceof Promise&&(r=await r),r.issues.length===0},d0=e=>{let t=Au(e),n=(i,r,u,s)=>{let o=u?{...u,direction:"backward"}:{direction:"backward"};return t(i,r,o,ia(n,s))};return n},N5=d0(Ft),h0=e=>{let t=Au(e),n=(i,r,u,s)=>t(i,r,u,ia(n,s));return n},M5=h0(Ft),f0=e=>{let t=bu(e),n=async(i,r,u,s)=>{let o=u?{...u,direction:"backward"}:{direction:"backward"};return await t(i,r,o,ia(n,s))};return n},U5=f0(Ft),p0=e=>{let t=bu(e),n=async(i,r,u,s)=>await t(i,r,u,ia(n,s));return n},j5=p0(Ft),m0=e=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Su(e)(t,n,r)},L5=m0(Ft),g0=e=>(t,n,i)=>Su(e)(t,n,i),q5=g0(Ft),v0=e=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Du(e)(t,n,r)},Z5=v0(Ft),C0=e=>async(t,n,i)=>Du(e)(t,n,i),W5=C0(Ft),ua={};bn(ua,{anyString:()=>kC,base64:()=>EC,base64url:()=>wC,bigint:()=>TC,boolean:()=>FC,browserEmail:()=>Q5,cidrv4:()=>CC,cidrv6:()=>yC,creditCard:()=>E0,cuid:()=>rC,cuid2:()=>iC,currencyCode:()=>SC,date:()=>IC,datetime:()=>BC,domain:()=>AC,duration:()=>cC,e164:()=>bC,email:()=>hC,emoji:()=>pC,extendedDuration:()=>G5,guid:()=>dC,hex:()=>NC,hostname:()=>_C,html5Email:()=>K5,httpProtocol:()=>y0,iban:()=>w0,idnEmail:()=>Y5,integer:()=>_0,ipv4:()=>mC,ipv6:()=>gC,ksuid:()=>oC,lowercase:()=>zC,mac:()=>vC,md5_base64:()=>r9,md5_base64url:()=>i9,md5_hex:()=>n9,nanoid:()=>aC,nanoidOfLength:()=>lC,null:()=>PC,number:()=>Ei,rfc5322Email:()=>X5,sha1_base64:()=>s9,sha1_base64url:()=>o9,sha1_hex:()=>u9,sha256_base64:()=>l9,sha256_base64url:()=>c9,sha256_hex:()=>a9,sha384_base64:()=>h9,sha384_base64url:()=>f9,sha384_hex:()=>d9,sha512_base64:()=>m9,sha512_base64url:()=>g9,sha512_hex:()=>p9,string:()=>xC,time:()=>$C,ulid:()=>uC,undefined:()=>RC,unicodeEmail:()=>fC,uppercase:()=>OC,uuid:()=>ni,uuid4:()=>V5,uuid6:()=>H5,uuid7:()=>J5,xid:()=>sC});var rC=/^[cC][0-9a-z]{6,}$/,iC=/^[0-9a-z]+$/,uC=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,sC=/^[0-9a-vA-V]{20}$/,oC=/^[A-Za-z0-9]{27}$/,aC=/^[a-zA-Z0-9_-]{21}$/;function lC(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var cC=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,G5=/^[-+]?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)?)??$/,dC=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ni=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,V5=ni(4),H5=ni(6),J5=ni(7),hC=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,K5=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,X5=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,fC=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Y5=fC,Q5=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,e9="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function pC(){return new RegExp(e9,"u")}var mC=/^(?:(?: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])$/,gC=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,vC=e=>{let t=An(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},CC=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,yC=/^(([0-9a-fA-F]{1,4}:){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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,EC=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,wC=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,_C=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,AC=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,y0=/^https?$/,bC=/^\+[1-9]\d{6,14}$/,E0=/^\d(?:[ -]?\d){11,18}$/,SC=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,w0=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,DC="(?:(?:\\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])))";function t9(e){return new RegExp(`^${e}$`)}var IC=t9(DC);function kc(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function $C(e){return new RegExp(`^${kc(e)}$`)}function BC(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${kc({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${kc({precision:e.precision})}`:n;return new RegExp(`^${DC}T(?:${i})$`)}var kC=/^[\s\S]{0,}$/,xC=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},TC=/^-?\d+n?$/,_0=/^-?\d+$/,Ei=/^-?\d+(?:\.\d+)?$/,FC=/^(?:true|false)$/i,PC=/^null$/i,RC=/^undefined$/i,zC=/^[^A-Z]*$/,OC=/^[^a-z]*$/,NC=/^[0-9a-fA-F]*$/;function Iu(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function $u(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var n9=/^[0-9a-fA-F]{32}$/,r9=Iu(22,"=="),i9=$u(22),u9=/^[0-9a-fA-F]{40}$/,s9=Iu(27,"="),o9=$u(27),a9=/^[0-9a-fA-F]{64}$/,l9=Iu(43,"="),c9=$u(43),d9=/^[0-9a-fA-F]{96}$/,h9=Iu(64,""),f9=$u(64),p9=/^[0-9a-fA-F]{128}$/,m9=Iu(86,"=="),g9=$u(86),Re=B("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),A0=e=>{let t=e.value;return!Qd(t)&&t.size!==void 0},b0=e=>{let t=e.value;return!Qd(t)&&t.length!==void 0},co={number:"number",bigint:"bigint",object:"date"},S0=B("$ZodCheckLessThan",(e,t)=>{Re.init(e,t);let n=co[typeof t.value];e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:co[typeof i.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),D0=B("$ZodCheckGreaterThan",(e,t)=>{Re.init(e,t);let n=co[typeof t.value];e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:co[typeof i.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),MC=B("$ZodCheckMultipleOf",(e,t)=>{Re.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):e0(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),UC=B("$ZodCheckNumberFormat",(e,t)=>{Re.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,u]=r0[t.format];e._zod.check=s=>{let o=s.value;if(n){if(!Number.isInteger(o)){s.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:o,inst:e});return}if(!Number.isSafeInteger(o)){o>0?s.issues.push({input:o,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):s.issues.push({input:o,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}o<r&&s.issues.push({origin:"number",input:o,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),o>u&&s.issues.push({origin:"number",input:o,code:"too_big",maximum:u,inclusive:!0,inst:e,continue:!t.abort})}}),jC=B("$ZodCheckBigIntFormat",(e,t)=>{Re.init(e,t);let[n,i]=i0[t.format];e._zod.check=r=>{let u=r.value;u<n&&r.issues.push({origin:"bigint",input:u,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),u>i&&r.issues.push({origin:"bigint",input:u,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),LC=B("$ZodCheckMaxSize",(e,t)=>{var n;Re.init(e,t),(n=e._zod.def).when??(n.when=A0),e._zod.check=i=>{let r=i.value;r.size<=t.maximum||i.issues.push({origin:ea(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),qC=B("$ZodCheckMinSize",(e,t)=>{var n;Re.init(e,t),(n=e._zod.def).when??(n.when=A0),e._zod.check=i=>{let r=i.value;r.size>=t.minimum||i.issues.push({origin:ea(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ZC=B("$ZodCheckSizeEquals",(e,t)=>{var n;Re.init(e,t),(n=e._zod.def).when??(n.when=A0),e._zod.check=i=>{let r=i.value,u=r.size;if(u===t.size)return;let s=u>t.size;i.issues.push({origin:ea(r),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),WC=B("$ZodCheckMaxLength",(e,t)=>{var n;Re.init(e,t),(n=e._zod.def).when??(n.when=b0),e._zod.check=i=>{let r=i.value,u=r.length;if((typeof r=="string"&&u>t.maximum?_u(r):u)<=t.maximum)return;let o=ta(r);i.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),GC=B("$ZodCheckMinLength",(e,t)=>{var n;Re.init(e,t),(n=e._zod.def).when??(n.when=b0),e._zod.check=i=>{let r=i.value,u=r.length;if((typeof r=="string"&&u>=t.minimum&&u<t.minimum*2?_u(r):u)>=t.minimum)return;let o=ta(r);i.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),VC=B("$ZodCheckLengthEquals",(e,t)=>{var n;Re.init(e,t),(n=e._zod.def).when??(n.when=b0),e._zod.check=i=>{let r=i.value,u=r.length,s=typeof r=="string"&&u>=t.length&&u<=t.length*2?_u(r):u;if(s===t.length)return;let o=ta(r),a=s>t.length;i.issues.push({origin:o,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),Bu=B("$ZodCheckStringFormat",(e,t)=>{var n,i;Re.init(e,t),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),HC=B("$ZodCheckRegex",(e,t)=>{Bu.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),JC=B("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=zC),Bu.init(e,t)}),KC=B("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=OC),Bu.init(e,t)}),XC=B("$ZodCheckIncludes",(e,t)=>{Re.init(e,t);let n=An(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),YC=B("$ZodCheckStartsWith",(e,t)=>{Re.init(e,t);let n=new RegExp(`^${An(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=i=>{i.value.startsWith(t.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),QC=B("$ZodCheckEndsWith",(e,t)=>{Re.init(e,t);let n=new RegExp(`.*${An(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=i=>{i.value.endsWith(t.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});function ho(e,t,n){e.issues.length&&t.issues.push(...Nt(n,e.issues))}var ey=B("$ZodCheckProperty",(e,t)=>{Re.init(e,t),e._zod.check=n=>{let i=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(i instanceof Promise)return i.then(r=>ho(r,n,t.property));ho(i,n,t.property)}}),ty=B("$ZodCheckProperties",(e,t)=>{Re.init(e,t),u0(e,Symbol.iterator,function*(){yield e});let n;e._zod.check=i=>{if(i.value==null){i.issues.push({expected:"object",code:"invalid_type",input:i.value,inst:e});return}n??(n=Reflect.ownKeys(t.shape).map(s=>[s,t.shape[s]]));let r=i.value,u;for(let[s,o]of n){let a=o._zod.run({value:r[s],issues:[]},{});a instanceof Promise?(u??(u=[]),u.push(a.then(l=>ho(l,i,s)))):ho(a,i,s)}if(u)return Promise.all(u).then(()=>{})}}),ny=B("$ZodCheckMimeType",(e,t)=>{Re.init(e,t);let n=new Set(t.mime);e._zod.check=i=>{n.has(i.value.type)||i.issues.push({code:"invalid_value",values:t.mime,input:i.value.type,inst:e,continue:!t.abort})}}),ry=B("$ZodCheckOverwrite",(e,t)=>{Re.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}}),I0=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
|
|
10
|
+
`).filter(u=>u),i=Math.min(...n.map(u=>u.length-u.trimStart().length)),r=n.map(u=>u.slice(i)).map(u=>" ".repeat(this.indent*2)+u);for(let u of r)this.content.push(u)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
11
|
+
${t.join(`
|
|
12
|
+
`)}
|
|
13
|
+
};`)(...Object.values(this.closed))}},iy={major:4,minor:6,patch:7},le=B("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=iy;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let u of r)for(let s of u._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let u=(o,a,l)=>{if(o.memo)return o;let c=yt(o),m;for(let p of a){if(p._zod.def.when){if(Wv(o)||!p._zod.def.when(o))continue}else if(c)continue;let v=o.issues.length,g=p._zod.check(o);if(g instanceof Promise&&l?.async===!1)throw new Cn;if(m||g instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await g,o.issues.length!==v&&(ao(o.issues,v,e),c||(c=yt(o,v)))});else{if(o.issues.length===v)continue;ao(o.issues,v,e),c||(c=yt(o,v))}}return m?m.then(()=>o):o},s=(o,a,l)=>{if(yt(o))return o.aborted=!0,o;let c=u(a,r,l);if(c instanceof Promise){if(l.async===!1)throw new Cn;return c.then(m=>e._zod.parse(m,l))}return e._zod.parse(c,l)};e._zod.run=(o,a)=>{if(a.skipChecks)return e._zod.parse(o,a);if(a.direction==="backward"){let c=e._zod.parse({value:o.value,issues:[]},{...a,skipChecks:!0});return c instanceof Promise?c.then(m=>s(m,o,a)):s(c,o,a)}let l=e._zod.parse(o,a);if(l instanceof Promise){if(a.async===!1)throw new Cn;return l.then(c=>u(c,r,a))}return u(l,r,a)}}},{get"~standard"(){return u0(this,"~standard",$0(this))},set"~standard"(e){yr(this,"~standard",e)}}),uy=(e,t)=>e.issues.length?{issues:e.issues.map(n=>qt(n,t,at()))}:{value:e.value};async function v9(e,t){let n={async:!0};return uy(await e._zod.run({value:t,issues:[]},n),n)}function $0(e){return{validate:t=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return uy(i,n)}catch{}return v9(e,t)},vendor:"zod",version:1}}var ku=B("$ZodString",(e,t)=>{le.init(e,t),e._zod.pattern=t.pattern??kC,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),_e=B("$ZodStringFormat",(e,t)=>{Bu.init(e,t),ku.init(e,t)}),sy=B("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=dC),_e.init(e,t)}),oy=B("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ni(i))}else t.pattern??(t.pattern=ni());_e.init(e,t)}),ay=B("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=hC),_e.init(e,t)}),B0=1,uu=2;function k0(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function x0(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?k0(e)||uu:ly(e,t)}function ly(e,t){if(!t.normalize&&t.protocol?.source===y0.source&&!/^https?:\/\//i.test(e))return B0;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse=="function")return n.parse(e)??uu}return new URL(e)}catch{return uu}}var C9=/[\t\n\r]/g;function fo(e){return e.replace(C9,"")}function T0(e,t){return t.lastIndex=0,t.test(e.hostname)}function F0(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var cy=B("$ZodURL",(e,t)=>{_e.init(e,t),e._zod.check=n=>{try{let i=n.value.trim(),r=x0(i,t);if(r===B0){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===uu){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=fo(i);return}t.hostname&&!T0(r,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!F0(r,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?r.href:fo(i);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),dy=B("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=pC()),_e.init(e,t)}),hy=B("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?aC:lC(t.length)),_e.init(e,t)}),fy=B("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=rC),_e.init(e,t)}),py=B("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=iC),_e.init(e,t)}),my=B("$ZodULID",(e,t)=>{t.pattern??(t.pattern=uC),_e.init(e,t)}),gy=B("$ZodXID",(e,t)=>{t.pattern??(t.pattern=sC),_e.init(e,t)}),vy=B("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=oC),_e.init(e,t)}),Cy=B("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=BC(t)),_e.init(e,t)}),yy=B("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=IC),_e.init(e,t)}),Ey=B("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=$C(t)),_e.init(e,t)}),wy=B("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=cC),_e.init(e,t)}),_y=B("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=mC),_e.init(e,t)}),y9=/^[0-9a-fA-F:.]+$/;function sa(e){return y9.test(e)?k0(`http://[${e}]`):!1}var Ay=B("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=gC),_e.init(e,t),e._zod.check=n=>{sa(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),by=B("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=vC(t.delimiter)),_e.init(e,t)}),Sy=B("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=CC),_e.init(e,t)});function P0(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);return`${r}`!==i||r<0||r>128?!1:sa(n)}var Dy=B("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=yC),_e.init(e,t),e._zod.check=n=>{P0(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function oa(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var R0=/^[0-9a-zA-Z+/]*={0,2}$/,Iy=B("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=R0),_e.init(e,t),e._zod.check=n=>{oa(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),aa=/^[A-Za-z0-9_-]*$/;function z0(e){if(!aa.test(e))return!1;let t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return oa(n)}var $y=B("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=aa),_e.init(e,t),e._zod.check=n=>{z0(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),By=B("$ZodE164",(e,t)=>{t.pattern??(t.pattern=bC),_e.init(e,t)}),E9=/[- ]/g;function w9(e){let t=e.length,n=1,i=0;for(;t;){let r=e.charCodeAt(--t)-48;n^=1,i+=n?[0,2,4,6,8,1,3,5,7,9][r]:r}return i%10===0}function O0(e){return E0.test(e)?w9(e.replace(E9,"")):!1}var ky=B("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=E0),_e.init(e,t),e._zod.check=n=>{O0(n.value)||n.issues.push({code:"invalid_format",format:"credit_card",input:n.value,inst:e,continue:!t.abort})}});function _9(e){let t=0,n=e.length;for(let i=4;i<n;i++){let r=e.charCodeAt(i);t=(r>=65?t*100+(r-55):t*10+(r-48))%97}for(let i=0;i<4;i++){let r=e.charCodeAt(i);t=(r>=65?t*100+(r-55):t*10+(r-48))%97}return t===1}function N0(e){return w0.test(e)?_9(e):!1}var xy=B("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=w0),_e.init(e,t),e._zod.check=n=>{N0(n.value)||n.issues.push({code:"invalid_format",format:"iban",input:n.value,inst:e,continue:!t.abort})}});function M0(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}var Ty=B("$ZodJWT",(e,t)=>{_e.init(e,t),e._zod.check=n=>{M0(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Fy=B("$ZodCustomStringFormat",(e,t)=>{_e.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),U0=B("$ZodNumber",(e,t)=>{le.init(e,t),e._zod.pattern=Ei,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let u=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:String(r):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...u?{received:u}:{}}),n}}),Py=B("$ZodNumberFormat",(e,t)=>{UC.init(e,t),U0.init(e,t)}),j0=B("$ZodBoolean",(e,t)=>{le.init(e,t),e._zod.pattern=FC,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=!!n.value}catch{}let r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),L0=B("$ZodBigInt",(e,t)=>{le.init(e,t),e._zod.pattern=TC,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),Ry=B("$ZodBigIntFormat",(e,t)=>{jC.init(e,t),L0.init(e,t)}),zy=B("$ZodSymbol",(e,t)=>{le.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;return typeof r=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:r,inst:e}),n}}),Oy=B("$ZodUndefined",(e,t)=>{le.init(e,t),e._zod.pattern=RC,e._zod.values=new Set([void 0]),e._zod.parse=(n,i)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),Ny=B("$ZodNull",(e,t)=>{le.init(e,t),e._zod.pattern=PC,e._zod.values=new Set([null]),e._zod.parse=(n,i)=>{let r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),My=B("$ZodAny",(e,t)=>{le.init(e,t),e._zod.parse=n=>n}),Uy=B("$ZodUnknown",(e,t)=>{le.init(e,t),e._zod.parse=n=>n}),jy=B("$ZodNever",(e,t)=>{le.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),Ly=B("$ZodVoid",(e,t)=>{le.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"void",code:"invalid_type",input:r,inst:e}),n}}),qy=B("$ZodDate",(e,t)=>{le.init(e,t),e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let r=n.value,u=r instanceof Date;return u&&!Number.isNaN(r.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:r,...u?{received:"Invalid Date"}:{},inst:e}),n}});function q0(e,t){let n=oo(e._zod.def.checks);if(!n.length)return;let i=Math.min(...n.map(u=>u[0])),r=e._zod.parse;e._zod.parse=(u,s)=>{let o=t(u.value);if(o>i&&!s?.skipChecks&&s?.direction!=="backward"){for(let[a,l]of oo(e._zod.def.checks))if(o>a&&l._zod.def.when(u)){let c=u.issues.length;return l._zod.check(u),u.issues[c].continue=!1,ao(u.issues,c,e),u}}return r(u,s)}}var A9=e=>Array.isArray(e)?e.length:-1,b9=e=>e instanceof Map?e.size:-1,S9=e=>e instanceof Set?e.size:-1;function Lp(e,t,n){e.issues.length&&t.issues.push(...Nt(n,e.issues)),t.value[n]=e.value}var Zy=B("$ZodArray",(e,t)=>{le.init(e,t);let n=gt.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let u=i.value;if(!Array.isArray(u))return i.issues.push({expected:"array",code:"invalid_type",input:u,inst:e}),i;i.value=n?n.alloc(e,i,Array(u.length),r):Array(u.length);let s=[],o=r?.abortEarly;for(let a=0;a<u.length;a++){let l=u[a],c=t.element._zod.run({value:l,issues:[]},r);if(c instanceof Promise)s.push(c.then(m=>Lp(m,i,a)));else if(Lp(c,i,a),o&&c.issues.length!==0&&yt(c))break}return s.length?Promise.all(s).then(()=>i):i},q0(e,A9)});function po(e,t,n,i,r,u){let s=n in i,o=u==="optional";if(!(!s&&o&&r==="optional")){if(e.issues.length){if(r!==void 0&&o&&!s)return;t.issues.push(...Nt(n,e.issues))}if(!s&&r===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?(s||r==="defaulted"&&!o)&&(t.value[n]=void 0):t.value[n]=e.value}}var D9=[];function Wy(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:D9,r=i.length?[...t,...i]:t;for(let s of r)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let u=qv(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(u)}}function Gy(e,t,n,i,r,u,s){let o=[],a=r.keySet,l=r.catchall._zod,c=l.def.type,m=l.optin,p=l.optout,v=0;for(let g in t){if(s&&n.issues.length!==v){if(yt(n,v))break;v=n.issues.length}if(a.has(g))continue;if(g==="__proto__"){c==="never"&&o.push(g);continue}if(c==="never"){o.push(g);continue}let C=l.run({value:t[g],issues:[]},i);C instanceof Promise?e.push(C.then(y=>po(y,n,g,t,m,p))):po(C,n,g,t,m,p)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:u,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var Vy=B("$ZodObject",(e,t)=>{le.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let c={...i};return Object.defineProperty(t,"shape",{value:c}),l.raw=c,c};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=wu(()=>Wy(t));fe(e,"propValues",l=>{let c=l.def.shape,m={};for(let p in c){let v=c[p]._zod;if(v.values){Object.prototype.hasOwnProperty.call(m,p)||Tt(m,p,new Set);for(let g of v.values)m[p].add(g);v.optin!==void 0&&m[p].add(void 0)}}return m});let u=ti,s=t.catchall,o,a=gt.memoizer;a?.attach(e),e._zod.parse=(l,c)=>{o??(o=r.value);let m=l.value;if(!u(m))return l.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),l;l.value=a?a.alloc(e,l,{},c):{};let p=[],v=o.shape,g=c?.abortEarly,C=l.issues.length;for(let y of o.allKeys){if(g&&l.issues.length!==C){if(yt(l,C))break;C=l.issues.length}if(y==="__proto__")continue;let b=v[y],A=b._zod.optin,S=b._zod.optout,z=b._zod.run({value:m[y],issues:[]},c);z instanceof Promise?p.push(z.then(M=>po(M,l,y,m,A,S))):po(z,l,y,m,A,S)}return s?Gy(p,m,l,c,r.value,e,g===!0):p.length?Promise.all(p).then(()=>l):l}}),Hy=B("$ZodObjectJIT",(e,t)=>{Vy.init(e,t);let n=e._zod.parse,i=wu(()=>Wy(t)),r=gt.memoizer,u=v=>{let g=i.value,C=g.symbolKeys,y=new I0(["payload","ctx"],{shape:v,inst:e,memo:r,syms:C}),b=M=>`shape[${M}]._zod.run({ value: input[${M}], issues: [] }, ctx)`,A=(M,T)=>`
|
|
14
|
+
let ${M}_ab = false;
|
|
15
|
+
for (let i = 0; i < ${M}.issues.length; i++) {
|
|
16
|
+
const iss = ${M}.issues[i];
|
|
17
|
+
iss.path = iss.path ? [${T}, ...iss.path] : [${T}];
|
|
18
|
+
payload.issues.push(iss);
|
|
19
|
+
if (iss.continue !== true) ${M}_ab = true;
|
|
20
|
+
}
|
|
21
|
+
if (${M}_ab && ctx && ctx.abortEarly) {
|
|
22
|
+
payload.value = newResult;
|
|
23
|
+
return payload;
|
|
24
|
+
}`;y.write("const input = payload.value;");let S=Object.create(null),z=0;for(let M of g.allKeys)S[M]=`key_${z++}`;y.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let M of g.allKeys){if(M==="__proto__")continue;let T=S[M],G=typeof M=="symbol"?`syms[${C.indexOf(M)}]`:$t(M),re=`${G} in input`,Z=v[M],oe=Z?._zod?.optin,te=oe!==void 0,ye=Z?._zod?.optout==="optional";if(y.write(`const ${T} = ${b(G)};`),te&&ye){let Ne=oe==="optional"?`${T}_present`:`${T}.value !== undefined || ${T}_present`;y.write(`
|
|
25
|
+
const ${T}_present = ${re};
|
|
26
|
+
if (!${T}.issues.length || ${T}_present) {
|
|
27
|
+
if (${T}.issues.length) {${A(T,G)}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (${Ne}) {
|
|
31
|
+
newResult[${G}] = ${T}.value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
`)}else te?(y.write(`
|
|
36
|
+
if (${T}.issues.length) {${A(T,G)}
|
|
37
|
+
}
|
|
38
|
+
`),oe==="defaulted"?y.write(`newResult[${G}] = ${T}.value;`):y.write(`
|
|
39
|
+
if (${T}.value !== undefined || ${re}) {
|
|
40
|
+
newResult[${G}] = ${T}.value;
|
|
41
|
+
}
|
|
42
|
+
`)):y.write(`
|
|
43
|
+
const ${T}_present = ${re};
|
|
44
|
+
if (${T}.issues.length) {${A(T,G)}
|
|
45
|
+
}
|
|
46
|
+
if (!${T}_present && !${T}.issues.length) {
|
|
47
|
+
payload.issues.push({
|
|
48
|
+
code: "invalid_type",
|
|
49
|
+
expected: "nonoptional",
|
|
50
|
+
input: undefined,
|
|
51
|
+
path: [${G}]
|
|
52
|
+
});
|
|
53
|
+
if (ctx && ctx.abortEarly) {
|
|
54
|
+
payload.value = newResult;
|
|
55
|
+
return payload;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (${T}_present) {
|
|
60
|
+
newResult[${G}] = ${T}.value;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
`)}return y.write("payload.value = newResult;"),y.write("return payload;"),y.compile()},s,o=ti,a=!gt.jitless,c=a&&jv.value,m=t.catchall,p;e._zod.parse=(v,g)=>{p??(p=i.value);let C=v.value;return o(C)?a&&c&&g?.async===!1&&g.jitless!==!0?(s||(s=u(t.shape)),v=s(v,g),m?Gy([],C,v,g,p,e,g?.abortEarly===!0):v):n(v,g):(v.issues.push({expected:"object",code:"invalid_type",input:C,inst:e}),v)}});function qp(e,t,n,i){for(let u of e)if(u.issues.length===0)return t.value=u.value,t;let r=e.filter(u=>!yt(u));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(u=>u.issues.map(s=>qt(s,i,at())))}),t)}var la=B("$ZodUnion",(e,t)=>{le.init(e,t),fe(e,"optin",i=>i.def.options.some(r=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some(r=>r._zod.optin!==void 0)?"optional":void 0),fe(e,"optout",i=>i.def.options.some(r=>r._zod.optout==="optional")?"optional":void 0),fe(e,"values",i=>{if(i.def.options.every(r=>r._zod.values))return new Set(i.def.options.flatMap(r=>Array.from(r._zod.values)))}),fe(e,"pattern",i=>{if(i.def.options.every(r=>r._zod.pattern)){let r=i.def.options.map(u=>u._zod.pattern);return new RegExp(`^(${r.map(u=>Mn(u.source)).join("|")})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let u=!1,s=[];for(let o of t.options){let a=o._zod.run({value:i.value,issues:[]},r);if(a instanceof Promise)s.push(a),u=!0;else{if(a.issues.length===0)return a;s.push(a)}}return u?Promise.all(s).then(o=>qp(o,i,e,r)):qp(s,i,e,r)}});function Zp(e,t,n,i){let r=[];for(let u=0;u<e.length;u++)e[u].issues.length===0&&r.push(u);return r.length===1?(t.value=e[r[0]].value,t):(r.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(u=>u.issues.map(s=>qt(s,i,at())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1,matches:r}),t)}var Jy=B("$ZodXor",(e,t)=>{la.init(e,t),t.inclusive=!1;let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let u=!1,s=[];for(let o of t.options){let a=o._zod.run({value:i.value,issues:[]},r);a instanceof Promise?(s.push(a),u=!0):s.push(a)}return u?Promise.all(s).then(o=>Zp(o,i,e,r)):Zp(s,i,e,r)}});function Ky(e,t){let n=e._zod,i=n.bag.optionsMap;i||(i=Xy(n.def),n.bag.optionsMap=i);let r=i.get(t);if(r===null)throw new Error(`Ambiguous discriminator value "${String(t)}"`);return r}function Xy(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw new Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var Yy=B("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,la.init(e,t);let n=e._zod.parse;fe(e,"propValues",r=>{let u={},s=0;for(let o of r.def.options){let a=o._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${r.def.options.indexOf(o)}"`);a[r.def.discriminator]?.has(void 0)&&s++;for(let[l,c]of Object.entries(a)){Object.prototype.hasOwnProperty.call(u,l)||Tt(u,l,new Set);for(let m of c)u[l].add(m)}}return!r.def.unionFallback&&s>1&&u[r.def.discriminator]?.delete(void 0),u}),t.options.forEach((r,u)=>{let s=Yo(r._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw new Error(`Invalid discriminated union option at index "${u}"`)});let i=wu(()=>Xy(t));e._zod.parse=(r,u)=>{let s=r.value;if(!ti(s))return r.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),r;let o=s?.[t.discriminator],a=i.value.get(o);return a&&(o!==void 0||u.direction!=="backward")?a._zod.run(r,u):t.unionFallback||u.direction==="backward"?n(r,u):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter(l=>i.value.get(l)!==null),input:s,path:[t.discriminator],inst:e}),r)}}),Qy=B("$ZodIntersection",(e,t)=>{le.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,u=t.left._zod.run({value:r,issues:[]},i),s=t.right._zod.run({value:r,issues:[]},i);return u instanceof Promise||s instanceof Promise?Promise.all([u,s]).then(([a,l])=>Wp(n,a,l)):Wp(n,u,s)}});function su(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(_n(e)&&_n(t)){let n=Object.keys(t),i=Object.keys(e).filter(u=>n.indexOf(u)!==-1),r={...e,...t};Object.prototype.hasOwnProperty.call(r,"__proto__")&&delete r.__proto__;for(let u of i){if(u==="__proto__")continue;let s=su(e[u],t[u]);if(!s.valid)return{valid:!1,mergeErrorPath:[u,...s.mergeErrorPath]};r[u]=s.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],u=t[i],s=su(r,u);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Wp(e,t,n){let i=new Map,r,u=new Map,s=(l,c)=>{let m;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),m=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let p=String(l.path[0]);u.has(p)||u.set(p,l),m=[p]}else return!1;for(let p of m)i.has(p)||i.set(p,{}),i.get(p)[c]=!0;return!0};for(let l of t.issues)s(l,"l")||e.issues.push(l);for(let l of n.issues)s(l,"r")||e.issues.push(l);let o=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(o.length){let l=r?o.filter(c=>r.keys.includes(c)):[];l.length&&e.issues.push({...r,keys:l});for(let c of o)!l.includes(c)&&u.has(c)&&e.issues.push(u.get(c))}let a=su(t.value,n.value);if(!a.valid){if(yt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`)}return e.value=a.data,e}var Z0=B("$ZodTuple",(e,t)=>{le.init(e,t);let n=t.items,i=gt.memoizer;i?.attach(e),e._zod.parse=(r,u)=>{let s=r.value;if(!Array.isArray(s))return r.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(e,r,[],u):[];let o=[],a=Gp(n,"optin"),l=Gp(n,"optout");if(!t.rest){if(s.length<a)return r.issues.push({code:"too_small",minimum:a,inclusive:!0,input:s,inst:e,origin:"array"}),r;s.length>n.length&&r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}let c=new Array(n.length),m=t.rest?u?.abortEarly:void 0,p=!1;for(let v=0;v<n.length;v++){let g=n[v]._zod.run({value:s[v],issues:[]},u);g instanceof Promise?o.push(g.then(C=>{c[v]=C})):(c[v]=g,m&&!p&&g.issues.length&&(p=yt(g)))}if(t.rest&&!p){let v=n.length-1,g=s.slice(n.length),C=r.issues.length;for(let y of g){if(m&&r.issues.length!==C){if(yt(r,C))break;C=r.issues.length}v++;let b=t.rest._zod.run({value:y,issues:[]},u);b instanceof Promise?o.push(b.then(A=>Vp(A,r,v))):Vp(b,r,v)}}return o.length?Promise.all(o).then(()=>Hp(c,r,n,s,l)):Hp(c,r,n,s,l)}});function Gp(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Vp(e,t,n){e.issues.length&&t.issues.push(...Nt(n,e.issues)),t.value[n]=e.value}function Hp(e,t,n,i,r){for(let u=0;u<n.length;u++){let s=e[u],o=u<i.length;if(!o&&u>=r&&n[u]._zod.optin==="optional"){t.value.length=u;break}if(s.issues.length){if(!o&&u>=r){t.value.length=u;break}t.issues.push(...Nt(u,s.issues))}t.value[u]=s.value}for(let u=t.value.length-1;u>=i.length&&(n[u]._zod.optout==="optional"&&t.value[u]===void 0);u--)t.value.length=u;return t}var e3=B("$ZodRecord",(e,t)=>{le.init(e,t);let n=gt.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let u=i.value;if(!_n(u))return i.issues.push({expected:"record",code:"invalid_type",input:u,inst:e}),i;let s=[],o=t.keyType._zod.values;if(o&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let a=new Set;for(let c of o)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){if(a.add(typeof c=="number"?c.toString():c),c==="__proto__")continue;let m=t.keyType._zod.run({value:c,issues:[]},r);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(m.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:m.issues.map(g=>qt(g,r,at())),input:c,path:[c],inst:e});continue}let p=m.value;if(p==="__proto__")continue;let v=t.valueType._zod.run({value:u[c],issues:[]},r);v instanceof Promise?s.push(v.then(g=>{g.issues.length&&i.issues.push(...Nt(c,g.issues)),i.value[p]=g.value})):(v.issues.length&&i.issues.push(...Nt(c,v.issues)),i.value[p]=v.value)}let l;for(let c in u)if(!a.has(c))if(t.mode==="loose"){if(c==="__proto__")continue;i.value[c]=u[c]}else l=l??[],l.push(c);l&&l.length>0&&i.issues.push({code:"unrecognized_keys",input:u,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let a;for(let l of Reflect.ownKeys(u)){if(l==="__proto__"||!Object.prototype.propertyIsEnumerable.call(u,l))continue;let c=t.keyType._zod.run({value:l,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&Ei.test(l)&&c.issues.length){let g=t.keyType._zod.run({value:Number(l),issues:[]},r);if(g instanceof Promise)throw new Error("Async schemas not supported in object keys currently");g.issues.length===0&&(c=g)}if(c.issues.length){t.mode==="loose"?i.value[l]=u[l]:o?(a=a??[],a.push(l)):i.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(g=>qt(g,r,at())),input:l,path:[l],inst:e});continue}let p=c.value;if(p==="__proto__")continue;let v=t.valueType._zod.run({value:u[l],issues:[]},r);v instanceof Promise?s.push(v.then(g=>{g.issues.length&&i.issues.push(...Nt(l,g.issues)),i.value[p]=g.value})):(v.issues.length&&i.issues.push(...Nt(l,v.issues)),i.value[p]=v.value)}a&&a.length>0&&i.issues.push({code:"unrecognized_keys",input:u,inst:e,keys:a,continue:!0})}return s.length?Promise.all(s).then(()=>i):i}}),t3=B("$ZodMap",(e,t)=>{le.init(e,t);let n=gt.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let u=i.value;if(!(u instanceof Map))return i.issues.push({expected:"map",code:"invalid_type",input:u,inst:e}),i;let s=[];i.value=n?n.alloc(e,i,new Map,r):new Map;let o=r?.abortEarly,a=i.issues.length;for(let[l,c]of u){if(o&&i.issues.length!==a){if(yt(i,a))break;a=i.issues.length}let m=t.keyType._zod.run({value:l,issues:[]},r),p=t.valueType._zod.run({value:c,issues:[]},r);m instanceof Promise||p instanceof Promise?s.push(Promise.all([m,p]).then(([v,g])=>{Jp(v,g,i,l,u,e,r)})):Jp(m,p,i,l,u,e,r)}return s.length?Promise.all(s).then(()=>i):i},q0(e,b9)});function Jp(e,t,n,i,r,u,s){e.issues.length&&(so.has(typeof i)?n.issues.push(...Nt(i,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:r,inst:u,issues:e.issues.map(o=>qt(o,s,at()))})),t.issues.length&&(so.has(typeof i)?n.issues.push(...Nt(i,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:r,inst:u,key:i,issues:t.issues.map(o=>qt(o,s,at()))})),n.value.set(e.value,t.value)}var n3=B("$ZodSet",(e,t)=>{le.init(e,t);let n=gt.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let u=i.value;if(!(u instanceof Set))return i.issues.push({input:u,inst:e,expected:"set",code:"invalid_type"}),i;let s=[];i.value=n?n.alloc(e,i,new Set,r):new Set;let o=r?.abortEarly,a=i.issues.length;for(let l of u){if(o&&i.issues.length!==a){if(yt(i,a))break;a=i.issues.length}let c=t.valueType._zod.run({value:l,issues:[]},r);c instanceof Promise?s.push(c.then(m=>Kp(m,i))):Kp(c,i)}return s.length?Promise.all(s).then(()=>i):i},q0(e,S9)});function Kp(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var r3=B("$ZodEnum",(e,t)=>{le.init(e,t);let n=io(t.entries),i=new Set(n);e._zod.values=i,fe(e,"pattern",r=>{let u=io(r.def.entries).filter(s=>so.has(typeof s));return new RegExp(u.length?`^(${u.map(s=>An(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,u)=>{let s=r.value;return i.has(s)||r.issues.push({code:"invalid_value",values:n,input:s,inst:e}),r}}),i3=B("$ZodLiteral",(e,t)=>{le.init(e,t);let n=new Set(t.values);e._zod.values=n,fe(e,"pattern",i=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map(u=>typeof u=="string"?An(u):u?An(u.toString()):String(u)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let u=i.value;return n.has(u)||i.issues.push({code:"invalid_value",values:t.values,input:u,inst:e}),i}}),u3=B("$ZodFile",(e,t)=>{le.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;return r instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:r,inst:e}),n}}),s3=B("$ZodTransform",(e,t)=>{le.init(e,t),e._zod.optin="optional",gt.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new ra(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then(s=>(n.value=s,n));if(r instanceof Promise)throw new Cn;return n.value=r,n}});function Xp(e,t){return e.value=t.issues.length?void 0:t.value,e}var W0=B("$ZodOptional",(e,t)=>{le.init(e,t),fe(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",fe(e,"values",n=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),fe(e,"pattern",n=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Mn(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);return r instanceof Promise?r.then(u=>Xp(n,u)):Xp(n,r)}return t.innerType._zod.run(n,i)}}),o3=B("$ZodExactOptional",(e,t)=>{W0.init(e,t),fe(e,"values",n=>n.def.innerType._zod.values),fe(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),a3=B("$ZodNullable",(e,t)=>{le.init(e,t),fe(e,"optin",n=>n.def.innerType._zod.optin),fe(e,"optout",n=>n.def.innerType._zod.optout),fe(e,"pattern",n=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Mn(i.source)}|null)$`):void 0}),fe(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>n.value===null?n:t.innerType._zod.run(n,i)}),l3=B("$ZodDefault",(e,t)=>{le.init(e,t),e._zod.optin="defaulted",fe(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(u=>Yp(u,t)):Yp(r,t)}});function Yp(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var c3=B("$ZodPrefault",(e,t)=>{le.init(e,t),e._zod.optin="defaulted",fe(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>(i.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,i))}),d3=B("$ZodNonOptional",(e,t)=>{le.init(e,t),fe(e,"values",n=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(u=>Qp(u,e)):Qp(r,e)}});function Qp(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var h3=B("$ZodSuccess",(e,t)=>{le.init(e,t),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new ra("ZodSuccess");let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(u=>(n.value=u.issues.length===0,n)):(n.value=r.issues.length===0,n)}});function em(e,t,n,i){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(r=>qt(r,i,at()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var f3=B("$ZodCatch",(e,t)=>{le.init(e,t),fe(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),fe(e,"optout",n=>n.def.innerType._zod.optout),fe(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);return r instanceof Promise?r.then(u=>em(n,u,t,i)):em(n,r,t,i)}}),p3=B("$ZodNaN",(e,t)=>{le.init(e,t),e._zod.parse=(n,i)=>((typeof n.value!="number"||!Number.isNaN(n.value))&&n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n)}),G0=B("$ZodPipe",(e,t)=>{le.init(e,t),fe(e,"values",n=>n.def.in._zod.values),fe(e,"optin",n=>n.def.in._zod.optin),fe(e,"optout",n=>n.def.out._zod.optout),fe(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let u=t.out._zod.run(n,i);return u instanceof Promise?u.then(s=>hs(s,t.in,i)):hs(u,t.in,i)}let r=t.in._zod.run(n,i);return r instanceof Promise?r.then(u=>hs(u,t.out,i)):hs(r,t.out,i)}});function hs(e,t,n){return e.issues.some(i=>i.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var V0=B("$ZodCodec",(e,t)=>{le.init(e,t),fe(e,"values",n=>n.def.in._zod.values),fe(e,"optin",n=>n.def.in._zod.optin),fe(e,"optout",n=>n.def.out._zod.optout),fe(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if((i.direction||"forward")==="forward"){let u=t.in._zod.run(n,i);return u instanceof Promise?u.then(s=>fs(s,t,i)):fs(u,t,i)}else{let u=t.out._zod.run(n,i);return u instanceof Promise?u.then(s=>fs(s,t,i)):fs(u,t,i)}}});function fs(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){let r=t.transform(e.value,e);return r instanceof Promise?r.then(u=>ps(e,u,t.out,n)):ps(e,r,t.out,n)}else{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(u=>ps(e,u,t.in,n)):ps(e,r,t.in,n)}}function ps(e,t,n,i){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},i)}var m3=B("$ZodPreprocess",(e,t)=>{G0.init(e,t)}),g3=B("$ZodReadonly",(e,t)=>{le.init(e,t),fe(e,"propValues",n=>n.def.innerType._zod.propValues),fe(e,"values",n=>n.def.innerType._zod.values),fe(e,"optin",n=>n.def.innerType?._zod?.optin),fe(e,"optout",n=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(tm):tm(r)}});function tm(e){return e.memo||(e.value=Object.freeze(e.value)),e}function I9(e){let t=e._zod.def,n=t.pattern,i=!!t.format?.includes("int"),r,u;for(let o of t.checks??[]){let a=o._zod.def;a.pattern&&(n=a.pattern),i||(i=!!a.format?.includes("int"));let l=a.minimum??a.length,c=a.maximum??a.length;l!==void 0&&(r===void 0||l>r)&&(r=l),c!==void 0&&(u===void 0||c<u)&&(u=c)}if(n)return n.source;if(r!==void 0&&u!==void 0&&r>u)return"(?!)";if(r!==void 0||u!==void 0)return xC({minimum:r,maximum:u}).source;let s=e._zod.pattern;return(i&&s===Ei?_0:s)?.source}function xc(e){let t=e._zod.def,n=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let r=i._zod.pattern?.source,u=xc(i);return n&&r&&u&&u!==r?n.replace(Mn(r),()=>Mn(u)):n}if(t.options){let r=t.options.map(xc);if(r.every(Boolean))return`^(${r.map(u=>Mn(u)).join("|")})$`}return I9(e)}var v3=B("$ZodTemplateLiteral",(e,t)=>{le.init(e,t);let n=[];for(let i of t.parts)if(typeof i=="object"&&i!==null){let r=xc(i);if(!r)throw new Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);n.push(Mn(r))}else if(i===null||Lv.has(typeof i))n.push(An(`${i}`));else throw new Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>typeof i.value!="string"?(i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(i.value)||i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i)}),C3=B("$ZodFunction",(e,t)=>(le.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=n=>{if(typeof n!="function")throw new Error("implement() must be called with a function");return Object.defineProperty(function(...i){let r=e._def.input?$c(e._def.input,i):i,u=Reflect.apply(n,this,r);return e._def.output?$c(e._def.output,u):u},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=n=>{if(typeof n!="function")throw new Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...i){let r=e._def.input?await Bc(e._def.input,i):i,u=await Reflect.apply(n,this,r);return e._def.output?await Bc(e._def.output,u):u},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(n,i)=>typeof n.value!="function"?(n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n):(e._def.output&&e._def.output._zod.def.type==="promise"?n.value=e.implementAsync(n.value):n.value=e.implement(n.value),n),e.input=(...n)=>{let i=e.constructor;return Array.isArray(n[0])?new i({type:"function",input:new Z0({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output}):new i({type:"function",input:n[0],output:e._def.output})},e.output=n=>{let i=e.constructor;return new i({type:"function",input:e._def.input,output:n})},e)),y3=B("$ZodPromise",(e,t)=>{le.init(e,t),e._zod.parse=(n,i)=>Promise.resolve(n.value).then(r=>t.innerType._zod.run({value:r,issues:[]},i))}),H0=B("$ZodLazy",(e,t)=>{le.init(e,t),Ov(e._zod,"innerType",()=>{let n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),fe(e,"pattern",n=>n.innerType?._zod?.pattern),fe(e,"propValues",n=>n.innerType?._zod?.propValues),fe(e,"optin",n=>n.innerType?._zod?.optin??void 0),fe(e,"optout",n=>n.innerType?._zod?.optout??void 0),e._zod.parse=(n,i)=>e._zod.innerType._zod.run(n,i)}),E3=B("$ZodCustom",(e,t)=>{Re.init(e,t),le.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=n=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then(u=>nm(u,n,i,e));nm(r,n,i,e)}});function nm(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(r.params=i._zod.def.params),t.issues.push(lo(r))}}var w3=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},Tc="~memo",rm=[];function _3(e){return e!==null&&typeof e=="object"}function Rl(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var A3=new WeakMap,Wr=0,Ts=1,Hi=2;function Ji(e,t,n){let i=A3.get(e);if(i!==void 0)return i?Hi:Wr;if(t.has(e))return Hi;t.add(e);let r=Wr,u=c=>{if(r!==Hi&&c?._zod){let m=Ji(c,t,n);m>r&&(r=m)}},s=(c,m)=>{let p=Wr;for(let v of Reflect.ownKeys(c)){let g=Object.getOwnPropertyDescriptor(c,v);if(m&&!g.enumerable)continue;let C=g.get?Ts:g.value?._zod?Ji(g.value,t,n):Wr;C>p&&(p=C)}return p},o=c=>{c>r&&(r=c)},a=e._zod.def,l=a.type;switch(l){case"object":{let c=Yo(a);o(c?s(c,!0):Ts),u(a.catchall);break}case"array":u(a.element);break;case"tuple":for(let c of a.items)u(c);u(a.rest);break;case"record":case"map":u(a.keyType),u(a.valueType);break;case"set":u(a.valueType);break;case"union":for(let c of a.options)u(c);break;case"intersection":u(a.left),u(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":u(a.innerType);break;case"pipe":u(a.in),u(a.out);break;case"function":u(a.input),u(a.output);break;case"lazy":{let c=a._cachedInner??(n?e._zod.innerType:void 0);o(c?Ji(c,t,!1):Ts);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let c in a){let m=Object.getOwnPropertyDescriptor(a,c);if(!m||m.get)continue;let p=m.value;if(!(!p||typeof p!="object")){if(p._zod)u(p);else if(Array.isArray(p))for(let v of p)u(v)}}}return t.delete(e),$9(e,r)}function $9(e,t){return t!==Ts&&A3.set(e,t===Hi),t}function J0(e){return Ji(e,new Set,!0)!==Wr}function B9(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var ms,gs=[],k9={alloc(e,t,n){let i=ms;if(!i)return n;ms=void 0;let r={value:n,issues:null};return i.set(t.value,r),gs.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,u)=>{if(u.direction!=="backward"&&X0(u,r.value))throw new w3;return n(r,u)};e._zod.parse=i,e._zod.run===n&&(e._zod.run=i)})},attach(e){var t;let n,i=!1,r,u;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,o=(a,l)=>{if(n===void 0){let b=Ji(e,new Set,!1);if(b===Wr)return e._zod.parse=s,e._zod.run===o&&(e._zod.run=s),s(a,l);b===Hi||i?n=!0:i=!0}let c=a.value;if(!_3(c))return s(a,l);let m=l[Tc];m||(m={buckets:new WeakMap,backEdges:void 0},l[Tc]=m);let p;r===l?p=u:(p=B9(m,e),r=l,u=p);let v=p.get(c);if(v)return a.value=v.value,v.issues?v.issues.length&&a.issues.push(...Rl(v.issues)):(a.memo=!0,m.backEdges??(m.backEdges=new WeakSet),m.backEdges.add(v.value)),a;ms=p;let g=gs.length,C=s(a,l);ms=void 0;let y=gs.length>g?gs.pop():void 0;return C instanceof Promise?C.then(b=>(y&&(y.issues=b.issues.length?Rl(b.issues):rm),b)):(y&&(y.issues=C.issues.length?Rl(C.issues):rm),C)};e._zod.parse=o,e._zod.run===s&&(e._zod.run=o)})}};function K0(){return k9}function X0(e,t){let n=e[Tc]?.backEdges;return n!==void 0&&_3(t)&&n.has(t)}var Y0={};bn(Y0,{ar:()=>T9,az:()=>P9,be:()=>z9,bg:()=>N9,bn:()=>U9,ca:()=>L9,ckb:()=>Z9,cs:()=>G9,da:()=>H9,de:()=>K9,el:()=>Y9,en:()=>b3,eo:()=>t$,es:()=>r$,fa:()=>u$,fi:()=>o$,fr:()=>l$,frCA:()=>d$,gu:()=>f$,he:()=>m$,hi:()=>v$,hr:()=>y$,hu:()=>w$,hy:()=>A$,id:()=>S$,is:()=>I$,it:()=>B$,ja:()=>x$,ka:()=>F$,kh:()=>R$,km:()=>S3,kn:()=>O$,ko:()=>M$,lt:()=>j$,mk:()=>q$,ms:()=>W$,ne:()=>V$,nl:()=>J$,nn:()=>X$,no:()=>Q$,ota:()=>tB,pl:()=>uB,ps:()=>rB,pt:()=>oB,ptBR:()=>lB,ro:()=>dB,ru:()=>fB,sk:()=>mB,sl:()=>vB,sv:()=>yB,ta:()=>wB,tg:()=>AB,th:()=>SB,tk:()=>IB,tr:()=>BB,ua:()=>xB,uk:()=>D3,ur:()=>FB,uz:()=>RB,vi:()=>OB,yo:()=>qB,zhCN:()=>MB,zhTW:()=>jB});var x9=()=>{let e={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},map:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(r){return e[r]??null}let n={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",mac:"\u0639\u0646\u0648\u0627\u0646 MAC",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",credit_card:"\u0631\u0642\u0645 \u0628\u0637\u0627\u0642\u0629 \u0627\u0644\u0627\u0626\u062A\u0645\u0627\u0646",currency_code:"\u0631\u0645\u0632 \u0627\u0644\u0639\u0645\u0644\u0629",iban:"IBAN",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${r.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${o}`:`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${u}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${o}`}case"invalid_value":return r.values.length===1?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${J(r.values[0])}`:`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${r.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${u} ${r.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${r.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${u} ${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${r.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${u} ${r.minimum.toString()} ${s.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${r.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${u} ${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${r.prefix}"`:u.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${u.suffix}"`:u.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${u.includes}"`:u.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${u.pattern}`:`${n[u.format]??r.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${r.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${r.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${r.keys.length>1?"\u0629":""}: ${R(r.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${r.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${r.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function T9(){return{localeError:x9()}}var F9=()=>{let e={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"},map:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(r){return e[r]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",credit_card:"kredit kart\u0131 n\xF6mr\u0259si",currency_code:"valyuta kodu",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${r.expected}, daxil olan ${o}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${u}, daxil olan ${o}`}case"invalid_value":return r.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${J(r.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${r.origin??"d\u0259y\u0259r"} ${u}${r.maximum.toString()} ${s.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${r.origin??"d\u0259y\u0259r"} ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${r.origin} ${u}${r.minimum.toString()} ${s.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${r.origin} ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${u.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:u.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${u.suffix}" il\u0259 bitm\u0259lidir`:u.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${u.includes}" daxil olmal\u0131d\u0131r`:u.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${u.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${n[u.format]??r.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${r.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${r.keys.length>1?"lar":""}: ${R(r.keys,", ")}`;case"invalid_key":return`${r.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${r.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function P9(){return{localeError:F9()}}function im(e,t,n,i){let r=Math.abs(e),u=r%10,s=r%100;return s>=11&&s<=19?i:u===1?t:u>=2&&u<=4?n:i}var R9=()=>{let e={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},map:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function t(r){return e[r]??null}let n={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",mac:"MAC \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",credit_card:"\u043D\u0443\u043C\u0430\u0440 \u043A\u0440\u044D\u0434\u044B\u0442\u043D\u0430\u0439 \u043A\u0430\u0440\u0442\u044B",currency_code:"\u043A\u043E\u0434 \u0432\u0430\u043B\u044E\u0442\u044B",iban:"IBAN",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},i={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${r.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${o}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${u}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${o}`}case"invalid_value":return r.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${J(r.values[0])}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);if(s){let o=Number(r.maximum),a=im(o,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${u}${r.maximum.toString()} ${a}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);if(s){let o=Number(r.minimum),a=im(o,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${u}${r.minimum.toString()} ${a}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${u.prefix}"`:u.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${u.suffix}"`:u.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${u.includes}"`:u.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${u.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${n[u.format]??r.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${r.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${R(r.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${r.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${r.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function z9(){return{localeError:R9()}}var O9=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},map:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",mac:"MAC \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",credit_card:"\u043D\u043E\u043C\u0435\u0440 \u043D\u0430 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u0430 \u043A\u0430\u0440\u0442\u0430",currency_code:"\u043A\u043E\u0434 \u043D\u0430 \u0432\u0430\u043B\u0443\u0442\u0430",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${r.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${o}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${u}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${o}`}case"invalid_value":return r.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${J(r.values[0])}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${u}${r.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${u}${r.minimum.toString()} ${s.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;if(u.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${u.prefix}"`;if(u.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${u.suffix}"`;if(u.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${u.includes}"`;if(u.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${u.pattern}`;let s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return u.format==="emoji"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),u.format==="datetime"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),u.format==="date"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),u.format==="time"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),u.format==="duration"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${s} ${n[u.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${r.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${r.keys.length>1?"\u043E\u0432\u0435":""}: ${R(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${r.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};function N9(){return{localeError:O9()}}var M9=()=>{let e={string:{unit:"\u0985\u0995\u09CD\u09B7\u09B0",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},file:{unit:"\u09AC\u09BE\u0987\u099F",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},array:{unit:"\u0986\u0987\u099F\u09C7\u09AE",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},set:{unit:"\u0986\u0987\u099F\u09C7\u09AE",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},map:{unit:"\u098F\u09A8\u09CD\u099F\u09CD\u09B0\u09BF",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"}};function t(r){return e[r]??null}let n={regex:"\u0987\u09A8\u09AA\u09C1\u099F",email:"\u0987\u09AE\u09C7\u0987\u09B2 \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",url:"URL",emoji:"\u0987\u09AE\u09CB\u099C\u09BF",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u09A4\u09BE\u09B0\u09BF\u0996 \u0993 \u09B8\u09AE\u09AF\u09BC",date:"ISO \u09A4\u09BE\u09B0\u09BF\u0996",time:"ISO \u09B8\u09AE\u09AF\u09BC",duration:"ISO \u09B8\u09AE\u09AF\u09BC\u0995\u09BE\u09B2",ipv4:"IPv4 \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",ipv6:"IPv6 \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",mac:"MAC \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",cidrv4:"IPv4 \u09B0\u09C7\u099E\u09CD\u099C",cidrv6:"IPv6 \u09B0\u09C7\u099E\u09CD\u099C",base64:"base64-\u098F\u09A8\u0995\u09CB\u09A1\u09C7\u09A1 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982",base64url:"base64url-\u098F\u09A8\u0995\u09CB\u09A1\u09C7\u09A1 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982",json_string:"JSON \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982",e164:"E.164 \u09A8\u09AE\u09CD\u09AC\u09B0",credit_card:"\u0995\u09CD\u09B0\u09C7\u09A1\u09BF\u099F \u0995\u09BE\u09B0\u09CD\u09A1 \u09A8\u09AE\u09CD\u09AC\u09B0",currency_code:"\u09AE\u09C1\u09A6\u09CD\u09B0\u09BE \u0995\u09CB\u09A1",iban:"IBAN",jwt:"JWT",template_literal:"\u0987\u09A8\u09AA\u09C1\u099F"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return`\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F: \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4 ${u}, \u09AA\u09CD\u09B0\u09BE\u09AA\u09CD\u09A4 ${o}`}case"invalid_value":return r.values.length===1?`\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F: \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4 ${J(r.values[0])}`:`\u0985\u09AC\u09C8\u09A7 \u0985\u09AA\u09B6\u09A8: ${R(r.values," | ")} \u098F\u09B0 \u09AE\u09A7\u09CD\u09AF\u09C7 \u098F\u0995\u099F\u09BF \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0985\u09A8\u09C7\u0995 \u09AC\u09A1\u09BC: ${r.origin??"\u09AE\u09BE\u09A8"} ${u}${r.maximum.toString()} ${s.unit??"\u098F\u09B2\u09BF\u09AE\u09C7\u09A8\u09CD\u099F"} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:`\u0985\u09A8\u09C7\u0995 \u09AC\u09A1\u09BC: ${r.origin??"\u09AE\u09BE\u09A8"} ${u}${r.maximum.toString()} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u0985\u09A8\u09C7\u0995 \u099B\u09CB\u099F: ${r.origin} ${u}${r.minimum.toString()} ${s.unit} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:`\u0985\u09A8\u09C7\u0995 \u099B\u09CB\u099F: ${r.origin} ${u}${r.minimum.toString()} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: "${u.prefix}" \u09A6\u09BF\u09AF\u09BC\u09C7 \u09B6\u09C1\u09B0\u09C1 \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:u.format==="ends_with"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: "${u.suffix}" \u09A6\u09BF\u09AF\u09BC\u09C7 \u09B6\u09C7\u09B7 \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:u.format==="includes"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: "${u.includes}" \u0985\u09A8\u09CD\u09A4\u09B0\u09CD\u09AD\u09C1\u0995\u09CD\u09A4 \u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7`:u.format==="regex"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: ${u.pattern} \u09AA\u09CD\u09AF\u09BE\u099F\u09BE\u09B0\u09CD\u09A8 \u09AE\u09BF\u09B2\u09A4\u09C7 \u09B9\u09AC\u09C7`:`\u0985\u09AC\u09C8\u09A7 ${n[u.format]??r.format}`}case"not_multiple_of":return`\u0985\u09AC\u09C8\u09A7 \u09A8\u09AE\u09CD\u09AC\u09B0: ${r.divisor} \u098F\u09B0 \u0997\u09C1\u09A3\u09BF\u09A4\u0995 \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`;case"unrecognized_keys":return`\u0985\u099A\u09C7\u09A8\u09BE \u0995\u09C0${r.keys.length>1?"\u0997\u09C1\u09B2\u09CB":""}: ${R(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u098F \u0985\u09AC\u09C8\u09A7 \u0995\u09C0`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0985\u09AC\u09C8\u09A7 \u09A1\u09BF\u09B8\u0995\u09CD\u09B0\u09BF\u09AE\u09BF\u09A8\u09C7\u099F\u09B0 \u09AE\u09BE\u09A8\u0964 \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4 ${r.options.map(s=>`'${s}'`).join(" | ")}`:"\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F";case"invalid_element":return`${r.origin} \u098F \u0985\u09AC\u09C8\u09A7 \u09AE\u09BE\u09A8`;default:return"\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F"}}};function U9(){return{localeError:M9()}}var j9=()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"},map:{unit:"elements",verb:"contenir"}};function t(r){return e[r]??null}let n={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",mac:"adre\xE7a MAC",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",credit_card:"n\xFAmero de targeta de cr\xE8dit",currency_code:"codi de moneda",iban:"IBAN",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${r.expected}, s'ha rebut ${o}`:`Tipus inv\xE0lid: s'esperava ${u}, s'ha rebut ${o}`}case"invalid_value":return r.values.length===1?`Valor inv\xE0lid: s'esperava ${J(r.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${R(r.values," o ")}`;case"too_big":{let u=r.inclusive?"com a m\xE0xim":"menys de",s=t(r.origin);return s?`Massa gran: s'esperava que ${r.origin??"el valor"} contingu\xE9s ${u} ${r.maximum.toString()} ${s.unit??"elements"}`:`Massa gran: s'esperava que ${r.origin??"el valor"} fos ${u} ${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?"com a m\xEDnim":"m\xE9s de",s=t(r.origin);return s?`Massa petit: s'esperava que ${r.origin} contingu\xE9s ${u} ${r.minimum.toString()} ${s.unit}`:`Massa petit: s'esperava que ${r.origin} fos ${u} ${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${u.prefix}"`:u.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${u.suffix}"`:u.format==="includes"?`Format inv\xE0lid: ha d'incloure "${u.includes}"`:u.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${u.pattern}`:`Format inv\xE0lid per a ${n[u.format]??r.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${r.divisor}`;case"unrecognized_keys":return`Clau${r.keys.length>1?"s":""} no reconeguda${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${r.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${r.origin}`;default:return"Entrada inv\xE0lida"}}};function L9(){return{localeError:j9()}}var q9=()=>{let e={string:{unit:"\u067E\u06CC\u062A",verb:"\u0628\u06CE\u062A"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u0628\u06CE\u062A"},array:{unit:"\u062F\u0627\u0646\u06D5",verb:"\u0628\u06CE\u062A"},set:{unit:"\u062F\u0627\u0646\u06D5",verb:"\u0628\u06CE\u062A"},map:{unit:"\u062F\u0627\u0646\u06D5",verb:"\u0628\u06CE\u062A"}};function t(r){return e[r]??null}let n={regex:"regex",email:"\u0626\u06CC\u0645\u06D5\u06CC\u06B5",url:"\u0628\u06D5\u0633\u062A\u06D5\u0631 (URL)",emoji:"\u0626\u06CC\u0645\u06C6\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0695\u06CE\u06A9\u06D5\u0648\u062A \u0648 \u06A9\u0627\u062A",date:"\u0695\u06CE\u06A9\u06D5\u0648\u062A",time:"\u06A9\u0627\u062A",duration:"\u0645\u0627\u0648\u06D5",ipv4:"\u0646\u0627\u0648\u0646\u06CC\u0634\u0627\u0646\u06CC IPv4",ipv6:"\u0646\u0627\u0648\u0646\u06CC\u0634\u0627\u0646\u06CC IPv6",mac:"\u0646\u0627\u0648\u0646\u06CC\u0634\u0627\u0646\u06CC MAC",cidrv4:"\u0645\u06D5\u0648\u062F\u0627\u06CC IPv4",cidrv6:"\u0645\u06D5\u0648\u062F\u0627\u06CC IPv6",base64:"\u062F\u06D5\u0642\u06CC base64",base64url:"\u062F\u06D5\u0642\u06CC base64url",json_string:"\u062F\u06D5\u0642\u06CC JSON",e164:"\u0698\u0645\u0627\u0631\u06D5\u06CC E.164",credit_card:"\u0698\u0645\u0627\u0631\u06D5\u06CC \u06A9\u0627\u0631\u062A\u06CC \u06A9\u0631\u06CE\u062F\u06CC\u062A",currency_code:"\u06A9\u06C6\u062F\u06CC \u062F\u0631\u0627\u0648",iban:"IBAN",jwt:"JWT",template_literal:"\u062A\u06CE\u06A9\u0631\u062F\u06D5"},i={nan:"NaN",string:"\u0646\u0648\u0648\u0633\u06CC\u0646",number:"\u0698\u0645\u0627\u0631\u06D5",boolean:"boolean",array:"array",object:"object",date:"\u0695\u06CE\u06A9\u06D5\u0648\u062A",integer:"\u0698\u0645\u0627\u0631\u06D5",float:"\u0698\u0645\u0627\u0631\u06D5",null:"null",undefined:"undefined",function:"function",symbol:"symbol",unknown:"unknown",promise:"promise",void:"void",never:"never",map:"map",set:"set"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s,a=["\u0627","\u0648","\u06C6","\u0648\u0648","\u06D5","\u06CC","\u06CE"].some(c=>o.endsWith(c))?"\u06CC\u06D5":"\u06D5",l=/^[a-zA-Z]+$/.test(o);return s==="null"||s==="undefined"?"\u062F\u0627\u0648\u0627\u06A9\u0631\u0627\u0648\u06D5":`\u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648\u06D5 ${u} \u0628\u06CE\u062A\u060C \u0628\u06D5\u06B5\u0627\u0645 ${o}${l?"":a}`}case"invalid_value":return r.values.length===1?`\u0628\u06D5\u0647\u0627\u06A9\u06D5 \u0646\u0627\u062F\u0631\u0648\u0648\u0633\u062A\u06D5: \u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648\u06D5 ${J(r.values[0])} \u0628\u06CE\u062A`:`\u0647\u06D5\u06B5\u0628\u0698\u0627\u0631\u062F\u06D5\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648\u06D5 \u06CC\u06D5\u06A9\u06CE\u06A9 \u0628\u06CE\u062A \u0644\u06D5 ${R(r.values,"|")}`;case"too_big":{let u=t(r.origin);return u?`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u0632\u06C6\u0631\u06D5\u0648\u06D5 ${r.maximum.toString()} ${u.unit} ${u.verb}`:`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u0632\u06C6\u0631\u06D5\u0648\u06D5 ${r.maximum.toString()} \u0628\u06CE\u062A`}case"too_small":{let u=t(r.origin);return u?`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u06A9\u06D5\u0645\u06D5\u0648\u06D5 ${r.minimum.toString()} ${u.unit} ${u.verb}`:`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u06A9\u06D5\u0645\u06D5\u0648\u06D5 ${r.minimum.toString()} \u0628\u06CE\u062A`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u062F\u06D5\u0633\u062A\u067E\u06CE\u0628\u06A9\u0627\u062A \u0628\u06D5 "${u.prefix}"`:u.format==="ends_with"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u06A9\u06C6\u062A\u0627\u06CC\u06CC\u0628\u06CE\u062A \u0628\u06D5 "${u.suffix}"`:u.format==="includes"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 "${u.includes}" \u0644\u06D5\u062E\u06C6\u0628\u06AF\u0631\u06CE\u062A`:u.format==="regex"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0644\u06D5\u06AF\u06D5\u06B5 \u067E\u0627\u062A\u06CE\u0631\u0646\u06CC ${u.pattern} \u0628\u06AF\u0648\u0646\u062C\u06CE\u062A`:`\u0628\u06D5\u0647\u0627\u06CC ${n[u.format]??r.format} \u0646\u0627\u062F\u0631\u0648\u0633\u062A\u06D5`}case"not_multiple_of":return`\u0698\u0645\u0627\u0631\u06D5\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u062F\u06D5\u0628\u06CE\u062A \u0686\u06D5\u0646\u062F \u0647\u06CE\u0646\u062F\u06D5 \u0628\u06CE\u062A \u0628\u06C6 ${r.divisor}`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u0644\u06CC \u0646\u06D5\u0646\u0627\u0633\u0631\u0627\u0648: ${R(r.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u0644\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A \u0644\u06D5 ${r.origin}`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0628\u06D5\u0647\u0627\u06CC \u0646\u06D5\u0646\u0627\u0633\u0631\u0627\u0648 \u0647\u06D5\u06CC\u06D5. \u0628\u06D5\u0647\u0627\u06CC \u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648: ${r.options.map(s=>`'${s}'`).join(" | ")}`:"\u06CC\u06D5\u06A9\u06AF\u0631\u062A\u0646\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A";case"invalid_element":return`${r.origin} \u0628\u06D5\u0647\u0627\u06A9\u06D5 \u0646\u0627\u062F\u0631\u0648\u0633\u062A\u06D5`;default:return"\u062A\u06CE\u06A9\u0631\u062F\u06D5\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A"}}};function Z9(){return{localeError:q9()}}var W9=()=>{let e={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"},map:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(r){return e[r]??null}let n={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",mac:"MAC adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",credit_card:"\u010D\xEDslo kreditn\xED karty",currency_code:"k\xF3d m\u011Bny",iban:"IBAN",jwt:"JWT",template_literal:"vstup"},i={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${r.expected}, obdr\u017Eeno ${o}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${u}, obdr\u017Eeno ${o}`}case"invalid_value":return r.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${J(r.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${r.origin??"hodnota"} mus\xED m\xEDt ${u}${r.maximum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${r.origin??"hodnota"} mus\xED b\xFDt ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED m\xEDt ${u}${r.minimum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED b\xFDt ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${u.prefix}"`:u.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${u.suffix}"`:u.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${u.includes}"`:u.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${u.pattern}`:`Neplatn\xFD form\xE1t ${n[u.format]??r.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${r.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${R(r.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${r.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${r.origin}`;default:return"Neplatn\xFD vstup"}}};function G9(){return{localeError:W9()}}var V9=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"},map:{unit:"elementer",verb:"indeholdt"}};function t(r){return e[r]??null}let n={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-adresse",ipv6:"IPv6-adresse",mac:"MAC-adresse",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",credit_card:"kreditkortnummer",currency_code:"valutakode",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ugyldigt input: forventede instanceof ${r.expected}, fik ${o}`:`Ugyldigt input: forventede ${u}, fik ${o}`}case"invalid_value":return r.values.length===1?`Ugyldig v\xE6rdi: forventede ${J(r.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin),o=i[r.origin]??r.origin;return s?`For stor: forventede ${o??"value"} ${s.verb} ${u} ${r.maximum.toString()} ${s.unit??"elementer"}`:`For stor: forventede ${o??"value"} havde ${u} ${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin),o=i[r.origin]??r.origin;return s?`For lille: forventede ${o} ${s.verb} ${u} ${r.minimum.toString()} ${s.unit}`:`For lille: forventede ${o} havde ${u} ${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Ugyldig streng: skal starte med "${u.prefix}"`:u.format==="ends_with"?`Ugyldig streng: skal ende med "${u.suffix}"`:u.format==="includes"?`Ugyldig streng: skal indeholde "${u.includes}"`:u.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${u.pattern}`:`Ugyldig ${n[u.format]??r.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${R(r.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${r.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${r.origin}`;default:return"Ugyldigt input"}}};function H9(){return{localeError:V9()}}var J9=()=>{let e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"},map:{unit:"Elemente",verb:"zu haben"}};function t(r){return e[r]??null}let n={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",mac:"MAC-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",credit_card:"Kreditkartennummer",currency_code:"W\xE4hrungscode",iban:"IBAN",jwt:"JWT",template_literal:"Eingabe"},i={nan:"NaN",number:"Zahl",array:"Array"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${r.expected}, erhalten ${o}`:`Ung\xFCltige Eingabe: erwartet ${u}, erhalten ${o}`}case"invalid_value":return r.values.length===1?`Ung\xFCltige Eingabe: erwartet ${J(r.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Zu gro\xDF: erwartet, dass ${r.origin??"Wert"} ${u}${r.maximum.toString()} ${s.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${r.origin??"Wert"} ${u}${r.maximum.toString()} ist`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Zu klein: erwartet, dass ${r.origin} ${u}${r.minimum.toString()} ${s.unit} hat`:`Zu klein: erwartet, dass ${r.origin} ${u}${r.minimum.toString()} ist`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Ung\xFCltiger String: muss mit "${u.prefix}" beginnen`:u.format==="ends_with"?`Ung\xFCltiger String: muss mit "${u.suffix}" enden`:u.format==="includes"?`Ung\xFCltiger String: muss "${u.includes}" enthalten`:u.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${u.pattern} entsprechen`:`Ung\xFCltig: ${n[u.format]??r.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${r.divisor} sein`;case"unrecognized_keys":return`${r.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${R(r.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${r.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${r.origin}`;default:return"Ung\xFCltige Eingabe"}}};function K9(){return{localeError:J9()}}var X9=()=>{let e={string:{unit:"\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},file:{unit:"bytes",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},array:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},set:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},map:{unit:"\u03BA\u03B1\u03C4\u03B1\u03C7\u03C9\u03C1\u03AE\u03C3\u03B5\u03B9\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"}};function t(r){return e[r]??null}let n={regex:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2",email:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1 \u03BA\u03B1\u03B9 \u03CE\u03C1\u03B1",date:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1",time:"ISO \u03CE\u03C1\u03B1",duration:"ISO \u03B4\u03B9\u03AC\u03C1\u03BA\u03B5\u03B9\u03B1",ipv4:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv4",ipv6:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv6",mac:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 MAC",cidrv4:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv4",cidrv6:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv6",base64:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64",base64url:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64url",json_string:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC JSON",e164:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 E.164",credit_card:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 \u03C0\u03B9\u03C3\u03C4\u03C9\u03C4\u03B9\u03BA\u03AE\u03C2 \u03BA\u03AC\u03C1\u03C4\u03B1\u03C2",currency_code:"\u03BA\u03C9\u03B4\u03B9\u03BA\u03CC\u03C2 \u03BD\u03BF\u03BC\u03AF\u03C3\u03BC\u03B1\u03C4\u03BF\u03C2",iban:"IBAN",jwt:"JWT",template_literal:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return typeof r.expected=="string"&&/^[A-Z]/.test(r.expected)?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD instanceof ${r.expected}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${o}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${u}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${o}`}case"invalid_value":return r.values.length===1?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${J(r.values[0])}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03C0\u03B9\u03BB\u03BF\u03B3\u03AE: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD \u03AD\u03BD\u03B1 \u03B1\u03C0\u03CC ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${r.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${u}${r.maximum.toString()} ${s.unit??"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1"}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${r.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${r.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${u}${r.minimum.toString()} ${s.unit}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${r.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03BE\u03B5\u03BA\u03B9\u03BD\u03AC \u03BC\u03B5 "${u.prefix}"`:u.format==="ends_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B5\u03BB\u03B5\u03B9\u03CE\u03BD\u03B5\u03B9 \u03BC\u03B5 "${u.suffix}"`:u.format==="includes"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C0\u03B5\u03C1\u03B9\u03AD\u03C7\u03B5\u03B9 "${u.includes}"`:u.format==="regex"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B1\u03B9\u03C1\u03B9\u03AC\u03B6\u03B5\u03B9 \u03BC\u03B5 \u03C4\u03BF \u03BC\u03BF\u03C4\u03AF\u03B2\u03BF ${u.pattern}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${n[u.format]??r.format}`}case"not_multiple_of":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF\u03C2 \u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 \u03C0\u03BF\u03BB\u03BB\u03B1\u03C0\u03BB\u03AC\u03C3\u03B9\u03BF \u03C4\u03BF\u03C5 ${r.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${r.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${r.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${R(r.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${r.origin}`;case"invalid_union":return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2";case"invalid_element":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C4\u03B9\u03BC\u03AE \u03C3\u03C4\u03BF ${r.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}};function Y9(){return{localeError:X9()}}var Q9=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(u){return e[u]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(u,s){return u==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):i[u]??u}return u=>{switch(u.code){case"invalid_type":{let s=r(u.expected),o=K(u.input),a=r(o,u.input);return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return u.values.length===1?`Invalid input: expected ${J(u.values[0])}`:`Invalid option: expected one of ${R(u.values,"|")}`;case"too_big":{let s=u.exact?"exactly ":u.inclusive?"<=":"<",o=t(u.origin);return o?`Too big: expected ${u.origin??"value"} to have ${s}${u.maximum.toString()} ${o.unit??"elements"}`:`Too big: expected ${u.origin??"value"} to be ${s}${u.maximum.toString()}`}case"too_small":{let s=u.exact?"exactly ":u.inclusive?">=":">",o=t(u.origin);return o?`Too small: expected ${u.origin} to have ${s}${u.minimum.toString()} ${o.unit}`:`Too small: expected ${u.origin} to be ${s}${u.minimum.toString()}`}case"invalid_format":{let s=u;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${n[s.format]??u.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${u.divisor}`;case"unrecognized_keys":return`Unrecognized key${u.keys.length>1?"s":""}: ${R(u.keys,", ")}`;case"invalid_key":return`Invalid key in ${u.origin}`;case"invalid_union":return u.options&&Array.isArray(u.options)&&u.options.length>0?`Invalid discriminator value. Expected ${u.options.map(o=>`'${o}'`).join(" | ")}`:u.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${u.origin}`;default:return"Invalid input"}}};function b3(){return{localeError:Q9()}}var e$=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"},map:{unit:"elementojn",verb:"havi"}};function t(r){return e[r]??null}let n={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",mac:"MAC-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",credit_card:"kreditkarta numero",currency_code:"valuta kodo",iban:"IBAN",jwt:"JWT",template_literal:"enigo"},i={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${r.expected}, ricevi\u011Dis ${o}`:`Nevalida enigo: atendi\u011Dis ${u}, ricevi\u011Dis ${o}`}case"invalid_value":return r.values.length===1?`Nevalida enigo: atendi\u011Dis ${J(r.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Tro granda: atendi\u011Dis ke ${r.origin??"valoro"} havu ${u}${r.maximum.toString()} ${s.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${r.origin??"valoro"} havu ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Tro malgranda: atendi\u011Dis ke ${r.origin} havu ${u}${r.minimum.toString()} ${s.unit}`:`Tro malgranda: atendi\u011Dis ke ${r.origin} estu ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${u.prefix}"`:u.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${u.suffix}"`:u.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${u.includes}"`:u.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${u.pattern}`:`Nevalida ${n[u.format]??r.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${r.divisor}`;case"unrecognized_keys":return`Nekonata${r.keys.length>1?"j":""} \u015Dlosilo${r.keys.length>1?"j":""}: ${R(r.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${r.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${r.origin}`;default:return"Nevalida enigo"}}};function t$(){return{localeError:e$()}}var n$=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(r){return e[r]??null}let n={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",mac:"direcci\xF3n MAC",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",credit_card:"n\xFAmero de tarjeta de cr\xE9dito",currency_code:"c\xF3digo de moneda",iban:"IBAN",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${r.expected}, recibido ${o}`:`Entrada inv\xE1lida: se esperaba ${u}, recibido ${o}`}case"invalid_value":return r.values.length===1?`Entrada inv\xE1lida: se esperaba ${J(r.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin),o=i[r.origin]??r.origin;return s?`Demasiado grande: se esperaba que ${o??"valor"} tuviera ${u}${r.maximum.toString()} ${s.unit??"elementos"}`:`Demasiado grande: se esperaba que ${o??"valor"} fuera ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin),o=i[r.origin]??r.origin;return s?`Demasiado peque\xF1o: se esperaba que ${o} tuviera ${u}${r.minimum.toString()} ${s.unit}`:`Demasiado peque\xF1o: se esperaba que ${o} fuera ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${u.prefix}"`:u.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${u.suffix}"`:u.format==="includes"?`Cadena inv\xE1lida: debe incluir "${u.includes}"`:u.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${u.pattern}`:`Inv\xE1lido ${n[u.format]??r.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${r.divisor}`;case"unrecognized_keys":return`Llave${r.keys.length>1?"s":""} desconocida${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${i[r.origin]??r.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${i[r.origin]??r.origin}`;default:return"Entrada inv\xE1lida"}}};function r$(){return{localeError:n$()}}var i$=()=>{let e={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},map:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(r){return e[r]??null}let n={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",mac:"MAC \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",credit_card:"\u0634\u0645\u0627\u0631\u0647 \u06A9\u0627\u0631\u062A \u0627\u0639\u062A\u0628\u0627\u0631\u06CC",currency_code:"\u06A9\u062F \u0627\u0631\u0632",iban:"IBAN",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${r.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${o} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`:`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${u} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${o} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return r.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${J(r.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${R(r.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${r.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${u}${r.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${r.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${u}${r.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${r.origin} \u0628\u0627\u06CC\u062F ${u}${r.minimum.toString()} ${s.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${r.origin} \u0628\u0627\u06CC\u062F ${u}${r.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${u.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:u.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${u.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:u.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${u.includes}" \u0628\u0627\u0634\u062F`:u.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${u.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${n[u.format]??r.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${r.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${r.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${R(r.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${r.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${r.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function u$(){return{localeError:i$()}}var s$=()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},map:{unit:"alkiota",subject:"kuvauksen"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(r){return e[r]??null}let n={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",mac:"MAC-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",credit_card:"luottokortin numero",currency_code:"valuuttakoodi",iban:"IBAN",jwt:"JWT",template_literal:"templaattimerkkijono"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Virheellinen tyyppi: odotettiin instanceof ${r.expected}, oli ${o}`:`Virheellinen tyyppi: odotettiin ${u}, oli ${o}`}case"invalid_value":return r.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${J(r.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Liian suuri: ${s.subject} t\xE4ytyy olla ${u}${r.maximum.toString()} ${s.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Liian pieni: ${s.subject} t\xE4ytyy olla ${u}${r.minimum.toString()} ${s.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${u.prefix}"`:u.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${u.suffix}"`:u.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${u.includes}"`:u.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${u.pattern}`:`Virheellinen ${n[u.format]??r.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${r.divisor} monikerta`;case"unrecognized_keys":return`${r.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${R(r.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};function o$(){return{localeError:s$()}}var a$=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(r){return e[r]??null}let n={regex:"expression r\xE9guli\xE8re",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",mac:"adresse MAC",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne de caract\xE8res encod\xE9e en base64",base64url:"cha\xEEne de caract\xE8res encod\xE9e en base64url",json_string:"cha\xEEne de caract\xE8res JSON",e164:"num\xE9ro au format E.164",credit_card:"num\xE9ro de carte de cr\xE9dit",currency_code:"code de devise",iban:"IBAN",jwt:"JWT",template_literal:"entr\xE9e"},i={string:"cha\xEEne de caract\xE8res",number:"nombre",int:"entier",boolean:"bool\xE9en",bigint:"grand entier",symbol:"symbole",undefined:"ind\xE9fini",null:"null",never:"jamais",void:"vide",date:"date",array:"tableau",object:"objet",tuple:"tuple",record:"record",map:"map",set:"ensemble",file:"fichier",nonoptional:"non optionnel",nan:"NaN",function:"fonction"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Entr\xE9e invalide : instance de ${r.expected} attendu, ${o} re\xE7u`:`Entr\xE9e invalide : ${u} attendu, ${o} re\xE7u`}case"invalid_value":return r.values.length===1?`Entr\xE9e invalide : ${J(r.values[0])} attendu`:`Option invalide : une valeur parmi ${R(r.values,"|")} attendue`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Trop grand : ${i[r.origin]??"valeur"} doit ${s.verb} ${u}${r.maximum.toString()} ${s.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${i[r.origin]??"valeur"} doit \xEAtre ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Trop petit : ${i[r.origin]??"valeur"} doit ${s.verb} ${u}${r.minimum.toString()} ${s.unit}`:`Trop petit : ${i[r.origin]??"valeur"} doit \xEAtre ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Cha\xEEne de caract\xE8res invalide : doit commencer par "${u.prefix}"`:u.format==="ends_with"?`Cha\xEEne de caract\xE8res invalide : doit se terminer par "${u.suffix}"`:u.format==="includes"?`Cha\xEEne de caract\xE8res invalide : doit inclure "${u.includes}"`:u.format==="regex"?`Cha\xEEne de caract\xE8res invalide : doit correspondre au motif ${u.pattern}`:`${n[u.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${r.divisor}`;case"unrecognized_keys":return`Cl\xE9${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${R(r.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${r.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entr\xE9e invalide"}}};function l$(){return{localeError:a$()}}var c$=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"},map:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(r){return e[r]??null}let n={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",mac:"adresse MAC",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",credit_card:"num\xE9ro de carte de cr\xE9dit",currency_code:"code de devise",iban:"IBAN",jwt:"JWT",template_literal:"entr\xE9e"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Entr\xE9e invalide : attendu instanceof ${r.expected}, re\xE7u ${o}`:`Entr\xE9e invalide : attendu ${u}, re\xE7u ${o}`}case"invalid_value":return r.values.length===1?`Entr\xE9e invalide : attendu ${J(r.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"\u2264":"<",s=t(r.origin);return s?`Trop grand : attendu que ${r.origin??"la valeur"} ait ${u}${r.maximum.toString()} ${s.unit}`:`Trop grand : attendu que ${r.origin??"la valeur"} soit ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?"\u2265":">",s=t(r.origin);return s?`Trop petit : attendu que ${r.origin} ait ${u}${r.minimum.toString()} ${s.unit}`:`Trop petit : attendu que ${r.origin} soit ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${u.prefix}"`:u.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${u.suffix}"`:u.format==="includes"?`Cha\xEEne invalide : doit inclure "${u.includes}"`:u.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${u.pattern}`:`${n[u.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${r.divisor}`;case"unrecognized_keys":return`Cl\xE9${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${R(r.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${r.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entr\xE9e invalide"}}};function d$(){return{localeError:c$()}}var h$=()=>{let e={string:{unit:"\u0A85\u0A95\u0ACD\u0AB7\u0AB0",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},file:{unit:"\u0AAC\u0ABE\u0AAF\u0A9F",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},array:{unit:"\u0A86\u0A87\u0A9F\u0AAE",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},set:{unit:"\u0A86\u0A87\u0A9F\u0AAE",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},map:{unit:"\u0A8F\u0AA8\u0ACD\u0A9F\u0ACD\u0AB0\u0AC0",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"}};function t(r){return e[r]??null}let n={regex:"\u0A87\u0AA8\u0AAA\u0AC1\u0A9F",email:"\u0A88\u0AAE\u0AC7\u0A87\u0AB2 \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",url:"URL",emoji:"\u0A87\u0AAE\u0ACB\u0A9C\u0AC0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0AA4\u0ABE\u0AB0\u0AC0\u0A96 \u0A85\u0AA8\u0AC7 \u0AB8\u0AAE\u0AAF",date:"ISO \u0AA4\u0ABE\u0AB0\u0AC0\u0A96",time:"ISO \u0AB8\u0AAE\u0AAF",duration:"ISO \u0A85\u0AB5\u0AA7\u0ABF",ipv4:"IPv4 \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",ipv6:"IPv6 \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",mac:"MAC \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",cidrv4:"IPv4 \u0AB6\u0ACD\u0AB0\u0AC7\u0AA3\u0AC0",cidrv6:"IPv6 \u0AB6\u0ACD\u0AB0\u0AC7\u0AA3\u0AC0",base64:"base64-\u0A8F\u0AA8\u0ACD\u0A95\u0ACB\u0AA1\u0AC7\u0AA1 \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97",base64url:"base64url-\u0A8F\u0AA8\u0ACD\u0A95\u0ACB\u0AA1\u0AC7\u0AA1 \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97",json_string:"JSON \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97",e164:"E.164 \u0AA8\u0A82\u0AAC\u0AB0",credit_card:"\u0A95\u0ACD\u0AB0\u0AC7\u0AA1\u0ABF\u0A9F \u0A95\u0ABE\u0AB0\u0ACD\u0AA1 \u0AA8\u0A82\u0AAC\u0AB0",currency_code:"\u0A9A\u0AB2\u0AA3 \u0A95\u0ACB\u0AA1",iban:"IBAN",jwt:"JWT",template_literal:"\u0A87\u0AA8\u0AAA\u0AC1\u0A9F"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F: \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4 ${u}, \u0AAA\u0ACD\u0AB0\u0ABE\u0AAA\u0ACD\u0AA4 ${o}`}case"invalid_value":return r.values.length===1?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F: \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4 ${J(r.values[0])}`:`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB5\u0ABF\u0A95\u0AB2\u0ACD\u0AAA: ${R(r.values," | ")} \u0AAE\u0ABE\u0AA7\u0ACD\u0AAF\u0AAE\u0AA5\u0AC0 \u0A8F\u0A95 \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0A96\u0AC2\u0AAC \u0AAE\u0ACB\u0A9F\u0AC1\u0A82: ${r.origin??"\u0AAE\u0AC2\u0AB2\u0ACD\u0AAF"} ${u}${r.maximum.toString()} ${s.unit??"\u0A8F\u0AB2\u0ABF\u0AAE\u0AC7\u0AA8\u0ACD\u0A9F"} \u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F`:`\u0A96\u0AC2\u0AAC \u0AAE\u0ACB\u0A9F\u0AC1\u0A82: ${r.origin??"\u0AAE\u0AC2\u0AB2\u0ACD\u0AAF"} ${u}${r.maximum.toString()} \u0AB9\u0ACB\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u0A96\u0AC2\u0AAC \u0AA8\u0ABE\u0AA8\u0AC1\u0A82: ${r.origin} ${u}${r.minimum.toString()} ${s.unit} \u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F`:`\u0A96\u0AC2\u0AAC \u0AA8\u0ABE\u0AA8\u0AC1\u0A82: ${r.origin} ${u}${r.minimum.toString()} \u0AB9\u0ACB\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: "${u.prefix}" \u0AA5\u0AC0 \u0AB6\u0AB0\u0AC2 \u0AA5\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:u.format==="ends_with"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: "${u.suffix}" \u0AAA\u0AB0 \u0AB8\u0AAE\u0ABE\u0AAA\u0ACD\u0AA4 \u0AA5\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:u.format==="includes"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: "${u.includes}" \u0AB6\u0ABE\u0AAE\u0AC7\u0AB2 \u0AB9\u0ACB\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:u.format==="regex"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: \u0AAA\u0AC7\u0A9F\u0AB0\u0ACD\u0AA8 ${u.pattern} \u0AB8\u0ABE\u0AA5\u0AC7 \u0AAE\u0AC7\u0AB3 \u0A96\u0ABE\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF ${n[u.format]??r.format}`}case"not_multiple_of":return`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AA8\u0A82\u0AAC\u0AB0: ${r.divisor} \u0AA8\u0ACB \u0A97\u0AC1\u0AA3\u0ABE\u0A82\u0A95 \u0AB9\u0ACB\u0AB5\u0ACB \u0A9C\u0ACB\u0A88\u0A8F`;case"unrecognized_keys":return`\u0A93\u0AB3\u0A96\u0AC0 \u0AB6\u0A95\u0ABE\u0AA4\u0ABE \u0AA8\u0AB9\u0AC0\u0A82 \u0AA4\u0AC7 \u0A95\u0AC0${r.keys.length>1?"\u0A93":""}: ${R(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u0AAE\u0ABE\u0A82 \u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A95\u0AC0`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AA1\u0ABF\u0AB8\u0ACD\u0A95\u0ACD\u0AB0\u0ABF\u0AAE\u0ABF\u0AA8\u0AC7\u0A9F\u0AB0 \u0AAE\u0AC2\u0AB2\u0ACD\u0AAF. \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4 ${r.options.map(s=>`'${s}'`).join(" | ")}`:"\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F";case"invalid_element":return`${r.origin} \u0AAE\u0ABE\u0A82 \u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AAE\u0AC2\u0AB2\u0ACD\u0AAF`;default:return"\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F"}}};function f$(){return{localeError:h$()}}var p$=()=>{let e={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},t={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},n=l=>l?e[l]:void 0,i=l=>{let c=n(l);return c?c.label:l??e.unknown.label},r=l=>`\u05D4${i(l)}`,u=l=>(n(l)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",s=l=>l?t[l]??null:null,o={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},uuidv4:{label:"UUIDv4",gender:"m"},uuidv6:{label:"UUIDv6",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},mac:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA MAC",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},credit_card:{label:"\u05DE\u05E1\u05E4\u05E8 \u05DB\u05E8\u05D8\u05D9\u05E1 \u05D0\u05E9\u05E8\u05D0\u05D9",gender:"m"},currency_code:{label:"\u05E7\u05D5\u05D3 \u05DE\u05D8\u05D1\u05E2",gender:"m"},iban:{label:"IBAN",gender:"m"},jwt:{label:"JWT",gender:"m"},template_literal:{label:"\u05E7\u05DC\u05D8",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},a={nan:"NaN"};return l=>{switch(l.code){case"invalid_type":{let c=l.expected,m=a[c??""]??i(c),p=K(l.input),v=a[p]??e[p]?.label??p;return/^[A-Z]/.test(l.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${l.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${v}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}, \u05D4\u05EA\u05E7\u05D1\u05DC ${v}`}case"invalid_value":{if(l.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${J(l.values[0])}`;let c=l.values.map(v=>J(v));if(l.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${c[0]} \u05D0\u05D5 ${c[1]}`;let m=c[c.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${c.slice(0,-1).join(", ")} \u05D0\u05D5 ${m}`}case"too_big":{let c=s(l.origin),m=r(l.origin??"value");if(l.origin==="string")return`${c?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${m} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.maximum.toString()} ${c?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(l.origin==="number"){let g=l.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${l.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${m} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${g}`}if(l.origin==="array"||l.origin==="set"){let g=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",C=l.inclusive?`${l.maximum} ${c?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${l.maximum} ${c?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${m} ${g} \u05DC\u05D4\u05DB\u05D9\u05DC ${C}`.trim()}let p=l.inclusive?"<=":"<",v=u(l.origin??"value");return c?.unit?`${c.longLabel} \u05DE\u05D3\u05D9: ${m} ${v} ${p}${l.maximum.toString()} ${c.unit}`:`${c?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${m} ${v} ${p}${l.maximum.toString()}`}case"too_small":{let c=s(l.origin),m=r(l.origin??"value");if(l.origin==="string")return`${c?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${m} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.minimum.toString()} ${c?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(l.origin==="number"){let g=l.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${l.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${m} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${g}`}if(l.origin==="array"||l.origin==="set"){let g=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(l.minimum===1&&l.inclusive){let y=(l.origin==="set","\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${m} ${g} \u05DC\u05D4\u05DB\u05D9\u05DC ${y}`}let C=l.inclusive?`${l.minimum} ${c?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${l.minimum} ${c?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${m} ${g} \u05DC\u05D4\u05DB\u05D9\u05DC ${C}`.trim()}let p=l.inclusive?">=":">",v=u(l.origin??"value");return c?.unit?`${c.shortLabel} \u05DE\u05D3\u05D9: ${m} ${v} ${p}${l.minimum.toString()} ${c.unit}`:`${c?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${m} ${v} ${p}${l.minimum.toString()}`}case"invalid_format":{let c=l;if(c.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${c.prefix}"`;if(c.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${c.suffix}"`;if(c.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${c.includes}"`;if(c.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${c.pattern}`;let m=o[c.format],p=m?.label??c.format,g=(m?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${p} \u05DC\u05D0 ${g}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${l.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${l.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${l.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${R(l.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${r(l.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function m$(){return{localeError:p$()}}var g$=()=>{let e={string:{unit:"\u0905\u0915\u094D\u0937\u0930",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},file:{unit:"\u092C\u093E\u0907\u091F\u094D\u0938",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},array:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},set:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},map:{unit:"\u092A\u094D\u0930\u0935\u093F\u0937\u094D\u091F\u093F\u092F\u093E\u0901",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"}};function t(r){return e[r]??null}let n={regex:"\u0907\u0928\u092A\u0941\u091F",email:"\u0908\u092E\u0947\u0932 \u092A\u0924\u093E",url:"URL",emoji:"\u0907\u092E\u094B\u091C\u0940",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0924\u093F\u0925\u093F \u0914\u0930 \u0938\u092E\u092F",date:"ISO \u0924\u093F\u0925\u093F",time:"ISO \u0938\u092E\u092F",duration:"ISO \u0905\u0935\u0927\u093F",ipv4:"IPv4 \u092A\u0924\u093E",ipv6:"IPv6 \u092A\u0924\u093E",mac:"MAC \u092A\u0924\u093E",cidrv4:"IPv4 \u0936\u094D\u0930\u0947\u0923\u0940",cidrv6:"IPv6 \u0936\u094D\u0930\u0947\u0923\u0940",base64:"Base64-\u090F\u0928\u094D\u0915\u094B\u0921\u0947\u0921 \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917",base64url:"Base64URL-\u090F\u0928\u094D\u0915\u094B\u0921\u0947\u0921 \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917",json_string:"JSON \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917",e164:"E.164 \u0938\u0902\u0916\u094D\u092F\u093E",credit_card:"\u0915\u094D\u0930\u0947\u0921\u093F\u091F \u0915\u093E\u0930\u094D\u0921 \u0938\u0902\u0916\u094D\u092F\u093E",currency_code:"\u092E\u0941\u0926\u094D\u0930\u093E \u0915\u094B\u0921",iban:"IBAN",jwt:"JWT",template_literal:"\u0907\u0928\u092A\u0941\u091F"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${u}, \u092A\u094D\u0930\u093E\u092A\u094D\u0924 ${o}`}case"invalid_value":return r.values.length===1?`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${J(r.values[0])}`:`\u0905\u092E\u093E\u0928\u094D\u092F \u0935\u093F\u0915\u0932\u094D\u092A: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u092E\u093E\u0928\u094B\u0902 \u092E\u0947\u0902 \u0938\u0947 \u090F\u0915 ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u092C\u0939\u0941\u0924 \u092C\u0921\u093C\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${r.origin??"\u092E\u093E\u0928"} \u092E\u0947\u0902 ${u}${r.maximum} ${s.unit} \u0939\u094B\u0902`:`\u092C\u0939\u0941\u0924 \u092C\u0921\u093C\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${r.origin??"\u092E\u093E\u0928"} ${u}${r.maximum} \u0939\u094B`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u092C\u0939\u0941\u0924 \u091B\u094B\u091F\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${r.origin} \u092E\u0947\u0902 ${u}${r.minimum} ${s.unit} \u0939\u094B\u0902`:`\u092C\u0939\u0941\u0924 \u091B\u094B\u091F\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${r.origin} ${u}${r.minimum} \u0939\u094B`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: "${u.prefix}" \u0938\u0947 \u0936\u0941\u0930\u0942 \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:u.format==="ends_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: "${u.suffix}" \u092A\u0930 \u0938\u092E\u093E\u092A\u094D\u0924 \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:u.format==="includes"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: \u0907\u0938\u092E\u0947\u0902 "${u.includes}" \u0936\u093E\u092E\u093F\u0932 \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:u.format==="regex"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: \u092A\u0948\u091F\u0930\u094D\u0928 ${u.pattern} \u0938\u0947 \u092E\u0947\u0932 \u0916\u093E\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:`\u0905\u092E\u093E\u0928\u094D\u092F ${n[u.format]??r.format}`}case"not_multiple_of":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u0902\u0916\u094D\u092F\u093E: \u092F\u0939 ${r.divisor} \u0915\u093E \u0917\u0941\u0923\u091C \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`;case"unrecognized_keys":return`\u0905\u092A\u0930\u093F\u091A\u093F\u0924 \u0915\u0941\u0902\u091C\u0940${r.keys.length>1?"\u092F\u093E\u0901":""}: ${R(r.keys,", ")}`;case"invalid_key":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0915\u0941\u0902\u091C\u0940: ${r.origin} \u092E\u0947\u0902`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0905\u092E\u093E\u0928\u094D\u092F \u0921\u093F\u0938\u094D\u0915\u094D\u0930\u093F\u092E\u093F\u0928\u0947\u091F\u0930 \u092E\u093E\u0928: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${r.options.map(s=>`'${s}'`).join(" | ")}`:"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F";case"invalid_element":return`\u0905\u092E\u093E\u0928\u094D\u092F \u092E\u093E\u0928: ${r.origin} \u092E\u0947\u0902`;default:return"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F"}}};function v$(){return{localeError:g$()}}var C$=()=>{let e={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function t(r){return e[r]??null}let n={regex:"unos",email:"email adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum i vrijeme",date:"ISO datum",time:"ISO vrijeme",duration:"ISO trajanje",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",mac:"MAC adresa",cidrv4:"IPv4 raspon",cidrv6:"IPv6 raspon",base64:"base64 kodirani tekst",base64url:"base64url kodirani tekst",json_string:"JSON tekst",e164:"E.164 broj",credit_card:"broj kreditne kartice",currency_code:"kod valute",iban:"IBAN",jwt:"JWT",template_literal:"unos"},i={nan:"NaN",string:"tekst",number:"broj",boolean:"boolean",array:"niz",object:"objekt",set:"skup",file:"datoteka",date:"datum",bigint:"bigint",symbol:"simbol",undefined:"undefined",null:"null",function:"funkcija",map:"mapa"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Neispravan unos: o\u010Dekuje se instanceof ${r.expected}, a primljeno je ${o}`:`Neispravan unos: o\u010Dekuje se ${u}, a primljeno je ${o}`}case"invalid_value":return r.values.length===1?`Neispravna vrijednost: o\u010Dekivano ${J(r.values[0])}`:`Neispravna opcija: o\u010Dekivano jedno od ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin),o=i[r.origin]??r.origin;return s?`Preveliko: o\u010Dekivano da ${o??"vrijednost"} ima ${u}${r.maximum.toString()} ${s.unit??"elemenata"}`:`Preveliko: o\u010Dekivano da ${o??"vrijednost"} bude ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin),o=i[r.origin]??r.origin;return s?`Premalo: o\u010Dekivano da ${o} ima ${u}${r.minimum.toString()} ${s.unit}`:`Premalo: o\u010Dekivano da ${o} bude ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Neispravan tekst: mora zapo\u010Dinjati s "${u.prefix}"`:u.format==="ends_with"?`Neispravan tekst: mora zavr\u0161avati s "${u.suffix}"`:u.format==="includes"?`Neispravan tekst: mora sadr\u017Eavati "${u.includes}"`:u.format==="regex"?`Neispravan tekst: mora odgovarati uzorku ${u.pattern}`:`Neispravna ${n[u.format]??r.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${r.divisor}`;case"unrecognized_keys":return`Neprepoznat${r.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${R(r.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${i[r.origin]??r.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${i[r.origin]??r.origin}`;default:return"Neispravan unos"}}};function y$(){return{localeError:C$()}}var E$=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"},map:{unit:"elem",verb:"legyen"}};function t(r){return e[r]??null}let n={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",mac:"MAC c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",credit_card:"hitelk\xE1rtyasz\xE1m",currency_code:"p\xE9nznemk\xF3d",iban:"IBAN",jwt:"JWT",template_literal:"bemenet"},i={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${r.expected}, a kapott \xE9rt\xE9k ${o}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${u}, a kapott \xE9rt\xE9k ${o}`}case"invalid_value":return r.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${J(r.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`T\xFAl nagy: ${r.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${u}${r.maximum.toString()} ${s.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${r.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${r.origin} m\xE9rete t\xFAl kicsi ${u}${r.minimum.toString()} ${s.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${r.origin} t\xFAl kicsi ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\xC9rv\xE9nytelen string: "${u.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:u.format==="ends_with"?`\xC9rv\xE9nytelen string: "${u.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:u.format==="includes"?`\xC9rv\xE9nytelen string: "${u.includes}" \xE9rt\xE9ket kell tartalmaznia`:u.format==="regex"?`\xC9rv\xE9nytelen string: ${u.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${n[u.format]??r.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${r.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${r.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${r.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function w$(){return{localeError:E$()}}function um(e,t,n){return Math.abs(e)===1?t:n}function zr(e){if(!e)return"";let t=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],n=e[e.length-1];return e+(t.includes(n)?"\u0576":"\u0568")}var _$=()=>{let e={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},map:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(r){return e[r]??null}let n={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",mac:"MAC \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",credit_card:"\u056F\u0580\u0565\u0564\u056B\u057F \u0584\u0561\u0580\u057F\u056B \u0570\u0561\u0574\u0561\u0580",currency_code:"\u0561\u0580\u056A\u0578\u0582\u0575\u0569\u056B \u056F\u0578\u0564",iban:"IBAN",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},i={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${r.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${o}`:`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${u}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${o}`}case"invalid_value":return r.values.length===1?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${J(r.values[1])}`:`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);if(s){let o=Number(r.maximum),a=um(o,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${zr(r.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${u}${r.maximum.toString()} ${a}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${zr(r.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);if(s){let o=Number(r.minimum),a=um(o,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${zr(r.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${u}${r.minimum.toString()} ${a}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${zr(r.origin)} \u056C\u056B\u0576\u056B ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${u.prefix}"-\u0578\u057E`:u.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${u.suffix}"-\u0578\u057E`:u.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${u.includes}"`:u.format==="regex"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${u.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${n[u.format]??r.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${r.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${r.keys.length>1?"\u0576\u0565\u0580":""}. ${R(r.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${zr(r.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${zr(r.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function A$(){return{localeError:_$()}}var b$=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"},map:{unit:"item",verb:"memiliki"}};function t(r){return e[r]??null}let n={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",mac:"alamat MAC",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",credit_card:"nomor kartu kredit",currency_code:"kode mata uang",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Input tidak valid: diharapkan instanceof ${r.expected}, diterima ${o}`:`Input tidak valid: diharapkan ${u}, diterima ${o}`}case"invalid_value":return r.values.length===1?`Input tidak valid: diharapkan ${J(r.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Terlalu besar: diharapkan ${r.origin??"value"} memiliki ${u}${r.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: diharapkan ${r.origin??"value"} menjadi ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Terlalu kecil: diharapkan ${r.origin} memiliki ${u}${r.minimum.toString()} ${s.unit}`:`Terlalu kecil: diharapkan ${r.origin} menjadi ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`String tidak valid: harus dimulai dengan "${u.prefix}"`:u.format==="ends_with"?`String tidak valid: harus berakhir dengan "${u.suffix}"`:u.format==="includes"?`String tidak valid: harus menyertakan "${u.includes}"`:u.format==="regex"?`String tidak valid: harus sesuai pola ${u.pattern}`:`${n[u.format]??r.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${r.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${r.origin}`;default:return"Input tidak valid"}}};function S$(){return{localeError:b$()}}var D$=()=>{let e={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"},map:{unit:"hluti",verb:"a\xF0 hafa"}};function t(r){return e[r]??null}let n={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",credit_card:"kreditkortan\xFAmer",currency_code:"gjaldmi\xF0ilsk\xF3\xF0i",iban:"IBAN",jwt:"JWT",template_literal:"gildi"},i={nan:"NaN",number:"n\xFAmer",array:"fylki"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${o} \xFEar sem \xE1 a\xF0 vera instanceof ${r.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${o} \xFEar sem \xE1 a\xF0 vera ${u}`}case"invalid_value":return r.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${J(r.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin??"gildi"} hafi ${u}${r.maximum.toString()} ${s.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin??"gildi"} s\xE9 ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin} hafi ${u}${r.minimum.toString()} ${s.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin} s\xE9 ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${u.prefix}"`:u.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${u.suffix}"`:u.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${u.includes}"`:u.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${u.pattern}`:`Rangt ${n[u.format]??r.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${r.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${r.keys.length>1?"ir lyklar":"ur lykill"}: ${R(r.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${r.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${r.origin}`;default:return"Rangt gildi"}}};function I$(){return{localeError:D$()}}var $$=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"},map:{unit:"elementi",verb:"avere"}};function t(r){return e[r]??null}let n={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",mac:"indirizzo MAC",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",credit_card:"numero di carta di credito",currency_code:"codice valuta",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"numero",array:"vettore"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Input non valido: atteso instanceof ${r.expected}, ricevuto ${o}`:`Input non valido: atteso ${u}, ricevuto ${o}`}case"invalid_value":return r.values.length===1?`Input non valido: atteso ${J(r.values[0])}`:`Opzione non valida: atteso uno tra ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Troppo grande: ${r.origin??"valore"} deve avere ${u}${r.maximum.toString()} ${s.unit??"elementi"}`:`Troppo grande: ${r.origin??"valore"} deve essere ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Troppo piccolo: ${r.origin} deve avere ${u}${r.minimum.toString()} ${s.unit}`:`Troppo piccolo: ${r.origin} deve essere ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Stringa non valida: deve iniziare con "${u.prefix}"`:u.format==="ends_with"?`Stringa non valida: deve terminare con "${u.suffix}"`:u.format==="includes"?`Stringa non valida: deve includere "${u.includes}"`:u.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${u.pattern}`:`Input non valido: ${n[u.format]??r.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${r.divisor}`;case"unrecognized_keys":return`Chiav${r.keys.length>1?"i":"e"} non riconosciut${r.keys.length>1?"e":"a"}: ${R(r.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${r.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${r.origin}`;default:return"Input non valido"}}};function B$(){return{localeError:$$()}}var k$=()=>{let e={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},map:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(r){return e[r]??null}let n={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",mac:"MAC\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",credit_card:"\u30AF\u30EC\u30B8\u30C3\u30C8\u30AB\u30FC\u30C9\u756A\u53F7",currency_code:"\u901A\u8CA8\u30B3\u30FC\u30C9",iban:"IBAN",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},i={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${r.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${o}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${u}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${o}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return r.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${J(r.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${R(r.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let u=r.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",s=t(r.origin);return s?`\u5927\u304D\u3059\u304E\u308B\u5024: ${r.origin??"\u5024"}\u306F${r.maximum.toString()}${s.unit??"\u8981\u7D20"}${u}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${r.origin??"\u5024"}\u306F${r.maximum.toString()}${u}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let u=r.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",s=t(r.origin);return s?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${r.origin}\u306F${r.minimum.toString()}${s.unit}${u}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${r.origin}\u306F${r.minimum.toString()}${u}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${u.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:u.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${u.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:u.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${u.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:u.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${u.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${n[u.format]??r.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${r.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${r.keys.length>1?"\u7FA4":""}: ${R(r.keys,"\u3001")}`;case"invalid_key":return`${r.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${r.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function x$(){return{localeError:k$()}}var T$=()=>{let e={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},map:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function t(r){return e[r]??null}let n={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",mac:"MAC \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",json_string:"JSON \u10D5\u10D4\u10DA\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",credit_card:"\u10E1\u10D0\u10D9\u10E0\u10D4\u10D3\u10D8\u10E2\u10DD \u10D1\u10D0\u10E0\u10D0\u10D7\u10D8\u10E1 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",currency_code:"\u10D5\u10D0\u10DA\u10E3\u10E2\u10D8\u10E1 \u10D9\u10DD\u10D3\u10D8",iban:"IBAN",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},i={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10D5\u10D4\u10DA\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${r.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${o}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${u}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${o}`}case"invalid_value":return r.values.length===1?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${J(r.values[0])}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${R(r.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${s.verb} ${u}${r.maximum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin} ${s.verb} ${u}${r.minimum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin} \u10D8\u10E7\u10DD\u10E1 ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${u.prefix}"-\u10D8\u10D7`:u.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${u.suffix}"-\u10D8\u10D7`:u.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${u.includes}"-\u10E1`:u.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${u.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${n[u.format]??r.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${r.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${r.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${R(r.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${r.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${r.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};function F$(){return{localeError:T$()}}var P$=()=>{let e={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},map:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(r){return e[r]??null}let n={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",mac:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 MAC",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",credit_card:"\u179B\u17C1\u1781\u1794\u17D0\u178E\u17D2\u178E\u17A5\u178E\u1791\u17B6\u1793",currency_code:"\u1780\u17BC\u178A\u179A\u17BC\u1794\u17B7\u1799\u1794\u17D0\u178E\u17D2\u178E",iban:"IBAN",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},i={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${r.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${o}`:`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${u} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${o}`}case"invalid_value":return r.values.length===1?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${J(r.values[0])}`:`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${u} ${r.maximum.toString()} ${s.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${u} ${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin} ${u} ${r.minimum.toString()} ${s.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin} ${u} ${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${u.prefix}"`:u.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${u.suffix}"`:u.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${u.includes}"`:u.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${u.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${n[u.format]??r.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${r.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${R(r.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${r.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${r.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};function S3(){return{localeError:P$()}}function R$(){return S3()}var z$=()=>{let e={string:{unit:"\u0C85\u0C95\u0CCD\u0CB7\u0CB0\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},file:{unit:"\u0CAC\u0CC8\u0C9F\u0CCD\u200C\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},array:{unit:"\u0CB5\u0CB8\u0CCD\u0CA4\u0CC1\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},set:{unit:"\u0CB5\u0CB8\u0CCD\u0CA4\u0CC1\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},map:{unit:"entries",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"}};function t(r){return e[r]??null}let n={regex:"\u0C87\u0CA8\u0CCD\u0CAA\u0CC1\u0C9F\u0CCD",email:"email \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0CA6\u0CBF\u0CA8\u0CBE\u0C82\u0C95\u0CA6 \u0CB8\u0CAE\u0CAF",date:"ISO \u0CA6\u0CBF\u0CA8\u0CBE\u0C82\u0C95",time:"ISO \u0CB8\u0CAE\u0CAF",duration:"ISO \u0C85\u0CB5\u0CA7\u0CBF",ipv4:"IPv4 \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",ipv6:"IPv6 \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",mac:"MAC \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",cidrv4:"IPv4 \u0CB5\u0CCD\u0CAF\u0CBE\u0CAA\u0CCD\u0CA4\u0CBF\u0CAF",cidrv6:"IPv6 \u0CB5\u0CCD\u0CAF\u0CBE\u0CAA\u0CCD\u0CA4\u0CBF\u0CAF",base64:"base64-encoded\u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD",base64url:"base64url-encoded\u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD",json_string:"JSON\u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD",e164:"E.164 \u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6",credit_card:"\u0C95\u0CCD\u0CB0\u0CC6\u0CA1\u0CBF\u0C9F\u0CCD \u0C95\u0CBE\u0CB0\u0CCD\u0CA1\u0CCD \u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6",currency_code:"\u0C95\u0CB0\u0CC6\u0CA8\u0CCD\u0CB8\u0CBF \u0C95\u0CCB\u0CA1\u0CCD",iban:"IBAN",jwt:"JWT",template_literal:"\u0C87\u0CA8\u0CCD\u0CAA\u0CC1\u0C9F\u0CCD"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${u}, \u0CB8\u0CCD\u0CB5\u0CC0\u0C95\u0CB0\u0CBF\u0CB8\u0CBF\u0CA6\u0CA8\u0CC1 ${o}`}case"invalid_value":return r.values.length===1?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${J(r.values[0])}`:`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C86\u0CAF\u0CCD\u0C95\u0CC6: \u0C87\u0CB5\u0CC1\u0C97\u0CB3\u0CB2\u0CCD\u0CB2\u0CBF \u0C92\u0C82\u0CA6\u0CA8\u0CCD\u0CA8\u0CC1 \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0CA6\u0CCA\u0CA1\u0CCD\u0CA1\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${r.origin??"value"} \u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1 ${u}${r.maximum.toString()} ${s.unit??"\u0C85\u0C82\u0CB6\u0C97\u0CB3\u0CC1"}`:`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0CA6\u0CCA\u0CA1\u0CCD\u0CA1\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${r.origin??"value"} \u0C8E\u0C82\u0CA6\u0CC1 ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0C9A\u0CBF\u0C95\u0CCD\u0C95\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${r.origin} \u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1 ${u}${r.minimum.toString()} ${s.unit}`:`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0C9A\u0CBF\u0C95\u0CCD\u0C95\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${r.origin} \u0C8E\u0C82\u0CA6\u0CC1 ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0C87\u0CA6\u0CB0\u0CCA\u0C82\u0CA6\u0CBF\u0C97\u0CC6 \u0CAA\u0CCD\u0CB0\u0CBE\u0CB0\u0C82\u0CAD\u0CBF\u0CB8\u0CAC\u0CC7\u0C95\u0CC1 "${u.prefix}"`:u.format==="ends_with"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0C87\u0CA6\u0CB0\u0CCA\u0C82\u0CA6\u0CBF\u0C97\u0CC6 \u0C95\u0CCA\u0CA8\u0CC6\u0C97\u0CCA\u0CB3\u0CCD\u0CB3\u0CAC\u0CC7\u0C95\u0CC1 "${u.suffix}"`:u.format==="includes"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0C92\u0CB3\u0C97\u0CCA\u0C82\u0CA1\u0CBF\u0CB0\u0CAC\u0CC7\u0C95\u0CC1 "${u.includes}"`:u.format==="regex"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0CAE\u0CBE\u0CA6\u0CB0\u0CBF\u0C97\u0CC6 \u0CB9\u0CCA\u0C82\u0CA6\u0CBF\u0C95\u0CC6\u0CAF\u0CBE\u0C97\u0CAC\u0CC7\u0C95\u0CC1 ${u.pattern}`:`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF ${n[u.format]??r.format}`}case"not_multiple_of":return`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6: \u0CAC\u0CB9\u0CC1\u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6\u0CAF\u0CBE\u0C97\u0CBF\u0CB0\u0CAC\u0CC7\u0C95\u0CC1 ${r.divisor}`;case"unrecognized_keys":return`\u0C97\u0CC1\u0CB0\u0CC1\u0CA4\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CA6 \u0C95\u0CC0 ${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0C95\u0CC0 \u0C87\u0CA8\u0CCD ${r.origin}`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CA4\u0CBE\u0CB0\u0CA4\u0CAE\u0CCD\u0CAF \u0CAE\u0CCC\u0CB2\u0CCD\u0CAF. \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${r.options.map(s=>`'${s}'`).join(" | ")}`:"\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD";case"invalid_element":return`\u0CB0\u0CB2\u0CCD\u0CB2\u0CBF \u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CAE\u0CCC\u0CB2\u0CCD\u0CAF ${r.origin}`;default:return"\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD"}}};function O$(){return{localeError:z$()}}var N$=()=>{let e={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"},map:{unit:"\uAC1C",verb:"to have"}};function t(r){return e[r]??null}let n={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",mac:"MAC \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",credit_card:"\uC2E0\uC6A9\uCE74\uB4DC \uBC88\uD638",currency_code:"\uD1B5\uD654 \uCF54\uB4DC",iban:"IBAN",jwt:"JWT",template_literal:"\uC785\uB825"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${r.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${o}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${u}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${o}\uC785\uB2C8\uB2E4`}case"invalid_value":return r.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${J(r.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${R(r.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let u=r.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",s=u==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",o=t(r.origin),a=o?.unit??"\uC694\uC18C";return o?`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${r.maximum.toString()}${a} ${u}${s}`:`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${r.maximum.toString()} ${u}${s}`}case"too_small":{let u=r.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",s=u==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",o=t(r.origin),a=o?.unit??"\uC694\uC18C";return o?`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${r.minimum.toString()}${a} ${u}${s}`:`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${r.minimum.toString()} ${u}${s}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${u.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:u.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${u.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:u.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${u.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:u.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${u.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${n[u.format]??r.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${r.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${R(r.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${r.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${r.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function M$(){return{localeError:N$()}}var zi=e=>e.charAt(0).toUpperCase()+e.slice(1);function sm(e){let t=Math.abs(e),n=t%10,i=t%100;return i>=11&&i<=19||n===0?"many":n===1?"one":"few"}var U$=()=>{let e={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function t(r,u,s,o){let a=e[r]??null;return a===null?a:{unit:a.unit[u],verb:a.verb[o][s?"inclusive":"notInclusive"]}}let n={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",mac:"MAC adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",credit_card:"kredito kortel\u0117s numeris",currency_code:"valiutos kodas",iban:"IBAN",jwt:"JWT",template_literal:"\u012Fvestis"},i={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Gautas tipas ${o}, o tik\u0117tasi - instanceof ${r.expected}`:`Gautas tipas ${o}, o tik\u0117tasi - ${u}`}case"invalid_value":return r.values.length===1?`Privalo b\u016Bti ${J(r.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${R(r.values,"|")} pasirinkim\u0173`;case"too_big":{let u=i[r.origin]??r.origin,s=t(r.origin,sm(Number(r.maximum)),r.inclusive??!1,"smaller");if(s?.verb)return`${zi(u??r.origin??"reik\u0161m\u0117")} ${s.verb} ${r.maximum.toString()} ${s.unit??"element\u0173"}`;let o=r.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${zi(u??r.origin??"reik\u0161m\u0117")} turi b\u016Bti ${o} ${r.maximum.toString()} ${s?.unit}`}case"too_small":{let u=i[r.origin]??r.origin,s=t(r.origin,sm(Number(r.minimum)),r.inclusive??!1,"bigger");if(s?.verb)return`${zi(u??r.origin??"reik\u0161m\u0117")} ${s.verb} ${r.minimum.toString()} ${s.unit??"element\u0173"}`;let o=r.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${zi(u??r.origin??"reik\u0161m\u0117")} turi b\u016Bti ${o} ${r.minimum.toString()} ${s?.unit}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${u.prefix}"`:u.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${u.suffix}"`:u.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${u.includes}"`:u.format==="regex"?`Eilut\u0117 privalo atitikti ${u.pattern}`:`Neteisingas ${n[u.format]??r.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${r.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${r.keys.length>1?"i":"as"} rakt${r.keys.length>1?"ai":"as"}: ${R(r.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let u=i[r.origin]??r.origin;return`${zi(u??r.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function j$(){return{localeError:U$()}}var L$=()=>{let e={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},map:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(r){return e[r]??null}let n={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",mac:"MAC \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",credit_card:"\u0431\u0440\u043E\u0458 \u043D\u0430 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u0430 \u043A\u0430\u0440\u0442\u0438\u0447\u043A\u0430",currency_code:"\u043A\u043E\u0434 \u043D\u0430 \u0432\u0430\u043B\u0443\u0442\u0430",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},i={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${r.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${o}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${u}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${o}`}case"invalid_value":return r.values.length===1?`Invalid input: expected ${J(r.values[0])}`:`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${u}${r.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin} \u0434\u0430 \u0438\u043C\u0430 ${u}${r.minimum.toString()} ${s.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${u.prefix}"`:u.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${u.suffix}"`:u.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${u.includes}"`:u.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${u.pattern}`:`Invalid ${n[u.format]??r.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${R(r.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${r.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${r.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function q$(){return{localeError:L$()}}var Z$=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"},map:{unit:"elemen",verb:"mempunyai"}};function t(r){return e[r]??null}let n={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",mac:"alamat MAC",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",credit_card:"nombor kad kredit",currency_code:"kod mata wang",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"nombor"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Input tidak sah: dijangka instanceof ${r.expected}, diterima ${o}`:`Input tidak sah: dijangka ${u}, diterima ${o}`}case"invalid_value":return r.values.length===1?`Input tidak sah: dijangka ${J(r.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Terlalu besar: dijangka ${r.origin??"nilai"} ${s.verb} ${u}${r.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: dijangka ${r.origin??"nilai"} adalah ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Terlalu kecil: dijangka ${r.origin} ${s.verb} ${u}${r.minimum.toString()} ${s.unit}`:`Terlalu kecil: dijangka ${r.origin} adalah ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`String tidak sah: mesti bermula dengan "${u.prefix}"`:u.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${u.suffix}"`:u.format==="includes"?`String tidak sah: mesti mengandungi "${u.includes}"`:u.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${u.pattern}`:`${n[u.format]??r.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${R(r.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${r.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${r.origin}`;default:return"Input tidak sah"}}};function W$(){return{localeError:Z$()}}var G$=()=>{let e={string:{unit:"\u0905\u0915\u094D\u0937\u0930",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},file:{unit:"\u092C\u093E\u0907\u091F",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},array:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},set:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},map:{unit:"\u092A\u094D\u0930\u0935\u093F\u0937\u094D\u091F\u093F",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"}};function t(r){return e[r]??null}let n={regex:"\u0907\u0928\u092A\u0941\u091F",email:"\u0907\u092E\u0947\u0932 \u0920\u0947\u0917\u093E\u0928\u093E",url:"URL",emoji:"\u0907\u092E\u094B\u091C\u0940",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u092E\u093F\u0924\u093F \u0930 \u0938\u092E\u092F",date:"ISO \u092E\u093F\u0924\u093F",time:"ISO \u0938\u092E\u092F",duration:"ISO \u0905\u0935\u0927\u093F",ipv4:"IPv4 \u0920\u0947\u0917\u093E\u0928\u093E",ipv6:"IPv6 \u0920\u0947\u0917\u093E\u0928\u093E",mac:"MAC \u0920\u0947\u0917\u093E\u0928\u093E",cidrv4:"IPv4 \u0926\u093E\u092F\u0930\u093E",cidrv6:"IPv6 \u0926\u093E\u092F\u0930\u093E",base64:"base64-\u0907\u0928\u094D\u0915\u094B\u0921 \u0917\u0930\u093F\u090F\u0915\u094B \u0938\u094D\u091F\u094D\u0930\u093F\u0919",base64url:"base64url-\u0907\u0928\u094D\u0915\u094B\u0921 \u0917\u0930\u093F\u090F\u0915\u094B \u0938\u094D\u091F\u094D\u0930\u093F\u0919",json_string:"JSON \u0938\u094D\u091F\u094D\u0930\u093F\u0919",e164:"E.164 \u0928\u092E\u094D\u092C\u0930",credit_card:"\u0915\u094D\u0930\u0947\u0921\u093F\u091F \u0915\u093E\u0930\u094D\u0921 \u0928\u092E\u094D\u092C\u0930",currency_code:"\u092E\u0941\u0926\u094D\u0930\u093E \u0915\u094B\u0921",iban:"IBAN",jwt:"JWT",template_literal:"\u0907\u0928\u092A\u0941\u091F"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${u}, \u092A\u094D\u0930\u093E\u092A\u094D\u0924 ${o}`}case"invalid_value":return r.values.length===1?`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${J(r.values[0])}`:`\u0905\u092E\u093E\u0928\u094D\u092F \u0935\u093F\u0915\u0932\u094D\u092A: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u092E\u093E\u0928\u0939\u0930\u0942 \u092E\u0927\u094D\u092F\u0947 \u090F\u0915 ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0927\u0947\u0930\u0948 \u0920\u0942\u0932\u094B: ${r.origin??"\u092E\u093E\u0928"} \u092E\u093E ${u}${r.maximum.toString()} ${s.unit} ${s.verb}`:`\u0927\u0947\u0930\u0948 \u0920\u0942\u0932\u094B: ${r.origin??"\u092E\u093E\u0928"} ${u}${r.maximum.toString()} \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u0927\u0947\u0930\u0948 \u0938\u093E\u0928\u094B: ${r.origin} \u092E\u093E ${u}${r.minimum.toString()} ${s.unit} ${s.verb}`:`\u0927\u0947\u0930\u0948 \u0938\u093E\u0928\u094B: ${r.origin} ${u}${r.minimum.toString()} \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: "${u.prefix}" \u092C\u093E\u091F \u0938\u0941\u0930\u0941 \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`:u.format==="ends_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: "${u.suffix}" \u092E\u093E \u0938\u092E\u093E\u092A\u094D\u0924 \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`:u.format==="includes"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: "${u.includes}" \u0938\u092E\u093E\u0935\u0947\u0936 \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`:u.format==="regex"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: \u0922\u093E\u0901\u091A\u093E ${u.pattern} \u0938\u0901\u0917 \u092E\u0947\u0932 \u0916\u093E\u0928\u0941\u092A\u0930\u094D\u091B`:`\u0905\u092E\u093E\u0928\u094D\u092F ${n[u.format]??r.format}`}case"not_multiple_of":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u0902\u0916\u094D\u092F\u093E: ${r.divisor} \u0915\u094B \u0917\u0941\u0923\u091C \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`;case"unrecognized_keys":return`\u0905\u092A\u0930\u093F\u091A\u093F\u0924 \u0915\u0941\u091E\u094D\u091C\u0940${r.keys.length>1?"\u0939\u0930\u0942":""}: ${R(r.keys,", ")}`;case"invalid_key":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0915\u0941\u091E\u094D\u091C\u0940: ${r.origin} \u092E\u093E`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0905\u092E\u093E\u0928\u094D\u092F \u0921\u093F\u0938\u094D\u0915\u094D\u0930\u093F\u092E\u093F\u0928\u0947\u091F\u0930 \u092E\u093E\u0928: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${r.options.map(s=>`'${s}'`).join(" | ")}`:"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F";case"invalid_element":return`\u0905\u092E\u093E\u0928\u094D\u092F \u092E\u093E\u0928: ${r.origin} \u092E\u093E`;default:return"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F"}}};function V$(){return{localeError:G$()}}var H$=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"},map:{unit:"elementen",verb:"heeft"}};function t(r){return e[r]??null}let n={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",mac:"MAC-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",credit_card:"creditcardnummer",currency_code:"valutacode",iban:"IBAN",jwt:"JWT",template_literal:"invoer"},i={nan:"NaN",number:"getal"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ongeldige invoer: verwacht instanceof ${r.expected}, ontving ${o}`:`Ongeldige invoer: verwacht ${u}, ontving ${o}`}case"invalid_value":return r.values.length===1?`Ongeldige invoer: verwacht ${J(r.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin),o=r.origin==="date"?"laat":r.origin==="string"?"lang":"groot";return s?`Te ${o}: verwacht dat ${r.origin??"waarde"} ${u}${r.maximum.toString()} ${s.unit??"elementen"} ${s.verb}`:`Te ${o}: verwacht dat ${r.origin??"waarde"} ${u}${r.maximum.toString()} is`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin),o=r.origin==="date"?"vroeg":r.origin==="string"?"kort":"klein";return s?`Te ${o}: verwacht dat ${r.origin} ${u}${r.minimum.toString()} ${s.unit} ${s.verb}`:`Te ${o}: verwacht dat ${r.origin} ${u}${r.minimum.toString()} is`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Ongeldige tekst: moet met "${u.prefix}" beginnen`:u.format==="ends_with"?`Ongeldige tekst: moet op "${u.suffix}" eindigen`:u.format==="includes"?`Ongeldige tekst: moet "${u.includes}" bevatten`:u.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${u.pattern}`:`Ongeldig: ${n[u.format]??r.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${r.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${r.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${r.origin}`;default:return"Ongeldige invoer"}}};function J$(){return{localeError:H$()}}var K$=()=>{let e={string:{unit:"teikn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"element",verb:"\xE5 innehalde"},set:{unit:"element",verb:"\xE5 innehalde"},map:{unit:"element",verb:"\xE5 innehalde"}};function t(r){return e[r]??null}let n={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varigheit",ipv4:"IPv4-adresse",ipv6:"IPv6-adresse",mac:"MAC-adresse",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkoda streng",base64url:"base64url-enkoda streng",json_string:"JSON-streng",e164:"E.164-nummer",credit_card:"kredittkortnummer",currency_code:"valutakode",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"tal",array:"liste"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ugyldig input: forventa instanceof ${r.expected}, fekk ${o}`:`Ugyldig input: forventa ${u}, fekk ${o}`}case"invalid_value":return r.values.length===1?`Ugyldig verdi: forventa ${J(r.values[0])}`:`Ugyldig val: forventa eitt av ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`For stor(t): forventa ${r.origin??"value"} til \xE5 ha ${u}${r.maximum.toString()} ${s.unit??"element"}`:`For stor(t): forventa ${r.origin??"value"} til \xE5 ha ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`For lite(n): forventa ${r.origin} til \xE5 ha ${u}${r.minimum.toString()} ${s.unit}`:`For lite(n): forventa ${r.origin} til \xE5 ha ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${u.prefix}"`:u.format==="ends_with"?`Ugyldig streng: m\xE5 slutte med "${u.suffix}"`:u.format==="includes"?`Ugyldig streng: m\xE5 innehalde "${u.includes}"`:u.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${u.pattern}`:`Ugyldig ${n[u.format]??r.format}`}case"not_multiple_of":return`Ugyldig tal: m\xE5 vere eit multiplum av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukjende n\xF8klar":"Ukjend n\xF8kkel"}: ${R(r.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${r.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${r.origin}`;default:return"Ugyldig input"}}};function X$(){return{localeError:K$()}}var Y$=()=>{let e={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"},map:{unit:"elementer",verb:"\xE5 inneholde"}};function t(r){return e[r]??null}let n={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-adresse",ipv6:"IPv6-adresse",mac:"MAC-adresse",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",credit_card:"kredittkortnummer",currency_code:"valutakode",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"tall",array:"liste"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ugyldig input: forventet instanceof ${r.expected}, fikk ${o}`:`Ugyldig input: forventet ${u}, fikk ${o}`}case"invalid_value":return r.values.length===1?`Ugyldig verdi: forventet ${J(r.values[0])}`:`Ugyldig valg: forventet en av ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`For stor(t): forventet ${r.origin??"value"} til \xE5 ha ${u}${r.maximum.toString()} ${s.unit??"elementer"}`:`For stor(t): forventet ${r.origin??"value"} til \xE5 ha ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`For lite(n): forventet ${r.origin} til \xE5 ha ${u}${r.minimum.toString()} ${s.unit}`:`For lite(n): forventet ${r.origin} til \xE5 ha ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${u.prefix}"`:u.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${u.suffix}"`:u.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${u.includes}"`:u.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${u.pattern}`:`Ugyldig ${n[u.format]??r.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${R(r.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${r.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${r.origin}`;default:return"Ugyldig input"}}};function Q$(){return{localeError:Y$()}}var eB=()=>{let e={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"},map:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(r){return e[r]??null}let n={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",mac:"MAC ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",credit_card:"i'tib\xE2r kart\u0131 numaras\u0131",currency_code:"para birimi kodu",iban:"IBAN",jwt:"JWT",template_literal:"giren"},i={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`F\xE2sit giren: umulan instanceof ${r.expected}, al\u0131nan ${o}`:`F\xE2sit giren: umulan ${u}, al\u0131nan ${o}`}case"invalid_value":return r.values.length===1?`F\xE2sit giren: umulan ${J(r.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Fazla b\xFCy\xFCk: ${r.origin??"value"}, ${u}${r.maximum.toString()} ${s.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${r.origin??"value"}, ${u}${r.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Fazla k\xFC\xE7\xFCk: ${r.origin}, ${u}${r.minimum.toString()} ${s.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${r.origin}, ${u}${r.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let u=r;return u.format==="starts_with"?`F\xE2sit metin: "${u.prefix}" ile ba\u015Flamal\u0131.`:u.format==="ends_with"?`F\xE2sit metin: "${u.suffix}" ile bitmeli.`:u.format==="includes"?`F\xE2sit metin: "${u.includes}" ihtiv\xE2 etmeli.`:u.format==="regex"?`F\xE2sit metin: ${u.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${n[u.format]??r.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${r.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`${r.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${r.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function tB(){return{localeError:eB()}}var nB=()=>{let e={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},map:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(r){return e[r]??null}let n={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",mac:"\u062F MAC \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",credit_card:"\u062F \u06A9\u0631\u06CC\u0689\u06CC\u067C \u06A9\u0627\u0631\u062A \u0634\u0645\u06CC\u0631\u0647",currency_code:"\u062F \u0627\u0633\u0639\u0627\u0631\u0648 \u06A9\u0648\u0689",iban:"IBAN",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${r.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${o} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${u} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${o} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return r.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${J(r.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${R(r.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${r.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${u}${r.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${r.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${u}${r.maximum.toString()} \u0648\u064A`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${r.origin} \u0628\u0627\u06CC\u062F ${u}${r.minimum.toString()} ${s.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${r.origin} \u0628\u0627\u06CC\u062F ${u}${r.minimum.toString()} \u0648\u064A`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${u.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:u.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${u.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:u.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${u.includes}" \u0648\u0644\u0631\u064A`:u.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${u.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${n[u.format]??r.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${r.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${r.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${R(r.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${r.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${r.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function rB(){return{localeError:nB()}}var iB=()=>{let e={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"},map:{unit:"element\xF3w",verb:"mie\u0107"}};function t(r){return e[r]??null}let n={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",mac:"adres MAC",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",credit_card:"numer karty kredytowej",currency_code:"kod waluty",iban:"IBAN",jwt:"JWT",template_literal:"wej\u015Bcie"},i={nan:"NaN",number:"liczba",array:"tablica"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${r.expected}, otrzymano ${o}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${u}, otrzymano ${o}`}case"invalid_value":return r.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${J(r.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${u}${r.maximum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${u}${r.minimum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${u.prefix}"`:u.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${u.suffix}"`:u.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${u.includes}"`:u.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${u.pattern}`:`Nieprawid\u0142ow(y/a/e) ${n[u.format]??r.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${r.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${r.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${r.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function uB(){return{localeError:iB()}}var sB=()=>{let e={string:{unit:"caracteres"},file:{unit:"bytes"},array:{unit:"elementos"},set:{unit:"elementos"},map:{unit:"entradas"}};function t(s){return e[s]??null}let n={regex:"a entrada",email:"o endere\xE7o de e-mail",url:"o URL",emoji:"o emoji",uuid:"o UUID",uuidv4:"o UUIDv4",uuidv6:"o UUIDv6",nanoid:"o nanoid",guid:"o GUID",cuid:"o cuid",cuid2:"o cuid2",ulid:"o ULID",xid:"o XID",ksuid:"o KSUID",datetime:"a data e hora ISO",date:"a data ISO",time:"a hora ISO",duration:"a dura\xE7\xE3o ISO",ipv4:"o endere\xE7o IPv4",ipv6:"o endere\xE7o IPv6",mac:"o endere\xE7o MAC",cidrv4:"o intervalo de endere\xE7os IPv4",cidrv6:"o intervalo de endere\xE7os IPv6",base64:"o texto codificado em base64",base64url:"o texto codificado em base64url",json_string:"o texto JSON",e164:"o n\xFAmero E.164",credit_card:"o n\xFAmero de cart\xE3o de cr\xE9dito",currency_code:"o c\xF3digo de moeda",iban:"o IBAN",jwt:"o JWT",template_literal:"a entrada"},i={masculine:{definite:"o",indefinite:"um"},feminine:{definite:"a",indefinite:"uma"}},r={string:{name:"texto",articles:i.masculine},number:{name:"n\xFAmero",articles:i.masculine},int:{name:"n\xFAmero inteiro",articles:i.masculine},boolean:{name:"valor booleano",articles:i.masculine},bigint:{name:"n\xFAmero bigint",articles:i.masculine},symbol:{name:"s\xEDmbolo",articles:i.masculine},undefined:{name:'valor "undefined"',articles:i.masculine},null:{name:'valor "nulo"',articles:i.masculine},never:{name:'valor "never"',articles:i.masculine},void:{name:'valor "void"',articles:i.masculine},date:{name:"data",articles:i.feminine},array:{name:"vetor",articles:i.masculine},object:{name:"objeto",articles:i.masculine},tuple:{name:"tuplo",articles:i.masculine},record:{name:"registo",articles:i.masculine},map:{name:"mapa",articles:i.masculine},set:{name:"conjunto",articles:i.masculine},file:{name:"ficheiro",articles:i.masculine},nonoptional:{name:"valor n\xE3o opcional",articles:i.masculine},nan:{name:'valor "NaN"',articles:i.masculine},function:{name:"fun\xE7\xE3o",articles:i.feminine}};function u(s,o){let a=r[s]??{name:`valor "${s}"`,articles:i.masculine};return`${a.articles[o]} ${a.name}`}return s=>{switch(s.code){case"invalid_type":{let o=u(s.expected,"indefinite"),a=K(s.input),l=u(a,"indefinite");return`Entrada inv\xE1lida: esperava ${o}, recebeu ${l}`}case"invalid_value":return s.values.length===1?`Entrada inv\xE1lida: esperava ${J(s.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperava uma das seguintes op\xE7\xF5es: ${R(s.values,"|")}`;case"too_big":{let o=s.inclusive?"<=":"<",a=t(s.origin);return a?`Demasiado grande: esperava que ${u(s.origin,"definite")} tivesse ${o} ${s.maximum.toString()} ${a.unit??"elementos"}`:`Demasiado grande: esperava que ${u(s.origin,"definite")} fosse ${o} ${s.maximum.toString()}`}case"too_small":{let o=s.inclusive?">=":">",a=t(s.origin);return a?`Demasiado pequeno: esperava que ${u(s.origin,"definite")} tivesse ${o} ${s.minimum.toString()} ${a.unit??"elementos"}`:`Demasiado pequeno: esperava que ${u(s.origin,"definite")} fosse ${o} ${s.minimum.toString()}`}case"invalid_format":{let o=s;return o.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar por "${o.prefix}"`:o.format==="ends_with"?`Texto inv\xE1lido: deve terminar em "${o.suffix}"`:o.format==="includes"?`Texto inv\xE1lido: deve incluir "${o.includes}"`:o.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${o.pattern}`:`Formato d${n[o.format]??s.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${s.divisor}`;case"unrecognized_keys":{let o=s.keys.length>1?"s":"";return`Chave${o} inv\xE1lida${o}: ${R(s.keys,", ")}`}case"invalid_key":return`Entrada inv\xE1lida n${u(s.origin,"definite")}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Valor de discrimina\xE7\xE3o inv\xE1lido. Esperava ${s.options.map(a=>`'${a}'`).join(" | ")}`:"Entrada inv\xE1lida";case"invalid_element":return`Entrada inv\xE1lida n${u(s.origin,"definite")}`;default:return"Entrada inv\xE1lida"}}};function oB(){return{localeError:sB()}}var aB=()=>{let e={string:{unit:"caracteres"},file:{unit:"bytes"},array:{unit:"elementos"},set:{unit:"elementos"},map:{unit:"entradas"}};function t(s){return e[s]??null}let n={regex:"a entrada",email:"o endere\xE7o de e-mail",url:"o URL",emoji:"o emoji",uuid:"o UUID",uuidv4:"o UUIDv4",uuidv6:"o UUIDv6",nanoid:"o nanoid",guid:"o GUID",cuid:"o cuid",cuid2:"o cuid2",ulid:"o ULID",xid:"o XID",ksuid:"o KSUID",datetime:"a data e hora ISO",date:"a data ISO",time:"a hora ISO",duration:"a dura\xE7\xE3o ISO",ipv4:"o endere\xE7o IPv4",ipv6:"o endere\xE7o IPv6",mac:"o endere\xE7o MAC",cidrv4:"a faixa de endere\xE7os IPv4",cidrv6:"a faixa de endere\xE7os IPv6",base64:"o texto codificado em base64",base64url:"o texto codificado em base64url",json_string:"o texto JSON",e164:"o n\xFAmero E.164",credit_card:"o n\xFAmero de cart\xE3o de cr\xE9dito",currency_code:"o c\xF3digo de moeda",iban:"o IBAN",jwt:"o JWT",template_literal:"a entrada"},i={masculine:{definite:"o",indefinite:"um"},feminine:{definite:"a",indefinite:"uma"}},r={string:{name:"texto",articles:i.masculine},number:{name:"n\xFAmero",articles:i.masculine},int:{name:"n\xFAmero inteiro",articles:i.masculine},boolean:{name:"valor booleano",articles:i.masculine},bigint:{name:"n\xFAmero bigint",articles:i.masculine},symbol:{name:"s\xEDmbolo",articles:i.masculine},undefined:{name:'valor "undefined"',articles:i.masculine},null:{name:'valor "nulo"',articles:i.masculine},never:{name:'valor "never"',articles:i.masculine},void:{name:'valor "void"',articles:i.masculine},date:{name:"data",articles:i.feminine},array:{name:"vetor",articles:i.masculine},object:{name:"objeto",articles:i.masculine},tuple:{name:"tupla",articles:i.feminine},record:{name:"registro",articles:i.masculine},map:{name:"mapa",articles:i.masculine},set:{name:"conjunto",articles:i.masculine},file:{name:"arquivo",articles:i.masculine},nonoptional:{name:"valor n\xE3o opcional",articles:i.masculine},nan:{name:'valor "NaN"',articles:i.masculine},function:{name:"fun\xE7\xE3o",articles:i.feminine}};function u(s,o){let a=r[s]??{name:`valor "${s}"`,articles:i.masculine};return`${a.articles[o]} ${a.name}`}return s=>{switch(s.code){case"invalid_type":{let o=u(s.expected,"indefinite"),a=K(s.input),l=u(a,"indefinite");return`Entrada inv\xE1lida: esperava ${o}, recebeu ${l}`}case"invalid_value":return s.values.length===1?`Entrada inv\xE1lida: esperava ${J(s.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperava uma das seguintes op\xE7\xF5es: ${R(s.values,"|")}`;case"too_big":{let o=s.inclusive?"<=":"<",a=t(s.origin);return a?`Grande demais: esperava que ${u(s.origin,"definite")} tivesse ${o} ${s.maximum.toString()} ${a.unit??"elementos"}`:`Grande demais: esperava que ${u(s.origin,"definite")} fosse ${o} ${s.maximum.toString()}`}case"too_small":{let o=s.inclusive?">=":">",a=t(s.origin);return a?`Pequeno demais: esperava que ${u(s.origin,"definite")} tivesse ${o} ${s.minimum.toString()} ${a.unit??"elementos"}`:`Pequeno demais: esperava que ${u(s.origin,"definite")} fosse ${o} ${s.minimum.toString()}`}case"invalid_format":{let o=s;return o.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${o.prefix}"`:o.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${o.suffix}"`:o.format==="includes"?`Texto inv\xE1lido: deve incluir "${o.includes}"`:o.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${o.pattern}`:`Formato d${n[o.format]??s.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${s.divisor}`;case"unrecognized_keys":{let o=s.keys.length>1?"s":"";return`Chave${o} inv\xE1lida${o}: ${R(s.keys,", ")}`}case"invalid_key":return`Entrada inv\xE1lida n${u(s.origin,"definite")}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Valor de discrimina\xE7\xE3o inv\xE1lido. Esperava ${s.options.map(a=>`'${a}'`).join(" | ")}`:"Entrada inv\xE1lida";case"invalid_element":return`Entrada inv\xE1lida n${u(s.origin,"definite")}`;default:return"Entrada inv\xE1lida"}}};function lB(){return{localeError:aB()}}var cB=()=>{let e={string:{unit:"caractere",verb:"s\u0103 aib\u0103"},file:{unit:"octe\u021Bi",verb:"s\u0103 aib\u0103"},array:{unit:"elemente",verb:"s\u0103 aib\u0103"},set:{unit:"elemente",verb:"s\u0103 aib\u0103"},map:{unit:"intr\u0103ri",verb:"s\u0103 aib\u0103"}};function t(r){return e[r]??null}let n={regex:"intrare",email:"adres\u0103 de email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"dat\u0103 \u0219i or\u0103 ISO",date:"dat\u0103 ISO",time:"or\u0103 ISO",duration:"durat\u0103 ISO",ipv4:"adres\u0103 IPv4",ipv6:"adres\u0103 IPv6",mac:"adres\u0103 MAC",cidrv4:"interval IPv4",cidrv6:"interval IPv6",base64:"\u0219ir codat base64",base64url:"\u0219ir codat base64url",json_string:"\u0219ir JSON",e164:"num\u0103r E.164",credit_card:"num\u0103r de card de credit",currency_code:"cod valutar",iban:"IBAN",jwt:"JWT",template_literal:"intrare"},i={nan:"NaN",string:"\u0219ir",number:"num\u0103r",boolean:"boolean",function:"func\u021Bie",array:"matrice",object:"obiect",undefined:"nedefinit",symbol:"simbol",bigint:"num\u0103r mare",void:"void",never:"never",map:"hart\u0103",set:"set"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return`Intrare invalid\u0103: a\u0219teptat ${u}, primit ${o}`}case"invalid_value":return r.values.length===1?`Intrare invalid\u0103: a\u0219teptat ${J(r.values[0])}`:`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Prea mare: a\u0219teptat ca ${r.origin??"valoarea"} ${s.verb} ${u}${r.maximum.toString()} ${s.unit??"elemente"}`:`Prea mare: a\u0219teptat ca ${r.origin??"valoarea"} s\u0103 fie ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Prea mic: a\u0219teptat ca ${r.origin} ${s.verb} ${u}${r.minimum.toString()} ${s.unit}`:`Prea mic: a\u0219teptat ca ${r.origin} s\u0103 fie ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${u.prefix}"`:u.format==="ends_with"?`\u0218ir invalid: trebuie s\u0103 se termine cu "${u.suffix}"`:u.format==="includes"?`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${u.includes}"`:u.format==="regex"?`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${u.pattern}`:`Format invalid: ${n[u.format]??r.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${r.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${R(r.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${r.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${r.origin}`;default:return"Intrare invalid\u0103"}}};function dB(){return{localeError:cB()}}function om(e,t,n,i){let r=Math.abs(e),u=r%10,s=r%100;return s>=11&&s<=19?i:u===1?t:u>=2&&u<=4?n:i}var hB=()=>{let e={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},map:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",mac:"MAC \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",credit_card:"\u043D\u043E\u043C\u0435\u0440 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u043E\u0439 \u043A\u0430\u0440\u0442\u044B",currency_code:"\u043A\u043E\u0434 \u0432\u0430\u043B\u044E\u0442\u044B",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${r.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${o}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${u}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${o}`}case"invalid_value":return r.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${J(r.values[0])}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);if(s){let o=Number(r.maximum),a=om(o,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${u}${r.maximum.toString()} ${a}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);if(s){let o=Number(r.minimum),a=om(o,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${u}${r.minimum.toString()} ${a}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin} \u0431\u0443\u0434\u0435\u0442 ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${u.prefix}"`:u.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${u.suffix}"`:u.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${u.includes}"`:u.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${u.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${n[u.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${r.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${r.keys.length>1?"\u0438":""}: ${R(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${r.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};function fB(){return{localeError:hB()}}var pB=()=>{let e={string:{unit:"znakov",verb:"ma\u0165"},file:{unit:"bajtov",verb:"ma\u0165"},array:{unit:"prvkov",verb:"ma\u0165"},set:{unit:"prvkov",verb:"ma\u0165"},map:{unit:"polo\u017Eiek",verb:"ma\u0165"}};function t(r){return e[r]??null}let n={regex:"regul\xE1rny v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"d\xE1tum a \u010Das vo form\xE1te ISO",date:"d\xE1tum vo form\xE1te ISO",time:"\u010Das vo form\xE1te ISO",duration:"doba trvania ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",mac:"MAC adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"re\u0165azec zak\xF3dovan\xFD vo form\xE1te base64",base64url:"re\u0165azec zak\xF3dovan\xFD vo form\xE1te base64url",json_string:"re\u0165azec vo form\xE1te JSON",e164:"\u010D\xEDslo E.164",credit_card:"\u010D\xEDslo kreditnej karty",currency_code:"k\xF3d meny",iban:"IBAN",jwt:"JWT",template_literal:"vstup"},i={nan:"NaN",number:"\u010D\xEDslo",string:"re\u0165azec",function:"funkcia",array:"pole"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Neplatn\xFD vstup: o\u010Dak\xE1van\xE9 instanceof ${r.expected}, obdr\u017Ean\xE9 ${o}`:`Neplatn\xFD vstup: o\u010Dak\xE1van\xE9 ${u}, obdr\u017Ean\xE9 ${o}`}case"invalid_value":return r.values.length===1?`Neplatn\xFD vstup: o\u010Dak\xE1van\xE9 ${J(r.values[0])}`:`Neplatn\xFD vstup: o\u010Dak\xE1van\xE1 jedna z hodn\xF4t ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Hodnota je pr\xEDli\u0161 ve\u013Ek\xE1: ${r.origin??"hodnota"} mus\xED ma\u0165 ${u}${r.maximum.toString()} ${s.unit??"prvkov"}`:`Hodnota je pr\xEDli\u0161 ve\u013Ek\xE1: ${r.origin??"hodnota"} mus\xED by\u0165 ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Hodnota je pr\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED ma\u0165 ${u}${r.minimum.toString()} ${s.unit??"prvkov"}`:`Hodnota je pr\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED by\u0165 ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Neplatn\xFD re\u0165azec: mus\xED za\u010D\xEDna\u0165 na "${u.prefix}"`:u.format==="ends_with"?`Neplatn\xFD re\u0165azec: mus\xED kon\u010Di\u0165 na "${u.suffix}"`:u.format==="includes"?`Neplatn\xFD re\u0165azec: mus\xED obsahova\u0165 "${u.includes}"`:u.format==="regex"?`Neplatn\xFD re\u0165azec: mus\xED zodpoveda\u0165 vzoru ${u.pattern}`:`Neplatn\xFD form\xE1t ${n[u.format]??r.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED by\u0165 n\xE1sobkom ${r.divisor}`;case"unrecognized_keys":return`Nezn\xE1me kl\xFA\u010De: ${R(r.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xFA\u010D v ${r.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${r.origin}`;default:return"Neplatn\xFD vstup"}}};function mB(){return{localeError:pB()}}var gB=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"},map:{unit:"elementov",verb:"imeti"}};function t(r){return e[r]??null}let n={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",mac:"MAC naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",credit_card:"\u0161tevilka kreditne kartice",currency_code:"koda valute",iban:"IBAN",jwt:"JWT",template_literal:"vnos"},i={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${r.expected}, prejeto ${o}`:`Neveljaven vnos: pri\u010Dakovano ${u}, prejeto ${o}`}case"invalid_value":return r.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${J(r.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Preveliko: pri\u010Dakovano, da bo ${r.origin??"vrednost"} imelo ${u}${r.maximum.toString()} ${s.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${r.origin??"vrednost"} ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Premajhno: pri\u010Dakovano, da bo ${r.origin} imelo ${u}${r.minimum.toString()} ${s.unit}`:`Premajhno: pri\u010Dakovano, da bo ${r.origin} ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${u.prefix}"`:u.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${u.suffix}"`:u.format==="includes"?`Neveljaven niz: mora vsebovati "${u.includes}"`:u.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${u.pattern}`:`Neveljaven ${n[u.format]??r.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${r.divisor}`;case"unrecognized_keys":return`Neprepoznan${r.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${R(r.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${r.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${r.origin}`;default:return"Neveljaven vnos"}}};function vB(){return{localeError:gB()}}var CB=()=>{let e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"},map:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(r){return e[r]??null}let n={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-adress",ipv6:"IPv6-adress",mac:"MAC-adress",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",credit_card:"kreditkortsnummer",currency_code:"valutakod",iban:"IBAN",jwt:"JWT",template_literal:"mall-literal"},i={nan:"NaN",number:"antal",array:"lista"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${r.expected}, fick ${o}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${u}, fick ${o}`}case"invalid_value":return r.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${J(r.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`F\xF6r stor(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${u}${r.maximum.toString()} ${s.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${r.origin??"v\xE4rdet"} att ha ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`F\xF6r lite(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${u}${r.minimum.toString()} ${s.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${u.prefix}"`:u.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${u.suffix}"`:u.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${u.includes}"`:u.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${u.pattern}"`:`Ogiltig(t) ${n[u.format]??r.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${R(r.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${r.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${r.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function yB(){return{localeError:CB()}}var EB=()=>{let e={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},map:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function t(r){return e[r]??null}let n={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",mac:"MAC \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",credit_card:"\u0B95\u0B9F\u0BA9\u0BCD \u0B85\u0B9F\u0BCD\u0B9F\u0BC8 \u0B8E\u0BA3\u0BCD",currency_code:"\u0BA8\u0BBE\u0BA3\u0BAF\u0B95\u0BCD \u0B95\u0BC1\u0BB1\u0BBF\u0BAF\u0BC0\u0B9F\u0BC1",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${r.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${o}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${u}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${o}`}case"invalid_value":return r.values.length===1?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${J(r.values[0])}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${R(r.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${u}${r.maximum.toString()} ${s.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${u}${r.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin} ${u}${r.minimum.toString()} ${s.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin} ${u}${r.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${u.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:u.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${u.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:u.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${u.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:u.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${u.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${n[u.format]??r.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${r.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${r.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${R(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${r.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};function wB(){return{localeError:EB()}}var _B=()=>{let e={string:{unit:"\u0430\u043B\u043E\u043C\u0430\u0442",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},file:{unit:"\u0431\u0430\u0439\u0442",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},array:{unit:"\u0443\u043D\u0441\u0443\u0440",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},set:{unit:"\u0443\u043D\u0441\u0443\u0440",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},map:{unit:"\u0441\u0430\u0431\u0442",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0443\u0440\u0443\u0434",email:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 email",url:"URL",emoji:"\u044D\u043C\u043E\u04B7\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0441\u0430\u043D\u0430\u0432\u0443 \u0432\u0430\u049B\u0442\u0438 ISO",date:"\u0441\u0430\u043D\u0430\u0438 ISO",time:"\u0432\u0430\u049B\u0442\u0438 ISO",duration:"\u0434\u0430\u0432\u043E\u043C\u043D\u043E\u043A\u0438\u0438 ISO",ipv4:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 IPv4",ipv6:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 IPv6",mac:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 MAC",cidrv4:"\u043C\u0430\u04B3\u0434\u0443\u0434\u0430\u0438 IPv4",cidrv6:"\u043C\u0430\u04B3\u0434\u0443\u0434\u0430\u0438 IPv6",base64:"\u0441\u0430\u0442\u0440\u0438 \u0434\u0430\u0440 \u0444\u043E\u0440\u043C\u0430\u0442\u0438 base64",base64url:"\u0441\u0430\u0442\u0440\u0438 \u0434\u0430\u0440 \u0444\u043E\u0440\u043C\u0430\u0442\u0438 base64url",json_string:"\u0441\u0430\u0442\u0440\u0438 JSON",e164:"\u0440\u0430\u049B\u0430\u043C\u0438 E.164",credit_card:"\u0440\u0430\u049B\u0430\u043C\u0438 \u043A\u043E\u0440\u0442\u0438 \u043A\u0440\u0435\u0434\u0438\u0442\u04E3",currency_code:"\u0440\u0430\u043C\u0437\u0438 \u0430\u0441\u044A\u043E\u0440",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0443\u0440\u0443\u0434"},i={nan:"NaN",number:"\u0440\u0430\u049B\u0430\u043C",string:"\u0441\u0430\u0442\u0440",array:"\u043C\u0430\u0441\u0441\u0438\u0432",object:"\u043E\u0431\u044A\u0435\u043A\u0442",date:"\u0441\u0430\u043D\u0430"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return`\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: ${u} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442, ${o} \u0433\u0438\u0440\u0438\u0444\u0442\u0430 \u0448\u0443\u0434`}case"invalid_value":return r.values.length===1?`\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: ${J(r.values[0])} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`:`\u0418\u043D\u0442\u0438\u0445\u043E\u0431\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u044F\u043A\u0435 \u0430\u0437 ${R(r.values,"|")} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0425\u0435\u043B\u0435 \u043A\u0430\u043B\u043E\u043D: ${r.origin??"\u049B\u0438\u043C\u0430\u0442"} \u0431\u043E\u044F\u0434 ${u}${r.maximum.toString()} ${s.unit} ${s.verb}`:`\u0425\u0435\u043B\u0435 \u043A\u0430\u043B\u043E\u043D: ${r.origin??"\u049B\u0438\u043C\u0430\u0442"} \u0431\u043E\u044F\u0434 ${u}${r.maximum.toString()} \u0431\u043E\u0448\u0430\u0434`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u0425\u0435\u043B\u0435 \u0445\u0443\u0440\u0434: ${r.origin} \u0431\u043E\u044F\u0434 ${u}${r.minimum.toString()} ${s.unit} ${s.verb}`:`\u0425\u0435\u043B\u0435 \u0445\u0443\u0440\u0434: ${r.origin} \u0431\u043E\u044F\u0434 ${u}${r.minimum.toString()} \u0431\u043E\u0448\u0430\u0434`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u043E "${u.prefix}" \u043E\u0493\u043E\u0437 \u0448\u0430\u0432\u0430\u0434`:u.format==="ends_with"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u043E "${u.suffix}" \u0430\u043D\u04B7\u043E\u043C \u0451\u0431\u0430\u0434`:u.format==="includes"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 "${u.includes}"-\u0440\u043E \u0434\u0430\u0440 \u0431\u0430\u0440 \u0433\u0438\u0440\u0430\u0434`:u.format==="regex"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u0430 \u043D\u0430\u043C\u0443\u043D\u0430\u0438 ${u.pattern} \u043C\u0443\u0432\u043E\u0444\u0438\u049B\u0430\u0442 \u043A\u0443\u043D\u0430\u0434`:`${n[u.format]??r.format}-\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442`}case"not_multiple_of":return`\u0420\u0430\u049B\u0430\u043C\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u0430 ${r.divisor} \u0431\u0435 \u0431\u0430\u049B\u0438\u044F \u0442\u0430\u049B\u0441\u0438\u043C \u0448\u0430\u0432\u0430\u0434`;case"unrecognized_keys":return`\u041A\u0430\u043B\u0438\u0434${r.keys.length>1?"\u04B3\u043E\u0438":"\u0438"} \u043D\u043E\u043C\u0430\u044A\u043B\u0443\u043C: ${R(r.keys,", ")}`;case"invalid_key":return`\u041A\u0430\u043B\u0438\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442 \u0434\u0430\u0440 ${r.origin}`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u049A\u0438\u043C\u0430\u0442\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442\u0438 \u0434\u0438\u0441\u043A\u0440\u0438\u043C\u0438\u043D\u0430\u0442\u043E\u0440: ${r.options.map(s=>`'${s}'`).join(" | ")} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`:"\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442";case"invalid_element":return`\u049A\u0438\u043C\u0430\u0442\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442 \u0434\u0430\u0440 ${r.origin}`;default:return"\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442"}}};function AB(){return{localeError:_B()}}var bB=()=>{let e={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},map:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(r){return e[r]??null}let n={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",mac:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 MAC",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",credit_card:"\u0E2B\u0E21\u0E32\u0E22\u0E40\u0E25\u0E02\u0E1A\u0E31\u0E15\u0E23\u0E40\u0E04\u0E23\u0E14\u0E34\u0E15",currency_code:"\u0E23\u0E2B\u0E31\u0E2A\u0E2A\u0E01\u0E38\u0E25\u0E40\u0E07\u0E34\u0E19",iban:"IBAN",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},i={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${r.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${o}`:`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${u} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${o}`}case"invalid_value":return r.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${J(r.values[0])}`:`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",s=t(r.origin);return s?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${u} ${r.maximum.toString()} ${s.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${u} ${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",s=t(r.origin);return s?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${u} ${r.minimum.toString()} ${s.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${u} ${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${u.prefix}"`:u.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${u.suffix}"`:u.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${u.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:u.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${u.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${n[u.format]??r.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${r.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${R(r.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${r.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${r.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function SB(){return{localeError:bB()}}var DB=()=>{let e={string:{unit:"simwol",verb:"bolmaly"},file:{unit:"ba\xFDt",verb:"bolmaly"},array:{unit:"elementler",verb:"bolmaly"},set:{unit:"elementler",verb:"bolmaly"},map:{unit:"elementler",verb:"bolmaly"}};function t(r){return e[r]??null}let n={regex:"giri\u015F",email:"e-po\xE7ta salgysy",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sene we wagt",date:"ISO sene",time:"ISO wagt",duration:"ISO wagt aralygy",ipv4:"IPv4 salgysy",ipv6:"IPv6 salgysy",mac:"MAC salgysy",cidrv4:"IPv4 aralygy",cidrv6:"IPv6 aralygy",base64:"base64 bilen \u015Fifrlenen setir",base64url:"base64url bilen \u015Fifrlenen setir",json_string:"JSON setiri",e164:"E.164 nomeri",credit_card:"kredit kartyny\u0148 nomeri",currency_code:"wal\xFDuta kody",iban:"IBAN",jwt:"JWT",template_literal:"\u015Fablon"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return`N\xE4dogry baha: gara\u015Fylan ${u} \xFDerine ${o} alyndy`}case"invalid_value":return r.values.length===1?`N\xE4dogry baha: ${J(r.values[0])} bolmaly`:`N\xE4dogry sa\xFDlaw: a\u015Fakdakylardan biri bolmaly: ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Has uly: gara\u015Fyl\xFDan ${r.origin??"baha"} ${u} ${r.maximum.toString()} ${s.unit??"element"}`:`Has uly: gara\u015Fyl\xFDan ${r.origin??"baha"} ${u} ${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Has ki\xE7i: gara\u015Fyl\xFDan ${r.origin} ${u} ${r.minimum.toString()} ${s.unit}`:`Has ki\xE7i: gara\u015Fyl\xFDan ${r.origin} ${u} ${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`N\xE4dogry setir: "${u.prefix}" bilen ba\u015Flamaly`:u.format==="ends_with"?`N\xE4dogry setir: "${u.suffix}" bilen gutarmaly`:u.format==="includes"?`N\xE4dogry setir: "${u.includes}" saklamaly`:u.format==="regex"?`N\xE4dogry setir: ${u.pattern} nusga la\xFDyk bolmaly`:`N\xE4dogry ${n[u.format]??r.format}`}case"not_multiple_of":return`N\xE4dogry san: ${r.divisor} bilen galyndysyz b\xF6l\xFCnmeli`;case"unrecognized_keys":return`Tanalma\xFDan a\xE7ar${r.keys.length>1?"lar":""}: ${R(r.keys,", ")}`;case"invalid_key":return`${r.origin} i\xE7inde n\xE4dogry a\xE7ar`;case"invalid_union":return"N\xE4dogry baha";case"invalid_element":return`${r.origin} i\xE7inde n\xE4dogry baha`;default:return"N\xE4dogry baha"}}};function IB(){return{localeError:DB()}}var $B=()=>{let e={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},map:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(r){return e[r]??null}let n={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",mac:"MAC adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",credit_card:"kredi kart\u0131 numaras\u0131",currency_code:"para birimi kodu",iban:"IBAN",jwt:"JWT",template_literal:"\u015Eablon dizesi"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${r.expected}, al\u0131nan ${o}`:`Ge\xE7ersiz de\u011Fer: beklenen ${u}, al\u0131nan ${o}`}case"invalid_value":return r.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${J(r.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\xC7ok b\xFCy\xFCk: beklenen ${r.origin??"de\u011Fer"} ${u}${r.maximum.toString()} ${s.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${r.origin??"de\u011Fer"} ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\xC7ok k\xFC\xE7\xFCk: beklenen ${r.origin} ${u}${r.minimum.toString()} ${s.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${r.origin} ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Ge\xE7ersiz metin: "${u.prefix}" ile ba\u015Flamal\u0131`:u.format==="ends_with"?`Ge\xE7ersiz metin: "${u.suffix}" ile bitmeli`:u.format==="includes"?`Ge\xE7ersiz metin: "${u.includes}" i\xE7ermeli`:u.format==="regex"?`Ge\xE7ersiz metin: ${u.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${n[u.format]??r.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${r.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${r.keys.length>1?"lar":""}: ${R(r.keys,", ")}`;case"invalid_key":return`${r.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${r.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function BB(){return{localeError:$B()}}var kB=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},map:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",mac:"\u0430\u0434\u0440\u0435\u0441\u0430 MAC",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",credit_card:"\u043D\u043E\u043C\u0435\u0440 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u043E\u0457 \u043A\u0430\u0440\u0442\u043A\u0438",currency_code:"\u043A\u043E\u0434 \u0432\u0430\u043B\u044E\u0442\u0438",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${r.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${o}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${u}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${o}`}case"invalid_value":return r.values.length===1?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${J(r.values[0])}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${s.verb} ${u}${r.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin} ${s.verb} ${u}${r.minimum.toString()} ${s.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin} \u0431\u0443\u0434\u0435 ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${u.prefix}"`:u.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${u.suffix}"`:u.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${u.includes}"`:u.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${u.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${n[u.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${r.keys.length>1?"\u0456":""}: ${R(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${r.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};function D3(){return{localeError:kB()}}function xB(){return D3()}var TB=()=>{let e={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},map:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(r){return e[r]??null}let n={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",mac:"\u0627\u06CC\u0645 \u0627\u06D2 \u0633\u06CC \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",credit_card:"\u06A9\u0631\u06CC\u0688\u0679 \u06A9\u0627\u0631\u0688 \u0646\u0645\u0628\u0631",currency_code:"\u06A9\u0631\u0646\u0633\u06CC \u06A9\u0648\u0688",iban:"IBAN",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},i={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${r.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${o} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${u} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${o} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return r.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${J(r.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${R(r.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${r.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${u}${r.maximum.toString()} ${s.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${r.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${u}${r.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${r.origin} \u06A9\u06D2 ${u}${r.minimum.toString()} ${s.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${r.origin} \u06A9\u0627 ${u}${r.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${u.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:u.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${u.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:u.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${u.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:u.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${u.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${n[u.format]??r.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${r.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${r.keys.length>1?"\u0632":""}: ${R(r.keys,"\u060C ")}`;case"invalid_key":return`${r.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${r.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function FB(){return{localeError:TB()}}var PB=()=>{let e={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"},map:{unit:"yozuv",verb:"bo\u2018lishi kerak"}};function t(r){return e[r]??null}let n={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",credit_card:"kredit karta raqami",currency_code:"valyuta kodi",iban:"IBAN",jwt:"JWT",template_literal:"kirish"},i={nan:"NaN",number:"raqam",array:"massiv"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${r.expected}, qabul qilingan ${o}`:`Noto\u2018g\u2018ri kirish: kutilgan ${u}, qabul qilingan ${o}`}case"invalid_value":return r.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${J(r.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Juda katta: kutilgan ${r.origin??"qiymat"} ${u}${r.maximum.toString()} ${s.unit} ${s.verb}`:`Juda katta: kutilgan ${r.origin??"qiymat"} ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Juda kichik: kutilgan ${r.origin} ${u}${r.minimum.toString()} ${s.unit} ${s.verb}`:`Juda kichik: kutilgan ${r.origin} ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${u.prefix}" bilan boshlanishi kerak`:u.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${u.suffix}" bilan tugashi kerak`:u.format==="includes"?`Noto\u2018g\u2018ri satr: "${u.includes}" ni o\u2018z ichiga olishi kerak`:u.format==="regex"?`Noto\u2018g\u2018ri satr: ${u.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${n[u.format]??r.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${r.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${r.keys.length>1?"lar":""}: ${R(r.keys,", ")}`;case"invalid_key":return`${r.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${r.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};function RB(){return{localeError:PB()}}var zB=()=>{let e={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},map:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(r){return e[r]??null}let n={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",mac:"\u0111\u1ECBa ch\u1EC9 MAC",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",credit_card:"s\u1ED1 th\u1EBB t\xEDn d\u1EE5ng",currency_code:"m\xE3 ti\u1EC1n t\u1EC7",iban:"IBAN",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},i={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${r.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${o}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${u}, nh\u1EADn \u0111\u01B0\u1EE3c ${o}`}case"invalid_value":return r.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${J(r.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${r.origin??"gi\xE1 tr\u1ECB"} ${s.verb} ${u}${r.maximum.toString()} ${s.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${r.origin??"gi\xE1 tr\u1ECB"} ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${r.origin} ${s.verb} ${u}${r.minimum.toString()} ${s.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${r.origin} ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${u.prefix}"`:u.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${u.suffix}"`:u.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${u.includes}"`:u.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${u.pattern}`:`${n[u.format]??r.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${r.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${R(r.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${r.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${r.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function OB(){return{localeError:zB()}}var NB=()=>{let e={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"},map:{unit:"\u9879",verb:"\u5305\u542B"}};function t(r){return e[r]??null}let n={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",mac:"MAC\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",credit_card:"\u4FE1\u7528\u5361\u53F7",currency_code:"\u8D27\u5E01\u4EE3\u7801",iban:"IBAN",jwt:"JWT",template_literal:"\u8F93\u5165"},i={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${r.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${o}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${u}\uFF0C\u5B9E\u9645\u63A5\u6536 ${o}`}case"invalid_value":return r.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${J(r.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${r.origin??"\u503C"} ${u}${r.maximum.toString()} ${s.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${r.origin??"\u503C"} ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${r.origin} ${u}${r.minimum.toString()} ${s.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${r.origin} ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${u.prefix}" \u5F00\u5934`:u.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${u.suffix}" \u7ED3\u5C3E`:u.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${u.includes}"`:u.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${u.pattern}`:`\u65E0\u6548${n[u.format]??r.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${r.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${R(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${r.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function MB(){return{localeError:NB()}}var UB=()=>{let e={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},map:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(r){return e[r]??null}let n={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",mac:"MAC \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",credit_card:"\u4FE1\u7528\u5361\u865F",currency_code:"\u8CA8\u5E63\u4EE3\u78BC",iban:"IBAN",jwt:"JWT",template_literal:"\u8F38\u5165"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${r.expected}\uFF0C\u4F46\u6536\u5230 ${o}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${u}\uFF0C\u4F46\u6536\u5230 ${o}`}case"invalid_value":return r.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${J(r.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${r.origin??"\u503C"} \u61C9\u70BA ${u}${r.maximum.toString()} ${s.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${r.origin??"\u503C"} \u61C9\u70BA ${u}${r.maximum.toString()}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${r.origin} \u61C9\u70BA ${u}${r.minimum.toString()} ${s.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${r.origin} \u61C9\u70BA ${u}${r.minimum.toString()}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${u.prefix}" \u958B\u982D`:u.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${u.suffix}" \u7D50\u5C3E`:u.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${u.includes}"`:u.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${u.pattern}`:`\u7121\u6548\u7684 ${n[u.format]??r.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${r.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${r.keys.length>1?"\u5011":""}\uFF1A${R(r.keys,"\u3001")}`;case"invalid_key":return`${r.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${r.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function jB(){return{localeError:UB()}}var LB=()=>{let e={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"},map:{unit:"nkan",verb:"n\xED"}};function t(r){return e[r]??null}let n={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",mac:"\xE0d\xEDr\u1EB9\u0301s\xEC MAC",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",credit_card:"n\u1ECDmba kaadi gbese",currency_code:"koodu ow\xF3",iban:"IBAN",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},i={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return r=>{switch(r.code){case"invalid_type":{let u=i[r.expected]??r.expected,s=K(r.input),o=i[s]??s;return/^[A-Z]/.test(r.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${r.expected}, \xE0m\u1ECD\u0300 a r\xED ${o}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${u}, \xE0m\u1ECD\u0300 a r\xED ${o}`}case"invalid_value":return r.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${J(r.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${R(r.values,"|")}`;case"too_big":{let u=r.inclusive?"<=":"<",s=t(r.origin);return s?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${r.origin??"iye"} ${s.verb} ${u}${r.maximum} ${s.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${u}${r.maximum}`}case"too_small":{let u=r.inclusive?">=":">",s=t(r.origin);return s?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${r.origin} ${s.verb} ${u}${r.minimum} ${s.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${u}${r.minimum}`}case"invalid_format":{let u=r;return u.format==="starts_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${u.prefix}"`:u.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${u.suffix}"`:u.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${u.includes}"`:u.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${u.pattern}`:`A\u1E63\xEC\u1E63e: ${n[u.format]??r.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${r.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${R(r.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${r.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${r.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};function qB(){return{localeError:LB()}}var am,I3=Symbol("ZodOutput"),$3=Symbol("ZodInput"),B3=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Q0(){return new B3}(am=globalThis).__zod_globalRegistry??(am.__zod_globalRegistry=Q0());var Mt=globalThis.__zod_globalRegistry,_t=Symbol.for("zod.compile.invalid"),lm=Symbol.for("zod.compile.fallback"),Ln=class extends Error{constructor(e="z.compile does not support async refinements, transforms, or checks"){super(e),this.name="ZodCompileAsyncError"}},ge=class extends Error{constructor(e,t=!0){super(`z.compile does not support ${e}; this schema must use the runtime parser`),this.name="ZodCompileUnsupportedError",this.islandable=t}};function ZB(e,t){try{return ca(e,{assertOnly:!0})}catch{return t}}function k3(e,t){try{let n=ca(e),i=eh(e,n);return i._zod.bag.validator=ZB(e,n),i}catch(n){if(t?.strict)throw n;return e}}function eh(e,t){if(J0(e))throw new ge("a schema whose subtree contains a reference cycle");let n=je(e),i=e._zod.run,r=i.__originalRun??i,u=(s,o)=>{if(o?.async||o?.direction==="backward"||o?.skipChecks||o?.[lm]||o&&X0(o,s.value))return r(s,o);let a=t(s.value);return a!==_t?(s.value=a,s):(o&&(o[lm]=!0),r(s,o))};return u.__originalRun=r,n._zod.bag.fallbackRun=r,n._zod.bag.validator=t,n._zod.run=u,i.__originalRun||WB(n,e,t),n}function WB(e,t,n){let i=e,r=t;if(typeof r.safeParse=="function"){let u=r.safeParse;i.safeParse=(s,o)=>{let a=n(s);return a!==_t?{success:!0,data:a}:u(s,o)}}if(typeof r.parse=="function"){let u=r.parse;i.parse=(s,o)=>{let a=n(s);return a!==_t?a:u(s,o)}}}function ca(e,t){let n=!0;try{n=J0(e)}catch{}if(n)throw new ge("a schema whose subtree contains a reference cycle");let i={constants:new Map,constantCounter:0,varCounter:0,definite:!0},r=new I0(["input"]),u=Le(r,i,e,"input",!t?.assertOnly);r.write(u===null?"return true;":`return ${u};`);let s=["INVALID",...i.constants.keys()],o=[_t,...i.constants.values()],a=r.content.join(`
|
|
64
|
+
`),l=t?.debug?s.length>0?`// Constants: ${s.join(", ")}
|
|
65
|
+
${a}`:a:"",c=Function,m=`return (input) => {
|
|
66
|
+
${a}
|
|
67
|
+
}`,p;try{p=new c(...s,m)(...o)}catch(v){throw new ge(`this schema (generated code failed to evaluate: ${v.message})`)}return t?.debug&&(p.code=l),p.definite=i.definite,p}function ue(e,t){for(let[i,r]of e.constants)if(r===t)return i;let n=`c${e.constantCounter++}`;return e.constants.set(n,t),n}function Er(e,t){return e.definite=!1,ue(e,t)}function ee(e){return`v${e.varCounter++}`}function GB(e,t){let n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then=="function")return _t;let i=n;return i.issues.length===0?i.value:_t}function dt(e,t,n,i,r=!0){let u=e.content.length,s=t.constants.size,o=t.constantCounter,a=t.varCounter;try{return Le(e,t,n,i,r)}catch(l){if(!(l instanceof ge)||!l.islandable)throw l;if(e.content.length=u,t.constants.size>s){let c=Array.from(t.constants.keys()).slice(s);for(let m of c)t.constants.delete(m)}return t.constantCounter=o,t.varCounter=a,VB(e,t,n,i)}}function VB(e,t,n,i){t.definite=!1;let r=ue(t,n),u=ue(t,GB),s=ee(t);return e.write(`const ${s} = ${u}(${r}, ${i});`),e.write(`if (${s} === INVALID) return INVALID;`),s}var HB=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function JB(e,t,n,i){let r=n._zod.def.checks;if(!r||r.length===0)return i;let u=i;for(let s of r){let o=s._zod.def;if(o.when&&!HB.has(o.check))throw new ge('check with a custom "when" condition');switch(o.check){case"greater_than":KB(e,t,o,u);break;case"less_than":XB(e,t,o,u);break;case"multiple_of":YB(e,t,o,u);break;case"number_format":T3(e,o,u);break;case"min_length":{let a=Rn(o.minimum,"min_length"),l=zl(e,t,u,`${u}.length >= ${a} && ${u}.length < ${o.minimum*2}`);e.write(`if (${l} < ${a}) return INVALID;`);break}case"max_length":{let a=Rn(o.maximum,"max_length"),l=zl(e,t,u,`${u}.length > ${a}`);e.write(`if (${l} > ${a}) return INVALID;`);break}case"length_equals":{let a=Rn(o.length,"length_equals"),l=zl(e,t,u,`${u}.length >= ${a} && ${u}.length <= ${o.length*2}`);e.write(`if (${l} !== ${a}) return INVALID;`);break}case"min_size":e.write(`if (${u}.size < ${Rn(o.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${u}.size > ${Rn(o.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${u}.size !== ${Rn(o.size,"size_equals")}) return INVALID;`);break;case"string_format":u=F3(e,t,o,u);break;case"custom":u=ik(e,t,s,u);break;case"bigint_format":QB(e,o,u);break;case"mime_type":ek(e,t,o,u);break;case"property":nk(e,t,o,u);break;case"properties":tk(e,t,o,u);break;case"overwrite":{let a=ee(t);rk(e,t,s,u,a),u=a;break}default:throw new ge(`check type ${o.check}`)}}return u}function zl(e,t,n,i){let r=ue(t,_u),u=ee(t);return e.write(`const ${u} = typeof ${n} === "string" && ${i} ? ${r}(${n}) : ${n}.length;`),u}function Rn(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new ge(`${t} bound of type ${typeof e}`);return`${e}`}function x3(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new ge("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new ge("comparison check with Invalid Date bound");return ue(e,t)}throw new ge(`comparison check bound of type ${typeof t}`)}function KB(e,t,n,i){let r=n.inclusive?"<":"<=";e.write(`if (${i} ${r} ${x3(t,n.value)}) return INVALID;`)}function XB(e,t,n,i){let r=n.inclusive?">":">=";e.write(`if (${i} ${r} ${x3(t,n.value)}) return INVALID;`)}function YB(e,t,n,i){if(typeof n.value=="bigint"){if(n.value===BigInt(0))throw new ge("multiple_of check with a zero divisor");e.write(`if (${i} % ${n.value}n !== 0n) return INVALID;`)}else{let r=ue(t,e0);e.write(`if (${r}(${i}, ${Rn(n.value,"multiple_of")}) !== 0) return INVALID;`)}}function T3(e,t,n){let i=t.format;switch(i){case"safeint":e.write(`if (!Number.isSafeInteger(${n})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${n}) || ${n} < -2147483648 || ${n} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${n}) || ${n} < 0 || ${n} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${n}) || ${n} < -3.4028234663852886e38 || ${n} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${n})) return INVALID;`);break;default:throw new ge(`number format ${i}`)}}function QB(e,t,n){let i=t.format;if(i)switch(i){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break;default:throw new ge(`bigint format ${i}`)}}function ek(e,t,n,i){let r=n.mime;if(r&&r.length>0){let u=ue(t,new Set(r));e.write(`if (!${u}.has(${i}.type)) return INVALID;`)}}function tk(e,t,n,i){if(n.when)throw new ge('check with a custom "when" condition');e.write(`if (${i} == null) return INVALID;`);let r=n.shape;for(let u of Reflect.ownKeys(r)){let s=typeof u=="symbol"?ue(t,u):$t(u),o=ee(t);e.write(`const ${o} = ${i}[${s}];`),dt(e,t,r[u],o,!1)}}function nk(e,t,n,i){let r=`${i}[${JSON.stringify(n.property)}]`;Le(e,t,n.schema,r)}function rk(e,t,n,i,r){let u=n._zod.def.tx;if(!u)throw new ge("overwrite check without a transform function");if(wr(u))throw new Ln("z.compile: async overwrite transforms are not supported");let s=ue(t,u);e.write(`const ${r} = ${s}(${i});`)}function Fc(){throw new Cn}function th(e){this.issues.push(e)}function ik(e,t,n,i){let r=n._zod.def;if(r.fn){if(wr(r.fn))throw new Ln("z.compile: async .refine() predicates are not supported");let u=Er(t,r.fn),s=ue(t,Fc),o=ee(t);return e.write(`const ${o} = ${u}(${i});`),e.write(`if (${o} instanceof Promise) ${s}();`),e.write(`if (!${o}) return INVALID;`),i}if(n._zod.check){if(wr(n._zod.check))throw new Ln("z.compile: async .superRefine() / check functions are not supported");let u=n._zod.check,o=Er(t,l=>{let c={value:l,issues:[],addIssue:th};return u(c)instanceof Promise&&Fc(),c.issues.length===0?c.value:_t}),a=ee(t);return e.write(`const ${a} = ${o}(${i});`),e.write(`if (${a} === INVALID) return INVALID;`),a}throw new ge("custom check without a predicate or check function")}var uk=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function F3(e,t,n,i,r=!0){let u=n.format;if(u==="base64"){let l=ue(t,oa);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(u==="base64url"){let l=ue(t,z0);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(u==="jwt"){let l=ue(t,M0),c=ue(t,n.alg??null);return e.write(`if (!${l}(${i}, ${c})) return INVALID;`),i}if(u==="ipv6"){let l=ue(t,sa);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(u==="cidrv6"){let l=ue(t,P0);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(u==="credit_card"){let l=ue(t,O0);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(u==="iban"){let l=ue(t,N0);return e.write(`if (!${l}(${i})) return INVALID;`),i}let s=n;if(u==="url"||u==="httpurl"||s.normalize||s.hostname!==void 0||s.protocol!==void 0){let l=ue(t,x0),c=ue(t,n),m=ee(t),p=ee(t);if(e.write(`const ${m} = ${i}.trim();`),e.write(`const ${p} = ${l}(${m}, ${c});`),e.write(`if (typeof ${p} === "number") return INVALID;`),s.hostname!==void 0){let C=ue(t,T0);e.write(`if (!${C}(${p}, ${c}.hostname)) return INVALID;`)}if(s.protocol!==void 0){let C=ue(t,F0);e.write(`if (!${C}(${p}, ${c}.protocol)) return INVALID;`)}if(!r)return null;let v=ee(t),g=s.normalize?`${p}.href`:`${ue(t,fo)}(${m})`;return e.write(`const ${v} = ${g};`),v}let o=n.fn;if(o){if(wr(o))throw new ge(`async string format ${u}`);let l=ue(t,o);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(uk.has(u)&&n.pattern){let l=ue(t,n.pattern);return e.write(`${l}.lastIndex = 0;`),e.write(`if (!${l}.test(${i})) return INVALID;`),i}let a=n.format;switch(a){case"regex":throw new ge("regex format without a pattern");case"lowercase":e.write(`if (${i} !== ${i}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${i} !== ${i}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${i}.includes(${$t(n.includes)})) return INVALID;`);break;case"starts_with":{let l=n.prefix;e.write(`if (${i}.slice(0, ${l.length}) !== ${$t(l)}) return INVALID;`);break}case"ends_with":{let l=n.suffix;e.write(`if (${i}.slice(-${l.length}) !== ${$t(l)}) return INVALID;`);break}default:throw new ge(`string format ${a}`)}return i}function Le(e,t,n,i,r=!0){let u=n._zod.def,s=u.type;if(u.coerce)throw new ge(`coercion (z.coerce.${s}())`);let o=r||!!u.checks?.length,a;switch(s){case"string":a=sk(e,t,n,i,o);break;case"number":a=ok(e,n,i);break;case"boolean":a=ak(e,i);break;case"bigint":a=lk(e,n,i);break;case"symbol":a=ck(e,i);break;case"undefined":a=dk(e,i);break;case"null":a=hk(e,i);break;case"any":case"unknown":a=i;break;case"never":e.write("return INVALID;"),a=i;break;case"void":a=fk(e,i);break;case"nan":a=pk(e,i);break;case"date":a=mk(e,i);break;case"object":a=gk(e,t,n,i,o);break;case"optional":a=vk(e,t,n,i,o);break;case"nullable":a=Ek(e,t,n,i,o);break;case"array":a=wk(e,t,n,i,o);break;case"literal":a=_k(e,t,n,i);break;case"enum":a=Ak(e,t,n,i);break;case"readonly":{let l=dm(e,t,n,i),c=ee(t);e.write(`const ${c} = Object.freeze(${l});`),a=c;break}case"success":dm(e,t,n,i),a="true";break;case"default":case"prefault":a=bk(e,t,n,i);break;case"nonoptional":a=Sk(e,t,n,i);break;case"tuple":a=Dk(e,t,n,i);break;case"union":a=Ik(e,t,n,i);break;case"intersection":a=kk(e,t,n,i);break;case"record":a=xk(e,t,n,i);break;case"map":a=Fk(e,t,n,i);break;case"set":a=Pk(e,t,n,i);break;case"file":a=Rk(e,i);break;case"template_literal":a=zk(e,t,n,i);break;case"lazy":a=Ok(e,t,n,i);break;case"pipe":a=Nk(e,t,n,i);break;case"custom":a=Mk(e,t,n,i);break;case"transform":a=Lk(e,t,n,i);break;case"catch":a=jk(e,t,n,i);break;default:throw new ge(`schema type ${s}`)}return a===null?null:JB(e,t,n,a)}function sk(e,t,n,i,r=!0){e.write(`if (typeof ${i} !== "string") return INVALID;`);let u=n._zod.def;return u.format===void 0?i:F3(e,t,u,i,r)}function ok(e,t,n){e.write(`if (typeof ${n} !== "number" || !Number.isFinite(${n})) return INVALID;`);let i=t._zod.def;return i.check==="number_format"&&i.format&&T3(e,{format:i.format},n),n}function ak(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function lk(e,t,n){e.write(`if (typeof ${n} !== "bigint") return INVALID;`);let i=t._zod.def;if(i.format)switch(i.format){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break}return n}function ck(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function dk(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function hk(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function fk(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function pk(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function mk(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function gk(e,t,n,i,r=!0){let u=n._zod.def;e.write(`if (typeof ${i} !== "object" || ${i} === null || Array.isArray(${i})) return INVALID;`);let s=u.shape,o=Object.keys(s),a=Object.getOwnPropertySymbols(s),l=a.length?[...o,...a]:o,c=A=>typeof A=="symbol"?ue(t,A):$t(A),m=A=>typeof A=="symbol"?`[${c(A)}]`:$t(A),p=s;if(o.includes("__proto__"))throw new ge('object shape key "__proto__"');let v=new Map;for(let A of l){let S=p[A],z=c(A),M=ee(t);if(e.write(`const ${M} = ${i}[${z}];`),S._zod.optin!==void 0){let T=ee(t);e.write(`let ${T} = (() => {`),e.indented(G=>{let re=dt(G,t,S,M);G.write(`return ${re};`)}),e.write("})();"),S._zod.optout==="optional"?(e.write(`if (${T} === INVALID) {`),e.indented(G=>{G.write(`if (${z} in ${i}) return INVALID;`),G.write(`${T} = undefined;`)}),e.write("}")):e.write(`if (${T} === INVALID) return INVALID;`),v.set(A,T)}else{yk(S)&&e.write(`if (!(${z} in ${i})) return INVALID;`);let T=dt(e,t,S,M,r);T!==null&&v.set(A,T)}}let g=u.catchall,C="none";if(g){let A=g._zod.def.type;if(A==="never"){let S=o.map(z=>`k !== ${$t(z)}`).join(" && ")||"true";e.write(`for (const k in ${i}) {`),e.indented(z=>{z.write(`if (${S}) return INVALID;`)}),e.write("}")}else(A==="unknown"||A==="any")&&!g._zod.def.checks?.length?C="passthrough":C="schema"}let y=ee(t),b=l.some(A=>cm(p[A])||Pc(p[A]));if(!r){if(C==="schema"){let A=o.length>0?ue(t,new Set(o)):null;e.write(`for (const k in ${i}) {`),e.indented(S=>{S.write('if (k === "__proto__") continue;'),A&&S.write(`if (${A}.has(k)) continue;`);let z=ee(t);S.write(`const ${z} = ${i}[k];`),dt(S,t,g,z,!1)}),e.write("}")}return null}if(b){e.write(`const ${y} = {};`);for(let A of l){let S=c(A),z=v.get(A);Pc(p[A])?e.write(`if (${S} in ${i}) ${y}[${S}] = ${z};`):cm(p[A])?e.write(`if (${z} !== undefined || ${S} in ${i}) ${y}[${S}] = ${z};`):e.write(`${y}[${S}] = ${z};`)}}else{let A=l.map(S=>`${m(S)}: ${v.get(S)}`).join(", ");e.write(`const ${y} = { ${A} };`)}if(C!=="none"){let A=o.length>0?ue(t,new Set(o)):null;e.write(`for (const k in ${i}) {`),e.indented(S=>{if(S.write('if (k === "__proto__") continue;'),A&&S.write(`if (${A}.has(k)) continue;`),C==="passthrough")S.write(`${y}[k] = ${i}[k];`);else{let z=ee(t);S.write(`const ${z} = ${i}[k];`);let M=dt(S,t,g,z);S.write(`${y}[k] = ${M};`)}}),e.write("}")}return y}function vk(e,t,n,i,r=!0){let u=n._zod.def;if(Ck(n))return Le(e,t,u.innerType,i,r);if(u.innerType._zod.optin==="defaulted"){let o=ee(t),a=ee(t);return e.write(`let ${o};`),e.write(`if (${i} === undefined) {`),e.indented(l=>{l.write(`const ${a} = (() => {`),l.indented(c=>{let m=Le(c,t,u.innerType,i);c.write(`return ${m};`)}),l.write("})();"),l.write(`if (${a} !== INVALID) ${o} = ${a};`)}),e.write("} else {"),e.indented(l=>{let c=Le(l,t,u.innerType,i);l.write(`${o} = ${c};`)}),e.write("}"),o}let s=r?ee(t):null;return s&&e.write(`let ${s};`),e.write(`if (${i} !== undefined) {`),e.indented(o=>{let a=Le(o,t,u.innerType,i,r);s&&a!==null&&o.write(`${s} = ${a};`)}),e.write("}"),s}function Ck(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function yk(e){return e._zod.optin===void 0&&or(e)}function or(e){if(e._zod.def.coerce)return!0;let t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?or(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?or(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(or):!0;case"intersection":return!t.left||!t.right?!0:or(t.left)&&or(t.right);case"pipe":return t.in?or(t.in):!0;default:return!0}}function Pc(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function cm(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&Ur(e)}function Ur(e){let t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?Ur(t.innerType):!0;case"union":return t.options?t.options.some(Ur):!0;case"intersection":return!t.left||!t.right||Ur(t.left)||Ur(t.right);case"pipe":return t.out?Ur(t.out):!0;default:return!0}}function Ek(e,t,n,i,r=!0){let u=n._zod.def,s=r?ee(t):null;return s&&e.write(`let ${s} = null;`),e.write(`if (${i} !== null) {`),e.indented(o=>{let a=Le(o,t,u.innerType,i,r);s&&a!==null&&o.write(`${s} = ${a};`)}),e.write("}"),s}function nh(e,t,n){for(let[i,r]of oo(t._zod.def.checks))e.write(`if (${n} > ${Rn(i,r._zod.def.check)}) return INVALID;`)}function wk(e,t,n,i,r=!0){let u=n._zod.def;e.write(`if (!Array.isArray(${i})) return INVALID;`),nh(e,n,`${i}.length`);let s=r?ee(t):null,o=ee(t),a=ee(t);return s&&e.write(`const ${s} = new Array(${i}.length);`),e.write(`for (let ${o} = 0; ${o} < ${i}.length; ${o}++) {`),e.indented(l=>{l.write(`const ${a} = ${i}[${o}];`);let c=dt(l,t,u.element,a,r);s&&c!==null&&l.write(`${s}[${o}] = ${c};`)}),e.write("}"),s}function _k(e,t,n,i){let u=n._zod.def.values;if(u.length!==1){let o=ue(t,new Set(u));return e.write(`if (!${o}.has(${i})) return INVALID;`),i}let s=u[0];if(typeof s=="number"&&Number.isNaN(s)){let o=ue(t,new Set(u));return e.write(`if (!${o}.has(${i})) return INVALID;`),i}if(typeof s=="string")e.write(`if (${i} !== ${$t(s)}) return INVALID;`);else if(typeof s=="number"||typeof s=="boolean")e.write(`if (${i} !== ${s}) return INVALID;`);else if(s===null)e.write(`if (${i} !== null) return INVALID;`);else if(s===void 0)e.write(`if (${i} !== undefined) return INVALID;`);else if(typeof s=="bigint")e.write(`if (${i} !== ${s}n) return INVALID;`);else throw new ge(`literal type ${typeof s}`);return i}function Ak(e,t,n,i){let r=n._zod.values;if(!r)throw new ge("enum schema without enumerated values");let u=ue(t,r);return e.write(`if (!${u}.has(${i})) return INVALID;`),i}function dm(e,t,n,i){let r=n._zod.def;return Le(e,t,r.innerType,i)}function bk(e,t,n,i){let r=n._zod.def,s=Object.getOwnPropertyDescriptor(n._zod.def,"defaultValue")?()=>n._zod.def.defaultValue:void 0;if(n._zod.def.type==="prefault"){if(!s)return Le(e,t,r.innerType,i);let a=ue(t,s),l=ee(t);return e.write(`let ${l} = ${i};`),e.write(`if (${i} === undefined) ${l} = ${a}();`),Le(e,t,r.innerType,l)}let o=ee(t);if(s){let a=ue(t,s),l=ue(t,n0);e.write(`let ${o};`),e.write(`if (${i} === undefined) {`),e.indented(c=>{c.write(`${o} = ${l}(${a}());`)}),e.write("} else {"),e.indented(c=>{let m=Le(c,t,r.innerType,i);c.write(`${o} = ${m} === undefined ? ${l}(${a}()) : ${m};`)}),e.write("}")}else e.write(`let ${o};`),e.write(`if (${i} !== undefined) {`),e.indented(a=>{let l=Le(a,t,r.innerType,i);a.write(`${o} = ${l};`)}),e.write("}");return o}function Sk(e,t,n,i){let r=n._zod.def,u=Le(e,t,r.innerType,i),s=ee(t);return e.write(`const ${s} = ${u};`),e.write(`if (${s} === undefined) return INVALID;`),s}function Dk(e,t,n,i){let r=n._zod.def,u=r.items,s=r.rest;e.write(`if (!Array.isArray(${i})) return INVALID;`);let o=hm(u,"optin"),a=hm(u,"optout");s?e.write(`if (${i}.length < ${o}) return INVALID;`):e.write(`if (${i}.length < ${o} || ${i}.length > ${u.length}) return INVALID;`);let l=ee(t);e.write(`const ${l} = [];`);for(let c=0;c<u.length;c++){let m=u[c];if(c>=a)e.write(`if (${l}.length === ${c}) {`),e.indented(p=>{p.write(`if (${c} < ${i}.length) {`),p.indented(v=>{let g=ee(t);v.write(`const ${g} = ${i}[${c}];`);let C=dt(v,t,m,g);v.write(`${l}[${c}] = ${C};`)}),p.write("} else {"),p.indented(v=>{if(Pc(m)){v.write(`${l}.length = ${c};`);return}let g=ee(t),C=ee(t);v.write(`const ${g} = undefined;`),v.write(`const ${C} = (() => {`),v.indented(y=>{let b=dt(y,t,m,g);y.write(`return ${b};`)}),v.write("})();"),v.write(`if (${C} === INVALID || ${C} === undefined) ${l}.length = ${c};`),v.write(`else ${l}[${c}] = ${C};`)}),p.write("}")}),e.write("}");else{let p=ee(t);e.write(`const ${p} = ${i}[${c}];`);let v=dt(e,t,m,p);e.write(`${l}[${c}] = ${v};`)}}if(s){let c=ee(t),m=ee(t);e.write(`for (let ${c} = ${u.length}; ${c} < ${i}.length; ${c}++) {`),e.indented(p=>{p.write(`const ${m} = ${i}[${c}];`);let v=dt(p,t,s,m);p.write(`${l}[${c}] = ${v};`)}),e.write("}")}return l}function hm(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Ik(e,t,n,i){let r=n._zod.def,u=r.options;if(r.discriminator)return $k(e,t,r,i);if(r.inclusive===!1)throw new ge("exclusive unions (z.xor)");if(u.length===0)return e.write("return INVALID;"),i;if(u.length===1)return Le(e,t,u[0],i);if(u.every(a=>a._zod.def.type==="literal"&&!a._zod.def.checks?.length)){let a=new Set(u.flatMap(c=>c._zod.def.values)),l=ue(t,a);return e.write(`if (!${l}.has(${i})) return INVALID;`),i}let o=ee(t);e.write(`let ${o};`);for(let a=0;a<u.length;a++){let l=u[a];a===0?e.write(`${o} = (() => {`):e.write(`if (${o} === INVALID) ${o} = (() => {`),e.indented(c=>{let m=Le(c,t,l,i);c.write(`return ${m};`)}),e.write("})();")}return e.write(`if (${o} === INVALID) return INVALID;`),o}function $k(e,t,n,i){if(n.unionFallback)throw new ge("discriminated union with unionFallback");if(n.options.length===0)return e.write("return INVALID;"),i;let r=ee(t),u=ee(t);e.write(`const ${r} = ${i}?.[${$t(n.discriminator)}];`),e.write(`let ${u};`);let s=!0,o=new Set;for(let a of n.options){let l=a._zod.propValues?.[n.discriminator];if(!l||l.size===0)throw new ge("discriminated union option without static discriminator values");for(let p of l){if(o.has(p))throw new ge(`duplicate discriminator value ${String(p)}`);o.add(p)}let c=Array.from(l,p=>Bk(t,r,p)),m=s?"if":"else if";e.write(`${m} (${c.join(" || ")}) {`),e.indented(p=>{let v=Le(p,t,a,i);p.write(`${u} = ${v};`)}),e.write("}"),s=!1}return e.write("else { return INVALID; }"),u}function Bk(e,t,n){if(typeof n=="string")return`${t} === ${$t(n)}`;if(typeof n=="number")return Number.isNaN(n)?`Number.isNaN(${t})`:`${t} === ${n}`;if(typeof n=="boolean")return`${t} === ${n}`;if(n===null)return`${t} === null`;if(n===void 0)return`${t} === undefined`;if(typeof n=="bigint")return`${t} === ${n}n`;if(typeof n=="symbol"){let i=ue(e,n);return`${t} === ${i}`}throw new ge(`literal discriminator value ${String(n)}`)}function kk(e,t,n,i){let r=n._zod.def;t.definite=!1;let u=dt(e,t,r.left,i),s=dt(e,t,r.right,i),o=ue(t,su),a=ee(t);return e.write(`const ${a} = ${o}(${u}, ${s});`),e.write(`if (!${a}.valid) return INVALID;`),`${a}.data`}function xk(e,t,n,i){let r=n._zod.def,u=ue(t,_n);e.write(`if (!${u}(${i})) return INVALID;`);let s=ee(t),o=ee(t),a=ee(t);e.write(`const ${s} = {};`);let l=r,c=l.partial?void 0:r.keyType._zod.values;if(c){let v=[];for(let C of c){if(!(typeof C=="string"||typeof C=="number"||typeof C=="symbol"))throw new ge(`record key value ${String(C)}`);let y=typeof C=="number"?C.toString():C;if(y==="__proto__")throw new ge('record key "__proto__"');v.push(y);let b=ue(t,C),A=Le(e,t,r.keyType,b),S=ee(t);e.write(`const ${S} = ${i}[${Tk(t,y)}];`);let z=dt(e,t,r.valueType,S);e.write(`${s}[${A}] = ${z};`)}let g=ue(t,new Set(v));return e.write(`for (const ${o} in ${i}) {`),e.indented(C=>{C.write(`if (${g}.has(${o})) continue;`),l.mode==="loose"?C.write(`if (${o} !== "__proto__") ${s}[${o}] = ${i}[${o}];`):C.write("return INVALID;")}),e.write("}"),s}let m=r.keyType._zod.def;if(!(m.type==="string"&&m.format===void 0&&!m.coerce&&(m.checks?.length??0)===0)){let v=r.mode==="loose",g=ca(r.keyType);g.definite===!1&&(t.definite=!1);let C=ue(t,g),y=ue(t,Ei),b=ee(t);return fm(e,t,i,o,A=>{A.write(`let ${b} = ${C}(${o});`),A.write(`if (${b} === INVALID && typeof ${o} === "string" && ${y}.test(${o})) ${b} = ${C}(Number(${o}));`),v?A.write(`if (${b} === INVALID) { ${s}[${o}] = ${i}[${o}]; continue; }`):A.write(`if (${b} === INVALID) return INVALID;`),A.write(`if (${b} === "__proto__") continue;`);let S=ee(t);A.write(`const ${S} = ${i}[${o}];`);let z=dt(A,t,r.valueType,S);A.write(`${s}[${b}] = ${z};`)}),s}return fm(e,t,i,o,v=>{v.write(`const ${a} = ${i}[${o}];`);let g=dt(v,t,r.valueType,a);v.write(`${s}[${o}] = ${g};`)},"return INVALID;"),s}function fm(e,t,n,i,r,u){let s=ue(t,Object.prototype.propertyIsEnumerable),o=ee(t),a=ee(t),l=ee(t);e.write(`const ${o} = Object.getOwnPropertySymbols(${n});`),e.write(`const ${a} = Object.getOwnPropertyNames(${n});`),e.write(`for (let ${l} = 0; ${l} < ${a}.length; ${l}++) {`),e.indented(c=>{c.write(`const ${i} = ${a}[${l}];`),c.write(`if (${i} === "__proto__" || !${s}.call(${n}, ${i})) continue;`),r(c)}),e.write("}"),e.write(`for (let ${l} = 0; ${l} < ${o}.length; ${l}++) {`),e.indented(c=>{c.write(`const ${i} = ${o}[${l}];`),c.write(`if (!${s}.call(${n}, ${i})) continue;`),u?c.write(u):r(c)}),e.write("}")}function Tk(e,t){return typeof t=="string"?$t(t):ue(e,t)}function Fk(e,t,n,i){let r=n._zod.def;e.write(`if (!(${i} instanceof Map)) return INVALID;`),nh(e,n,`${i}.size`);let u=ee(t),s=ee(t),o=ee(t);return e.write(`const ${u} = new Map();`),e.write(`for (const [${s}, ${o}] of ${i}) {`),e.indented(a=>{let l=Le(a,t,r.keyType,s),c=Le(a,t,r.valueType,o);a.write(`${u}.set(${l}, ${c});`)}),e.write("}"),u}function Pk(e,t,n,i){let r=n._zod.def;e.write(`if (!(${i} instanceof Set)) return INVALID;`),nh(e,n,`${i}.size`);let u=ee(t),s=ee(t);return e.write(`const ${u} = new Set();`),e.write(`for (const ${s} of ${i}) {`),e.indented(o=>{let a=Le(o,t,r.valueType,s);o.write(`${u}.add(${a});`)}),e.write("}"),u}function Rk(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function zk(e,t,n,i){e.write(`if (typeof ${i} !== "string") return INVALID;`);let r=n._zod.pattern;if(r){let u=ue(t,r);e.write(`${u}.lastIndex = 0;`),e.write(`if (!${u}.test(${i})) return INVALID;`)}return i}function Ok(e,t,n,i){let r=n._zod.def,u=Er(t,r.getter),s=ue(t,{parser:null});e.write(`if (!${s}.parser) {`),e.indented(a=>{a.write(`const inner = ${u}();`),a.write(`${s}.parser = function(input) {`),a.indented(l=>{l.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),l.write("return result.issues.length === 0 ? result.value : INVALID;")}),a.write("};")}),e.write("}");let o=ee(t);return e.write(`const ${o} = ${s}.parser(${i});`),e.write(`if (${o} === INVALID) return INVALID;`),o}function Nk(e,t,n,i){let r=n._zod.def,u=Le(e,t,r.in,i);if(r.transform){if(wr(r.transform))throw new Ln("z.compile: async transforms in pipes are not supported");let s=r.transform,a=Er(t,c=>{let m={value:c,issues:[],addIssue:th},p=s(c,m);return p instanceof Promise?_t:m.issues.length===0?p:_t}),l=ee(t);return e.write(`const ${l} = ${a}(${u});`),e.write(`if (${l} === INVALID) return INVALID;`),Le(e,t,r.out,l)}else return Le(e,t,r.out,u)}function wr(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function Mk(e,t,n,i){let r=n._zod.def;if(r.fn){if(wr(r.fn))throw new Ln("z.compile: async custom predicates are not supported");let u=Er(t,r.fn),s=ue(t,Fc),o=ee(t);e.write(`const ${o} = ${u}(${i});`),e.write(`if (${o} instanceof Promise) ${s}();`),e.write(`if (!${o}) return INVALID;`)}else throw new ge("custom schema without a predicate function");return i}function Uk(e,t,n){let i=e._zod.run({value:n,issues:[]},{});if(i&&typeof i.then=="function")return _t;let r=i;return r.issues.length===0?r.value:t()}function jk(e,t,n,i){let r=n._zod.def;if(!r.catchValue[s0])throw new ge("catch with a callback (only a constant catch value compiles)",!1);let u=ee(t);e.write(`let ${u} = (() => {`),e.indented(l=>{let c=dt(l,t,r.innerType,i);l.write(`return ${c};`)}),e.write("})();");let s=ue(t,r.innerType),o=Er(t,r.catchValue),a=ue(t,Uk);return e.write(`if (${u} === INVALID) {`),e.indented(l=>{l.write(`${u} = ${a}(${s}, ${o}, ${i});`),l.write(`if (${u} === INVALID) return INVALID;`)}),e.write("}"),u}function Lk(e,t,n,i){let r=n._zod.def;if(r.transform){if(wr(r.transform))throw new Ln("z.compile: async transforms are not supported");let u=r.transform,o=Er(t,l=>{let c={value:l,issues:[],addIssue:th},m=u(l,c);return m instanceof Promise?_t:c.issues.length===0?m:_t}),a=ee(t);return e.write(`const ${a} = ${o}(${i});`),e.write(`if (${a} === INVALID) return INVALID;`),a}return i}function da(e){return e.checks&&(e.checks=[...e.checks]),e}function P3(e,t){return new e(da({type:"string",...L(t)}))}function R3(e,t){return new e(da({type:"string",coerce:!0,...L(t)}))}function rh(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...L(t)})}function ih(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...L(t)})}function uh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...L(t)})}function sh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...L(t)})}function oh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...L(t)})}function ah(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...L(t)})}function ha(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...L(t)})}function lh(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...L(t)})}function ch(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...L(t)})}function dh(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...L(t)})}function hh(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...L(t)})}function fh(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...L(t)})}function ph(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...L(t)})}function mh(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...L(t)})}function gh(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...L(t)})}function vh(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...L(t)})}function z3(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...L(t)})}function Ch(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...L(t)})}function yh(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...L(t)})}function Eh(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...L(t)})}function wh(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...L(t)})}function _h(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...L(t)})}function O3(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...L(t)})}function N3(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...L(t)})}function Ah(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...L(t)})}var M3={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function bh(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...L(t)})}function Sh(e,t){return new e({type:"string",format:"date",check:"string_format",...L(t)})}function Dh(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...L(t)})}function Ih(e,t){return new e({type:"string",format:"duration",check:"string_format",...L(t)})}function U3(e,t){return new e(da({type:"number",checks:[],...L(t)}))}function j3(e,t){return new e(da({type:"number",coerce:!0,checks:[],...L(t)}))}function L3(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...L(t)})}function q3(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...L(t)})}function Z3(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...L(t)})}function W3(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...L(t)})}function G3(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...L(t)})}function V3(e,t){return new e({type:"boolean",...L(t)})}function H3(e,t){return new e({type:"boolean",coerce:!0,...L(t)})}function J3(e,t){return new e({type:"bigint",...L(t)})}function K3(e,t){return new e({type:"bigint",coerce:!0,...L(t)})}function X3(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...L(t)})}function Y3(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...L(t)})}function Q3(e,t){return new e({type:"symbol",...L(t)})}function eE(e,t){return new e({type:"undefined",...L(t)})}function tE(e,t){return new e({type:"null",...L(t)})}function nE(e){return new e({type:"any"})}function rE(e){return new e({type:"unknown"})}function iE(e,t){return new e({type:"never",...L(t)})}function uE(e,t){return new e({type:"void",...L(t)})}function sE(e,t){return new e({type:"date",...L(t)})}function oE(e,t){return new e({type:"date",coerce:!0,...L(t)})}function aE(e,t){return new e({type:"nan",...L(t)})}function qn(e,t){return new S0({check:"less_than",...L(t),value:e,inclusive:!1})}function jt(e,t){return new S0({check:"less_than",...L(t),value:e,inclusive:!0})}function Zn(e,t){return new D0({check:"greater_than",...L(t),value:e,inclusive:!1})}function Lt(e,t){return new D0({check:"greater_than",...L(t),value:e,inclusive:!0})}function $h(e){return Zn(0,e)}function Bh(e){return qn(0,e)}function kh(e){return jt(0,e)}function xh(e){return Lt(0,e)}function ri(e,t){return new MC({check:"multiple_of",...L(t),value:e})}function wi(e,t){return new LC({check:"max_size",...L(t),maximum:e})}function Wn(e,t){return new qC({check:"min_size",...L(t),minimum:e})}function xu(e,t){return new ZC({check:"size_equals",...L(t),size:e})}function Tu(e,t){return new WC({check:"max_length",...L(t),maximum:e})}function _r(e,t){return new GC({check:"min_length",...L(t),minimum:e})}function Fu(e,t){return new VC({check:"length_equals",...L(t),length:e})}function fa(e,t){return new HC({check:"string_format",format:"regex",...L(t),pattern:e})}function pa(e){return new JC({check:"string_format",format:"lowercase",...L(e)})}function ma(e){return new KC({check:"string_format",format:"uppercase",...L(e)})}function ga(e,t){return new XC({check:"string_format",format:"includes",...L(t),includes:e})}function va(e,t){return new YC({check:"string_format",format:"starts_with",...L(t),prefix:e})}function Ca(e,t){return new QC({check:"string_format",format:"ends_with",...L(t),suffix:e})}function Th(e,t,n){return new ey({check:"property",property:e,schema:t,...L(n)})}function ya(e,t){return new ty({check:"properties",shape:e,...L(t)})}function Ea(e,t){return new ny({check:"mime_type",mime:e,...L(t)})}function Dn(e){return new ry({check:"overwrite",tx:e})}function wa(e){return Dn(t=>t.normalize(e))}function _a(){return Dn(e=>e.trim())}function Aa(){return Dn(e=>e.toLowerCase())}function ba(){return Dn(e=>e.toUpperCase())}function Sa(){return Dn(e=>Uv(e))}function lE(e,t,n){return new e({type:"array",element:t,...L(n)})}function qk(e,t,n){return new e({type:"union",options:t,...L(n)})}function Zk(e,t,n){return new e({type:"union",options:t,inclusive:!1,...L(n)})}function Wk(e,t,n,i){return new e({type:"union",options:n,discriminator:t,...L(i)})}function Gk(e,t,n){return new e({type:"intersection",left:t,right:n})}function Vk(e,t,n,i){let r=n instanceof le,u=r?i:n,s=r?n:null;return new e({type:"tuple",items:t,rest:s,...L(u)})}function Hk(e,t,n,i){return new e({type:"record",keyType:t,valueType:n,...L(i)})}function Jk(e,t,n,i){return new e({type:"map",keyType:t,valueType:n,...L(i)})}function Kk(e,t,n){return new e({type:"set",valueType:t,...L(n)})}function Xk(e,t,n){let i=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new e({type:"enum",entries:i,...L(n)})}function Yk(e,t,n){return new e({type:"enum",entries:t,...L(n)})}function Qk(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...L(n)})}function cE(e,t){return new e({type:"file",...L(t)})}function ex(e,t){return new e({type:"transform",transform:t})}function tx(e,t){return new e({type:"optional",innerType:t})}function nx(e,t){return new e({type:"nullable",innerType:t})}function rx(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():n0(n)}})}function ix(e,t,n){return new e({type:"nonoptional",innerType:t,...L(n)})}function ux(e,t){return new e({type:"success",innerType:t})}function sx(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:Jv(n)})}function ox(e,t,n){return new e({type:"pipe",in:t,out:n})}function ax(e,t){return new e({type:"readonly",innerType:t})}function lx(e,t,n){return new e({type:"template_literal",parts:t,...L(n)})}function cx(e,t){return new e({type:"lazy",getter:t})}function dx(e,t){return new e({type:"promise",innerType:t})}function dE(e,t,n){let i=L(n);return i.abort??(i.abort=!0),new e({type:"custom",check:"custom",fn:t,...i})}function hE(e,t,n){return new e({type:"custom",check:"custom",fn:t,...L(n)})}function fE(e,t){let n=pE(i=>(i.addIssue=r=>{if(typeof r=="string")i.issues.push(lo(r,i.value,n._zod.def));else{let u=r;u.fatal&&(u.continue=!1),u.code??(u.code="custom"),"input"in u||(u.input=i.value),u.inst??(u.inst=n),u.continue??(u.continue=!n._zod.def.abort),i.issues.push(lo(u))}},e(i.value,i)),t);return n}function pE(e,t){let n=new Re({check:"custom",...L(t)});return n._zod.check=e,n}function mE(e){let t=new Re({check:"describe"});return t._zod.onattach=[n=>{let i=Mt.get(n)??{};Mt.add(n,{...i,description:e})}],t._zod.check=()=>{},t}function gE(e){let t=new Re({check:"meta"});return t._zod.onattach=[n=>{let i=Mt.get(n)??{};Mt.add(n,{...i,...e})}],t._zod.check=()=>{},t}function vE(e,t){let n=L(t),i=n.truthy??["true","1","yes","on","y","enabled"],r=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(i=i.map(v=>typeof v=="string"?v.toLowerCase():v),r=r.map(v=>typeof v=="string"?v.toLowerCase():v));let u=new Set(i),s=new Set(r),o=e.Codec??V0,a=e.Boolean??j0,l=e.String??ku,c=new l({type:"string",error:n.error}),m=new a({type:"boolean",error:n.error}),p=new o({type:"pipe",in:c,out:m,transform:((v,g)=>{let C=v;return n.case!=="sensitive"&&(C=C.toLowerCase()),u.has(C)?!0:s.has(C)?!1:(g.issues.push({code:"invalid_value",expected:"stringbool",values:[...u,...s],input:g.value,inst:p,continue:!1}),{})}),reverseTransform:((v,g)=>v===!0?i[0]||"true":r[0]||"false"),error:n.error});return p._zod.bag.truthy=i,p._zod.bag.falsy=r,p._zod.bag.case=n.case??"insensitive",p}function _i(e,t,n,i={}){let r=L(i),u={check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:o=>n.test(o),...r};return n instanceof RegExp&&(u.pattern=n),new e(u)}function Ki(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,i)&&Tt(e,i,n[i]);return e}function ii(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Mt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function it(e,t,n,i,r){let u=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(u==="any")return!1;if(u===void 0||u==="throw")throw new Error(r);return Object.assign(n,u),!0}function Ee(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,u=t.seen.get(e);if(u)return u.count++,n.schemaPath.includes(e)&&(u.cycle=n.path),u.schema;let s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let o=e._zod.toJSONSchema?.();if(o)s.schema=o;else{let c={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,c);else{let p=s.schema,v=t.processors[r.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);v(e,t,p,c)}let m=e._zod.parent;m&&(s.ref||(s.ref=m),Ee(m,t,c),t.seen.get(m).isParent=!0)}let a=t.metadataRegistry.get(e);return a&&Ki(s.schema,a),t.io==="input"&&ft(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((i=s.schema).default??(i.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function pm(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ui(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let s of e.seen.entries()){let o=e.metadataRegistry.get(s[0])?.id;if(o){let a=i.get(o);if(a&&a!==s[0])throw new Error(`Duplicate schema id "${o}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(o,s[0])}}let r=s=>{let o=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let m=e.external.registry.get(s[0])?.id,p=e.external.uri??(g=>g);if(m)return{ref:p(m)};let v=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=v,{defId:v,ref:`${p("__shared")}#/${o}/${pm(v)}`}}let a="#",l=`${a}/${o}/`;if(s[1]===n&&!s[1].schema.id)return{ref:a};let c=s[1].schema.id??`__schema${e.counter++}`;return{defId:c,ref:l+pm(c)}},u=s=>{if(s[1].schema.$ref)return;let o=s[1],{ref:a,defId:l}=r(s);o.def={...o.schema},l&&(o.defId=l);let c=o.schema;for(let m in c)delete c[m];c.$ref=a};if(e.cycles==="throw")for(let s of e.seen.entries()){let o=s[1];if(o.cycle)throw new Error(`Cycle detected: #/${o.cycle?.join("/")}/<root>
|
|
68
|
+
|
|
69
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let o=s[1];if(t===s[0]){u(s);continue}if(e.external){let l=e.external.registry.get(s[0])?.id;if(t!==s[0]&&l){u(s);continue}}if(e.metadataRegistry.get(s[0])?.id){u(s);continue}if(o.cycle){u(s);continue}o.count>1&&e.reused==="ref"&&u(s)}e.external&&(e.sharedDefsExtractedFor=e.external)}function CE(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!="object")return;CE(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let u=i.type;for(let s of Array.isArray(u)?u:[u]){if(typeof s!="string")return;n.includes(s)||n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var yE=new Set(["type","properties","required","additionalProperties"]),mm=["oneOf","anyOf"];function gm(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Rc(e){let t=[];for(let u of e){if(typeof u!="object"||u.type!=="object")return null;for(let s in u)if(!yE.has(s))return null;t.push(u)}let n={},i=new Set;for(let u of t){for(let s in u.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;let o=[];for(let l of t){let c=l.properties?.[s]??gm(l);c!=null&&(o.some(m=>JSON.stringify(m)===JSON.stringify(c))||o.push(c))}let a=o.length===1?o[0]:Rc(o)??{allOf:o};Tt(n,s,a)}for(let s of u.required??[])i.add(s)}let r={type:"object",properties:n};if(i.size&&(r.required=[...i]),t.every(u=>u.additionalProperties===!1))r.additionalProperties=!1;else{let u=[];for(let s of t){let o=gm(s);o&&!u.some(a=>JSON.stringify(a)===JSON.stringify(o))&&u.push(o)}u.length===1?r.additionalProperties=u[0]:u.length>1&&(r.additionalProperties={allOf:u})}return r}function hx(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of yE)if(r in e)return;let n=t.filter(r=>mm.some(u=>Array.isArray(r[u]))),i=null;if(!n.length)i=Rc(t);else{let r=n[0],u=mm.find(a=>Array.isArray(r[a]));if(Object.keys(r).length!==1)return;let s=t.filter(a=>a!==r),o=r[u].map(a=>Rc([...s,a]));if(o.some(a=>!a))return;i={[u]:o}}i&&(delete e.allOf,Ki(e,i))}function si(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=o=>{let a=e.seen.get(o);if(a.ref===null)return;let l=a.def??a.schema,c={...l},m=a.ref;if(a.ref=null,m){i(m);let v=e.seen.get(m),g=v.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(g)):Ki(l,g),Ki(l,c),o._zod.parent===m)for(let y in l)y==="$ref"||y==="allOf"||y in c||delete l[y];if(g.$ref&&v.def)for(let y in l)y==="$ref"||y==="allOf"||y in v.def&&JSON.stringify(l[y])===JSON.stringify(v.def[y])&&delete l[y]}let p=o._zod.parent;if(p&&p!==m){i(p);let v=e.seen.get(p);if(v?.schema.$ref&&(l.$ref=v.schema.$ref,v.def))for(let g in l)g==="$ref"||g==="allOf"||g in v.def&&JSON.stringify(l[g])===JSON.stringify(v.def[g])&&delete l[g]}e.override({zodSchema:o,jsonSchema:l,path:a.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let o of[...e.seen.entries()].reverse())i(o[0]);if(e.target!=="openapi-3.0")for(let o of e.seen.entries())CE(o[1].def??o[1].schema);for(let o of e.deferred)o();if(e.intersections.length){let o=new Map;for(let a of e.seen.values())for(let l of[a.schema,a.def]){let c=l?.allOf;if(!Array.isArray(c))continue;let m=o.get(c);m?m.push(l):o.set(c,[l])}for(let a of e.intersections)for(let l of o.get(a)??[])hx(l)}}let r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let o=e.external.registry.get(t)?.id;if(!o)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(o)}Ki(r,n.defId?n.schema:n.def??n.schema);let u=e.metadataRegistry.get(t)?.id;u!==void 0&&r.id===u&&delete r.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let o of e.seen.entries()){let a=o[1];a.def&&a.defId&&(a.def.id===a.defId&&delete a.def.id,Tt(s,a.defId,a.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?r.$defs=s:r.definitions=s);try{let o=JSON.parse(JSON.stringify(r));return Object.defineProperty(o,"~standard",{value:{...t["~standard"],jsonSchema:{input:ou(t,"input",e.processors),output:ou(t,"output",e.processors)}},enumerable:!1,writable:!1}),o}catch{throw new Error("Error converting schema to JSON.")}}function ft(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return ft(i.element,n);if(i.type==="set")return ft(i.valueType,n);if(i.type==="lazy")return ft(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return ft(i.innerType,n);if(i.type==="intersection")return ft(i.left,n)||ft(i.right,n);if(i.type==="record"||i.type==="map")return ft(i.keyType,n)||ft(i.valueType,n);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ft(i.in,n)||ft(i.out,n);if(i.type==="object"){for(let r in i.shape)if(ft(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(ft(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(ft(r,n))return!0;return!!(i.rest&&ft(i.rest,n))}return!1}var EE=(e,t={})=>n=>{let i=ii({...n,processors:t});return Ee(e,i),ui(i,e),si(i,e)},ou=(e,t,n={})=>i=>{let{libraryOptions:r,target:u}=i??{},s=ii({...r??{},target:u,io:t,processors:n});return Ee(e,s),ui(s,e),si(s,e)},oi=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},ai=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},vm=(e,t)=>{oi(e,"minimum",t),ai(e,"maximum",t)},wE=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},_E=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},AE=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},bE=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Cm=(e,t)=>oi(e,"minimum",t.minimum),ym=(e,t)=>ai(e,"maximum",t.maximum),Em=e=>(t,n)=>{bE(t,n.format);let[i,r]=e[n.format];oi(t,"minimum",i),ai(t,"maximum",r)},fx={greater_than:(e,t)=>oi(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ai(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>wE(e,t.value),number_format:Em(r0),bigint_format:Em(i0),min_length:Cm,max_length:ym,length_equals:(e,t)=>vm(e,t.length),min_size:Cm,max_size:ym,size_equals:(e,t)=>vm(e,t.size),string_format:(e,t)=>{bE(e,t.format),t.pattern&&_E(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>AE(e,t.mime)};function rt(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let u of i)fx[u._zod.def.check]?.(t,u._zod.def);let r=e._zod.bag;r.minimum!==void 0&&oi(t,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&oi(t,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&ai(t,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&ai(t,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&wE(t,r.multipleOf),r.format!==void 0&&(t.format??(t.format=r.format),r.format.includes("int")&&(t.isInt=!0)),r.mime&&AE(t,r.mime);for(let u of r.patterns??[])_E(t,u);return t}var px={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},mx=new Map([[R0,EC],[aa,wC]]),SE=e=>mx.get(e)??e,DE=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:u,maximum:s,format:o,patterns:a,contentEncoding:l,laxFormat:c}=rt(e);if(typeof u=="number"&&(r.minLength=u),typeof s=="number"&&(r.maxLength=s),o&&(r.format=px[o]??o,r.format===""&&delete r.format,(o==="time"||c)&&delete r.format),l&&(r.contentEncoding=l),a&&a.size>0){let m=[...a].map(SE);m.length===1?r.pattern=m[0].source:m.length>1&&(r.allOf=[...m.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},IE=(e,t,n,i)=>{let r=n,{minimum:u,maximum:s,multipleOf:o,exclusiveMaximum:a,exclusiveMinimum:l,isInt:c}=rt(e);r.type=c?"integer":"number";let m=typeof l=="number"&&l>=(u??Number.NEGATIVE_INFINITY),p=typeof a=="number"&&a<=(s??Number.POSITIVE_INFINITY),v=t.target==="draft-04"||t.target==="openapi-3.0";if(m?v?(r.minimum=l,r.exclusiveMinimum=!0):r.exclusiveMinimum=l:typeof u=="number"&&(r.minimum=u),p?v?(r.maximum=a,r.exclusiveMaximum=!0):r.exclusiveMaximum=a:typeof s=="number"&&(r.maximum=s),o){let g=new Set;for(let b of o)Number.isFinite(b)&&b!==0?g.add(Math.abs(b)):it(e,t,r,i,`A multipleOf divisor of ${b} cannot be represented in JSON Schema`);let[C,...y]=g;C!==void 0&&(r.multipleOf=C),y.length&&(r.allOf=[...r.allOf??[],...y.map(b=>({multipleOf:b}))])}},$E=(e,t,n,i)=>{n.type="boolean"},BE=(e,t,n,i)=>{it(e,t,n,i,"BigInt cannot be represented in JSON Schema")},kE=(e,t,n,i)=>{it(e,t,n,i,"Symbols cannot be represented in JSON Schema")},xE=(e,t,n,i)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},TE=(e,t,n,i)=>{it(e,t,n,i,"Undefined cannot be represented in JSON Schema")},FE=(e,t,n,i)=>{it(e,t,n,i,"Void cannot be represented in JSON Schema")},PE=(e,t,n,i)=>{n.not={}},RE=(e,t,n,i)=>{},zE=(e,t,n,i)=>{},OE=(e,t,n,i)=>{it(e,t,n,i,"Date cannot be represented in JSON Schema")},NE=(e,t,n,i)=>{let r=e._zod.def,u=io(r.entries);if(u.length===0){n.not={};return}u.every(s=>typeof s=="number")&&(n.type="number"),u.every(s=>typeof s=="string")&&(n.type="string"),n.enum=u},ME=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let u=[];for(let s of r.values)if(s===void 0){if(it(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(it(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;u.push(Number(s))}else u.push(s);if(u.length!==0)if(u.length===1){let s=u[0];n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[s]:n.const=s}else u.every(s=>typeof s=="number")&&(n.type="number"),u.every(s=>typeof s=="string")&&(n.type="string"),u.every(s=>typeof s=="boolean")&&(n.type="boolean"),u.every(s=>s===null)&&(n.type="null"),n.enum=u},UE=(e,t,n,i)=>{it(e,t,n,i,"NaN cannot be represented in JSON Schema")},jE=(e,t,n,i)=>{let r=n,u=e._zod.pattern;if(!u)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=u.source},LE=(e,t,n,i)=>{let r=n;r.type="string",r.format="binary",r.contentEncoding="binary";let{minimum:u,maximum:s,mime:o}=rt(e);u!==void 0&&(r.minLength=u),s!==void 0&&(r.maxLength=s),o&&(o.length===0?r.not={}:o.length===1?r.contentMediaType=o[0]:r.anyOf=o.map(a=>({contentMediaType:a})))},qE=(e,t,n,i)=>{n.type="boolean"},ZE=(e,t,n,i)=>{it(e,t,n,i,"Custom types cannot be represented in JSON Schema")},WE=(e,t,n,i)=>{it(e,t,n,i,"Function types cannot be represented in JSON Schema")},GE=(e,t,n,i)=>{it(e,t,n,i,"Transforms cannot be represented in JSON Schema")},VE=(e,t,n,i)=>{it(e,t,n,i,"Map cannot be represented in JSON Schema")},HE=(e,t,n,i)=>{it(e,t,n,i,"Set cannot be represented in JSON Schema")},JE=(e,t,n,i)=>{let r=n,u=e._zod.def,{minimum:s,maximum:o}=rt(e);typeof s=="number"&&(r.minItems=s),typeof o=="number"&&(r.maxItems=o),r.type="array",r.items=Ee(u.element,t,{...i,path:[...i.path,"items"]})};function au(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?au(t.out):t.type==="catch"?au(t.innerType):e._zod.optin}var KE=(e,t,n,i)=>{let r=n,u=e._zod.def,s=u.shape;if(Object.getOwnPropertySymbols(s).length&&it(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in s)Tt(r.properties,l,Ee(s[l],t,{...i,path:[...i.path,"properties",l]}));let a=[];for(let l of Object.keys(s)){let c=u.shape[l];(t.io==="input"?au(c)===void 0:c._zod.optout===void 0)&&a.push(l)}a.length>0&&(r.required=a),u.catchall?._zod.def.type==="never"?r.additionalProperties=!1:u.catchall?u.catchall&&(r.additionalProperties=Ee(u.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},Fh=(e,t,n,i)=>{let r=e._zod.def,u=r.inclusive===!1,s=r.options.map((o,a)=>Ee(o,t,{...i,path:[...i.path,u?"oneOf":"anyOf",a]}));u?n.oneOf=s:n.anyOf=s},XE=(e,t,n,i)=>{let r=e._zod.def,u=Ee(r.left,t,{...i,path:[...i.path,"allOf",0]}),s=Ee(r.right,t,{...i,path:[...i.path,"allOf",1]}),o=l=>"allOf"in l&&Object.keys(l).length===1,a=[...o(u)?u.allOf:[u],...o(s)?s.allOf:[s]];n.allOf=a,t.intersections.push(a)},YE=(e,t,n,i)=>{let r=n,u=e._zod.def;r.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",o=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",a=u.items.map((C,y)=>Ee(C,t,{...i,path:[...i.path,s,y]})),l=u.rest?Ee(u.rest,t,{...i,path:[...i.path,o,...t.target==="openapi-3.0"?[u.items.length]:[]]}):null,c=u.items.length;for(;c>0;){let C=u.items[c-1];if(!(t.io==="input"?au(C)!==void 0:C._zod.optout==="optional"))break;c--}let m=u.items.length,p=!u.rest;t.target==="draft-2020-12"?(r.prefixItems=a,p?r.items=!1:l&&(r.items=l),c>0&&(r.minItems=c),p&&(r.maxItems=m)):t.target==="openapi-3.0"?(r.items={anyOf:a},l&&r.items.anyOf.push(l),c>0&&(r.minItems=c),p&&(r.maxItems=m)):(r.items=a,p?r.additionalItems=!1:l&&(r.additionalItems=l),c>0&&(r.minItems=c),p&&(r.maxItems=m));let{minimum:v,maximum:g}=rt(e);typeof v=="number"&&(r.minItems=v),typeof g=="number"&&(r.maxItems=g)};function zc(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let C=zc(e,g,n);return C===g?t:C}for(let g of["anyOf","oneOf"]){let C=t[g];if(!Array.isArray(C))continue;let y=C.map(b=>zc(e,b,n));y.some((b,A)=>b!==C[A])&&(t={...t,[g]:y})}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some(g=>g==="number"||g==="integer"),u=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!u?.some(g=>typeof g=="number"))return t;let{minimum:s,maximum:o,exclusiveMinimum:a,exclusiveMaximum:l,multipleOf:c,format:m,id:p,...v}=t;return v.enum?v.enum=v.enum.map(g=>typeof g=="number"?String(g):g):typeof v.const=="number"&&(v.const=String(v.const)),r&&(v.type="string",u||(v.pattern=(i.includes("number")?Ei:_0).source)),v}var Oc=new WeakMap;function gx(e){let t=new Map;for(let i of e.seen.values())i.def&&!t.has(i.schema)&&t.set(i.schema,i);let n=new Map;for(let i of Oc.get(e)??[]){let r=e.seen.get(i),u=(r?.def??r?.schema)?.propertyNames;if(!u||u===!0||n.has(u))continue;let s=zc(t,u,new Set);s!==u&&n.set(u,s)}if(n.size)for(let i of e.seen.values())for(let r of[i.schema,i.def]){let u=r&&n.get(r.propertyNames);u&&(r.propertyNames=u)}}var QE=(e,t,n,i)=>{let r=n,u=e._zod.def;r.type="object";let s=u.keyType,o=rt(s).patterns;if(u.mode==="loose"&&o&&o.size>0){let c=Ee(u.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let m of o)Tt(r.patternProperties,SE(m).source,c)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=Ee(u.keyType,t,{...i,path:[...i.path,"propertyNames"]});let c=Oc.get(t);c||(c=[],Oc.set(t,c),t.deferred.push(()=>gx(t))),c.push(e)}r.additionalProperties=Ee(u.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let a=s._zod.values,l=t.io==="input"&&au(u.valueType)!==void 0;if(a&&!u.partial&&!l){let c=[...a].filter(m=>typeof m=="string"||typeof m=="number");c.length>0&&(r.required=c.map(String))}},ew=(e,t,n,i)=>{let r=e._zod.def,u=Ee(r.innerType,t,i),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=r.innerType,n.nullable=!0):n.anyOf=[u,{type:"null"}]},tw=(e,t,n,i)=>{let r=e._zod.def;Ee(r.innerType,t,i);let u=t.seen.get(e);u.ref=r.innerType},Ph=Symbol();function nw(e,t,n,i,r){let u=!1,s=JSON.stringify(e,(o,a)=>typeof a!="bigint"?a:(u=!0,null));return u?(it(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),Ph):JSON.parse(s)}var rw=(e,t,n,i)=>{let r=e._zod.def;Ee(r.innerType,t,i);let u=t.seen.get(e);u.ref=r.innerType;let s=nw(r.defaultValue,e,t,n,i);s!==Ph&&(n.default=s)},iw=(e,t,n,i)=>{let r=e._zod.def;Ee(r.innerType,t,i);let u=t.seen.get(e);if(u.ref=r.innerType,t.io!=="input")return;let s=nw(r.defaultValue,e,t,n,i);s!==Ph&&(n._prefault=s)},uw=(e,t,n,i)=>{let r=e._zod.def;Ee(r.innerType,t,i);let u=t.seen.get(e);u.ref=r.innerType;let s;try{s=r.catchValue(void 0)}catch{it(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},sw=(e,t,n,i)=>{let r=e._zod.def,u=r.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?u?r.out:r.in:r.out;Ee(s,t,i);let o=t.seen.get(e);o.ref=s},ow=(e,t,n,i)=>{let r=e._zod.def;Ee(r.innerType,t,i);let u=t.seen.get(e);u.ref=r.innerType,n.readOnly=!0},aw=(e,t,n,i)=>{let r=e._zod.def;Ee(r.innerType,t,i);let u=t.seen.get(e);u.ref=r.innerType},Rh=(e,t,n,i)=>{let r=e._zod.def;Ee(r.innerType,t,i);let u=t.seen.get(e);u.ref=r.innerType},lw=(e,t,n,i)=>{let r=e._zod.innerType;Ee(r,t,i);let u=t.seen.get(e);u.ref=r},Nc={string:DE,number:IE,boolean:$E,bigint:BE,symbol:kE,null:xE,undefined:TE,void:FE,never:PE,any:RE,unknown:zE,date:OE,enum:NE,literal:ME,nan:UE,template_literal:jE,file:LE,success:qE,custom:ZE,function:WE,transform:GE,map:VE,set:HE,array:JE,object:KE,union:Fh,intersection:XE,tuple:YE,record:QE,nullable:ew,nonoptional:tw,default:rw,prefault:iw,catch:uw,pipe:sw,readonly:ow,promise:aw,optional:Rh,lazy:lw};function cw(e,t){if("_idmap"in e){let i=e,r=ii({...t,processors:Nc}),u={};for(let a of i._idmap.entries()){let[l,c]=a;Ee(c,r)}let s={},o={registry:i,uri:t?.uri,defs:u};r.external=o;for(let a of i._idmap.entries()){let[l,c]=a;ui(r,c),Tt(s,l,si(r,c))}if(Object.keys(u).length>0){let a=r.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[a]:u}}return{schemas:s}}let n=ii({...t,processors:Nc});return Ee(e,n),ui(n,e),si(n,e)}var vx=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(e){this.ctx.counter=e}get seen(){return this.ctx.seen}constructor(e){let t=e?.target??"draft-2020-12";t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),this.ctx=ii({processors:Nc,target:t,...e?.metadata&&{metadata:e.metadata},...e?.unrepresentable&&{unrepresentable:e.unrepresentable},...e?.override&&{override:e.override},...e?.io&&{io:e.io}})}process(e,t={path:[],schemaPath:[]}){return Ee(e,this.ctx,t)}emit(e,t){t&&(t.cycles&&(this.ctx.cycles=t.cycles),t.reused&&(this.ctx.reused=t.reused),t.external&&(this.ctx.external=t.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,ui(this.ctx,e);let n=si(this.ctx,e),{"~standard":i,...r}=n;return r}},Cx={},dw={};bn(dw,{ZodAny:()=>Lh,ZodArray:()=>Gh,ZodBase64:()=>Ua,ZodBase64URL:()=>ja,ZodBigInt:()=>Lu,ZodBigIntFormat:()=>Za,ZodBoolean:()=>ju,ZodCIDRv4:()=>Na,ZodCIDRv6:()=>Ma,ZodCUID:()=>xa,ZodCUID2:()=>Ta,ZodCatch:()=>hf,ZodCodec:()=>Vu,ZodCreditCard:()=>Oh,ZodCustom:()=>Hu,ZodCustomStringFormat:()=>Ir,ZodDate:()=>Ga,ZodDefault:()=>sf,ZodDiscriminatedUnion:()=>Hh,ZodE164:()=>La,ZodEmail:()=>Ia,ZodEmoji:()=>Ba,ZodEnum:()=>ci,ZodExactOptional:()=>Ka,ZodFile:()=>tf,ZodFunction:()=>_f,ZodGUID:()=>$a,ZodIBAN:()=>Nh,ZodIPv4:()=>za,ZodIPv6:()=>Oa,ZodISODate:()=>zu,ZodISODateTime:()=>Ru,ZodISODuration:()=>Nu,ZodISOTime:()=>Ou,ZodInstanceOf:()=>Sf,ZodIntersection:()=>Jh,ZodJWT:()=>qa,ZodKSUID:()=>Ra,ZodLazy:()=>yf,ZodLiteral:()=>ef,ZodMAC:()=>zh,ZodMap:()=>Yh,ZodNaN:()=>pf,ZodNanoID:()=>ka,ZodNever:()=>Zh,ZodNonOptional:()=>Xa,ZodNull:()=>jh,ZodNullable:()=>uf,ZodNumber:()=>Uu,ZodNumberFormat:()=>$r,ZodObject:()=>qu,ZodOptional:()=>Wu,ZodPipe:()=>Gu,ZodPrefault:()=>af,ZodPreprocess:()=>mf,ZodPromise:()=>wf,ZodReadonly:()=>gf,ZodRecord:()=>li,ZodSet:()=>Qh,ZodString:()=>Pu,ZodStringFormat:()=>Ae,ZodSuccess:()=>df,ZodSymbol:()=>Mh,ZodTemplateLiteral:()=>Cf,ZodTransform:()=>nf,ZodTuple:()=>Kh,ZodType:()=>ce,ZodULID:()=>Fa,ZodURL:()=>Mu,ZodUUID:()=>sn,ZodUndefined:()=>Uh,ZodUnion:()=>Zu,ZodUnknown:()=>qh,ZodVoid:()=>Wh,ZodXID:()=>Pa,ZodXor:()=>Vh,_ZodString:()=>Da,_default:()=>of,_function:()=>go,any:()=>d1,array:()=>Y,base64:()=>Ww,base64url:()=>Gw,bigint:()=>s1,boolean:()=>ke,catch:()=>ff,check:()=>x1,cidrv4:()=>qw,cidrv6:()=>Zw,codec:()=>I1,creditCard:()=>Hw,cuid:()=>Rw,cuid2:()=>zw,currencyCode:()=>e1,custom:()=>T1,date:()=>f1,describe:()=>F1,discriminatedUnion:()=>v1,e164:()=>Vw,email:()=>Dw,emoji:()=>Fw,enum:()=>Ha,exactOptional:()=>rf,file:()=>A1,float32:()=>n1,float64:()=>r1,function:()=>go,guid:()=>Iw,hash:()=>t1,hex:()=>Qw,hostname:()=>Yw,httpUrl:()=>Tw,iban:()=>Jw,instanceof:()=>R1,int:()=>Ke,int32:()=>i1,int64:()=>o1,intersection:()=>Xe,invertCodec:()=>$1,ipv4:()=>Uw,ipv6:()=>Lw,json:()=>O1,jwt:()=>Kw,keyof:()=>p1,ksuid:()=>Mw,lazy:()=>Ef,literal:()=>E,looseObject:()=>Va,looseRecord:()=>y1,mac:()=>jw,map:()=>E1,meta:()=>P1,nan:()=>D1,nanoid:()=>Pw,nativeEnum:()=>_1,never:()=>Wa,nonoptional:()=>cf,null:()=>Br,nullable:()=>lu,nullish:()=>b1,number:()=>se,object:()=>d,optional:()=>di,partialRecord:()=>C1,pipe:()=>mo,prefault:()=>lf,preprocess:()=>Df,promise:()=>k1,readonly:()=>vf,record:()=>_,refine:()=>Af,set:()=>w1,strictObject:()=>m1,string:()=>h,stringFormat:()=>Xw,stringbool:()=>z1,success:()=>S1,superRefine:()=>bf,symbol:()=>l1,templateLiteral:()=>B1,transform:()=>Ja,tuple:()=>Xh,uint32:()=>u1,uint64:()=>a1,ulid:()=>Ow,undefined:()=>c1,union:()=>U,unknown:()=>w,url:()=>Rt,uuid:()=>$w,uuidv4:()=>Bw,uuidv6:()=>kw,uuidv7:()=>xw,void:()=>h1,xid:()=>Nw,xor:()=>g1});var hw={};bn(hw,{endsWith:()=>Ca,gt:()=>Zn,gte:()=>Lt,includes:()=>ga,length:()=>Fu,lowercase:()=>pa,lt:()=>qn,lte:()=>jt,maxLength:()=>Tu,maxSize:()=>wi,mime:()=>Ea,minLength:()=>_r,minSize:()=>Wn,multipleOf:()=>ri,negative:()=>Bh,nonnegative:()=>xh,nonpositive:()=>kh,normalize:()=>wa,overwrite:()=>Dn,positive:()=>$h,properties:()=>ya,property:()=>Th,regex:()=>fa,size:()=>xu,slugify:()=>Sa,startsWith:()=>va,toLowerCase:()=>Aa,toUpperCase:()=>ba,trim:()=>_a,uppercase:()=>ma});var wm=new WeakSet([Object.prototype,Error.prototype]);function vs(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var fw=(e,t)=>{Yv.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);wm.has(n)||(wm.add(n),vs(n,"format",i=>r=>a0(i,r)),vs(n,"flatten",i=>r=>o0(i,r)),vs(n,"addIssue",i=>r=>{i.issues.push(r),i.message=JSON.stringify(i.issues,uo,2)}),vs(n,"addIssues",i=>r=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,uo,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},yx=B("ZodError",fw),Pt=B("ZodError",fw,void 0,{Parent:Error}),pw=Au(Pt),mw=bu(Pt),gw=Su(Pt),vw=Du(Pt),Cw=d0(Pt),yw=h0(Pt),Ew=f0(Pt),ww=p0(Pt),_w=m0(Pt),Aw=g0(Pt),bw=v0(Pt),Sw=C0(Pt);function Ex(){gt.localeError||at(b3())}function Dr(){gt.memoizer||at({memoizer:K0()})}var ce=B("ZodType",(e,t)=>(Ex(),le.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ne.mergeDefs(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return je(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Af(e,t))},superRefine(e,t){return this.check(bf(e,t))},overwrite(e){return this.check(Dn(e))},optional(){return di(this)},exactOptional(){return rf(this)},nullable(){return lu(this)},nullish(){return di(lu(this))},nonoptional(e){return cf(this,e)},array(){return Y(this)},or(e){return U([this,e])},and(e){return Xe(this,e)},transform(e){return mo(this,Ja(e))},default(e){return of(this,e)},prefault(e){return lf(this,e)},catch(e){return ff(this,e)},pipe(e){return mo(this,e)},readonly(){return vf(this)},describe(e){let t=this.clone();return Mt.add(t,{description:e}),t},meta(...e){if(e.length===0)return Mt.get(this);let t=this.clone();return Mt.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return ne.hide(this,"~standard",{...$0(this),jsonSchema:{input:ou(this,"input"),output:ou(this,"output")}})},set"~standard"(e){ne.own(this,"~standard",e)},parse:function e(t,n){return pw(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await mw(this,t,n,{callee:e})},safeParse(e,t){return gw(this,e,t)},async safeParseAsync(e,t){return vw(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){ne.own(this,"spa",e)},validate(e,t){return l0(this,e,t)},validateAsync(e,t){return c0(this,e,t)},encode:function e(t,n){return Cw(this,t,n,{callee:e})},decode:function e(t,n){return yw(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Ew(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await ww(this,t,n,{callee:e})},safeEncode(e,t){return _w(this,e,t)},safeDecode(e,t){return Aw(this,e,t)},async safeEncodeAsync(e,t){return bw(this,e,t)},async safeDecodeAsync(e,t){return Sw(this,e,t)},toJSONSchema(e){return EE(this,{})(e)},get description(){return Mt.get(this)?.description},get _def(){return this._zod.def}}),Da=B("_ZodString",(e,t)=>{ku.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>DE(e,n,i,r)},ne.derived({format:e=>rt(e).format??null,minLength:e=>rt(e).minimum??null,maxLength:e=>rt(e).maximum??null},{regex(...e){return this.check(fa(...e))},includes(...e){return this.check(ga(...e))},startsWith(...e){return this.check(va(...e))},endsWith(...e){return this.check(Ca(...e))},min(...e){return this.check(_r(...e))},max(...e){return this.check(Tu(...e))},length(...e){return this.check(Fu(...e))},nonempty(...e){return this.check(_r(1,...e))},lowercase(e){return this.check(pa(e))},uppercase(e){return this.check(ma(e))},trim(){return this.check(_a())},normalize(...e){return this.check(wa(...e))},toLowerCase(){return this.check(Aa())},toUpperCase(){return this.check(ba())},slugify(){return this.check(Sa())}})),Pu=B("ZodString",(e,t)=>{ku.init(e,t),Da.init(e,t)},{email(e){return this.check(rh(Ia,e))},url(e){return this.check(ha(Mu,e))},jwt(e){return this.check(Ah(qa,e))},emoji(e){return this.check(lh(Ba,e))},guid(e){return this.check(ih($a,e))},uuid(e){return this.check(uh(sn,e))},uuidv4(e){return this.check(sh(sn,e))},uuidv6(e){return this.check(oh(sn,e))},uuidv7(e){return this.check(ah(sn,e))},nanoid(e){return this.check(ch(ka,e))},cuid(e){return this.check(dh(xa,e))},cuid2(e){return this.check(hh(Ta,e))},ulid(e){return this.check(fh(Fa,e))},base64(e){return this.check(Eh(Ua,e))},base64url(e){return this.check(wh(ja,e))},xid(e){return this.check(ph(Pa,e))},ksuid(e){return this.check(mh(Ra,e))},ipv4(e){return this.check(gh(za,e))},ipv6(e){return this.check(vh(Oa,e))},cidrv4(e){return this.check(Ch(Na,e))},cidrv6(e){return this.check(yh(Ma,e))},e164(e){return this.check(_h(La,e))},datetime(e){return this.check(bh(Ru,e))},date(e){return this.check(Sh(zu,e))},time(e){return this.check(Dh(Ou,e))},duration(e){return this.check(Ih(Nu,e))}});function h(e){return P3(Pu,e)}var Ae=B("ZodStringFormat",(e,t)=>{_e.init(e,t),Da.init(e,t)}),Ru=B("ZodISODateTime",(e,t)=>{Cy.init(e,t),Ae.init(e,t)}),zu=B("ZodISODate",(e,t)=>{yy.init(e,t),Ae.init(e,t)}),Ou=B("ZodISOTime",(e,t)=>{Ey.init(e,t),Ae.init(e,t)}),Nu=B("ZodISODuration",(e,t)=>{wy.init(e,t),Ae.init(e,t)}),Ia=B("ZodEmail",(e,t)=>{ay.init(e,t),Ae.init(e,t)});function Dw(e){return rh(Ia,e)}var $a=B("ZodGUID",(e,t)=>{sy.init(e,t),Ae.init(e,t)});function Iw(e){return ih($a,e)}var sn=B("ZodUUID",(e,t)=>{oy.init(e,t),Ae.init(e,t)});function $w(e){return uh(sn,e)}function Bw(e){return sh(sn,e)}function kw(e){return oh(sn,e)}function xw(e){return ah(sn,e)}var Mu=B("ZodURL",(e,t)=>{cy.init(e,t),Ae.init(e,t)});function Rt(e){return ha(Mu,e)}function Tw(e){return ha(Mu,{protocol:y0,hostname:AC,...ne.normalizeParams(e)})}var Ba=B("ZodEmoji",(e,t)=>{dy.init(e,t),Ae.init(e,t)});function Fw(e){return lh(Ba,e)}var ka=B("ZodNanoID",(e,t)=>{hy.init(e,t),Ae.init(e,t)});function Pw(e){return ch(ka,e)}var xa=B("ZodCUID",(e,t)=>{fy.init(e,t),Ae.init(e,t)});function Rw(e){return dh(xa,e)}var Ta=B("ZodCUID2",(e,t)=>{py.init(e,t),Ae.init(e,t)});function zw(e){return hh(Ta,e)}var Fa=B("ZodULID",(e,t)=>{my.init(e,t),Ae.init(e,t)});function Ow(e){return fh(Fa,e)}var Pa=B("ZodXID",(e,t)=>{gy.init(e,t),Ae.init(e,t)});function Nw(e){return ph(Pa,e)}var Ra=B("ZodKSUID",(e,t)=>{vy.init(e,t),Ae.init(e,t)});function Mw(e){return mh(Ra,e)}var za=B("ZodIPv4",(e,t)=>{_y.init(e,t),Ae.init(e,t)});function Uw(e){return gh(za,e)}var zh=B("ZodMAC",(e,t)=>{by.init(e,t),Ae.init(e,t)});function jw(e){return z3(zh,e)}var Oa=B("ZodIPv6",(e,t)=>{Ay.init(e,t),Ae.init(e,t)});function Lw(e){return vh(Oa,e)}var Na=B("ZodCIDRv4",(e,t)=>{Sy.init(e,t),Ae.init(e,t)});function qw(e){return Ch(Na,e)}var Ma=B("ZodCIDRv6",(e,t)=>{Dy.init(e,t),Ae.init(e,t)});function Zw(e){return yh(Ma,e)}var Ua=B("ZodBase64",(e,t)=>{Iy.init(e,t),Ae.init(e,t)});function Ww(e){return Eh(Ua,e)}var ja=B("ZodBase64URL",(e,t)=>{$y.init(e,t),Ae.init(e,t)});function Gw(e){return wh(ja,e)}var La=B("ZodE164",(e,t)=>{By.init(e,t),Ae.init(e,t)});function Vw(e){return _h(La,e)}var Oh=B("ZodCreditCard",(e,t)=>{ky.init(e,t),Ae.init(e,t)});function Hw(e){return O3(Oh,e)}var Nh=B("ZodIBAN",(e,t)=>{xy.init(e,t),Ae.init(e,t)});function Jw(e){return N3(Nh,e)}var qa=B("ZodJWT",(e,t)=>{Ty.init(e,t),Ae.init(e,t)});function Kw(e){return Ah(qa,e)}var Ir=B("ZodCustomStringFormat",(e,t)=>{Fy.init(e,t),Ae.init(e,t)});function Xw(e,t,n={}){return _i(Ir,e,t,n)}function Yw(e){return _i(Ir,"hostname",_C,e)}function Qw(e){return _i(Ir,"hex",NC,e)}function e1(e){return _i(Ir,"currency_code",SC,e)}function t1(e,t){let n=t?.enc??"hex",i=`${e}_${n}`,r=ua[i];if(!r)throw new Error(`Unrecognized hash format: ${i}`);return _i(Ir,i,r,t)}var Uu=B("ZodNumber",(e,t)=>{U0.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>IE(e,n,i,r),e.isFinite=!0},ne.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=rt(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=rt(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:n}=rt(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>rt(e).format??null},{gt(e,t){return this.check(Zn(e,t))},gte(e,t){return this.check(Lt(e,t))},min(e,t){return this.check(Lt(e,t))},lt(e,t){return this.check(qn(e,t))},lte(e,t){return this.check(jt(e,t))},max(e,t){return this.check(jt(e,t))},int(e){return this.check(Ke(e))},safe(e){return this.check(Ke(e))},positive(e){return this.check(Zn(0,e))},nonnegative(e){return this.check(Lt(0,e))},negative(e){return this.check(qn(0,e))},nonpositive(e){return this.check(jt(0,e))},multipleOf(e,t){return this.check(ri(e,t))},step(e,t){return this.check(ri(e,t))},finite(){return this}}));function se(e){return U3(Uu,e)}var $r=B("ZodNumberFormat",(e,t)=>{Py.init(e,t),Uu.init(e,t)});function Ke(e){return L3($r,e)}function n1(e){return q3($r,e)}function r1(e){return Z3($r,e)}function i1(e){return W3($r,e)}function u1(e){return G3($r,e)}var ju=B("ZodBoolean",(e,t)=>{j0.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>$E(e,n,i,r)});function ke(e){return V3(ju,e)}var Lu=B("ZodBigInt",(e,t)=>{L0.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>BE(e,n,i,r)},ne.derived({minValue:e=>rt(e).minimum??null,maxValue:e=>rt(e).maximum??null,format:e=>rt(e).format??null},{gte(e,t){return this.check(Lt(e,t))},min(e,t){return this.check(Lt(e,t))},gt(e,t){return this.check(Zn(e,t))},lt(e,t){return this.check(qn(e,t))},lte(e,t){return this.check(jt(e,t))},max(e,t){return this.check(jt(e,t))},positive(e){return this.check(Zn(BigInt(0),e))},negative(e){return this.check(qn(BigInt(0),e))},nonpositive(e){return this.check(jt(BigInt(0),e))},nonnegative(e){return this.check(Lt(BigInt(0),e))},multipleOf(e,t){return this.check(ri(e,t))}}));function s1(e){return J3(Lu,e)}var Za=B("ZodBigIntFormat",(e,t)=>{Ry.init(e,t),Lu.init(e,t)});function o1(e){return X3(Za,e)}function a1(e){return Y3(Za,e)}var Mh=B("ZodSymbol",(e,t)=>{zy.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>kE(e,n,i,r)});function l1(e){return Q3(Mh,e)}var Uh=B("ZodUndefined",(e,t)=>{Oy.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>TE(e,n,i,r)});function c1(e){return eE(Uh,e)}var jh=B("ZodNull",(e,t)=>{Ny.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xE(e,n,i,r)});function Br(e){return tE(jh,e)}var Lh=B("ZodAny",(e,t)=>{My.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>RE(e,n,i,r)});function d1(){return nE(Lh)}var qh=B("ZodUnknown",(e,t)=>{Uy.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>zE(e,n,i,r)});function w(){return rE(qh)}var Zh=B("ZodNever",(e,t)=>{jy.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>PE(e,n,i,r)});function Wa(e){return iE(Zh,e)}var Wh=B("ZodVoid",(e,t)=>{Ly.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>FE(e,n,i,r)});function h1(e){return uE(Wh,e)}var Ga=B("ZodDate",(e,t)=>{qy.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>OE(e,n,i,r),e.min=(n,i)=>e.check(Lt(n,i)),e.max=(n,i)=>e.check(jt(n,i))},ne.derived({minDate:e=>{let{minimum:t}=rt(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=rt(e);return t?new Date(t):null}},{}));function f1(e){return sE(Ga,e)}var Gh=B("ZodArray",(e,t)=>{Dr(),Zy.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>JE(e,n,i,r),e.element=t.element},{min(e,t){return this.check(_r(e,t))},nonempty(e){return this.check(_r(1,e))},max(e,t){return this.check(Tu(e,t))},length(e,t){return this.check(Fu(e,t))},unwrap(){return this.element}});function Y(e,t){return lE(Gh,e,t)}function p1(e){let t=e._zod.def.shape;return Ha(Object.keys(t))}var qu=B("ZodObject",(e,t)=>{Dr(),Hy.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>KE(e,n,i,r),ne.installLazyProp(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return Ha(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ne.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ne.mergeDefs(this._zod.def,{catchall:w()}))},loose(){return this.clone(ne.mergeDefs(this._zod.def,{catchall:w()}))},strict(){return this.clone(ne.mergeDefs(this._zod.def,{catchall:Wa()}))},strip(){return this.clone(ne.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return ne.extend(this,e)},safeExtend(e){return ne.safeExtend(this,e)},merge(e){return ne.merge(this,e)},pick(e){return ne.pick(this,e)},omit(e){return ne.omit(this,e)},partial(...e){return ne.partial(Wu,this,e[0])},exactPartial(...e){return ne.partial(Ka,this,e[0],"exactPartial")},required(...e){return ne.required(Xa,this,e[0])}});function d(e,t){let n={type:"object",shape:e??{},...ne.normalizeParams(t)};return new qu(n)}function m1(e,t){return new qu({type:"object",shape:e,catchall:Wa(),...ne.normalizeParams(t)})}function Va(e,t){return new qu({type:"object",shape:e,catchall:w(),...ne.normalizeParams(t)})}var Zu=B("ZodUnion",(e,t)=>{la.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Fh(e,n,i,r),e.options=t.options});function U(e,t){return new Zu({type:"union",options:e,...ne.normalizeParams(t)})}var Vh=B("ZodXor",(e,t)=>{Zu.init(e,t),Jy.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Fh(e,n,i,r),e.options=t.options});function g1(e,t){return new Vh({type:"union",options:e,inclusive:!1,...ne.normalizeParams(t)})}var Hh=B("ZodDiscriminatedUnion",(e,t)=>{Zu.init(e,t),Yy.init(e,t)});function v1(e,t,n){return new Hh({type:"union",options:t,discriminator:e,...ne.normalizeParams(n)})}var Jh=B("ZodIntersection",(e,t)=>{Qy.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>XE(e,n,i,r)});function Xe(e,t){return new Jh({type:"intersection",left:e,right:t})}var Kh=B("ZodTuple",(e,t)=>{Dr(),Z0.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>YE(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Wu({type:"optional",innerType:t}))})}});function Xh(e,t,n){let i=t instanceof le,r=i?n:t,u=i?t:null;return new Kh({type:"tuple",items:e,rest:u,...ne.normalizeParams(r)})}var li=B("ZodRecord",(e,t)=>{Dr(),e3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>QE(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function _(e,t,n){return!t||!t._zod?new li({type:"record",keyType:h(),valueType:e,...ne.normalizeParams(t)}):new li({type:"record",keyType:e,valueType:t,...ne.normalizeParams(n)})}function C1(e,t,n){return new li({type:"record",keyType:e,valueType:t,...ne.normalizeParams(n),partial:!0})}function y1(e,t,n){return new li({type:"record",keyType:e,valueType:t,mode:"loose",...ne.normalizeParams(n)})}var Yh=B("ZodMap",(e,t)=>{Dr(),t3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>VE(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(Wn(...n)),e.nonempty=n=>e.check(Wn(1,n)),e.max=(...n)=>e.check(wi(...n)),e.size=(...n)=>e.check(xu(...n))});function E1(e,t,n){return new Yh({type:"map",keyType:e,valueType:t,...ne.normalizeParams(n)})}var Qh=B("ZodSet",(e,t)=>{Dr(),n3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>HE(e,n,i,r),e.min=(...n)=>e.check(Wn(...n)),e.nonempty=n=>e.check(Wn(1,n)),e.max=(...n)=>e.check(wi(...n)),e.size=(...n)=>e.check(xu(...n))});function w1(e,t){return new Qh({type:"set",valueType:e,...ne.normalizeParams(t)})}var ci=B("ZodEnum",(e,t)=>{r3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(i,r,u)=>NE(e,i,r,u),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let u={};for(let s of i)if(n.has(s))u[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new ci({...t,checks:[],...ne.normalizeParams(r),entries:u})},e.exclude=(i,r)=>{let u={...t.entries};for(let s of i)if(n.has(s))delete u[s];else throw new Error(`Key ${s} not found in enum`);return new ci({...t,checks:[],...ne.normalizeParams(r),entries:u})}});function Ha(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new ci({type:"enum",entries:n,...ne.normalizeParams(t)})}function _1(e,t){return new ci({type:"enum",entries:e,...ne.normalizeParams(t)})}var ef=B("ZodLiteral",(e,t)=>{i3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ME(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function E(e,t){return new ef({type:"literal",values:Array.isArray(e)?e:[e],...ne.normalizeParams(t)})}var tf=B("ZodFile",(e,t)=>{u3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>LE(e,n,i,r),e.min=(n,i)=>e.check(Wn(n,i)),e.max=(n,i)=>e.check(wi(n,i)),e.mime=(n,i)=>e.check(Ea(Array.isArray(n)?n:[n],i))});function A1(e){return cE(tf,e)}var nf=B("ZodTransform",(e,t)=>{Dr(),s3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>GE(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new ra(e.constructor.name);n.addIssue=u=>{if(typeof u=="string")n.issues.push(ne.issue(u,n.value,t));else{let s=u;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=e),n.issues.push(ne.issue(s))}};let r=t.transform(n.value,n);return r instanceof Promise?r.then(u=>(n.value=u,n)):(n.value=r,n)}});function Ja(e){return new nf({type:"transform",transform:e})}var Wu=B("ZodOptional",(e,t)=>{W0.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Rh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function di(e){return new Wu({type:"optional",innerType:e})}var Ka=B("ZodExactOptional",(e,t)=>{o3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Rh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function rf(e){return new Ka({type:"optional",innerType:e})}var uf=B("ZodNullable",(e,t)=>{a3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ew(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function lu(e){return new uf({type:"nullable",innerType:e})}function b1(e){return di(lu(e))}var sf=B("ZodDefault",(e,t)=>{l3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>rw(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function of(e,t){return new sf({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():ne.shallowClone(t)}})}var af=B("ZodPrefault",(e,t)=>{c3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>iw(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function lf(e,t){return new af({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():ne.shallowClone(t)}})}var Xa=B("ZodNonOptional",(e,t)=>{d3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>tw(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function cf(e,t){return new Xa({type:"nonoptional",innerType:e,...ne.normalizeParams(t)})}var df=B("ZodSuccess",(e,t)=>{h3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>qE(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function S1(e){return new df({type:"success",innerType:e})}var hf=B("ZodCatch",(e,t)=>{f3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>uw(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ff(e,t){return new hf({type:"catch",innerType:e,catchValue:typeof t=="function"?t:ne.constantCatch(t)})}var pf=B("ZodNaN",(e,t)=>{p3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>UE(e,n,i,r)});function D1(e){return aE(pf,e)}var Gu=B("ZodPipe",(e,t)=>{G0.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>sw(e,n,i,r),e.in=t.in,e.out=t.out});function mo(e,t){return new Gu({type:"pipe",in:e,out:t})}var Vu=B("ZodCodec",(e,t)=>{Gu.init(e,t),V0.init(e,t)});function I1(e,t,n){return new Vu({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function $1(e){let t=e._zod.def;return new Vu({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var mf=B("ZodPreprocess",(e,t)=>{Gu.init(e,t),m3.init(e,t)}),gf=B("ZodReadonly",(e,t)=>{g3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ow(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function vf(e){return new gf({type:"readonly",innerType:e})}var Cf=B("ZodTemplateLiteral",(e,t)=>{v3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>jE(e,n,i,r)});function B1(e,t){return new Cf({type:"template_literal",parts:e,...ne.normalizeParams(t)})}var yf=B("ZodLazy",(e,t)=>{H0.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>lw(e,n,i,r),e.unwrap=()=>e._zod.def.getter()});function Ef(e){return new yf({type:"lazy",getter:e})}var wf=B("ZodPromise",(e,t)=>{y3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>aw(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function k1(e){return new wf({type:"promise",innerType:e})}var _f=B("ZodFunction",(e,t)=>{C3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>WE(e,n,i,r)});function go(e){return new _f({type:"function",input:Array.isArray(e?.input)?Xh(e?.input):e?.input??Y(w()),output:e?.output??w()})}var Hu=B("ZodCustom",(e,t)=>{E3.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ZE(e,n,i,r)});function x1(e){let t=new Re({check:"custom"});return t._zod.check=e,t}function T1(e,t){return dE(Hu,e??(()=>!0),t)}function Af(e,t={}){return hE(Hu,e,t)}function bf(e,t){return fE(e,t)}var F1=mE,P1=gE,Sf=B("ZodInstanceOf",(e,t)=>{Hu.init(e,t)},{properties(e,t){return this.check(ya(e,t))}});function R1(e,t={}){let n=new Sf({type:"custom",check:"custom",fn:i=>i instanceof e,abort:!0,...ne.normalizeParams(t)});return n._zod.bag.Class=e,n._zod.check=i=>{i.value instanceof e||i.issues.push({code:"invalid_type",expected:e.name,input:i.value,inst:n,path:[...n._zod.def.path??[]]})},n}var z1=(...e)=>vE({Codec:Vu,Boolean:ju,String:Pu},...e);function O1(e){let t=Ef(()=>U([h(e),se(),ke(),Br(),Y(t),_(h(),t)]));return t}function Df(e,t){return new mf({type:"pipe",in:Ja(e),out:t})}var wx={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function _x(e){at({customError:e})}function Ax(){return at().customError}var Mc;Mc||(Mc={});var Ai={};bn(Ai,{ZodISODate:()=>zu,ZodISODateTime:()=>Ru,ZodISODuration:()=>Nu,ZodISOTime:()=>Ou,date:()=>Sx,datetime:()=>bx,duration:()=>Ix,time:()=>Dx});function bx(e){return bh(Ru,e)}function Sx(e){return Sh(zu,e)}function Dx(e){return Dh(Ou,e)}function Ix(e){return Ih(Nu,e)}var W={...dw,...hw,iso:Ai},$x=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function Bx(e,t){let n=e.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function _m(e,t){return e.map((n,i)=>i<t?n:n.optional())}function kx(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function xx(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let n=e.slice(1).split("/").filter(Boolean);if(n.length===0)return t.rootSchema;let i=t.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===i){let r=n[1]===void 0?void 0:kx(n[1]);if(!r||!t.defs[r])throw new Error(`Reference not found: ${e}`);return t.defs[r]}throw new Error(`Reference not found: ${e}`)}function Tx(e,t){return W.transform(i=>i).check(i=>{let r=i.value;if(typeof r!="object"||r===null||Array.isArray(r))return;let u=Object.getOwnPropertyNames(r);if(t.minProperties!==void 0&&u.length<t.minProperties&&i.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:r,inst:e,continue:!0}),t.maxProperties!==void 0&&u.length>t.maxProperties&&i.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:r,inst:e,continue:!0}),t.keySchema)for(let s of u){let o=t.keySchema.safeParse(s);o.success||i.issues.push({code:"invalid_key",origin:"record",issues:o.error.issues,input:s,path:[s],continue:!0})}}).pipe(e)}function Uc(e,t){if(e===null)return"z";let n=typeof e;if(n!=="object"){if(n==="number"&&Number.isNaN(e))return null;let i=String(e);return`${n[0]}${i.length}:${i}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let u=[];for(let s of e){let o=Uc(s,t);if(o===null)return null;u.push(o)}return`a${u.length}:[${u.join(",")}]`}let i=Object.keys(e).sort(),r=[];for(let u of i){let s=Uc(e[u],t);if(s===null)return null;r.push(`${u.length}:${u}=${s}`)}return`o${r.length}:{${r.join(",")}}`}finally{t.delete(e)}}var Fx=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),Px=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function Xi(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(Xi):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>Fx.has(t)?Xi(n):!Px.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(Xi))}function Am(e){return e===1?"element":"elements"}function Rx(e,t){return W.transform(i=>i).check(i=>{let r=i.value;if(Array.isArray(r)){if(t.uniqueItems===!0){let u=new Map;for(let s=0;s<r.length;s++){let o=Uc(r[s],new Set);if(o===null)continue;let a=u.get(o);if(a===void 0){u.set(o,s);continue}i.issues.push({code:"custom",message:`Array items must be unique: element at index ${s} duplicates the one at index ${a}`,input:r,path:[s],continue:!0})}}if(t.containsSchema){let u=t.minContains??1,s=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY,o=0;for(let a of r)if(t.containsSchema.safeParse(a).success&&++o>=s)break;o<u&&i.issues.push({code:"custom",message:`Array must contain at least ${u} matching ${Am(u)}; found ${o}`,input:r,continue:!0}),t.maxContains!==void 0&&o>t.maxContains&&i.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${Am(t.maxContains)}`,input:r,continue:!0})}}}).pipe(e)}function bm(e,t){if(e!==!1)return e===void 0||e===!0?W.any():pt(e,t)}var zx=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function N1(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return W.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let r=e.$ref;if(t.refs.has(r))return t.refs.get(r);if(t.processing.has(r))return W.lazy(()=>{if(!t.refs.has(r))throw new Error(`Circular reference not resolved: ${r}`);return t.refs.get(r)});t.processing.add(r);let u=xx(r,t),s=pt(u,t);return t.refs.set(r,s),t.processing.delete(r),s}if(e.enum!==void 0){let r=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&r.length===1&&r[0]===null)return W.null();if(r.length===0)return W.never();if(r.length===1)return W.literal(r[0]);if(r.every(s=>typeof s=="string"))return W.enum(r);let u=r.map(s=>W.literal(s));return u.length<2?u[0]:W.union([u[0],u[1],...u.slice(2)])}if(e.const!==void 0)return W.literal(e.const);let n=e.type;if(Array.isArray(n)){let r=n.map(u=>{let s={...e,type:u};return N1(s,t)});return r.length===0?W.never():r.length===1?r[0]:W.union(r)}if(!n)return W.any();let i;switch(n){case"string":{let r=W.string();if(e.format){let u=e.format;u==="email"?r=r.check(W.email()):u==="uri"||u==="uri-reference"?r=r.check(W.url()):u==="uuid"||u==="guid"?r=r.check(W.uuid()):u==="date-time"?r=r.check(W.iso.datetime({offset:!0})):u==="date"?r=r.check(W.iso.date()):u==="time"?r=r.check(W.regex(zx)):u==="duration"?r=r.check(W.iso.duration()):u==="hostname"?r=r.check(W.hostname()):u==="ipv4"?r=r.check(W.ipv4()):u==="ipv6"?r=r.check(W.ipv6()):u==="mac"?r=r.check(W.mac()):u==="cidr"?r=r.check(W.cidrv4()):u==="cidr-v6"?r=r.check(W.cidrv6()):u==="base64"?r=r.check(W.base64()):u==="base64url"?r=r.check(W.base64url()):u==="e164"?r=r.check(W.e164()):u==="credit_card"?r=r.check(W.creditCard()):u==="iban"?r=r.check(W.iban()):u==="jwt"?r=r.check(W.jwt()):u==="emoji"?r=r.check(W.emoji()):u==="nanoid"?r=r.check(W.nanoid()):u==="cuid"?r=r.check(W.cuid()):u==="cuid2"?r=r.check(W.cuid2()):u==="ulid"?r=r.check(W.ulid()):u==="xid"?r=r.check(W.xid()):u==="ksuid"&&(r=r.check(W.ksuid()))}typeof e.minLength=="number"&&(r=r.min(e.minLength)),typeof e.maxLength=="number"&&(r=r.max(e.maxLength)),e.pattern&&(r=r.regex(new RegExp(e.pattern))),i=r;break}case"number":case"integer":{let r=n==="integer"?W.number().int():W.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(r=r.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(r=r.max(e.maximum)),typeof e.exclusiveMinimum=="number"?r=r.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(r=r.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?r=r.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(r=r.lt(e.maximum)),typeof e.multipleOf=="number"&&(r=r.multipleOf(e.multipleOf)),i=r;break}case"boolean":{i=W.boolean();break}case"null":{i=W.null();break}case"object":{let r={},u=e.properties||{},s=new Set(e.required||[]),o=typeof e.additionalProperties=="object"?pt(e.additionalProperties,t):void 0;for(let[m,p]of Object.entries(u)){let v=pt(p,t);Tt(r,m,s.has(m)?v:v.optional())}if(e.patternProperties){let m=e.patternProperties,p=Object.keys(m),v=[];for(let C of p){let y=pt(m[C],t),b=W.string().regex(new RegExp(C));v.push(W.looseRecord(b,y))}let g=[];if(Object.keys(r).length>0&&g.push(W.object(r).passthrough()),g.push(...v),g.length===0)i=W.object({}).passthrough();else if(g.length===1)i=g[0];else{let C=W.intersection(g[0],g[1]);for(let y=2;y<g.length;y++)C=W.intersection(C,g[y]);i=C}if(e.additionalProperties===!1){let C=Object.keys(r),y=p.map(A=>new RegExp(A)),b=i;i=i.check(A=>{if(!_n(A.value))return;let S=[];for(let z of Object.keys(A.value))C.includes(z)||y.some(M=>M.test(z))||S.push(z);S.length&&A.issues.push({code:"unrecognized_keys",keys:S,input:A.value,inst:b})})}}else{let m=W.object(r);e.additionalProperties===!1?i=m.strict():o?i=m.catchall(o):i=m.passthrough()}let a=e.propertyNames!==void 0&&e.propertyNames!==!0,l=typeof e.minProperties=="number"?e.minProperties:void 0,c=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(a||l!==void 0||c!==void 0){let m;if(a){let p=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;m=pt(p,t)}i=Tx(i,{keySchema:m,minProperties:l,maxProperties:c})}break}case"array":{let r=e.prefixItems,u=e.items;if(r&&Array.isArray(r)){let s=typeof e.minItems=="number"?e.minItems:0,o=r.map(m=>pt(m,t)),a=_m(o,s),l=Array.isArray(u)?void 0:bm(u,t),c=W.tuple(a);i=l?c.rest(l):c,typeof e.minItems=="number"&&(i=i.check(W.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(W.maxLength(e.maxItems)))}else if(Array.isArray(u)){let s=typeof e.minItems=="number"?e.minItems:0,o=u.map(m=>pt(m,t)),a=_m(o,s),l=bm(e.additionalItems,t),c=W.tuple(a);i=l?c.rest(l):c,typeof e.minItems=="number"&&(i=i.check(W.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(W.maxLength(e.maxItems)))}else if(u!==void 0){let s=pt(u,t),o=W.array(s);typeof e.minItems=="number"&&(o=o.min(e.minItems)),typeof e.maxItems=="number"&&(o=o.max(e.maxItems)),i=o}else i=W.array(W.any());(e.uniqueItems===!0||e.contains!==void 0)&&(i=Rx(i,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?pt(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${n}`)}return i}function pt(e,t){if(typeof e=="boolean")return e?W.any():W.never();let n=N1(e,t),i=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let o=e.anyOf.map(l=>pt(l,t)),a=W.union(o);n=i?W.intersection(n,a):a}if(e.oneOf&&Array.isArray(e.oneOf)){let o=e.oneOf.map(l=>pt(l,t)),a=W.xor(o);n=i?W.intersection(n,a):a}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=i?n:W.any();else{let o=i?n:pt(e.allOf[0],t),a=i?0:1;for(let l=a;l<e.allOf.length;l++)o=W.intersection(o,pt(e.allOf[l],t));n=o}e.nullable===!0&&t.version==="openapi-3.0"&&(n=W.nullable(n)),e.readOnly===!0&&(n=W.readonly(n)),e.default!==void 0&&(n=n.default(e.default));let r={},u=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let o of u)o in e&&(r[o]=e[o]);let s=["contentEncoding","contentMediaType","contentSchema"];for(let o of s)o in e&&(r[o]=e[o]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!Xi(e.propertyNames)&&(r.propertyNames=e.propertyNames);for(let o of["minProperties","maxProperties"])e[o]!==void 0&&(r[o]=e[o])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!Xi(e.contains)&&(r.contains=e.contains);for(let o of["uniqueItems","minContains","maxContains"])e[o]!==void 0&&(r[o]=e[o])}for(let o of Object.keys(e))$x.has(o)||Tt(r,o,e[o]);return Object.keys(r).length>0&&t.registry.add(n,r),e.description&&(n=n.describe(e.description)),n}function Ox(e,t){if(typeof e=="boolean")return e?W.any():W.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=Bx(n,t?.defaultTarget),r=n.$defs||n.definitions||{},u={version:i,defs:r,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??Mt};return pt(n,u)}var Sm=Symbol("z.visit/resolving");function If(e,t){let n=typeof t=="function"?t:(s,o)=>{let a=t[s._zod.def.type];return a?a(s,o):s},i=new Map;function r(s){let o=i.get(s);if(o===Sm)return new H0({type:"lazy",getter:()=>i.get(s)});if(o!==void 0)return o;i.set(s,Sm);let a=u(s),l=n(a,a!==s);return i.set(s,l),l}function u(s){let o=s._zod.def,a=o.type;switch(a){case"object":{let l=o.shape,c=Object.keys(l),m=!1,p={};for(let g of c){let C=r(l[g]);C!==l[g]&&(m=!0),p[g]=C}let v=o.catchall;return o.catchall&&(v=r(o.catchall),v!==o.catchall&&(m=!0)),m?je(s,{...o,shape:p,catchall:v}):s}case"array":{let l=r(o.element);return l===o.element?s:je(s,{...o,element:l})}case"tuple":{let l=o.items,c=!1,m=[];for(let v of l){let g=r(v);g!==v&&(c=!0),m.push(g)}let p=o.rest;return o.rest&&(p=r(o.rest),p!==o.rest&&(c=!0)),c?je(s,{...o,items:m,rest:p}):s}case"record":case"map":{let l=r(o.keyType),c=r(o.valueType);return l===o.keyType&&c===o.valueType?s:je(s,{...o,keyType:l,valueType:c})}case"set":{let l=r(o.valueType);return l===o.valueType?s:je(s,{...o,valueType:l})}case"union":{let l=o.options,c=!1,m=[];for(let p of l){let v=r(p);v!==p&&(c=!0),m.push(v)}return c?je(s,{...o,options:m}):s}case"intersection":{let l=r(o.left),c=r(o.right);return l===o.left&&c===o.right?s:je(s,{...o,left:l,right:c})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let l=r(o.innerType);return l===o.innerType?s:je(s,{...o,innerType:l})}case"pipe":{let l=r(o.in),c=r(o.out);return l===o.in&&c===o.out?s:je(s,{...o,in:l,out:c})}case"function":{let l=r(o.input),c=r(o.output);return l===o.input&&c===o.output?s:je(s,{...o,input:l,output:c})}case"lazy":{let l=o.getter,{_cachedInner:c,...m}=o;return je(s,{...m,getter:()=>r(l())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return s;default:return s}}return r(e)}function Nx(e){return If(e,{object:t=>t.partial(),union:t=>{let n=t._zod.def;return n.discriminator===void 0?t:U(n.options)}})}function Mx(e,t){if(!t?.length)return e;let n=e._zod.def;return je(e,an(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function M1(e){return Mx(e.out,e.checks)}function Ux(e){return e.in._zod.traits.has("$ZodTransform")?M1(e):e.in}function jx(e){return If(e,{pipe:t=>Ux(t._zod.def),default:(t,n)=>n?di(t._zod.def.innerType):t,catch:(t,n)=>n?t._zod.def.innerType:t})}function Lx(e){return If(e,{pipe:t=>M1(t._zod.def),prefault:(t,n)=>n?t._zod.def.innerType:t})}var U1={};bn(U1,{bigint:()=>Gx,boolean:()=>Wx,date:()=>Vx,number:()=>Zx,string:()=>qx});function qx(e){return R3(Pu,e)}function Zx(e){return j3(Uu,e)}function Wx(e){return H3(ju,e)}function Gx(e){return K3(Lu,e)}function Vx(e){return oE(Ga,e)}var Dm=Symbol("skippedItem");function f(e,t){return e.catch(t)}function ht(e,t){let n=e.catch(t);return w().transform((i,r)=>i!==void 0?n.parse(i):(r.addIssue({code:"custom",message:"Required value is missing"}),na))}function j1(e,t){if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e[t];return typeof n=="string"?n:void 0}function ze(e,t,n){return e.superRefine((i,r)=>{let u=j1(i,t);u!==void 0&&n.includes(u)&&r.addIssue({code:"custom",path:[t],message:`${t} ${JSON.stringify(u)} is reserved by a known variant, but the value does not match that variant's schema`})})}function Oe(e,t,n){return w().transform((i,r)=>{let u=e.safeParse(i);if(!u.success){for(let a of u.error.issues)r.addIssue({...a,input:i});return na}let s=u.data,o=j1(i,t);if(o!==void 0&&!n.includes(o)){let a=i;for(let[l,c]of Object.entries(a))l!=="__proto__"&&(Object.hasOwn(s,l)||(s[l]=c))}return s})}function L1(e,t){return Df(n=>{if(n===null||typeof n!="object"||Array.isArray(n))return n;let i=n,r=i[t];if(r==null||typeof r=="string")return n;let u={...i};return delete u[t],u},e)}function ie(e){return Y(e.catch(Dm)).transform(t=>t.filter(n=>n!==Dm))}var Gn=U([se(),h()]).nullable(),$e=h(),q1=d({sessionId:$e,path:h(),content:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),Z1=d({sessionId:$e,path:h(),line:Ke().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),limit:Ke().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),$f=h(),W1=U([E("read"),E("edit"),E("delete"),E("move"),E("search"),E("execute"),E("think"),E("fetch"),E("switch_mode"),E("other")]),G1=U([E("pending"),E("in_progress"),E("completed"),E("failed")]),Hx=U([E("assistant"),E("user")]),Ju=d({audience:f(ie(Hx).nullish(),()=>{}),lastModified:f(h().nullish(),()=>{}),priority:f(se().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),Jx=d({annotations:f(Ju.nullish(),()=>{}),text:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),Kx=d({annotations:f(Ju.nullish(),()=>{}),data:h(),mimeType:h(),uri:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),Xx=d({annotations:f(Ju.nullish(),()=>{}),data:h(),mimeType:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),Yx=d({annotations:f(Ju.nullish(),()=>{}),description:f(h().nullish(),()=>{}),mimeType:f(h().nullish(),()=>{}),name:h(),size:f(se().nullish(),()=>{}),title:f(h().nullish(),()=>{}),uri:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),Qx=d({mimeType:f(h().nullish(),()=>{}),text:h(),uri:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),eT=d({blob:h(),mimeType:f(h().nullish(),()=>{}),uri:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),tT=U([Qx,eT]),nT=d({annotations:f(Ju.nullish(),()=>{}),resource:tT,_meta:f(_(h(),w()).nullish(),()=>{})}),Jn=U([Jx.and(d({type:E("text")})),Kx.and(d({type:E("image")})),Xx.and(d({type:E("audio")})),Yx.and(d({type:E("resource_link")})),nT.and(d({type:E("resource")}))]),rT=d({content:Jn,_meta:f(_(h(),w()).nullish(),()=>{})}),iT=d({path:h(),oldText:f(h().nullish(),()=>{}),newText:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),bi=h(),uT=d({terminalId:bi,_meta:f(_(h(),w()).nullish(),()=>{})}),V1=U([rT.and(d({type:E("content")})),iT.and(d({type:E("diff")})),uT.and(d({type:E("terminal")}))]),H1=d({path:h(),line:f(Ke().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),J1=d({toolCallId:$f,kind:f(W1.nullish(),()=>{}),status:f(G1.nullish(),()=>{}),title:f(h().nullish(),()=>{}),name:f(h().nullish(),()=>{}),content:f(ie(V1).nullish(),()=>{}),locations:f(ie(H1).nullish(),()=>{}),rawInput:f(w().optional(),()=>{}),rawOutput:f(w().optional(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),K1=h(),sT=U([E("allow_once"),E("allow_always"),E("reject_once"),E("reject_always")]),oT=d({optionId:K1,name:h(),kind:sT,_meta:f(_(h(),w()).nullish(),()=>{})}),X1=d({sessionId:$e,toolCall:J1,options:Y(oT),_meta:f(_(h(),w()).nullish(),()=>{})}),Y1=d({name:h(),value:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),Q1=d({sessionId:$e,command:h(),args:Y(h()).optional(),env:Y(Y1).optional(),cwd:h().nullish(),outputByteLimit:se().nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),e6=d({sessionId:$e,terminalId:bi,_meta:f(_(h(),w()).nullish(),()=>{})}),t6=d({sessionId:$e,terminalId:bi,_meta:f(_(h(),w()).nullish(),()=>{})}),n6=d({sessionId:$e,terminalId:bi,_meta:f(_(h(),w()).nullish(),()=>{})}),r6=d({sessionId:$e,terminalId:bi,_meta:f(_(h(),w()).nullish(),()=>{})}),Ya=d({sessionId:$e,toolCallId:f($f.nullish(),()=>{})}),Qa=d({requestId:Gn}),aT=E("object"),lT=U([E("email"),E("uri"),E("date"),E("date-time")]),i6=d({const:h(),title:h(),description:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),u6=d({title:f(h().nullish(),()=>{}),description:f(h().nullish(),()=>{}),minLength:Ke().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),maxLength:Ke().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),pattern:h().nullish(),format:lT.nullish(),default:f(h().nullish(),()=>{}),enum:Y(h()).nullish(),oneOf:Y(i6).nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),s6=d({title:f(h().nullish(),()=>{}),description:f(h().nullish(),()=>{}),minimum:se().nullish(),maximum:se().nullish(),default:f(se().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),o6=d({title:f(h().nullish(),()=>{}),description:f(h().nullish(),()=>{}),minimum:se().nullish(),maximum:se().nullish(),default:f(se().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),a6=d({title:f(h().nullish(),()=>{}),description:f(h().nullish(),()=>{}),default:f(ke().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),l6=d({enum:Y(h()),_meta:f(_(h(),w()).nullish(),()=>{})}),cT=d({anyOf:Y(i6),_meta:f(_(h(),w()).nullish(),()=>{})}),dT=Oe(U([l6.and(d({type:E("string")})),ze(d({type:h()}),"type",["string"]),cT]),"type",["string"]),c6=d({title:f(h().nullish(),()=>{}),description:f(h().nullish(),()=>{}),minItems:se().nullish(),maxItems:se().nullish(),items:dT,default:f(ie(h()).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),hT=Oe(U([u6.and(d({type:E("string")})),s6.and(d({type:E("number")})),o6.and(d({type:E("integer")})),a6.and(d({type:E("boolean")})),c6.and(d({type:E("array")})),ze(d({type:h()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),fT=d({type:f(aT.optional().default("object"),()=>"object"),title:f(h().nullish(),()=>{}),properties:_(h(),hT).optional().default({}),required:Y(h()).nullish(),description:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),d6=Xe(U([Ya,Qa]),d({requestedSchema:fT})),h6=h(),f6=Xe(U([Ya,Qa]),d({elicitationId:h6,url:Rt()})),p6=Oe(Xe(U([d6.and(d({mode:E("form")})),f6.and(d({mode:E("url")})),ze(Xe(U([Ya,Qa]),d({mode:h()})),"mode",["form","url"])]),d({message:h(),_meta:f(_(h(),w()).nullish(),()=>{})})),"mode",["form","url"]),Bf=h(),m6=h(),pT=d({serverId:Bf,requestId:m6,method:h(),params:_(h(),w()).nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),g6=w(),JZ=d({id:Gn,method:h(),params:U([q1,Z1,X1,Q1,e6,t6,n6,r6,p6,pT,g6]).nullish()}),v6=Ke().gte(0).lte(65535),mT=d({image:f(ke().optional().default(!1),()=>!1),audio:f(ke().optional().default(!1),()=>!1),embeddedContext:f(ke().optional().default(!1),()=>!1),_meta:f(_(h(),w()).nullish(),()=>{})}),gT=d({http:f(ke().optional().default(!1),()=>!1),sse:f(ke().optional().default(!1),()=>!1),acp:f(ke().optional().default(!1),()=>!1),_meta:f(_(h(),w()).nullish(),()=>{})}),vT=d({_meta:f(_(h(),w()).nullish(),()=>{})}),CT=d({_meta:f(_(h(),w()).nullish(),()=>{})}),yT=d({_meta:f(_(h(),w()).nullish(),()=>{})}),ET=d({_meta:f(_(h(),w()).nullish(),()=>{})}),wT=d({override:f(ET.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),_T=d({mode:f(wT.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),AT=d({_meta:f(_(h(),w()).nullish(),()=>{})}),bT=d({_meta:f(_(h(),w()).nullish(),()=>{})}),ST=d({_meta:f(_(h(),w()).nullish(),()=>{})}),DT=d({list:f(vT.nullish(),()=>{}),delete:f(CT.nullish(),()=>{}),additionalDirectories:f(yT.nullish(),()=>{}),systemPrompt:f(_T.nullish(),()=>{}),fork:f(AT.nullish(),()=>{}),resume:f(bT.nullish(),()=>{}),close:f(ST.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),IT=d({_meta:f(_(h(),w()).nullish(),()=>{})}),$T=d({logout:f(IT.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),BT=d({_meta:f(_(h(),w()).nullish(),()=>{})}),kT=d({loadSession:f(ke().optional().default(!1),()=>!1),promptCapabilities:f(mT.optional().default({image:!1,audio:!1,embeddedContext:!1}),()=>({image:!1,audio:!1,embeddedContext:!1})),mcpCapabilities:f(gT.optional().default({http:!1,sse:!1,acp:!1}),()=>({http:!1,sse:!1,acp:!1})),sessionCapabilities:f(DT.optional().default({}),()=>({})),auth:f($T.optional().default({}),()=>({})),providers:f(BT.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),kf=h(),xT=d({id:kf,name:h(),description:f(h().nullish(),()=>{}),args:Y(h()).optional(),env:_(h(),h()).optional(),_meta:f(_(h(),w()).nullish(),()=>{})}),TT=d({id:kf,name:h(),description:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),FT=U([xT.and(d({type:E("terminal")})),TT]),C6=d({name:h(),title:f(h().nullish(),()=>{}),version:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),PT=d({protocolVersion:v6,agentCapabilities:f(kT.optional().default({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}}),()=>({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}})),authMethods:f(ie(FT).optional().default([]),()=>[]),agentInfo:f(C6.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),RT=d({_meta:f(_(h(),w()).nullish(),()=>{})}),xf=h(),Tf=U([E("anthropic"),E("openai"),E("azure"),E("vertex"),E("bedrock"),h()]),zT=d({apiType:Tf,baseUrl:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),OT=d({providerId:xf,supported:ht(ie(Tf),()=>[]),required:ke(),current:zT.nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),NT=d({providers:Y(OT),_meta:f(_(h(),w()).nullish(),()=>{})}),MT=d({_meta:f(_(h(),w()).nullish(),()=>{})}),UT=d({_meta:f(_(h(),w()).nullish(),()=>{})}),jT=d({_meta:f(_(h(),w()).nullish(),()=>{})}),el=h(),LT=d({id:el,name:h(),description:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),tl=d({currentModeId:el,availableModes:ht(ie(LT),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),y6=h(),qT=U([E("mode"),E("model"),E("model_config"),E("thought_level"),h()]),Ff=h(),E6=d({value:Ff,name:h(),description:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),ZT=h(),WT=d({group:ZT,name:h(),options:ht(ie(E6),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),GT=U([Y(E6),Y(WT)]),VT=d({currentValue:Ff,options:GT}),HT=d({currentValue:ke()}),Si=Xe(U([VT.and(d({type:E("select")})),HT.and(d({type:E("boolean")}))]),d({id:y6,name:h(),description:f(h().nullish(),()=>{}),category:f(qT.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})})),JT=d({sessionId:$e,modes:f(tl.nullish(),()=>{}),configOptions:f(ie(Si).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),KT=d({modes:f(tl.nullish(),()=>{}),configOptions:f(ie(Si).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),XT=d({sessionId:$e,cwd:h(),additionalDirectories:f(ie(h()).optional(),()=>[]),title:f(h().nullish(),()=>{}),updatedAt:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),YT=d({sessions:ht(ie(XT),()=>[]),nextCursor:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),QT=d({_meta:f(_(h(),w()).nullish(),()=>{})}),e7=d({sessionId:$e,modes:f(tl.nullish(),()=>{}),configOptions:f(ie(Si).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),t7=d({modes:f(tl.nullish(),()=>{}),configOptions:f(ie(Si).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),n7=d({_meta:f(_(h(),w()).nullish(),()=>{})}),r7=d({_meta:f(_(h(),w()).nullish(),()=>{})}),i7=d({configOptions:ht(ie(Si),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),u7=U([E("end_turn"),E("max_tokens"),E("max_turn_requests"),E("refusal"),E("cancelled")]),Pf=d({totalTokens:se(),inputTokens:se(),outputTokens:se(),thoughtTokens:f(se().nullish(),()=>{}),cachedReadTokens:f(se().nullish(),()=>{}),cachedWriteTokens:f(se().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),s7=d({stopReason:u7,usage:f(Pf.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),w6=w(),o7=U([E(-32700),E(-32600),E(-32601),E(-32602),E(-32603),E(-32800),E(-32e3),E(-32002),Ke().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"})]),nl=d({code:o7,message:h(),data:f(w().optional(),()=>{})}),KZ=U([d({id:Gn,result:U([PT,RT,NT,MT,UT,jT,JT,KT,YT,QT,e7,t7,n7,r7,i7,s7,w6])}),d({id:Gn,error:nl})]),Rf=h(),Ol=d({content:Jn,messageId:f(Rf.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),a7=d({toolCallId:$f,title:h(),name:f(h().nullish(),()=>{}),kind:f(W1.optional(),()=>{}),status:f(G1.optional(),()=>{}),content:f(ie(V1).optional(),()=>[]),locations:f(ie(H1).optional(),()=>[]),rawInput:f(w().optional(),()=>{}),rawOutput:f(w().optional(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),l7=U([E("high"),E("medium"),E("low")]),c7=U([E("pending"),E("in_progress"),E("completed")]),_6=d({content:h(),priority:l7,status:c7,_meta:f(_(h(),w()).nullish(),()=>{})}),d7=d({entries:ht(ie(_6),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),rl=h(),h7=d({planId:rl,entries:ht(ie(_6),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),f7=d({planId:rl,uri:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),p7=d({planId:rl,content:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),m7=U([h7.and(d({type:E("items")})),f7.and(d({type:E("file")})),p7.and(d({type:E("markdown")}))]),g7=d({plan:m7,_meta:f(_(h(),w()).nullish(),()=>{})}),v7=d({planId:rl,_meta:f(_(h(),w()).nullish(),()=>{})}),C7=d({hint:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),y7=C7,E7=d({name:h(),description:h(),input:f(y7.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),w7=d({availableCommands:ht(ie(E7),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),_7=d({currentModeId:el,_meta:f(_(h(),w()).nullish(),()=>{})}),A7=d({configOptions:ht(ie(Si),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),b7=d({title:f(h().nullish(),()=>{}),updatedAt:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),S7=d({amount:se(),currency:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),D7=d({used:se(),size:se(),cost:f(S7.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),I7=U([E("info"),E("warning"),E("error"),h()]),$7=d({severity:I7,title:h().min(1),description:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),A6=h(),B7=U([E("in_progress"),E("completed"),E("failed"),E("cancelled"),h()]),k7=d({compactionId:A6,status:B7,summary:f(ie(Jn).nullish(),()=>{}),error:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),x7=d({compactionId:A6,content:Jn,_meta:f(_(h(),w()).nullish(),()=>{})}),T7=d({_meta:f(_(h(),w()).nullish(),()=>{})}),F7=d({cancel:f(T7.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),b6=d({_meta:f(_(h(),w()).nullish(),()=>{})}),S6=d({error:f(nl.nullish(),()=>{})}),D6=L1(Oe(Xe(U([d({stopReason:E("end_turn")}),d({stopReason:E("max_tokens")}),d({stopReason:E("max_turn_requests")}),d({stopReason:E("refusal")}),d({stopReason:E("cancelled")}),S6.and(d({stopReason:E("error")})),ze(d({stopReason:h()}),"stopReason",["cancelled","end_turn","error","max_tokens","max_turn_requests","refusal"]),d({stopReason:Br().optional()})]),d({usage:f(Pf.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{}),stopReason:f(h().nullish(),()=>{})})),"stopReason",["cancelled","end_turn","error","max_tokens","max_turn_requests","refusal"]),"stopReason"),I6=d({_meta:f(_(h(),w()).nullish(),()=>{})}),$6=d({_meta:f(_(h(),w()).nullish(),()=>{})}),P7=Oe(U([b6.and(d({state:E("running")})),D6.and(d({state:E("idle")})),I6.and(d({state:E("requires_action")})),$6.and(d({state:E("unknown")})),ze(d({state:h()}),"state",["idle","requires_action","running","unknown"])]),"state",["idle","requires_action","running","unknown"]),R7=d({sessionId:$e,title:f(h().nullish(),()=>{}),description:f(h().nullish(),()=>{}),capabilities:f(F7.nullish(),()=>{}),state:f(P7.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),z7=d({messageId:Rf,senderSessionId:f($e.nullish(),()=>{}),recipientSessionId:f($e.nullish(),()=>{}),content:f(ie(Jn).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),O7=d({messageId:Rf,senderSessionId:f($e.nullish(),()=>{}),recipientSessionId:f($e.nullish(),()=>{}),content:Jn,_meta:f(_(h(),w()).nullish(),()=>{})}),N7=U([Ol.and(d({sessionUpdate:E("user_message_chunk")})),Ol.and(d({sessionUpdate:E("agent_message_chunk")})),Ol.and(d({sessionUpdate:E("agent_thought_chunk")})),a7.and(d({sessionUpdate:E("tool_call")})),J1.and(d({sessionUpdate:E("tool_call_update")})),d7.and(d({sessionUpdate:E("plan")})),g7.and(d({sessionUpdate:E("plan_update")})),v7.and(d({sessionUpdate:E("plan_removed")})),w7.and(d({sessionUpdate:E("available_commands_update")})),_7.and(d({sessionUpdate:E("current_mode_update")})),A7.and(d({sessionUpdate:E("config_option_update")})),b7.and(d({sessionUpdate:E("session_info_update")})),D7.and(d({sessionUpdate:E("usage_update")})),$7.and(d({sessionUpdate:E("notice")})),k7.and(d({sessionUpdate:E("compaction_update")})),x7.and(d({sessionUpdate:E("compaction_summary_chunk")})),R7.and(d({sessionUpdate:E("subagent_update")})),z7.and(d({sessionUpdate:E("session_message")})),O7.and(d({sessionUpdate:E("session_message_chunk")}))]),zf=d({sessionId:$e,update:N7,_meta:f(_(h(),w()).nullish(),()=>{})}),B6=d({elicitationId:h6,_meta:f(_(h(),w()).nullish(),()=>{})}),k6=w(),XZ=d({method:h(),params:U([zf,B6,k6]).nullish()}),M7=d({readTextFile:f(ke().optional().default(!1),()=>!1),writeTextFile:f(ke().optional().default(!1),()=>!1),_meta:f(_(h(),w()).nullish(),()=>{})}),U7=_(h(),w()),j7=d({_meta:f(_(h(),w()).nullish(),()=>{})}),L7=d({boolean:f(j7.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),q7=_(h(),w()),Z7=d({compaction:f(U7.nullish(),()=>{}),configOptions:f(L7.nullish(),()=>{}),notices:f(q7.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),W7=d({_meta:f(_(h(),w()).nullish(),()=>{})}),G7=d({_meta:f(_(h(),w()).nullish(),()=>{})}),V7=d({terminal:f(ke().optional().default(!1),()=>!1),_meta:f(_(h(),w()).nullish(),()=>{})}),H7=d({_meta:f(_(h(),w()).nullish(),()=>{})}),J7=d({_meta:f(_(h(),w()).nullish(),()=>{})}),K7=d({form:f(H7.nullish(),()=>{}),url:f(J7.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),X7=d({fs:f(M7.optional().default({readTextFile:!1,writeTextFile:!1}),()=>({readTextFile:!1,writeTextFile:!1})),terminal:f(ke().optional().default(!1),()=>!1),session:f(Z7.nullish(),()=>{}),subagents:f(W7.nullish(),()=>{}),plan:f(G7.nullish(),()=>{}),auth:f(V7.optional().default({terminal:!1}),()=>({terminal:!1})),elicitation:f(K7.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),Of=d({protocolVersion:v6,clientCapabilities:f(X7.optional().default({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}}),()=>({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}})),clientInfo:f(C6.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),x6=d({methodId:kf,_meta:f(_(h(),w()).nullish(),()=>{})}),T6=d({_meta:f(_(h(),w()).nullish(),()=>{})}),F6=d({providerId:xf,apiType:Tf,baseUrl:h(),headers:_(h(),h()).optional(),_meta:f(_(h(),w()).nullish(),()=>{})}),P6=d({providerId:xf,_meta:f(_(h(),w()).nullish(),()=>{})}),R6=d({_meta:f(_(h(),w()).nullish(),()=>{})}),z6=d({name:h(),value:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),Y7=d({name:h(),url:h(),headers:Y(z6),_meta:f(_(h(),w()).nullish(),()=>{})}),Q7=d({name:h(),url:h(),headers:Y(z6),_meta:f(_(h(),w()).nullish(),()=>{})}),eF=d({name:h(),serverId:Bf,_meta:f(_(h(),w()).nullish(),()=>{})}),tF=d({name:h(),command:h(),args:Y(h()),env:Y(Y1),_meta:f(_(h(),w()).nullish(),()=>{})}),il=U([Y7.and(d({type:E("http")})),Q7.and(d({type:E("sse")})),eF.and(d({type:E("acp")})),tF]),nF=U([E("append"),E("override"),h()]),ul=d({mode:nF,content:Y(Jn),_meta:f(_(h(),w()).nullish(),()=>{})}),O6=d({cwd:h(),additionalDirectories:Y(h()).optional(),mcpServers:Y(il),systemPrompt:ul.nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),N6=d({mcpServers:Y(il),cwd:h(),additionalDirectories:Y(h()).optional(),sessionId:$e,systemPrompt:ul.nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),M6=d({cwd:h().nullish(),cursor:h().nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),U6=d({sessionId:$e,_meta:f(_(h(),w()).nullish(),()=>{})}),j6=d({sessionId:$e,cwd:h(),additionalDirectories:Y(h()).optional(),mcpServers:Y(il).optional(),systemPrompt:ul.nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),L6=d({sessionId:$e,cwd:h(),additionalDirectories:Y(h()).optional(),mcpServers:Y(il).optional(),systemPrompt:ul.nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),q6=d({sessionId:$e,_meta:f(_(h(),w()).nullish(),()=>{})}),Z6=d({sessionId:$e,modeId:el,_meta:f(_(h(),w()).nullish(),()=>{})}),W6=Xe(U([d({value:ke(),type:E("boolean")}),d({value:Ff})]),d({sessionId:$e,configId:y6,_meta:f(_(h(),w()).nullish(),()=>{})})),G6=d({sessionId:$e,prompt:Y(Jn),_meta:f(_(h(),w()).nullish(),()=>{})}),YZ=d({id:Gn,method:h(),params:U([Of,x6,T6,F6,P6,R6,O6,N6,M6,U6,j6,L6,q6,Z6,W6,G6,g6]).nullish()}),rF=d({_meta:f(_(h(),w()).nullish(),()=>{})}),iF=d({content:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),uF=d({optionId:K1,_meta:f(_(h(),w()).nullish(),()=>{})}),sF=U([d({outcome:E("cancelled")}),uF.and(d({outcome:E("selected")}))]),oF=d({outcome:sF,_meta:f(_(h(),w()).nullish(),()=>{})}),aF=d({terminalId:bi,_meta:f(_(h(),w()).nullish(),()=>{})}),lF=d({exitCode:f(Ke().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),cF=d({output:h(),truncated:ke(),exitStatus:f(lF.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),dF=d({_meta:f(_(h(),w()).nullish(),()=>{})}),hF=d({exitCode:f(Ke().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),fF=d({_meta:f(_(h(),w()).nullish(),()=>{})}),pF=U([h(),se(),se(),ke(),Y(h())]),V6=d({content:_(h(),pF).nullish()}),mF=Oe(Xe(U([V6.and(d({action:E("accept")})),d({action:E("decline")}),d({action:E("cancel")}),ze(d({action:h()}),"action",["accept","cancel","decline"])]),d({_meta:f(_(h(),w()).nullish(),()=>{})})),"action",["accept","cancel","decline"]),gF=Va({code:Ke().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"}),message:h(),data:w().optional()}),vF=U([d({result:w(),_meta:f(_(h(),w()).nullish(),()=>{})}),d({error:gF,_meta:f(_(h(),w()).nullish(),()=>{})})]),QZ=U([d({id:Gn,result:U([rF,iF,oF,aF,cF,dF,hF,fF,mF,vF,w6])}),d({id:Gn,error:nl})]),H6=d({sessionId:$e,_meta:f(_(h(),w()).nullish(),()=>{})}),CF=d({serverId:Bf,requestId:m6,method:h(),params:_(h(),w()).nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),eW=d({method:h(),params:U([H6,CF,k6]).nullish()}),tW=d({requestId:Gn,_meta:f(_(h(),w()).nullish(),()=>{})}),Im="$/cancel_request";function Jr(e){return Mf(e)&&"id"in e&&typeof e.method=="string"&&Uf(e.id)}function Nf(e){if(!Mf(e)||"method"in e||!("id"in e)||!Uf(e.id))return!1;let t=Object.hasOwn(e,"result"),n=Object.hasOwn(e,"error");return t===n?!1:!n||EF(e.error)}function On(e){return Mf(e)&&!("id"in e)&&typeof e.method=="string"}function kr(e){return typeof e=="object"&&e!==null}function Mf(e){return kr(e)&&e.jsonrpc==="2.0"}function Uf(e){return e===null||typeof e=="string"||typeof e=="number"&&Number.isFinite(e)}function vo(e){return kr(e)&&!("method"in e)&&("id"in e||"result"in e||"error"in e)}function J6(e){let t=!1,n=!1,i=!1,r=!1;for(let u of e)t||=Jr(u)||On(u),n||=Nf(u),kr(u)&&(i||="method"in u,r||="result"in u||"error"in u);return t?!1:n?!0:r&&!i}function yF(e){if(!(!kr(e)||!Uf(e.requestId)))return e.requestId}function EF(e){return kr(e)&&typeof e.code=="number"&&Number.isInteger(e.code)&&typeof e.message=="string"}var He={yes(){return{handled:!0}},no(e,t=!1){return{handled:!1,message:e,retry:t}}};function ar(e){let t=Promise.reject(e);return t.catch(()=>{}),t}function wF(e){if(e instanceof Error||typeof e=="object"&&e!=null&&"message"in e&&typeof e.message=="string")return e.message}function _F(e){return typeof e=="object"&&e!==null&&"name"in e&&e.name==="ZodError"&&"issues"in e&&Array.isArray(e.issues)&&"format"in e&&typeof e.format=="function"}function K6(e){if(e instanceof k)return e.toResult();if(_F(e))return k.invalidParams(e.format()).toResult();let t=wF(e);try{return k.internalError(t?JSON.parse(t):{}).toResult()}catch{return k.internalError({details:t}).toResult()}}function AF(e){return e instanceof k&&e.code===-32800?e:k.requestCancelled(e)}function bF(e,t){let n=SF(e,t);return n?n.toResult():K6(e)}function SF(e,t){if(!(!t.aborted||!DF(e)))return AF(t.reason)}function DF(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.name==="AbortError"||t.code==="ABORT_ERR"}var IF=class{id;sendResult;signal;finishRequest;didRespond=!1;constructor(e,t,n=new AbortController().signal,i){this.id=e,this.sendResult=t,this.signal=n,this.finishRequest=i}get responded(){return this.didRespond}respond(e){return this.respondWithResult({result:e??null})}respondWithError(e){let t=e instanceof k?e.toErrorResponse():e;return this.respondWithResult({error:t})}respondWithResult(e){return this.didRespond?ar(new Error("JSON-RPC request already responded")):(this.didRespond=!0,this.sendResult(e).finally(()=>{this.finishRequest?.()}))}},X6=new WeakMap;function $F(e){return X6.get(e)}var Ku=class{disposeHandler;active=!0;constructor(e){this.disposeHandler=e}dispose(){this.active&&(this.active=!1,this.disposeHandler())}[Symbol.dispose](){this.dispose()}runIndefinitely(){return this}},BF=class{connection;constructor(e){this.connection=e}sendRequest(e,t,n,i){return this.connection.sendRequest(e,t,n,i)}sendNotification(e,t){return this.connection.sendNotification(e,t)}sendBatch(e){return this.connection.sendBatch(e)}sendCancelRequest(e){return this.connection.sendCancelRequest(e)}addDynamicHandler(e){return this.connection.addDynamicHandler(e)}get signal(){return this.connection.signal}get closed(){return this.connection.closed}},Xu=class{pendingResponses=new Map;incomingRequests=new Map;nextRequestId=0;staticHandlers=[];dynamicHandlers=new Set;fallbackHandlers=[];stream;writeQueue=Promise.resolve();abortController=new AbortController;closedPromise;retryQueue=[];context=new BF(this);receiveReader;allowBatches=!0;constructor(e,t,n,i){if(typeof e=="function"){let o=e,a=t,l=n;this.initialize(l,[...i?.handlers??[],this.legacyHandler(o,a)],i);return}let r=e,u=t,s=n;this.initialize(r,[...s?.handlers??[],...u],s)}static builder(){return new kF}runUntil(e){let t=!1,n=Promise.resolve().then(()=>e(this.context)).finally(()=>{t=!0}),i=this.closed.then(()=>{if(t)return new Promise(()=>{});throw this.closedReason()});return Promise.race([n,i]).finally(()=>{t=!0,this.close()})}addDynamicHandler(e){if(this.dynamicHandlers.add(e),this.retryQueue.length>0)for(let t of this.retryQueue.splice(0))this.processIncomingMessage(t).catch(n=>this.close(n));return new Ku(()=>{this.dynamicHandlers.delete(e)})}get signal(){return this.abortController.signal}get closed(){return this.closedPromise}getContext(){return this.context}sendRequest(e,t,n,i={}){if(this.abortController.signal.aborted)return ar(this.closedReason());let r=this.prepareRequest(e,t,n,i);return this.sendWireMessage(r.message).catch(()=>{}),i.cancellationSignal?.aborted&&r.cancel(),r.response}sendBatch(e){if(this.abortController.signal.aborted)return ar(this.closedReason());if(!this.allowBatches)return ar(new TypeError("JSON-RPC batches are not supported on this connection"));if(e.length===0)return ar(new TypeError("JSON-RPC batch must contain at least one entry"));let t=[],n=[],i=[];for(let o of e){if(o.kind==="notification"){t.push({jsonrpc:"2.0",method:o.method,params:o.params}),i.push(Promise.resolve(void 0));continue}let a=this.prepareRequest(o.method,o.params,o.mapResponse,o.options);t.push(a.message),i.push(a.response),n.push({signal:o.options?.cancellationSignal,cancel:a.cancel})}let r=t,u=this.sendWireMessage(r);for(let o of n)o.signal?.aborted&&o.cancel();let s=Promise.all([u,...i]).then(([,...o])=>o);return s.catch(()=>{}),s}sendCancelRequest(e){return this.sendNotification(Im,{requestId:e})}sendNotification(e,t){return this.abortController.signal.aborted?ar(this.closedReason()):this.sendWireMessage({jsonrpc:"2.0",method:e,params:t})}prepareRequest(e,t,n,i={}){let r=this.nextRequestId++,u=()=>{},s=new Promise((o,a)=>{let l={resolve:c=>{try{o(n?n(c):c)}catch(m){a(m)}},reject:a};u=()=>{l.cancellationSent||(l.cancellationSent=!0,l.cleanup?.(),this.sendCancelRequest(r).catch(()=>{}))},i.cancellationSignal?.addEventListener("abort",u,{once:!0}),l.cleanup=()=>{i.cancellationSignal?.removeEventListener("abort",u)},this.pendingResponses.set(r,l)});return s.catch(()=>{}),{message:{jsonrpc:"2.0",id:r,method:e,params:t},response:s,cancel:()=>u()}}close(e){if(this.abortController.signal.aborted)return;let t=e??new Error("ACP connection closed");this.abortController.abort(t);for(let n of this.pendingResponses.values())n.cleanup?.(),n.reject(t);this.pendingResponses.clear();for(let n of this.incomingRequests.values())n.abort(t);this.incomingRequests.clear(),this.receiveReader?.cancel(t).catch(()=>{})}initialize(e,t,n){this.stream=e,this.staticHandlers=t,this.fallbackHandlers=[...n?.fallbackHandlers??[]],this.allowBatches=n?.allowBatches??!0,this.closedPromise=new Promise(i=>{this.abortController.signal.addEventListener("abort",()=>i())}),this.receive()}legacyHandler(e,t){return{handleMessage:async(n,i)=>{if(n.kind==="request"){let r=await e(n.method,n.params,i);await n.responder.respond(r)}else await t(n.method,n.params,i);return He.yes()}}}async receive(){let e;try{let t=this.stream.readable.getReader();this.receiveReader=t;try{for(;!this.abortController.signal.aborted;){let{value:n,done:i}=await t.read();if(this.abortController.signal.aborted||i)break;this.receiveWireMessage(n)}}finally{this.receiveReader===t&&(this.receiveReader=void 0),t.releaseLock()}}catch(t){e=t}finally{this.close(e)}}receiveWireMessage(e){if(Array.isArray(e)){if(!this.allowBatches){this.close(new TypeError("JSON-RPC batches are not supported on this connection"));return}this.receiveBatch(e);return}if(!Jr(e)&&!On(e)&&!vo(e)){this.sendWireMessage(Yi(k.invalidRequest(e))).catch(()=>{});return}this.receiveMessage(e)}receiveBatch(e){if(e.length===0){this.sendWireMessage(Yi(k.invalidRequest(e))).catch(()=>{});return}let t=J6(e),i=t?0:e.reduce((l,c)=>l+(On(c)?0:1),0),r=e.reduce((l,c)=>l+(On(c)?1:0),0),u=!1,s=[],o=async()=>{u||i!==0||r!==0||s.length===0||(u=!0,await this.sendWireMessage(s))},a=async l=>{s.push(l),i-=1,await o()};for(let l of e){if(t){vo(l)&&this.receiveMessage(l);continue}if(!Jr(l)&&!On(l)){a(Yi(k.invalidRequest(l))).catch(()=>{});continue}let c=this.receiveMessage(l,Jr(l)?a:void 0,e.length);On(l)&&c.finally(()=>{r-=1,o().catch(m=>this.close(m))})}}receiveMessage(e,t,n){return this.abortController.signal.aborted?Promise.resolve():kr(e)?"method"in e?("id"in e||this.handleProtocolNotification(e),this.processIncomingMessage(this.toIncomingMessage(e,t,n)).catch(i=>this.close(i))):("id"in e?this.handleResponse(e):console.error("Invalid message",{message:e}),Promise.resolve()):(console.error("Invalid message",{message:e}),Promise.resolve())}async processIncomingMessage(e){if(this.abortController.signal.aborted)return;let t=e,n=!1;try{for(let i of[...this.staticHandlers,...this.dynamicHandlers.values(),...this.fallbackHandlers]){if(this.abortController.signal.aborted)return;let r=await i.handleMessage(t,this.context)??{handled:!0};if(r.handled)return;t=r.message??t,n=n||!!r.retry}n?this.retryQueue.push(t):t.kind==="request"&&await t.responder.respondWithError(k.methodNotFound(t.method))}catch(i){if(this.abortController.signal.aborted)return;if(t.kind==="request"&&!t.responder.responded)await t.responder.respondWithResult(bF(i,t.responder.signal));else{let r=K6(i);"error"in r&&console.error("Error handling notification",e.raw,r.error)}}}toIncomingMessage(e,t,n){if("id"in e){let i=new AbortController;this.incomingRequests.set(e.id,i);let r=()=>{this.incomingRequests.get(e.id)===i&&this.incomingRequests.delete(e.id)},u=new IF(e.id,s=>{let o={jsonrpc:"2.0",id:e.id,...s};return t?t(o):this.sendWireMessage(o)},i.signal,r);return n!==void 0&&X6.set(u,n),{kind:"request",method:e.method,params:e.params,raw:e,signal:i.signal,responder:u}}return{kind:"notification",method:e.method,params:e.params,raw:e}}handleResponse(e){let t=this.pendingResponses.get(e.id);if(t)if(this.pendingResponses.delete(e.id),t.cleanup?.(),!Nf(e))t.reject(k.invalidRequest(e));else if("result"in e)t.resolve(e.result);else{let{code:n,message:i,data:r}=e.error;t.reject(new k(n,i,r))}else console.error("Got response to unknown request",e.id)}handleProtocolNotification(e){if(e.method!==Im)return;let t=yF(e.params);if(t===void 0)return;let n=this.incomingRequests.get(t);!n||n.signal.aborted||n.abort(k.requestCancelled({requestId:t}))}closedReason(){return this.abortController.signal.reason??new Error("ACP connection closed")}async sendWireMessage(e){return this.abortController.signal.aborted?ar(this.closedReason()):(this.writeQueue=this.writeQueue.then(async()=>{if(this.abortController.signal.aborted)throw this.closedReason();let t=this.stream.writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{throw this.close(t),t}),this.writeQueue)}},kF=class{handlers=[];fallbackHandlers=[];connectionName;name(e){return this.connectionName=e,this}withHandler(e){return this.handlers.push(e),this}withFallbackHandler(e){return this.fallbackHandlers.push(e),this}onReceiveMessage(e){return this.withHandler({handleMessage:async(t,n)=>await e(t,n)??He.no(t),describe:()=>this.connectionName??"onReceiveMessage"})}onReceiveRequest(e,t,n){return this.withHandler({handleMessage:async(i,r)=>{if(i.kind!=="request"||i.method!==e)return He.no(i);let u=t(i.params);return await n(u,i.responder,r)??He.yes()},describe:()=>`${this.connectionName??"request"}:${e}`})}onReceiveNotification(e,t,n){return this.withHandler({handleMessage:async(i,r)=>{if(i.kind!=="notification"||i.method!==e)return He.no(i);let u=t(i.params);return await n(u,r)??He.yes()},describe:()=>`${this.connectionName??"notification"}:${e}`})}connect(e,t){return new Xu(e,this.handlers,{...t,fallbackHandlers:[...t?.fallbackHandlers??[],...this.fallbackHandlers]})}connectWith(e,t,n){return this.connect(e,n).runUntil(t)}},k=class en extends Error{code;data;constructor(t,n,i){super(n),this.code=t,this.name="RequestError",this.data=i}static parseError(t,n){return new en(-32700,`Parse error${n?`: ${n}`:""}`,t)}static invalidRequest(t,n){return new en(-32600,`Invalid request${n?`: ${n}`:""}`,t)}static methodNotFound(t){return new en(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,n){return new en(-32602,`Invalid params${n?`: ${n}`:""}`,t)}static internalError(t,n){return new en(-32603,`Internal error${n?`: ${n}`:""}`,t)}static requestCancelled(t,n){return new en(-32800,`Request cancelled${n?`: ${n}`:""}`,t)}static authRequired(t,n){return new en(-32e3,`Authentication required${n?`: ${n}`:""}`,t)}static resourceNotFound(t){return new en(-32002,`Resource not found${t?`: ${t}`:""}`,t&&{uri:t})}static unsupportedProtocolVersion(t,n){return new en(-32022,"Unsupported protocol version",{requested:t,supported:[...n]})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}};function Yi(e){return{jsonrpc:"2.0",id:null,error:e.toErrorResponse()}}var xF=32*1024*1024,Y6=class extends Error{maxMessageBytes;constructor(e){super(`Incoming ACP data exceeds the configured ${e} byte limit`),this.maxMessageBytes=e,this.name="MessageTooLargeError"}};function jf(e){let t=e??xF;if(!Number.isSafeInteger(t)||t<=0)throw new RangeError("maxMessageBytes must be a positive safe integer");return t}var TF=class{#e=new Uint8Array(0);#t=0;#n;constructor(e){this.#n=jf(e)}get byteLength(){return this.#t}get lastByte(){return this.#e[this.#t-1]}#r(e){if(e>this.#n-this.#t)throw this.clear(),new Y6(this.#n)}append(e){this.#r(e.byteLength);let t=this.#t+e.byteLength;if(t>this.#e.byteLength){let n=Math.min(this.#n,Math.max(t,this.#e.byteLength*2,1024)),i=new Uint8Array(n);i.set(this.#e.subarray(0,this.#t)),this.#e=i}this.#e.set(e,this.#t),this.#t=t}take(){let e=this.#e.subarray(0,this.#t);return this.clear(),e}clear(){this.#e=new Uint8Array(0),this.#t=0}},Oi=10,Fs=13,FF=class{#e;#t;#n;#r=!1;constructor(e,{splitOnCarriageReturn:t=!1}={}){this.#t=jf(e),this.#e=new TF(Math.min(Number.MAX_SAFE_INTEGER,this.#t+1)),this.#n=t}*push(e){let t=0;this.#r&&e.byteLength>0&&(this.#r=!1,e[0]===Oi&&(t=1));let n=e.indexOf(Oi,t),i=this.#n?e.indexOf(Fs,t):-1;for(;n!==-1||i!==-1;)i===-1||n!==-1&&n<i?(yield this.#i(e.subarray(t,n)),t=n+1,n=e.indexOf(Oi,t)):(yield this.#i(e.subarray(t,i)),t=i+1,t===e.byteLength?this.#r=!0:e[t]===Oi&&(t++,n=e.indexOf(Oi,t)),i=e.indexOf(Fs,t));if(t<e.byteLength){let r=e.subarray(t);this.#u(r),this.#e.append(r)}}flush(){if(this.#r=!1,this.#e.byteLength!==0)return Nl(this.#e.take())}clear(){this.#r=!1,this.#e.clear()}#i(e){return this.#u(e),this.#e.byteLength===0?Nl(e):(this.#e.append(e),Nl(this.#e.take()))}#u(e){let t=e.byteLength>0?e[e.byteLength-1]:this.#e.lastByte;if(this.#e.byteLength+e.byteLength-(t===Fs?1:0)>this.#t)throw this.clear(),new Y6(this.#t)}};function Nl(e){return e[e.byteLength-1]===Fs?e.subarray(0,-1):e}function PF(e,t,n={}){let i=jf(n.maxMessageBytes),r=new TextEncoder,u=new TextDecoder,s=!1,o,a=Promise.resolve(),l=p=>{let v=JSON.stringify(p)+`
|
|
70
|
+
`,g=a.then(async()=>{let C=e.getWriter();try{await C.write(r.encode(v))}finally{C.releaseLock()}});return a=g.catch(()=>{}),g},c=new ReadableStream({async start(p){let v=new FF(i),g=async y=>{let b=u.decode(y).trim();if(!b)return;let A;try{A=JSON.parse(b)}catch{await l(Yi(k.parseError()));return}kr(A)||Array.isArray(A)?p.enqueue(A):await l(Yi(k.invalidRequest(A)))},C=t.getReader();o=C;try{for(;;){let{value:b,done:A}=await C.read();if(s)return;if(A)break;if(b){for(let S of v.push(b))if(await g(S),s)return}}if(s)return;let y=v.flush();y&&await g(y)}catch(y){if(s)return;p.error(y),C.cancel(y).catch(()=>{});return}finally{v.clear(),o===C&&(o=void 0),C.releaseLock()}s||p.close()},cancel(p){return s=!0,o?.cancel(p)}}),m=new WritableStream({write(p){return l(p)}});return{readable:c,writable:m}}function Cs(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}var nW=d6.and(d({mode:E("form")})).and(d({message:h()})),rW=f6.and(d({mode:E("url")})).and(d({message:h()})),iW=U([Ya,Qa]).and(d({message:h()})),uW=u6.and(d({type:E("string")})),sW=s6.and(d({type:E("number")})),oW=o6.and(d({type:E("integer")})),aW=a6.and(d({type:E("boolean")})),lW=c6.and(d({type:E("array")})),cW=l6.and(d({type:E("string")})),dW=b6.and(d({state:E("running")})),hW=D6.and(d({usage:Pf.nullish()})).and(d({state:E("idle")})),fW=I6.and(d({state:E("requires_action")})),pW=$6.and(d({state:E("unknown")})),mW=d({stopReason:E("end_turn")}),gW=d({stopReason:E("max_tokens")}),vW=d({stopReason:E("max_turn_requests")}),CW=d({stopReason:E("refusal")}),yW=d({stopReason:E("cancelled")}),EW=S6.and(d({error:nl.nullish()})).and(d({stopReason:E("error")})),wW=d({stopReason:Br().optional()}),RF=V6.and(d({action:E("accept")})),zF=d({action:E("decline")}),OF=d({action:E("cancel")}),cr={isAccept(e){return Cs(e,"action")==="accept"&&RF.safeParse(e).success},isDecline(e){return Cs(e,"action")==="decline"&&zF.safeParse(e).success},isCancel(e){return Cs(e,"action")==="cancel"&&OF.safeParse(e).success},isCustom(e){let t=Cs(e,"action");return typeof t=="string"&&!["accept","cancel","decline"].includes(t)}};function Yu(e,t){return e?typeof e=="function"?e(t):e.parse(t):t}function sl(e,t,n,i,r,u){let s=async(o,a,l,c)=>{try{let m=await i(n(o,l,a.signal,a.id,c)),p=r?r(m):m;await a.respond(p),u?.afterResponse(o,p,l)}catch(m){throw u?.onError(l,m),m}};t.method==="*"?e.withFallbackHandler({handleMessage:async(o,a)=>o.kind!=="request"?He.no(o):(await s(o.params,o.responder,a,o.method),He.yes())}):e.onReceiveRequest(t.method,o=>Yu(t.params,o),(o,a,l)=>s(o,a,l,t.method))}function ol(e,t,n,i){t.method==="*"?e.withFallbackHandler({handleMessage:async(r,u)=>r.kind!=="notification"?He.no(r):(await i(n(r.params,u,u.signal,r.method)),He.yes())}):e.onReceiveNotification(t.method,r=>Yu(t.params,r),(r,u)=>i(n(r,u,u.signal,t.method)))}function NF(e,t,n){return PF(e,t,n)}function bt(e){return e??{}}function Q6(e){return typeof e=="object"&&e!==null&&"readable"in e&&"writable"in e}function e_(){let e=new TransformStream,t=new TransformStream;return[{readable:t.readable,writable:e.writable},{readable:e.readable,writable:t.writable}]}var ae={agent:{initialize:pe.initialize,authenticate:pe.authenticate,logout:pe.logout,providers:{list:pe.providers_list,set:pe.providers_set,disable:pe.providers_disable},session:{new:pe.session_new,load:pe.session_load,list:pe.session_list,delete:pe.session_delete,fork:pe.session_fork,resume:pe.session_resume,close:pe.session_close,setMode:pe.session_set_mode,setConfigOption:pe.session_set_config_option,prompt:pe.session_prompt,cancel:pe.session_cancel}},client:{session:{requestPermission:De.session_request_permission,update:De.session_update},fs:{writeTextFile:De.fs_write_text_file,readTextFile:De.fs_read_text_file},terminal:{create:De.terminal_create,output:De.terminal_output,release:De.terminal_release,waitForExit:De.terminal_wait_for_exit,kill:De.terminal_kill},elicitation:{create:De.elicitation_create,complete:De.elicitation_complete}},protocol:{cancelRequest:GI.cancel_request}},t_=Symbol("startActiveSession"),n_=class{cx;currentRequestId;constructor(e,t){this.cx=e,this.currentRequestId=t}get requestId(){return this.currentRequestId}get connectionContext(){return this.cx}sendRequest(e,t,n,i){return this.cx.sendRequest(e,t,n,i)}sendNotification(e,t){return this.cx.sendNotification(e,t)}addDynamicHandler(e){return this.cx.addDynamicHandler(e)}},jc=class r_ extends n_{constructor(t,n){super(t,n)}static create(t,n){return new r_(t,n)}async createTerminal(t,n){let i=await this.request(De.terminal_create,t,n);return nP.create(i.terminalId,t.sessionId,this.connectionContext)}request(t,n,i){let r=d_[t];return this.sendRequest(t,n,r?.mapResponse,i)}notify(t,n){return this.sendNotification(t,n)}},Lc=class i_ extends n_{constructor(t,n){super(t,n)}static create(t,n){return new i_(t,n)}[t_](t,n){return this.sendRequest(pe.session_new,t,i=>this.attachSession(i),n)}buildSession(t){return typeof t=="string"?Bm.create(this,{cwd:t,mcpServers:[]}):Bm.create(this,t)}attachSession(t){let n=new jF,i=this.connectionContext.signal,r=()=>{n.fail(i.reason??new Error("ACP connection closed"))};i.aborted?r():i.addEventListener("abort",r);let u=h_(this.connectionContext).attach(t,n),s=new Ku(()=>{i.removeEventListener("abort",r)});return LF.create(this,t,n,[u,s])}request(t,n,i){let r=c_[t];return this.sendRequest(t,n,r?.mapResponse,i)}notify(t,n){return this.sendNotification(t,n)}},u_=class{connection;constructor(e){this.connection=e}get signal(){return this.connection.signal}get closed(){return this.connection.closed}close(e){this.connection.close(e)}},MF=class extends u_{connectHandlers;client;didStartConnectHandlers=!1;constructor(e,t=[]){super(e),this.connectHandlers=t,this.client=jc.create(e.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,ll(this,this.connectHandlers))}},UF=class extends u_{connectHandlers;agent;didStartConnectHandlers=!1;constructor(e,t=[]){super(e),this.connectHandlers=t,this.agent=Lc.create(e.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,ll(this,this.connectHandlers))}};function s_(e,t=[]){return new MF(e,t)}function o_(e,t=[]){return new UF(e,t)}var jF=class{values=[];waiters=[];failed=!1;failure;enqueue(e){if(this.failed)return;let t=this.waiters.shift();t?t.resolve(e):this.values.push({kind:"value",value:e})}reject(e){if(!this.failed){if(this.waiters.length>0){for(let t of this.waiters.splice(0))t.reject(e);return}this.values.push({kind:"error",error:e})}}clearErrors(){this.values=this.values.filter(e=>e.kind==="value")}fail(e){if(!this.failed){this.failed=!0,this.failure=e;for(let t of this.waiters.splice(0))t.reject(e)}}next(){if(this.values.length>0){let e=this.values.shift();return e.kind==="error"?Promise.reject(e.error):Promise.resolve(e.value)}return this.failed?Promise.reject(this.failure):new Promise((e,t)=>{this.waiters.push({resolve:e,reject:t})})}};function $m(e){return{...e,additionalDirectories:e.additionalDirectories?[...e.additionalDirectories]:void 0,mcpServers:[...e.mcpServers]}}var Bm=class a_{cx;request;constructor(t,n){this.cx=t,this.request=$m(n)}static create(t,n){return new a_(t,n)}toRequest(){return $m(this.request)}withAdditionalDirectories(t){return this.request={...this.request,additionalDirectories:[...t]},this}withMcpServer(t){return this.request={...this.request,mcpServers:[...this.request.mcpServers,t]},this}async start(t){return this.cx[t_](this.toRequest(),t)}async withSession(t){let n=await this.start();try{return await t(n)}finally{n.dispose()}}},LF=class l_{cx;sessionResponse;updates;registrations;constructor(t,n,i,r){this.cx=t,this.sessionResponse=n,this.updates=i,this.registrations=r}static create(t,n,i,r){return new l_(t,n,i,r)}get sessionId(){return this.sessionResponse.sessionId}get modes(){return this.sessionResponse.modes}get meta(){return this.sessionResponse._meta}get newSessionResponse(){return this.sessionResponse}prompt(t,n){this.updates.clearErrors();let i=this.cx.request(pe.session_prompt,{sessionId:this.sessionId,prompt:this.promptBlocks(t)},n);return i.then(r=>{this.updates.enqueue({kind:"stop",response:r,stopReason:r.stopReason})},r=>{this.updates.reject(r)}),i}nextUpdate(){return this.updates.next()}async readText(){let t="";for(;;){let n=await this.nextUpdate();if(n.kind==="stop")return t;let{update:i}=n;i.sessionUpdate==="agent_message_chunk"&&i.content.type==="text"&&(t+=i.content.text)}}dispose(){for(let t of this.registrations.splice(0))t.dispose();this.updates.fail(new Error("Active session disposed"))}[Symbol.dispose](){this.dispose()}promptBlocks(t){return typeof t=="string"?[{type:"text",text:t}]:Array.isArray(t)?t:[t]}};function Te(e,t,n){return{method:e,params:i=>Yu(t,i??{}),mapResponse:n}}function qc(e,t){return{method:e,params:t}}function al(e){let t={};for(let n of Object.values(e))t[n.method]=n;return t}var qF={initialize:Te(pe.initialize,Of),newSession:Te(pe.session_new,O6),loadSession:Te(pe.session_load,N6,bt),unstable_forkSession:Te(pe.session_fork,j6),listSessions:Te(pe.session_list,M6),deleteSession:Te(pe.session_delete,U6,bt),resumeSession:Te(pe.session_resume,L6),closeSession:Te(pe.session_close,q6,bt),setSessionMode:Te(pe.session_set_mode,Z6,bt),setSessionConfigOption:Te(pe.session_set_config_option,W6),authenticate:Te(pe.authenticate,x6,bt),unstable_listProviders:Te(pe.providers_list,T6),unstable_setProvider:Te(pe.providers_set,F6,bt),unstable_disableProvider:Te(pe.providers_disable,P6,bt),logout:Te(pe.logout,R6,bt),prompt:Te(pe.session_prompt,G6)},ZF={cancel:qc(pe.session_cancel,H6)},WF={requestPermission:Te(De.session_request_permission,X1),writeTextFile:Te(De.fs_write_text_file,q1,bt),readTextFile:Te(De.fs_read_text_file,Z1),createTerminal:Te(De.terminal_create,Q1),terminalOutput:Te(De.terminal_output,e6),releaseTerminal:Te(De.terminal_release,t6,bt),waitForTerminalExit:Te(De.terminal_wait_for_exit,n6),killTerminal:Te(De.terminal_kill,r6,bt),createElicitation:Te(De.elicitation_create,p6)},GF={sessionUpdate:qc(De.session_update,zf),completeElicitation:qc(De.elicitation_complete,B6)},c_=al(qF),VF=al(ZF),d_=al(WF),HF=al(GF);function JF(e,t,n,i,r){return{method:r,params:e,requestId:i,signal:n,client:t}}function KF(e,t,n,i){return{method:i,params:e,signal:n,client:t}}function XF(e,t,n,i,r){return{method:r,params:e,requestId:i,signal:n,agent:t}}function YF(e,t,n,i){return{method:i,params:e,signal:n,agent:t}}var QF=class{activeSessions=new Map;handleMessage(e){if(e.kind!=="notification"||e.method!==De.session_update)return He.no(e);let t=zf.parse(e.params),n={kind:"session_update",notification:t,update:t.update},i=this.activeSessions.get(t.sessionId);if(i&&i.size>0)for(let r of i)r.enqueue(n);return He.no(e)}attach(e,t){let n=this.activeSessions.get(e.sessionId)??new Set;return n.add(t),this.activeSessions.set(e.sessionId,n),new Ku(()=>{n.delete(t),n.size===0&&this.activeSessions.delete(e.sessionId)})}},km=new WeakMap;function h_(e){let t=km.get(e);return t||(t=new QF,km.set(e,t)),t}function ll(e,t){for(let n of t){let i;try{i=n(e)}catch(r){throw e.close(r),r}Promise.resolve(i).catch(r=>{e.close(r)})}}var Co=Symbol("appBuilder"),Ps=Symbol("runAgentConnectHandlers"),Rs=Symbol("runClientConnectHandlers"),yo={allowBatches:!1};function eP(e){return new tP(e)}var tP=class{builder=Xu.builder();connectHandlers=[];fallbackKinds=new Set;constructor(e={}){e.name&&this.builder.name(e.name)}[Co](){return this.builder}[Ps](e){ll(e,this.connectHandlers)}connect(e,t={}){return this.connectConnection(e,t).connection}connectWith(e,t){let{rawConnection:n,connection:i}=this.connectConnection(e);return n.runUntil(()=>t(i.client))}onConnect(e){return this.connectHandlers.push(e),this}onRequest(e,t,n){if(e==="*"){if(n)throw new Error("Wildcard handlers receive raw params; omit the parser.");if(this.fallbackKinds.has("request"))throw new Error("A request fallback is already registered.");return this.fallbackKinds.add("request"),this.request({method:e},t)}if(n)return this.request({method:e,params:t},n);let i=c_[e];if(!i)throw new Error(`Unknown ACP request method '${e}'. Pass a params parser for custom methods.`);return this.request(i,t)}onNotification(e,t,n){if(e==="*"){if(n)throw new Error("Wildcard handlers receive raw params; omit the parser.");if(this.fallbackKinds.has("notification"))throw new Error("A notification fallback is already registered.");return this.fallbackKinds.add("notification"),this.notification({method:e},t)}if(n)return this.notification({method:e,params:t},n);let i=VF[e];if(!i)throw new Error(`Unknown ACP notification method '${e}'. Pass a params parser for custom methods.`);return this.notification(i,t)}request(e,t){return sl(this.builder,e,(n,i,r,u,s)=>JF(n,jc.create(i,u),r,u,s),t,e.mapResponse),this}notification(e,t){return ol(this.builder,e,(n,i,r,u)=>KF(n,jc.create(i),r,u),t),this}connectConnection(e,t={}){if(Q6(e)){let o=this.openStreamConnection(e);return t.deferConnectHandlers||this[Ps](o.connection),o}let[n,i]=e_(),r=e[Co]().connect(i,yo),u=o_(r),s=this.openStreamConnection(n);s.rawConnection.closed.then(()=>u.close()),r.closed.then(()=>s.connection.close());try{e[Rs](u),this[Ps](s.connection)}catch(o){throw u.close(o),s.connection.close(o),o}return s}openStreamConnection(e){let t=this.builder.connect(e,yo);return{rawConnection:t,connection:s_(t,this.connectHandlers)}}},_W=class{builder=Xu.builder();connectHandlers=[];fallbackKinds=new Set;constructor(e={}){e.name&&this.builder.name(e.name),this.builder.withHandler({handleMessage:(t,n)=>h_(n).handleMessage(t),describe:()=>"client-session-update-router"})}[Co](){return this.builder}[Rs](e){ll(e,this.connectHandlers)}connect(e){return this.connectConnection(e).connection}connectWith(e,t){let{rawConnection:n,connection:i}=this.connectConnection(e);return n.runUntil(()=>t(i.agent))}onConnect(e){return this.connectHandlers.push(e),this}onRequest(e,t,n){if(e==="*"){if(n)throw new Error("Wildcard handlers receive raw params; omit the parser.");if(this.fallbackKinds.has("request"))throw new Error("A request fallback is already registered.");return this.fallbackKinds.add("request"),this.request({method:e},t)}if(n)return this.request({method:e,params:t},n);let i=d_[e];if(!i)throw new Error(`Unknown ACP request method '${e}'. Pass a params parser for custom methods.`);return this.request(i,t)}onNotification(e,t,n){if(e==="*"){if(n)throw new Error("Wildcard handlers receive raw params; omit the parser.");if(this.fallbackKinds.has("notification"))throw new Error("A notification fallback is already registered.");return this.fallbackKinds.add("notification"),this.notification({method:e},t)}if(n)return this.notification({method:e,params:t},n);let i=HF[e];if(!i)throw new Error(`Unknown ACP notification method '${e}'. Pass a params parser for custom methods.`);return this.notification(i,t)}request(e,t){return sl(this.builder,e,(n,i,r,u,s)=>XF(n,Lc.create(i,u),r,u,s),t,e.mapResponse),this}notification(e,t){return ol(this.builder,e,(n,i,r,u)=>YF(n,Lc.create(i),r,u),t),this}connectConnection(e){if(Q6(e)){let s=this.openStreamConnection(e);return this[Rs](s.connection),s}let[t,n]=e_(),i=e[Co]().connect(n,yo),r=s_(i),u=this.openStreamConnection(t);u.rawConnection.closed.then(()=>r.close()),i.closed.then(()=>u.connection.close());try{e[Ps](r),this[Rs](u.connection)}catch(s){throw r.close(s),u.connection.close(s),s}return u}openStreamConnection(e){let t=this.builder.connect(e,yo);return{rawConnection:t,connection:o_(t,this.connectHandlers)}}},nP=class f_{id;sessionId;connection;constructor(t,n,i){this.id=t,this.sessionId=n,this.connection=i}static create(t,n,i){return new f_(t,n,i)}currentOutput(){return this.connection.sendRequest(De.terminal_output,{sessionId:this.sessionId,terminalId:this.id})}waitForExit(){return this.connection.sendRequest(De.terminal_wait_for_exit,{sessionId:this.sessionId,terminalId:this.id})}kill(){return this.connection.sendRequest(De.terminal_kill,{sessionId:this.sessionId,terminalId:this.id},bt)}release(){return this.connection.sendRequest(De.terminal_release,{sessionId:this.sessionId,terminalId:this.id},bt)}async[Symbol.asyncDispose](){await this.release()}},iP=class{logFilePath;constructor(){let e=process.env.APP_SERVER_LOGS;if(!e){this.logFilePath=null;return}try{xm.mkdirSync(e,{recursive:!0}),this.logFilePath=rP.join(e,"app-server.log"),this.log("Logger initialized",{logFilePath:this.logFilePath})}catch(t){console.error("Failed to initialize logger directory",t),this.logFilePath=null}}get enabled(){return this.logFilePath!==null}error(e,t){let n=this.formatError(t);if(!this.logFilePath){console.error(`[SYSTEM_ERROR] ${e}: ${n}`);return}this.log(`[SYSTEM_ERROR] ${e}`,{exception:n})}log(e,t){if(this.logFilePath)try{let n=this.formatTimestamp(new Date),i=` ${JSON.stringify({pid:process.pid,...t})}`;e.startsWith("[")||(e=`[SYS] ${e}`);let r=`${n} ${e}${i}`;xm.appendFileSync(this.logFilePath,`${r}
|
|
71
|
+
`)}catch(n){console.error("Logger write failed",n)}}formatTimestamp(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),r=String(e.getHours()).padStart(2,"0"),u=String(e.getMinutes()).padStart(2,"0"),s=String(e.getSeconds()).padStart(2,"0"),o=String(e.getMilliseconds()).padStart(3,"0");return`${t}-${n}-${i} ${r}:${u}:${s},${o}`}formatError(e){if(e instanceof Error){let t=[`${e.name}: ${e.message}`];return e.stack&&t.push(e.stack),"cause"in e&&e.cause&&t.push(`Caused by: ${this.formatError(e.cause)}`),t.join(`
|
|
72
|
+
`)}return typeof e=="string"?e:String(e)}},D=new iP;function uP(e){return{async write(t){try{t&&typeof t=="object"&&(t={...t},delete t.jsonrpc),e.write(JSON.stringify(t)+`
|
|
73
|
+
`)}catch{}},end(){e.end()},onError:new Vi.Emitter().event,onClose:new Vi.Emitter().event,dispose(){}}}function sP(e){let t=null;return{deliver(n){t?.(n)},listen(n){t=n;let i=o=>{let a=o.trim();if(!a)return;let l;try{l=JSON.parse(a)}catch(c){D.error(`Dropped a Codex app-server line that is not JSON (${a.length} chars)`,c);return}l&&typeof l=="object"&&l.jsonrpc===void 0&&(l.jsonrpc="2.0"),n(l)},r=new lP(i),u=o=>r.push(o),s=()=>r.end();return e.on("data",u),e.on("end",s),{dispose(){e.off("data",u),e.off("end",s)}}},onError:new Vi.Emitter().event,onClose:new Vi.Emitter().event,onPartialMessage:new Vi.Emitter().event,dispose(){}}}function oP(e,t){let n=aP(t),i=new WritableStream({write:o=>n(o)}),r=WI.toWeb(e),u=NF(i,r),s=new WritableStream({write:o=>n(JSON.stringify(o)+`
|
|
74
|
+
`)});return{readable:u.readable,writable:s}}function aP(e){let t,n=new Set,i=ZI(e,u=>{i(),e.on("error",()=>{}),e.off("drain",r),t=u??new Error("The output stream ended");for(let s of n)s.reject(t);n.clear()}),r=()=>{for(let u of n)u.resolve();n.clear()};return e.on("drain",r),u=>t!==void 0?Promise.reject(t):e.write(u)?Promise.resolve():new Promise((s,o)=>n.add({resolve:s,reject:o}))}var lP=class{constructor(e){this.onLine=e}onLine;decoder=new qI("utf8");parts=[];push(e){let t=this.decoder.write(e),n=0;for(let i=t.indexOf(`
|
|
75
|
+
`);i>=0;i=t.indexOf(`
|
|
76
|
+
`,n)){this.parts.push(t.slice(n,i));let r=this.parts.join("");this.parts=[],n=i+1,this.onLine(r)}n<t.length&&this.parts.push(t.slice(n))}end(){let e=this.decoder.end();if(e.length>0&&this.parts.push(e),this.parts.length>0){let t=this.parts.join("");this.parts=[],this.onLine(t)}}};async function Zc(e,t){let n,i=new Promise(r=>{n=setTimeout(()=>r("pending"),Math.max(0,t))});try{return await Promise.race([e,i])}finally{clearTimeout(n)}}var cP=UI(import.meta.url),Tm="codex-acp/stdoutDrained";function Lf(e,t,n=["app-server"],i={}){let r={...t??process.env},u=r.LODY_CODEX_PROCESS_TOKEN;delete r.LODY_CODEX_PROCESS_TOKEN;let s={env:r,windowsHide:!0},o=r.LODY_CODEX_PROFILE_CONFIG,a=o?dP(JSON.parse(o)):[];a.push(...n);let l;if(u){if(!o||!r.CODEX_HOME||!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(u))throw new Error("Invalid Codex profile process token");let y=xl.join(r.CODEX_HOME,"..","processes"),b=JSON.parse(jI(xl.join(y,`${u}.json`),"utf8"));if(b.version!==1||b.token!==u)throw new Error("Invalid Codex profile process record");l=xl.join(y,`${u}.native.json`)}let c;if(e)c=process.platform==="win32"?(0,MI.default)(e,a,s):Op(e,a,s);else{let y=cP.resolve("@openai/codex/bin/codex.js");c=Op(process.execPath,[y,...a],s)}hP(c),c.stdin.on("error",y=>D.log(`[STDIN ERROR] ${y.message}`)),c.stdout.on("error",y=>D.log(`[STDOUT ERROR] ${y.message}`));let m=y=>{if(l)try{LI(l,JSON.stringify({nativePid:c.pid,nativeExited:y}),{mode:384})}catch{}};m(!1),c.once("exit",()=>m(!0)),c.once("error",()=>{c.pid===void 0&&m(!0)});let p=sP(c.stdout),v=uP(c.stdin),g=NI.createMessageConnection(p,v);g.listen();let C=new Promise(y=>{g.onNotification(Tm,()=>y())});return c.stdout.on("end",()=>p.deliver?.({jsonrpc:"2.0",method:Tm})),(i.disposeOnExit??!0)&&c.on("exit",y=>{g.dispose()}),{connection:g,process:c,drained:C}}function dP(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid managed Codex startup configuration");let t=n=>{if(typeof n=="string"||typeof n=="boolean"||typeof n=="number")return JSON.stringify(n);if(Array.isArray(n))return`[${n.map(t).join(",")}]`;if(n&&typeof n=="object")return`{${Object.entries(n).map(([i,r])=>`${JSON.stringify(i)}=${t(r)}`).join(",")}}`;throw new Error("Invalid managed Codex startup value")};return Object.entries(e).flatMap(([n,i])=>{if(!/^[a-z_]+$/.test(n))throw new Error("Invalid managed Codex startup key");return["-c",`${n}=${t(i)}`]})}function hP(e){let t=e.stdin.write.bind(e.stdin);e.stdin.write=(n,i,r)=>(D.enabled&&D.log(`[IN] ${n.toString()}`),t(n,i,r)),e.stderr.on("data",n=>{process.stderr.write(n),D.enabled&&D.log(`[ERR] ${n.toString()}`)}),e.stdout.on("data",n=>{D.enabled&&D.log(`[OUT] ${n.toString()}`)}),e.on("exit",n=>{D.log(`[EXIT] code: ${n?.toString()}`)})}function Fm(e){let t=e?.session?.notices;return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Ml(e,t,n){return{sessionUpdate:"notice",severity:e,title:t,...n==null?{}:{description:n}}}var Kn={sessionPromptSuggestion:"_lody/session/prompt_suggestion",subagentEvent:"_lody/subagents/event",sessionUsageUpdate:"_lody/session/usage_update",rateLimitsGet:"_lody/rate_limits/get",rateLimitsUpdate:"_lody/rate_limits/update",sessionSteer:"_lody/session/steer",sessionSteerApplied:"_lody/session/steer_applied",sessionActivityUpdate:"_lody/session/activity_update",sessionGoal:"_lody/session/goal",sessionHistoryRead:"_lody/session/history/read",subagentsList:"_lody/subagents/list",subagentsCancel:"_lody/subagents/cancel",subagentsOutput:"_lody/subagents/output"},zs={imageGeneration:"ImageGeneration",cronCreate:"CronCreate",cronDelete:"CronDelete",cronList:"CronList",scheduleWakeup:"ScheduleWakeup"},Eo="plan_mode";function fP(e){return{id:Eo,name:"Plan",description:"Plan before implementing; permissions are controlled separately.",type:"boolean",currentValue:e}}var pP="_lody/subagents/event";function Ut(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Be(e){return typeof e=="string"}function ys(e,t){return Be(e)&&t.includes(e)}function mP(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function nt(e,t,n){return t.every(i=>e[i]===void 0||n(e[i]))}function St(e){return t=>t===null||e(t)}function pr(e){return nt(e,["_meta"],St(Ut))}function gP(e){return Ut(e)&&pr(e)&&nt(e,["audience"],St(t=>Array.isArray(t)&&t.every(n=>n==="user"||n==="assistant")))&&nt(e,["lastModified"],St(Be))&&nt(e,["priority"],St(t=>typeof t=="number"&&Number.isFinite(t)))}function p_(e){return Ut(e)&&Ut(e._meta)&&Ut(e._meta.lody)&&Ut(e._meta.lody.subagentEvents)&&e._meta.lody.subagentEvents.version===1}function Pm(e){if(!Ut(e)||!pr(e)||!nt(e,["annotations"],St(gP)))return!1;switch(e.type){case"text":return Be(e.text);case"image":return Be(e.data)&&Be(e.mimeType)&&nt(e,["uri"],St(Be));case"audio":return Be(e.data)&&Be(e.mimeType);case"resource_link":return Be(e.uri)&&Be(e.name)&&nt(e,["description","mimeType","title"],St(Be))&&nt(e,["size"],St(Number.isSafeInteger));case"resource":return Ut(e.resource)&&pr(e.resource)&&Be(e.resource.uri)&&nt(e.resource,["mimeType"],St(Be))&&(Be(e.resource.text)||Be(e.resource.blob));default:return!1}}function vP(e){if(!Ut(e)||!pr(e))return!1;switch(e.sessionUpdate){case"agent_message_chunk":case"agent_thought_chunk":return Pm(e.content)&&nt(e,["messageId"],St(Be));case"plan":return Array.isArray(e.entries)&&e.entries.every(t=>Ut(t)&&pr(t)&&Be(t.content)&&ys(t.priority,["high","medium","low"])&&ys(t.status,["pending","in_progress","completed"]));case"tool_call":case"tool_call_update":return Be(e.toolCallId)&&e.toolCallId.length>0&&(e.sessionUpdate!=="tool_call"||Be(e.title)&&["status","kind","locations","content"].every(t=>e[t]!==null))&&nt(e,["name"],St(Be))&&nt(e,["title"],t=>t===null||Be(t))&&nt(e,["status"],t=>t===null||ys(t,["pending","in_progress","completed","failed"]))&&nt(e,["kind"],t=>t===null||ys(t,["read","edit","delete","move","search","execute","think","fetch","switch_mode","other"]))&&nt(e,["locations"],t=>t===null||Array.isArray(t)&&t.every(n=>Ut(n)&&pr(n)&&Be(n.path)&&nt(n,["line"],St(i=>mP(i)&&Number.isSafeInteger(i)))))&&nt(e,["content"],t=>t===null||Array.isArray(t)&&t.every(n=>Ut(n)&&pr(n)&&(n.type==="content"&&Pm(n.content)||n.type==="terminal"&&Be(n.terminalId)||n.type==="diff"&&Be(n.path)&&Be(n.newText)&&nt(n,["oldText"],St(Be)))));default:return!1}}function Es(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Rm(e){if(!Es(e)||!Es(e._meta))return!1;let t=e._meta.lody;return Es(t)&&Es(t.promptSuggestions)&&t.promptSuggestions.version===1}var Kr=1,mr=Kn.sessionGoal,CP=["set","pause","resume","clear"];function yP(e){if(typeof e!="object"||e===null)return null;let t=e.lody;if(typeof t!="object"||t===null)return null;let n=t.goalControl;if(typeof n!="object"||n===null)return null;let{version:i,action:r,objective:u}=n;return i!==Kr?null:r==="pause"||r==="resume"||r==="clear"?{version:Kr,action:r}:r!=="set"?null:typeof u=="string"&&u.trim().length>0?{version:Kr,action:"set",objective:u}:null}var de={initialize:"initialize",auth_login:"auth/login",providers_list:"providers/list",providers_set:"providers/set",providers_disable:"providers/disable",session_new:"session/new",session_set_config_option:"session/set_config_option",session_prompt:"session/prompt",session_cancel:"session/cancel",mcp_message:"mcp/message",session_list:"session/list",session_delete:"session/delete",session_fork:"session/fork",session_resume:"session/resume",session_close:"session/close",auth_logout:"auth/logout"},Ot={session_request_permission:"session/request_permission",session_update:"session/update",mcp_message:"mcp/message",elicitation_create:"elicitation/create",elicitation_complete:"elicitation/complete"},Qu={cancel_request:"$/cancel_request"},vr=2,Vn=U([se(),h()]).nullable(),Pe=h(),es=h(),m_=U([E("read"),E("edit"),E("delete"),E("move"),E("search"),E("execute"),E("think"),E("fetch"),E("switch_mode"),E("other"),h()]),g_=U([E("pending"),E("in_progress"),E("completed"),E("failed"),E("cancelled"),h()]),EP=U([E("assistant"),E("user"),h()]),ln=d({audience:f(ie(EP).nullish(),()=>{}),lastModified:f(Ai.datetime({offset:!0}).nullish(),()=>{}),priority:f(se().gte(0).lte(1).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),v_=d({text:h(),annotations:f(ln.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),Xn=h(),C_=d({data:h(),mimeType:Xn,uri:f(Rt().nullish(),()=>{}),annotations:f(ln.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),y_=d({data:h(),mimeType:Xn,annotations:f(ln.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),wP=U([E("light"),E("dark"),h()]),_P=d({src:Rt(),mimeType:f(Xn.nullish(),()=>{}),sizes:f(ie(h()).nullish(),()=>{}),theme:f(wP.nullish(),()=>{})}),E_=d({name:h(),uri:Rt(),title:f(h().nullish(),()=>{}),description:f(h().nullish(),()=>{}),icons:f(ie(_P).nullish(),()=>{}),mimeType:f(Xn.nullish(),()=>{}),size:f(se().nullish(),()=>{}),annotations:f(ln.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),AP=d({text:h(),uri:Rt(),mimeType:f(Xn.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),bP=d({blob:h(),uri:Rt(),mimeType:f(Xn.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),SP=U([AP,bP]),w_=d({resource:SP,annotations:f(ln.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),Kt=Oe(U([v_.and(d({type:E("text")})),C_.and(d({type:E("image")})),y_.and(d({type:E("audio")})),E_.and(d({type:E("resource_link")})),w_.and(d({type:E("resource")})),ze(d({type:h()}),"type",["audio","image","resource","resource_link","text"])]),"type",["audio","image","resource","resource_link","text"]),__=d({content:Kt,_meta:f(_(h(),w()).nullish(),()=>{})}),DP=U([E("text"),E("binary"),E("directory"),E("symlink"),h()]),lt=h(),Xr=d({path:lt}),wo=d({oldPath:lt,path:lt}),IP=Oe(Xe(U([Xr.and(d({operation:E("add")})),Xr.and(d({operation:E("delete")})),Xr.and(d({operation:E("modify")})),wo.and(d({operation:E("move")})),wo.and(d({operation:E("copy")})),ze(d({operation:h()}),"operation",["add","copy","delete","modify","move"])]),d({fileType:f(DP.nullish(),()=>{}),mimeType:f(Xn.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})})),"operation",["add","copy","delete","modify","move"]),$P=U([E("git_patch"),h()]),A_=d({format:$P,text:h()}),b_=d({changes:ie(IP),patch:f(A_.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),ts=h(),S_=d({terminalId:ts,_meta:f(_(h(),w()).nullish(),()=>{})}),D_=Oe(U([__.and(d({type:E("content")})),b_.and(d({type:E("diff")})),S_.and(d({type:E("terminal")})),ze(d({type:h()}),"type",["content","diff","terminal"])]),"type",["content","diff","terminal"]),BP=d({path:lt,line:f(Ke().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),qf=d({toolCallId:es,name:f(h().nullish(),()=>{}),title:f(h().nullish(),()=>{}),kind:f(m_.nullish(),()=>{}),status:f(g_.nullish(),()=>{}),content:f(ie(D_).nullish(),()=>{}),locations:f(ie(BP).nullish(),()=>{}),rawInput:f(w().optional(),()=>{}),rawOutput:f(w().optional(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),I_=d({toolCall:qf}),$_=d({command:h(),cwd:lt,toolCallId:f(es.nullish(),()=>{}),terminalId:f(ts.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),kP=Oe(U([I_.and(d({type:E("tool_call")})),$_.and(d({type:E("command")})),ze(d({type:h()}),"type",["command","tool_call"])]),"type",["command","tool_call"]),B_=h(),xP=U([E("allow_once"),E("allow_always"),E("reject_once"),E("reject_always"),h()]),TP=d({optionId:B_,name:h(),kind:xP,_meta:f(_(h(),w()).nullish(),()=>{})}),k_=d({sessionId:Pe,title:h(),description:f(h().nullish(),()=>{}),subject:kP.nullish(),options:Y(TP).min(1),_meta:f(_(h(),w()).nullish(),()=>{})}),cl=d({sessionId:Pe,toolCallId:f(es.nullish(),()=>{})}),dl=d({requestId:Vn}),FP=E("object"),PP=U([E("email"),E("uri"),E("date"),E("date-time"),h()]),x_=d({const:h(),title:h(),description:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),T_=d({title:f(h().nullish(),()=>{}),description:f(h().nullish(),()=>{}),minLength:Ke().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),maxLength:Ke().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),pattern:h().nullish(),format:PP.nullish(),default:f(h().nullish(),()=>{}),enum:Y(h()).min(1).nullish(),oneOf:Y(x_).min(1).nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),F_=d({title:f(h().nullish(),()=>{}),description:f(h().nullish(),()=>{}),minimum:se().nullish(),maximum:se().nullish(),default:f(se().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),P_=d({title:f(h().nullish(),()=>{}),description:f(h().nullish(),()=>{}),minimum:se().nullish(),maximum:se().nullish(),default:f(se().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),R_=d({title:f(h().nullish(),()=>{}),description:f(h().nullish(),()=>{}),default:f(ke().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),z_=d({enum:Y(h()).min(1),_meta:f(_(h(),w()).nullish(),()=>{})}),RP=d({anyOf:Y(x_).min(1),_meta:f(_(h(),w()).nullish(),()=>{})}),zP=Oe(U([z_.and(d({type:E("string")})),ze(d({type:h()}),"type",["string"]),RP]),"type",["string"]),O_=d({title:f(h().nullish(),()=>{}),description:f(h().nullish(),()=>{}),minItems:se().nullish(),maxItems:se().nullish(),items:zP,default:f(ie(h()).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),OP=Oe(U([T_.and(d({type:E("string")})),F_.and(d({type:E("number")})),P_.and(d({type:E("integer")})),R_.and(d({type:E("boolean")})),O_.and(d({type:E("array")})),ze(d({type:h()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),NP=d({type:f(FP.optional().default("object"),()=>"object"),title:f(h().nullish(),()=>{}),properties:_(h(),OP).optional().default({}),required:Y(h()).nullish(),description:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),N_=Xe(U([cl,dl]),d({requestedSchema:NP})),M_=h(),U_=Xe(U([cl,dl]),d({elicitationId:M_,url:Rt()})),j_=Oe(Xe(U([N_.and(d({mode:E("form")})),U_.and(d({mode:E("url")})),ze(Xe(U([cl,dl]),d({mode:h()})),"mode",["form","url"])]),d({message:h(),_meta:f(_(h(),w()).nullish(),()=>{})})),"mode",["form","url"]),Zf=h(),L_=h(),q_=d({serverId:Zf,requestId:L_,method:h(),params:_(h(),w()).nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),Z_=w(),SW=d({id:Vn,method:h(),params:U([k_,j_,q_,Z_]).nullish()}),Wf=Ke().gte(0).lte(65535),W_=d({name:h(),title:f(h().nullish(),()=>{}),version:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),MP=d({_meta:f(_(h(),w()).nullish(),()=>{})}),UP=d({_meta:f(_(h(),w()).nullish(),()=>{})}),jP=d({_meta:f(_(h(),w()).nullish(),()=>{})}),LP=d({image:f(MP.nullish(),()=>{}),audio:f(UP.nullish(),()=>{}),embeddedContext:f(jP.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),qP=d({_meta:f(_(h(),w()).nullish(),()=>{})}),ZP=d({_meta:f(_(h(),w()).nullish(),()=>{})}),WP=d({_meta:f(_(h(),w()).nullish(),()=>{})}),GP=d({stdio:f(qP.nullish(),()=>{}),http:f(ZP.nullish(),()=>{}),acp:f(WP.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),VP=d({_meta:f(_(h(),w()).nullish(),()=>{})}),HP=d({_meta:f(_(h(),w()).nullish(),()=>{})}),JP=d({_meta:f(_(h(),w()).nullish(),()=>{})}),KP=d({override:f(JP.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),XP=d({mode:f(KP.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),YP=d({_meta:f(_(h(),w()).nullish(),()=>{})}),QP=d({prompt:f(LP.nullish(),()=>{}),mcp:f(GP.nullish(),()=>{}),delete:f(VP.nullish(),()=>{}),additionalDirectories:f(HP.nullish(),()=>{}),systemPrompt:f(XP.nullish(),()=>{}),fork:f(YP.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),eR=d({_meta:f(_(h(),w()).nullish(),()=>{})}),tR=d({_meta:f(_(h(),w()).nullish(),()=>{})}),nR=d({session:f(QP.nullish(),()=>{}),auth:f(eR.nullish(),()=>{}),providers:f(tR.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),ns=h(),G_=d({name:h(),value:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),V_=d({methodId:ns,name:h(),description:f(h().nullish(),()=>{}),args:Y(h()).optional(),env:Y(G_).optional(),_meta:f(_(h(),w()).nullish(),()=>{})}),H_=d({methodId:ns,name:h(),description:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),rR=Oe(U([V_.and(d({type:E("terminal")})),H_.and(d({type:E("agent")})),ze(d({type:h(),methodId:ns,name:h(),description:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),"type",["agent","terminal"])]),"type",["agent","terminal"]),J_=d({protocolVersion:Wf,info:W_,capabilities:f(nR.optional().default({}),()=>({})),authMethods:f(ie(rR).optional(),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),K_=d({_meta:f(_(h(),w()).nullish(),()=>{})}),Gf=h(),Vf=U([E("anthropic"),E("openai"),E("azure"),E("vertex"),E("bedrock"),h()]),iR=d({apiType:Vf,baseUrl:Rt(),_meta:f(_(h(),w()).nullish(),()=>{})}),uR=d({providerId:Gf,supported:ht(ie(Vf),()=>[]),required:ke(),current:iR.nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),X_=d({providers:Y(uR),_meta:f(_(h(),w()).nullish(),()=>{})}),Y_=d({_meta:f(_(h(),w()).nullish(),()=>{})}),Q_=d({_meta:f(_(h(),w()).nullish(),()=>{})}),eA=d({_meta:f(_(h(),w()).nullish(),()=>{})}),Yn=h(),sR=U([E("mode"),E("model"),E("model_config"),E("thought_level"),h()]),hl=h(),tA=d({value:hl,name:h(),description:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),oR=h(),aR=d({groupId:oR,name:h(),options:ht(ie(tA),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),lR=U([Y(tA),Y(aR)]),nA=d({currentValue:hl,options:lR}),rA=d({currentValue:ke()}),rs=Oe(Xe(U([nA.and(d({type:E("select")})),rA.and(d({type:E("boolean")})),ze(d({type:h()}),"type",["boolean","select"])]),d({configId:Yn,name:h(),description:f(h().nullish(),()=>{}),category:f(sR.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})})),"type",["boolean","select"]),iA=d({hint:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),cR=Oe(U([iA.and(d({type:E("text")})),ze(d({type:h()}),"type",["text"])]),"type",["text"]),fl=d({name:h(),description:h(),input:f(cR.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),uA=d({sessionId:Pe,configOptions:f(ie(rs).optional(),()=>[]),availableCommands:f(ie(fl).optional(),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),dR=d({sessionId:Pe,cwd:lt,additionalDirectories:f(ie(lt).optional(),()=>[]),title:f(h().nullish(),()=>{}),updatedAt:f(Ai.datetime({offset:!0}).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),sA=h(),oA=d({sessions:ht(ie(dR),()=>[]),nextCursor:f(sA.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),aA=d({_meta:f(_(h(),w()).nullish(),()=>{})}),lA=d({sessionId:Pe,configOptions:f(ie(rs).optional(),()=>[]),availableCommands:f(ie(fl).optional(),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),cA=d({configOptions:f(ie(rs).optional(),()=>[]),availableCommands:f(ie(fl).optional(),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),dA=d({_meta:f(_(h(),w()).nullish(),()=>{})}),hA=d({configOptions:ht(ie(rs),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),xr=h(),fA=d({messageId:xr,_meta:f(_(h(),w()).nullish(),()=>{})}),pA=w(),hR=U([E(-32700),E(-32600),E(-32601),E(-32602),E(-32603),E(-32800),E(-32e3),E(-32002),Ke().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"})]),pl=d({code:hR,message:h(),data:f(w().optional(),()=>{})}),DW=U([d({id:Vn,result:U([J_,K_,X_,Y_,Q_,eA,uA,oA,aA,lA,cA,dA,hA,fA,pA])}),d({id:Vn,error:pl})]),Yr=d({messageId:xr,content:Kt,_meta:f(_(h(),w()).nullish(),()=>{})}),mA=d({messageId:xr,content:f(ie(Kt).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),gA=d({messageId:xr,content:f(ie(Kt).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),vA=d({messageId:xr,content:f(ie(Kt).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),CA=d({_meta:f(_(h(),w()).nullish(),()=>{})}),yA=d({error:f(pl.nullish(),()=>{})}),EA=d({totalTokens:se(),inputTokens:se(),outputTokens:se(),thoughtTokens:f(se().nullish(),()=>{}),cachedReadTokens:f(se().nullish(),()=>{}),cachedWriteTokens:f(se().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),wA=L1(Oe(Xe(U([d({stopReason:E("end_turn")}),d({stopReason:E("max_tokens")}),d({stopReason:E("max_turn_requests")}),d({stopReason:E("refusal")}),d({stopReason:E("cancelled")}),yA.and(d({stopReason:E("error")})),ze(d({stopReason:h()}),"stopReason",["cancelled","end_turn","error","max_tokens","max_turn_requests","refusal"]),d({stopReason:Br().optional()})]),d({usage:f(EA.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{}),stopReason:f(h().nullish(),()=>{})})),"stopReason",["cancelled","end_turn","error","max_tokens","max_turn_requests","refusal"]),"stopReason"),_A=d({_meta:f(_(h(),w()).nullish(),()=>{})}),AA=d({_meta:f(_(h(),w()).nullish(),()=>{})}),ml=Oe(U([CA.and(d({state:E("running")})),wA.and(d({state:E("idle")})),_A.and(d({state:E("requires_action")})),AA.and(d({state:E("unknown")})),ze(d({state:h()}),"state",["idle","requires_action","running","unknown"])]),"state",["idle","requires_action","running","unknown"]),bA=d({toolCallId:es,content:D_,_meta:f(_(h(),w()).nullish(),()=>{})}),SA=d({data:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),DA=d({exitCode:f(Ke().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),IA=d({terminalId:ts,command:f(h().nullish(),()=>{}),cwd:f(lt.nullish(),()=>{}),output:f(SA.nullish(),()=>{}),exitStatus:f(DA.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),$A=d({terminalId:ts,data:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),Di=h(),fR=U([E("high"),E("medium"),E("low"),h()]),pR=U([E("pending"),E("in_progress"),E("completed"),E("cancelled"),h()]),mR=d({content:h(),priority:fR,status:pR,_meta:f(_(h(),w()).nullish(),()=>{})}),BA=d({planId:Di,entries:ht(ie(mR),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),kA=d({planId:Di,uri:Rt(),_meta:f(_(h(),w()).nullish(),()=>{})}),xA=d({planId:Di,content:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),gR=Oe(U([BA.and(d({type:E("items")})),kA.and(d({type:E("file")})),xA.and(d({type:E("markdown")})),ze(d({type:h(),planId:Di}),"type",["file","items","markdown"])]),"type",["file","items","markdown"]),TA=d({plan:gR,_meta:f(_(h(),w()).nullish(),()=>{})}),FA=d({planId:Di,_meta:f(_(h(),w()).nullish(),()=>{})}),PA=d({availableCommands:ht(ie(fl),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),RA=d({configOptions:ht(ie(rs),()=>[]),_meta:f(_(h(),w()).nullish(),()=>{})}),zA=d({title:f(h().nullish(),()=>{}),updatedAt:f(Ai.datetime({offset:!0}).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),OA=d({amount:se(),currency:h().regex(/^[A-Z]{3}$/),_meta:f(_(h(),w()).nullish(),()=>{})}),NA=d({used:se(),size:se(),cost:f(OA.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),vR=U([E("info"),E("warning"),E("error"),h()]),MA=d({severity:vR,title:h().min(1),description:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),UA=h(),CR=U([E("in_progress"),E("completed"),E("failed"),E("cancelled"),h()]),jA=d({compactionId:UA,status:CR,summary:f(ie(Kt).nullish(),()=>{}),error:f(h().nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),LA=d({compactionId:UA,content:Kt,_meta:f(_(h(),w()).nullish(),()=>{})}),yR=d({_meta:f(_(h(),w()).nullish(),()=>{})}),qA=d({cancel:f(yR.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),ZA=d({sessionId:Pe,title:f(h().nullish(),()=>{}),description:f(h().nullish(),()=>{}),capabilities:f(qA.nullish(),()=>{}),state:f(ml.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),WA=d({messageId:xr,senderSessionId:f(Pe.nullish(),()=>{}),recipientSessionId:f(Pe.nullish(),()=>{}),content:f(ie(Kt).nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),GA=d({messageId:xr,senderSessionId:f(Pe.nullish(),()=>{}),recipientSessionId:f(Pe.nullish(),()=>{}),content:Kt,_meta:f(_(h(),w()).nullish(),()=>{})}),ER=Oe(U([Yr.and(d({sessionUpdate:E("user_message_chunk")})),mA.and(d({sessionUpdate:E("user_message")})),Yr.and(d({sessionUpdate:E("agent_message_chunk")})),gA.and(d({sessionUpdate:E("agent_message")})),Yr.and(d({sessionUpdate:E("agent_thought_chunk")})),vA.and(d({sessionUpdate:E("agent_thought")})),ml.and(d({sessionUpdate:E("state_update")})),bA.and(d({sessionUpdate:E("tool_call_content_chunk")})),qf.and(d({sessionUpdate:E("tool_call_update")})),IA.and(d({sessionUpdate:E("terminal_update")})),$A.and(d({sessionUpdate:E("terminal_output_chunk")})),TA.and(d({sessionUpdate:E("plan_update")})),FA.and(d({sessionUpdate:E("plan_removed")})),PA.and(d({sessionUpdate:E("available_commands_update")})),RA.and(d({sessionUpdate:E("config_option_update")})),zA.and(d({sessionUpdate:E("session_info_update")})),NA.and(d({sessionUpdate:E("usage_update")})),MA.and(d({sessionUpdate:E("notice")})),jA.and(d({sessionUpdate:E("compaction_update")})),LA.and(d({sessionUpdate:E("compaction_summary_chunk")})),ZA.and(d({sessionUpdate:E("subagent_update")})),WA.and(d({sessionUpdate:E("session_message")})),GA.and(d({sessionUpdate:E("session_message_chunk")})),ze(d({sessionUpdate:h()}),"sessionUpdate",["agent_message","agent_message_chunk","agent_thought","agent_thought_chunk","available_commands_update","compaction_summary_chunk","compaction_update","config_option_update","notice","plan_removed","plan_update","session_info_update","session_message","session_message_chunk","state_update","subagent_update","terminal_output_chunk","terminal_update","tool_call_content_chunk","tool_call_update","usage_update","user_message","user_message_chunk"])]),"sessionUpdate",["agent_message","agent_message_chunk","agent_thought","agent_thought_chunk","available_commands_update","compaction_summary_chunk","compaction_update","config_option_update","notice","plan_removed","plan_update","session_info_update","session_message","session_message_chunk","state_update","subagent_update","terminal_output_chunk","terminal_update","tool_call_content_chunk","tool_call_update","usage_update","user_message","user_message_chunk"]),Hf=d({sessionId:Pe,update:ER,_meta:f(_(h(),w()).nullish(),()=>{})}),VA=d({elicitationId:M_,_meta:f(_(h(),w()).nullish(),()=>{})}),HA=w(),IW=d({method:h(),params:U([Hf,VA,HA]).nullish()}),wR=d({_meta:f(_(h(),w()).nullish(),()=>{})}),_R=d({terminal:f(wR.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),AR=d({_meta:f(_(h(),w()).nullish(),()=>{})}),bR=d({_meta:f(_(h(),w()).nullish(),()=>{})}),SR=d({form:f(AR.nullish(),()=>{}),url:f(bR.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),DR=d({auth:f(_R.nullish(),()=>{}),elicitation:f(SR.nullish(),()=>{}),_meta:f(_(h(),w()).nullish(),()=>{})}),_o=d({protocolVersion:Wf,info:W_,capabilities:f(DR.optional().default({}),()=>({})),_meta:f(_(h(),w()).nullish(),()=>{})}),JA=d({methodId:ns,_meta:f(_(h(),w()).nullish(),()=>{})}),KA=d({_meta:f(_(h(),w()).nullish(),()=>{})}),XA=d({providerId:Gf,apiType:Vf,baseUrl:Rt(),headers:_(h(),h()).optional(),_meta:f(_(h(),w()).nullish(),()=>{})}),YA=d({providerId:Gf,_meta:f(_(h(),w()).nullish(),()=>{})}),QA=d({_meta:f(_(h(),w()).nullish(),()=>{})}),IR=d({name:h(),value:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),eb=d({name:h(),url:Rt(),headers:Y(IR).optional(),_meta:f(_(h(),w()).nullish(),()=>{})}),tb=d({name:h(),serverId:Zf,_meta:f(_(h(),w()).nullish(),()=>{})}),nb=d({name:h(),command:lt,args:Y(h()).optional(),env:Y(G_).optional(),_meta:f(_(h(),w()).nullish(),()=>{})}),Jf=Oe(U([eb.and(d({type:E("http")})),tb.and(d({type:E("acp")})),nb.and(d({type:E("stdio")})),ze(d({type:h()}),"type",["acp","http","stdio"])]),"type",["acp","http","stdio"]),$R=U([E("append"),E("override"),h()]),Kf=d({mode:$R,content:Y(Kt),_meta:f(_(h(),w()).nullish(),()=>{})}),rb=d({cwd:lt,additionalDirectories:Y(lt).optional(),mcpServers:Y(Jf).optional(),systemPrompt:Kf.nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),ib=d({cwd:lt.nullish(),cursor:sA.nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),ub=d({sessionId:Pe,_meta:f(_(h(),w()).nullish(),()=>{})}),sb=d({sessionId:Pe,cwd:lt,additionalDirectories:Y(lt).optional(),mcpServers:Y(Jf).optional(),systemPrompt:Kf.nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),ob=d({_meta:f(_(h(),w()).nullish(),()=>{})}),BR=Oe(U([ob.and(d({type:E("start")})),ze(d({type:h(),_meta:f(_(h(),w()).nullish(),()=>{})}),"type",["start"])]),"type",["start"]),ab=d({sessionId:Pe,cwd:lt,additionalDirectories:Y(lt).optional(),mcpServers:Y(Jf).optional(),replayFrom:BR.nullish(),systemPrompt:Kf.nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),lb=d({sessionId:Pe,_meta:f(_(h(),w()).nullish(),()=>{})}),cb=Oe(Xe(U([d({value:hl,type:E("id")}),d({value:ke(),type:E("boolean")}),ze(d({type:h(),value:w()}),"type",["boolean","id"])]),d({sessionId:Pe,configId:Yn,_meta:f(_(h(),w()).nullish(),()=>{})})),"type",["boolean","id"]),db=d({sessionId:Pe,prompt:Y(Kt),_meta:f(_(h(),w()).nullish(),()=>{})}),$W=d({id:Vn,method:h(),params:U([_o,JA,KA,XA,YA,QA,rb,ib,ub,sb,ab,lb,cb,db,Z_]).nullish()}),hb=d({optionId:B_,_meta:f(_(h(),w()).nullish(),()=>{})}),kR=Oe(U([d({outcome:E("cancelled")}),hb.and(d({outcome:E("selected")})),ze(d({outcome:h()}),"outcome",["cancelled","selected"])]),"outcome",["cancelled","selected"]),fb=d({outcome:kR,_meta:f(_(h(),w()).nullish(),()=>{})}),xR=U([h(),se(),se(),ke(),Y(h())]),pb=d({content:_(h(),xR).nullish()}),mb=Oe(Xe(U([pb.and(d({action:E("accept")})),d({action:E("decline")}),d({action:E("cancel")}),ze(d({action:h()}),"action",["accept","cancel","decline"])]),d({_meta:f(_(h(),w()).nullish(),()=>{})})),"action",["accept","cancel","decline"]),TR=Va({code:Ke().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"}),message:h(),data:w().optional()}),gb=U([d({result:w(),_meta:f(_(h(),w()).nullish(),()=>{})}),d({error:TR,_meta:f(_(h(),w()).nullish(),()=>{})})]),BW=U([d({id:Vn,result:U([fb,mb,gb,pA])}),d({id:Vn,error:pl})]),vb=d({sessionId:Pe,_meta:f(_(h(),w()).nullish(),()=>{})}),Cb=d({serverId:Zf,requestId:L_,method:h(),params:_(h(),w()).nullish(),_meta:f(_(h(),w()).nullish(),()=>{})}),kW=d({method:h(),params:U([vb,Cb,HA]).nullish()}),FR=d({requestId:Vn,_meta:f(_(h(),w()).nullish(),()=>{})}),xW=d({method:h(),params:FR.nullish()});function me(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}var TW=I_.and(d({type:E("tool_call")})),FW=$_.and(d({toolCallId:es.nullish(),terminalId:ts.nullish()})).and(d({type:E("command")})),PW=__.and(d({type:E("content")})),RW=b_.and(d({patch:A_.nullish()})).and(d({type:E("diff")})),zW=S_.and(d({type:E("terminal")})),PR=v_.and(d({annotations:ln.nullish()})).and(d({type:E("text")})),RR=C_.and(d({annotations:ln.nullish()})).and(d({type:E("image")})),zR=y_.and(d({annotations:ln.nullish()})).and(d({type:E("audio")})),OR=E_.and(d({mimeType:Xn.nullish(),annotations:ln.nullish()})).and(d({type:E("resource_link")})),NR=w_.and(d({annotations:ln.nullish()})).and(d({type:E("resource")})),OW=Xr.and(d({operation:E("add")})),NW=Xr.and(d({operation:E("delete")})),MW=Xr.and(d({operation:E("modify")})),UW=wo.and(d({operation:E("move")})),jW=wo.and(d({operation:E("copy")})),LW=N_.and(d({mode:E("form")})).and(d({message:h()})),qW=U_.and(d({mode:E("url")})).and(d({message:h()})),ZW=U([cl,dl]).and(d({message:h()})),WW=T_.and(d({type:E("string")})),GW=F_.and(d({type:E("number")})),VW=P_.and(d({type:E("integer")})),HW=R_.and(d({type:E("boolean")})),JW=O_.and(d({type:E("array")})),KW=z_.and(d({type:E("string")})),XW=V_.and(d({type:E("terminal")})),YW=H_.and(d({type:E("agent")})),QW=d({methodId:ns,name:h()}),eG=nA.and(d({type:E("select")})).and(d({configId:Yn,name:h()})),tG=rA.and(d({type:E("boolean")})).and(d({configId:Yn,name:h()})),nG=d({configId:Yn,name:h()}),rG=iA.and(d({type:E("text")})),MR=Yr.and(d({sessionUpdate:E("user_message_chunk")})),UR=mA.and(d({sessionUpdate:E("user_message")})),jR=Yr.and(d({sessionUpdate:E("agent_message_chunk")})),LR=gA.and(d({sessionUpdate:E("agent_message")})),qR=Yr.and(d({sessionUpdate:E("agent_thought_chunk")})),ZR=vA.and(d({sessionUpdate:E("agent_thought")})),WR=ml.and(d({sessionUpdate:E("state_update")})),GR=bA.and(d({sessionUpdate:E("tool_call_content_chunk")})),VR=qf.and(d({kind:m_.nullish(),status:g_.nullish()})).and(d({sessionUpdate:E("tool_call_update")})),HR=IA.and(d({cwd:lt.nullish(),output:SA.nullish(),exitStatus:DA.nullish()})).and(d({sessionUpdate:E("terminal_update")})),JR=$A.and(d({sessionUpdate:E("terminal_output_chunk")})),KR=TA.and(d({sessionUpdate:E("plan_update")})),XR=FA.and(d({sessionUpdate:E("plan_removed")})),YR=PA.and(d({sessionUpdate:E("available_commands_update")})),QR=RA.and(d({sessionUpdate:E("config_option_update")})),e8=zA.and(d({sessionUpdate:E("session_info_update")})),t8=NA.and(d({cost:OA.nullish()})).and(d({sessionUpdate:E("usage_update")})),n8=MA.and(d({sessionUpdate:E("notice")})),r8=jA.and(d({sessionUpdate:E("compaction_update")})),i8=LA.and(d({sessionUpdate:E("compaction_summary_chunk")})),u8=ZA.and(d({capabilities:qA.nullish(),state:ml.nullish()})).and(d({sessionUpdate:E("subagent_update")})),s8=WA.and(d({senderSessionId:Pe.nullish(),recipientSessionId:Pe.nullish()})).and(d({sessionUpdate:E("session_message")})),o8=GA.and(d({senderSessionId:Pe.nullish(),recipientSessionId:Pe.nullish()})).and(d({sessionUpdate:E("session_message_chunk")})),iG=d({stopReason:E("end_turn")}),uG=d({stopReason:E("max_tokens")}),sG=d({stopReason:E("max_turn_requests")}),oG=d({stopReason:E("refusal")}),aG=d({stopReason:E("cancelled")}),lG=yA.and(d({error:pl.nullish()})).and(d({stopReason:E("error")})),cG=d({stopReason:Br().optional()}),a8=CA.and(d({state:E("running")})),l8=wA.and(d({usage:EA.nullish()})).and(d({state:E("idle")})),c8=_A.and(d({state:E("requires_action")})),d8=AA.and(d({state:E("unknown")})),dG=BA.and(d({type:E("items")})),hG=kA.and(d({type:E("file")})),fG=xA.and(d({type:E("markdown")})),pG=d({planId:Di}),mG=eb.and(d({type:E("http")})),gG=tb.and(d({type:E("acp")})),vG=nb.and(d({type:E("stdio")})),CG=ob.and(d({type:E("start")})),yG=d({type:E("id")}).and(d({value:hl})).and(d({sessionId:Pe,configId:Yn})),EG=d({type:E("boolean")}).and(d({value:ke()})).and(d({sessionId:Pe,configId:Yn})),wG=d({value:w()}).and(d({sessionId:Pe,configId:Yn})),_G=d({outcome:E("cancelled")}),AG=hb.and(d({outcome:E("selected")})),bG=pb.and(d({action:E("accept")})),SG=d({action:E("decline")}),DG=d({action:E("cancel")}),h8={isText(e){return me(e,"type")==="text"&&PR.safeParse(e).success},isImage(e){return me(e,"type")==="image"&&RR.safeParse(e).success},isAudio(e){return me(e,"type")==="audio"&&zR.safeParse(e).success},isResourceLink(e){return me(e,"type")==="resource_link"&&OR.safeParse(e).success},isResource(e){return me(e,"type")==="resource"&&NR.safeParse(e).success},isCustom(e){let t=me(e,"type");return typeof t=="string"&&!["audio","image","resource","resource_link","text"].includes(t)}},Wc={isUserMessageChunk(e){return me(e,"sessionUpdate")==="user_message_chunk"&&MR.safeParse(e).success},isUserMessage(e){return me(e,"sessionUpdate")==="user_message"&&UR.safeParse(e).success},isAgentMessageChunk(e){return me(e,"sessionUpdate")==="agent_message_chunk"&&jR.safeParse(e).success},isAgentMessage(e){return me(e,"sessionUpdate")==="agent_message"&&LR.safeParse(e).success},isAgentThoughtChunk(e){return me(e,"sessionUpdate")==="agent_thought_chunk"&&qR.safeParse(e).success},isAgentThought(e){return me(e,"sessionUpdate")==="agent_thought"&&ZR.safeParse(e).success},isStateUpdate(e){return me(e,"sessionUpdate")==="state_update"&&WR.safeParse(e).success},isToolCallContentChunk(e){return me(e,"sessionUpdate")==="tool_call_content_chunk"&&GR.safeParse(e).success},isToolCallUpdate(e){return me(e,"sessionUpdate")==="tool_call_update"&&VR.safeParse(e).success},isTerminalUpdate(e){return me(e,"sessionUpdate")==="terminal_update"&&HR.safeParse(e).success},isTerminalOutputChunk(e){return me(e,"sessionUpdate")==="terminal_output_chunk"&&JR.safeParse(e).success},isPlanUpdate(e){return me(e,"sessionUpdate")==="plan_update"&&KR.safeParse(e).success},isPlanRemoved(e){return me(e,"sessionUpdate")==="plan_removed"&&XR.safeParse(e).success},isAvailableCommandsUpdate(e){return me(e,"sessionUpdate")==="available_commands_update"&&YR.safeParse(e).success},isConfigOptionUpdate(e){return me(e,"sessionUpdate")==="config_option_update"&&QR.safeParse(e).success},isSessionInfoUpdate(e){return me(e,"sessionUpdate")==="session_info_update"&&e8.safeParse(e).success},isUsageUpdate(e){return me(e,"sessionUpdate")==="usage_update"&&t8.safeParse(e).success},isNotice(e){return me(e,"sessionUpdate")==="notice"&&n8.safeParse(e).success},isCompactionUpdate(e){return me(e,"sessionUpdate")==="compaction_update"&&r8.safeParse(e).success},isCompactionSummaryChunk(e){return me(e,"sessionUpdate")==="compaction_summary_chunk"&&i8.safeParse(e).success},isSubagentUpdate(e){return me(e,"sessionUpdate")==="subagent_update"&&u8.safeParse(e).success},isSessionMessage(e){return me(e,"sessionUpdate")==="session_message"&&s8.safeParse(e).success},isSessionMessageChunk(e){return me(e,"sessionUpdate")==="session_message_chunk"&&o8.safeParse(e).success},isCustom(e){let t=me(e,"sessionUpdate");return typeof t=="string"&&!["agent_message","agent_message_chunk","agent_thought","agent_thought_chunk","available_commands_update","compaction_summary_chunk","compaction_update","config_option_update","notice","plan_removed","plan_update","session_info_update","session_message","session_message_chunk","state_update","subagent_update","terminal_output_chunk","terminal_update","tool_call_content_chunk","tool_call_update","usage_update","user_message","user_message_chunk"].includes(t)}},f8={isRunning(e){return me(e,"state")==="running"&&a8.safeParse(e).success},isIdle(e){return me(e,"state")==="idle"&&l8.safeParse(e).success},isRequiresAction(e){return me(e,"state")==="requires_action"&&c8.safeParse(e).success},isUnknown(e){return me(e,"state")==="unknown"&&d8.safeParse(e).success},isCustom(e){let t=me(e,"state");return typeof t=="string"&&!["idle","requires_action","running","unknown"].includes(t)}},zm="initialize",Nn=1,dr=2,p8=65535,m8=class{v1;v2;withV1(e){return this.v1=e,this}withV2(e){return this.v2=e,this}connect(e,t={}){let n=new C8(t.deferConnectHandlers!==!0);return this.route(e,n).catch(async i=>{try{await Eb(e.writable,i)}catch{}finally{n.finish()}}),n}async route(e,t){let n=e.readable.getReader(),i;try{i=await n.read()}catch(g){throw n.releaseLock(),g}if(i.done){n.releaseLock(),await yb(e.writable),t.finish();return}let r=i.value;if(g8(r)){await _8(n,e.writable,k.invalidRequest("first ACP message must be an initialize request")),t.finish();return}let u=!1,s=r;if(Array.isArray(r))if(r.length===1&&Jr(r[0])&&r[0].method===zm)u=!0,s=r[0];else{await ir(n,e.writable,null,k.invalidRequest("first ACP message must be an initialize request")),t.finish();return}if(!Jr(s)){await ir(n,e.writable,null,k.invalidRequest("first ACP message must be an initialize request")),t.finish();return}if(s.method!==zm){await ir(n,e.writable,s.id,k.invalidRequest("first ACP request must be initialize"),u),t.finish();return}if(!Xf(s.params)){await ir(n,e.writable,s.id,Om(),u),t.finish();return}let o=s.params.protocolVersion;if(!b8(o)){await ir(n,e.writable,s.id,Om(),u),t.finish();return}let a=this.selectProtocol(o);if(!a){await ir(n,e.writable,s.id,k.unsupportedProtocolVersion(o,[...this.v1?[Nn]:[],...this.v2?[dr]:[]]),u),t.finish();return}let l;try{l=S8(s.params,o,a)}catch(g){let C=g instanceof Error?g.message:String(g);await ir(n,e.writable,s.id,k.invalidParams(`invalid initialize params: ${C}`),u),t.finish();return}let c={...s,params:l},p={readable:E8(n,u&&a===dr?[c]:c,t),writable:u&&a===Nn?w8(e.writable,s.id):e.writable},v=a===dr?this.v2:this.v1;if(!v)throw new Error("selected ACP protocol implementation is not configured");try{let g=v.connect(p,{deferConnectHandlers:!0});t.attach(g)}catch(g){try{await n.cancel(g)}catch{}finally{n.releaseLock()}throw g}}selectProtocol(e){if(this.v1&&!this.v2)return Nn;if(this.v2&&e>=dr)return dr;if(this.v1&&e>=Nn)return Nn}};function g8(e){return Array.isArray(e)?e.length>0&&(J6(e)||e.every(t=>On(t)||Nf(t))):On(e)||vo(e)}function v8(){return new m8}var C8=class{closed;resolveClosed=()=>{};isFinished=!1;startRequested;connectHandlersStarted=!1;selected;constructor(e){this.startRequested=e,this.closed=new Promise(t=>{this.resolveClosed=t})}startConnectHandlers(){this.startRequested=!0,this.maybeStartConnectHandlers()}attach(e){this.selected=y8(e),this.maybeStartConnectHandlers(),this.selected?.closed&&this.selected.closed.then(()=>this.finish(),()=>this.finish())}finish(){this.isFinished||(this.isFinished=!0,this.resolveClosed())}maybeStartConnectHandlers(){!this.startRequested||this.connectHandlersStarted||!this.selected?.startConnectHandlers||(this.connectHandlersStarted=!0,this.selected.startConnectHandlers())}};function y8(e){if(typeof e!="object"||e===null)return;let t=e;if(!(t.closed===void 0&&t.startConnectHandlers===void 0))return t}function E8(e,t,n){let i=t,r=!1,u=()=>{r||(r=!0,e.releaseLock())};return new ReadableStream({async pull(s){if(i!==void 0){s.enqueue(i),i=void 0;return}try{let o=await e.read();if(o.done){u(),s.close(),n.finish();return}s.enqueue(o.value)}catch(o){u(),s.error(o),n.finish()}},async cancel(s){try{await e.cancel(s)}finally{u(),n.finish()}}})}function w8(e,t){let n=!1;return new WritableStream({async write(i){let r=i;!n&&!Array.isArray(i)&&vo(i)&&"id"in i&&i.id===t&&(n=!0,r=[i]);let u=e.getWriter();try{await u.write(r)}finally{u.releaseLock()}},close:()=>yb(e),abort:i=>Eb(e,i)})}async function ir(e,t,n,i,r=!1){let u={jsonrpc:"2.0",id:n,error:A8(i)},s=t.getWriter();try{await s.write(r?[u]:u),await s.close()}finally{s.releaseLock();try{await e.cancel(i)}finally{e.releaseLock()}}}async function _8(e,t,n){let i=t.getWriter();try{await i.close()}finally{i.releaseLock();try{await e.cancel(n)}finally{e.releaseLock()}}}function A8(e){return{code:e.code,message:e.message,...e.data===void 0?{}:{data:e.data}}}function Om(){return k.invalidParams("initialize.protocolVersion must be a valid ACP protocol version")}async function yb(e){let t=e.getWriter();try{await t.close()}finally{t.releaseLock()}}async function Eb(e,t){if(e.locked)return;let n=e.getWriter();try{await n.abort(t)}finally{n.releaseLock()}}function b8(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=p8}function S8(e,t,n){return n===Nn?t>=dr?D8(_o.parse(e)):Nm(Of.parse(e),Nn):Nm(_o.parse(e),dr)}function Nm(e,t){return gl({...e,protocolVersion:t})}function D8(e){return gl({protocolVersion:Nn,clientCapabilities:I8(e.capabilities),clientInfo:e.info,_meta:e._meta})}function I8(e){let t={fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,session:{configOptions:{boolean:{}}},plan:{},auth:$8(e?.auth)};return e?.elicitation!=null&&(t.elicitation=e.elicitation),e?._meta!=null&&(t._meta=e._meta),t}function $8(e){let t=e?.terminal;if(t?._meta!=null)throw new Error("v2 AuthCapabilities.terminal metadata cannot be represented in v1");return{terminal:t!=null,...e?._meta==null?{}:{_meta:e._meta}}}function gl(e){let t={};for(let[n,i]of Object.entries(e))if(i!=null){if(n==="_meta"){t[n]=i;continue}if(Array.isArray(i)){i.length>0&&(t[n]=i.map(wb));continue}t[n]=Xf(i)?gl(i):i}return t}function wb(e){return Array.isArray(e)?e.map(wb):Xf(e)?gl(e):e}function Xf(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Or(e){return e??{}}var _b=new Set([...Object.values(de),...Object.values(Ot),...Object.values(Qu)]);function cu(e,t,n,i=!1){if(!(Object.hasOwn(t,e)||i&&e===Qu.cancel_request)&&_b.has(e))throw new TypeError(`ACP v2 ${n} method '${e}' is not valid in this direction`)}function Ao(e,t){if(_b.has(e))throw new TypeError(`Cannot replace the built-in ACP v2 ${t} parser for '${e}'`)}function Ab(e,t,n){for(let i of e)cu(i.method,i.kind==="request"?t:n,i.kind,i.kind==="notification")}function Yf(e){let t=Wf.parse(typeof e=="object"&&e!==null&&!Array.isArray(e)?e.protocolVersion:void 0);if(t<vr)throw k.unsupportedProtocolVersion(t,[vr]);let n=_o.parse(e);return structuredClone({...n,protocolVersion:vr})}function Mm(e){let n={...typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},protocolVersion:vr},i=Yf(n);return{wire:structuredClone(n),parsed:i}}function Qf(e){let t=J_.parse(e);if(t.protocolVersion!==vr)throw k.invalidRequest({expectedProtocolVersion:vr,receivedProtocolVersion:t.protocolVersion},`The v2 API only supports protocol version ${vr}`);return structuredClone(t)}function B8(e){return Qf(e),structuredClone(e)}function k8(e){return structuredClone(e)}function x8(){let e,t;return{promise:new Promise((i,r)=>{e=i,t=r}),resolve:e,reject:t}}var T8=class{phase="uninitialized";request;barrier=x8();constructor(){this.barrier.promise.catch(()=>{})}get status(){return this.phase}get initialized(){return this.barrier.promise.then(k8)}begin(e){if(this.phase!=="uninitialized")throw k.invalidRequest("ACP v2 initialize may only be requested once per connection");let t=structuredClone(e);this.request=t,this.phase="initializing"}complete(e){if(this.phase!=="initializing"||!this.request)throw k.invalidRequest("ACP v2 initialization is not in progress");let t={request:structuredClone(this.request),response:structuredClone(e)};this.phase="initialized",this.barrier.resolve(t)}fail(e){(this.phase==="uninitialized"||this.phase==="initializing")&&(this.phase="failed",this.request=void 0,this.barrier.reject(e??k.invalidRequest("ACP v2 connection initialization failed")))}waitUntilInitialized(e){return this.phase==="initialized"?Promise.resolve():this.phase==="initializing"?this.barrier.promise.then(()=>{}):Promise.reject(bb(e))}},Um=new WeakMap;function Hn(e){let t=Um.get(e);return t||(t=new T8,Um.set(e,t),e.signal.aborted?t.fail(e.signal.reason):e.signal.addEventListener("abort",()=>t?.fail(e.signal.reason),{once:!0})),t}function bb(e){return k.invalidRequest(`ACP v2 connection must be initialized before '${e}'`)}async function bo(e,t){let n=bb(e.method);return t.fail(n),Gc(e,n)}async function Gc(e,t){return e.kind==="request"&&await e.responder.respondWithError(t),He.yes()}function F8(){return{async handleMessage(e,t){let n=Hn(t);if(e.kind==="notification"&&e.method===Qu.cancel_request)return n.status==="initializing"||n.status==="initialized"?He.yes():bo(e,n);if(e.kind==="request"&&e.method===de.initialize){if(n.status!=="uninitialized")return Gc(e,k.invalidRequest("ACP v2 initialize may only be requested once per connection"));let i=$F(e.responder);if(i!==void 0&&i!==1){let u=k.invalidRequest("ACP v2 initialize must be the only entry in its batch");return n.fail(u),Gc(e,u)}let r;try{r=Yf(e.params)}catch(u){throw n.fail(u),u}return n.begin(r),He.no(e)}return n.status==="initialized"?He.no(e):n.status==="initializing"?(await n.waitUntilInitialized(e.method),He.no(e)):bo(e,n)},describe:()=>"agent-initialization"}}function P8(){return{async handleMessage(e,t){let n=Hn(t);return e.kind==="notification"&&e.method===Qu.cancel_request?n.status==="initializing"||n.status==="initialized"?He.yes():bo(e,n):n.status==="initialized"?He.no(e):n.status==="initializing"?(await n.waitUntilInitialized(e.method),He.no(e)):bo(e,n)},describe:()=>"client-initialization"}}function So(e,t){return Yu(e.response,t)}function Vc(e,t,n){return e.map(i=>{if(i.kind!=="request")return i;let r=t[i.method],u=i.mapResponse;return{...i,mapResponse:r?s=>{let o=So(r,s);return n&&i.method===de.initialize&&n(o),u?u(o):o}:u}})}function Sb(e){return typeof e=="object"&&e!==null&&"readable"in e&&"writable"in e}function Db(){let e=new TransformStream,t=new TransformStream;return[{readable:t.readable,writable:e.writable},{readable:e.readable,writable:t.writable}]}var Ve={agent:{initialize:de.initialize,auth:{login:de.auth_login,logout:de.auth_logout},providers:{list:de.providers_list,set:de.providers_set,disable:de.providers_disable},session:{new:de.session_new,list:de.session_list,delete:de.session_delete,fork:de.session_fork,resume:de.session_resume,close:de.session_close,setConfigOption:de.session_set_config_option,prompt:de.session_prompt,cancel:de.session_cancel},mcp:{message:de.mcp_message}},client:{session:{requestPermission:Ot.session_request_permission,update:Ot.session_update},mcp:{message:Ot.mcp_message},elicitation:{create:Ot.elicitation_create,complete:Ot.elicitation_complete}},protocol:{cancelRequest:Qu.cancel_request}},Ib=Symbol("startActiveSession"),$b=class{cx;currentRequestId;constructor(e,t){this.cx=e,this.currentRequestId=t}get initialized(){return Hn(this.cx).initialized}get initializationLifecycle(){return Hn(this.cx)}get requestId(){return this.currentRequestId}get connectionContext(){return this.cx}sendRequest(e,t,n,i){return this.cx.sendRequest(e,t,n,i)}sendNotification(e,t){return this.cx.sendNotification(e,t)}sendBatch(e){return this.cx.sendBatch(e)}addDynamicHandler(e){return this.cx.addDynamicHandler(e)}},Hc=class Bb extends $b{constructor(t,n){super(t,n)}static create(t,n){return new Bb(t,n)}request(t,n,i){cu(t,ji,"request");let r=ji[t];return this.initializationLifecycle.waitUntilInitialized(t).then(()=>this.sendRequest(t,n,r?u=>So(r,u):void 0,i))}notify(t,n){return cu(t,Xc,"notification",!0),this.initializationLifecycle.waitUntilInitialized(t).then(()=>this.sendNotification(t,n))}batch(t){return Ab(t,ji,Xc),this.initializationLifecycle.waitUntilInitialized("batch").then(()=>this.sendBatch(Vc(t,ji)))}},Jc=class kb extends $b{closeOnInitializationFailure;constructor(t,n,i){super(t,n),this.closeOnInitializationFailure=i}static create(t,n,i){return new kb(t,n,i)}[Ib](t,n){return this.request(de.session_new,t,n).then(i=>this.attachSession(i))}buildSession(t){return typeof t=="string"?Lm.create(this,{cwd:t,mcpServers:[]}):Lm.create(this,t)}attachSession(t){let n=new O8,i=this.connectionContext.signal,r=()=>{n.fail(i.reason??new Error("ACP connection closed"))};i.aborted?r():i.addEventListener("abort",r);let u=zb(this.connectionContext).attach(t,n),s=new Ku(()=>{i.removeEventListener("abort",r)});return N8.create(this,t,n,[u,s])}request(t,n,i){cu(t,jr,"request");let r=jr[t],u=this.initializationLifecycle;if(t===de.initialize){let{wire:s,parsed:o}=Mm(n);u.begin(o);let a;try{a=this.sendRequest(t,s,l=>{let c=So(r,l);return u.complete(c),c},i)}catch(l){throw u.fail(l),this.closeOnInitializationFailure?.(l),l}return a.catch(l=>{u.status!=="initialized"&&(u.fail(l),this.closeOnInitializationFailure?.(l))}),a}return u.waitUntilInitialized(t).then(()=>this.sendRequest(t,n,r?s=>So(r,s):void 0,i))}notify(t,n){return cu(t,Kc,"notification",!0),this.initializationLifecycle.waitUntilInitialized(t).then(()=>this.sendNotification(t,n))}batch(t){Ab(t,jr,Kc);let n=t.filter(i=>i.kind==="request"&&i.method===de.initialize);if(n.length>0){if(t.length!==1||n.length!==1)return Promise.reject(k.invalidRequest("ACP v2 initialize must be the only entry in its batch"));let i=this.initializationLifecycle,{wire:r,parsed:u}=Mm(n[0].params);i.begin(u);let s=[{...n[0],params:r}],o;try{o=this.sendBatch(Vc(s,jr,a=>i.complete(a)))}catch(a){throw i.fail(a),this.closeOnInitializationFailure?.(a),a}return o.catch(a=>{i.status!=="initialized"&&(i.fail(a),this.closeOnInitializationFailure?.(a))}),o}return this.initializationLifecycle.waitUntilInitialized("batch").then(()=>this.sendBatch(Vc(t,jr)))}},xb=class{connection;constructor(e){this.connection=e}get initialized(){return Hn(this.connection.getContext()).initialized}get signal(){return this.connection.signal}get closed(){return this.connection.closed}close(e){this.connection.close(e)}},R8=class extends xb{connectHandlers;client;didStartConnectHandlers=!1;constructor(e,t=[]){super(e),this.connectHandlers=t,this.client=Hc.create(e.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,Cl(this,this.connectHandlers))}},z8=class extends xb{connectHandlers;agent;didStartConnectHandlers=!1;constructor(e,t=[]){super(e),this.connectHandlers=t,this.agent=Jc.create(e.getContext(),void 0,n=>e.close(n))}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,Cl(this,this.connectHandlers))}};function Tb(e,t=[]){return new R8(e,t)}function Fb(e,t=[]){return new z8(e,t)}var O8=class{values=[];waiters=[];failed=!1;failure;enqueue(e){if(this.failed)return;let t=this.waiters.shift();t?t.resolve(e):this.values.push(e)}fail(e){if(!this.failed){this.failed=!0,this.failure=e;for(let t of this.waiters.splice(0))t.reject(e)}}next(e){return e?.aborted?Promise.reject(e.reason):this.values.length>0?Promise.resolve(this.values.shift()):this.failed?Promise.reject(this.failure):new Promise((t,n)=>{let i=()=>{e?.removeEventListener("abort",u)},r={resolve:s=>{i(),t(s)},reject:s=>{i(),n(s)}},u=()=>{let s=this.waiters.indexOf(r);s>=0&&this.waiters.splice(s,1),r.reject(e?.reason)};this.waiters.push(r),e?.addEventListener("abort",u,{once:!0}),e?.aborted&&u()})}};function jm(e){return structuredClone(e)}var Lm=class Pb{cx;request;constructor(t,n){this.cx=t,this.request=jm(n)}static create(t,n){return new Pb(t,n)}toRequest(){return jm(this.request)}withAdditionalDirectories(t){return this.request={...this.request,additionalDirectories:[...t]},this}withMcpServer(t){return this.request={...this.request,mcpServers:[...this.request.mcpServers??[],structuredClone(t)]},this}async start(t){return this.cx[Ib](this.toRequest(),t)}async withSession(t){let n=await this.start();try{return await t(n)}finally{n.dispose()}}},N8=class Rb{cx;sessionResponse;updates;registrations;constructor(t,n,i,r){this.cx=t,this.sessionResponse=n,this.updates=i,this.registrations=r}static create(t,n,i,r){return new Rb(t,n,i,r)}get sessionId(){return this.sessionResponse.sessionId}get configOptions(){return this.sessionResponse.configOptions}get meta(){return this.sessionResponse._meta}get newSessionResponse(){return this.sessionResponse}prompt(t,n){return this.cx.request(de.session_prompt,{sessionId:this.sessionId,prompt:this.promptBlocks(t)},n)}nextUpdate(t){return this.updates.next(t)}async readTextUntilIdle(t){let n=[],i=new Map,r=u=>{let s=i.get(u);return s||(s=[],n.push(u),i.set(u,s)),s};for(;;){let u=await this.nextUpdate(t);if(u.kind==="stop")return n.flatMap(o=>i.get(o)??[]).filter(h8.isText).map(o=>o.text).join("");let{update:s}=u;Wc.isAgentMessage(s)?(r(s.messageId),s.content!==void 0&&i.set(s.messageId,s.content??[])):Wc.isAgentMessageChunk(s)&&r(s.messageId).push(s.content)}}dispose(){for(let t of this.registrations.splice(0))t.dispose();this.updates.fail(new Error("Active session disposed"))}[Symbol.dispose](){this.dispose()}promptBlocks(t){return typeof t=="string"?[{type:"text",text:t}]:Array.isArray(t)?t:[t]}};function st(e,t,n,i){return{method:e,params:r=>Yu(t,r??{}),response:n,serializeResponse:i}}function Do(e,t){return{method:e,params:t}}function vl(e){let t=Object.create(null);for(let n of Object.values(e))t[n.method]=n;return t}var M8={initialize:st(de.initialize,Yf,Qf,B8),loginAuth:st(de.auth_login,JA,K_,Or),unstable_listProviders:st(de.providers_list,KA,X_),unstable_setProvider:st(de.providers_set,XA,Y_,Or),unstable_disableProvider:st(de.providers_disable,YA,Q_,Or),newSession:st(de.session_new,rb,uA),setSessionConfigOption:st(de.session_set_config_option,cb,hA),prompt:st(de.session_prompt,db,fA),listSessions:st(de.session_list,ib,oA),deleteSession:st(de.session_delete,ub,aA,Or),unstable_forkSession:st(de.session_fork,sb,lA),resumeSession:st(de.session_resume,ab,cA),closeSession:st(de.session_close,lb,dA,Or),logoutAuth:st(de.auth_logout,QA,eA,Or)},U8={cancelSession:Do(de.session_cancel,vb),unstable_messageMcp:Do(de.mcp_message,Cb)},j8={requestPermission:st(Ot.session_request_permission,k_,fb),unstable_messageMcp:st(Ot.mcp_message,q_,gb),createElicitation:st(Ot.elicitation_create,j_,mb)},L8={sessionUpdate:Do(Ot.session_update,Hf),completeElicitation:Do(Ot.elicitation_complete,VA)},jr=vl(M8),Kc=vl(U8),ji=vl(j8),Xc=vl(L8);function q8(e,t,n,i,r){return{method:r,params:e,requestId:i,signal:n,client:t}}function Z8(e,t,n,i){return{method:i,params:e,signal:n,client:t}}function W8(e,t,n,i,r){return{method:r,params:e,requestId:i,signal:n,agent:t}}function G8(e,t,n,i){return{method:i,params:e,signal:n,agent:t}}var V8=class{activeSessions=new Map;handleMessage(e){if(e.kind!=="notification"||e.method!==Ot.session_update)return He.no(e);let t=Hf.parse(e.params),{update:n}=t,i=Wc.isStateUpdate(n)&&f8.isIdle(n),r=this.activeSessions.get(t.sessionId);if(r&&r.size>0)for(let u of r)i?u.enqueue({kind:"stop",notification:t,update:n,stopReason:n.stopReason}):u.enqueue({kind:"session_update",notification:t,update:n});return He.no(e)}attach(e,t){let n=this.activeSessions.get(e.sessionId)??new Set;return n.add(t),this.activeSessions.set(e.sessionId,n),new Ku(()=>{n.delete(t),n.size===0&&this.activeSessions.delete(e.sessionId)})}},qm=new WeakMap;function zb(e){let t=qm.get(e);return t||(t=new V8,qm.set(e,t)),t}function Cl(e,t){for(let n of t){let i;try{i=n(e)}catch(r){throw e.close(r),r}Promise.resolve(i).catch(r=>{e.close(r)})}}var Io=Symbol("appBuilder"),Os=Symbol("runAgentConnectHandlers"),Ns=Symbol("runClientConnectHandlers");function $o(e,t){e.closed.then(async()=>{Hn(e.getContext()).status==="initialized"&&await t.initialized.catch(()=>{}),t.close(e.signal.reason)})}function H8(e){return new J8(e)}var J8=class{builder=Xu.builder();connectHandlers=[];fallbackKinds=new Set;hasInitializeHandler=!1;constructor(e={}){this.builder.withHandler(F8()),e.name&&this.builder.name(e.name)}[Io](){return this.assertInitializeHandler(),this.builder}[Os](e){Cl(e,this.connectHandlers)}connect(e,t={}){return this.connectConnection(e,t).connection}connectWith(e,t){let{rawConnection:n,connection:i}=this.connectConnection(e);return n.runUntil(()=>t(i.client))}onConnect(e){return this.connectHandlers.push(e),this}onRequest(e,t,n){if(e==="*"){if(n)throw new Error("Wildcard handlers receive raw params; omit the parser.");if(this.fallbackKinds.has("request"))throw new Error("A request fallback is already registered.");return this.fallbackKinds.add("request"),this.request({method:e},t)}if(n)return Ao(e,"request"),this.request({method:e,params:t},n);let i=jr[e];if(!i)throw new Error(`Unknown ACP request method '${e}'. Pass a params parser for custom methods.`);return e===de.initialize&&(this.hasInitializeHandler=!0),this.request(i,t)}onNotification(e,t,n){if(e==="*"){if(n)throw new Error("Wildcard handlers receive raw params; omit the parser.");if(this.fallbackKinds.has("notification"))throw new Error("A notification fallback is already registered.");return this.fallbackKinds.add("notification"),this.notification({method:e},t)}if(n)return Ao(e,"notification"),this.notification({method:e,params:t},n);let i=Kc[e];if(!i)throw new Error(`Unknown ACP notification method '${e}'. Pass a params parser for custom methods.`);return this.notification(i,t)}request(e,t){return sl(this.builder,e,(n,i,r,u,s)=>q8(n,Hc.create(i,u),r,u,s),t,e.serializeResponse,e.method===de.initialize?{afterResponse:(n,i,r)=>{Hn(r).complete(Qf(i))},onError:(n,i)=>Hn(n).fail(i)}:void 0),this}notification(e,t){return ol(this.builder,e,(n,i,r,u)=>Z8(n,Hc.create(i),r,u),t),this}connectConnection(e,t={}){if(this.assertInitializeHandler(),Sb(e)){let o=this.openStreamConnection(e);return t.deferConnectHandlers||this[Os](o.connection),o}let[n,i]=Db(),r=e[Io]().connect(i),u=Fb(r),s=this.openStreamConnection(n);$o(s.rawConnection,u),$o(r,s.connection);try{e[Ns](u),this[Os](s.connection)}catch(o){throw u.close(o),s.connection.close(o),o}return s}openStreamConnection(e){let t=this.builder.connect(e);return{rawConnection:t,connection:Tb(t,this.connectHandlers)}}assertInitializeHandler(){if(!this.hasInitializeHandler)throw new Error("AgentApp requires an initialize request handler before connecting")}},IG=class{builder=Xu.builder();connectHandlers=[];fallbackKinds=new Set;constructor(e={}){e.name&&this.builder.name(e.name),this.builder.withHandler(P8()),this.builder.withHandler({handleMessage:(t,n)=>zb(n).handleMessage(t),describe:()=>"client-session-update-router"})}[Io](){return this.builder}[Ns](e){Cl(e,this.connectHandlers)}connect(e){return this.connectConnection(e).connection}connectWith(e,t){let{rawConnection:n,connection:i}=this.connectConnection(e);return n.runUntil(()=>t(i.agent))}onConnect(e){return this.connectHandlers.push(e),this}onRequest(e,t,n){if(e==="*"){if(n)throw new Error("Wildcard handlers receive raw params; omit the parser.");if(this.fallbackKinds.has("request"))throw new Error("A request fallback is already registered.");return this.fallbackKinds.add("request"),this.request({method:e},t)}if(n)return Ao(e,"request"),this.request({method:e,params:t},n);let i=ji[e];if(!i)throw new Error(`Unknown ACP request method '${e}'. Pass a params parser for custom methods.`);return this.request(i,t)}onNotification(e,t,n){if(e==="*"){if(n)throw new Error("Wildcard handlers receive raw params; omit the parser.");if(this.fallbackKinds.has("notification"))throw new Error("A notification fallback is already registered.");return this.fallbackKinds.add("notification"),this.notification({method:e},t)}if(n)return Ao(e,"notification"),this.notification({method:e,params:t},n);let i=Xc[e];if(!i)throw new Error(`Unknown ACP notification method '${e}'. Pass a params parser for custom methods.`);return this.notification(i,t)}request(e,t){return sl(this.builder,e,(n,i,r,u,s)=>W8(n,Jc.create(i,u),r,u,s),t,e.serializeResponse),this}notification(e,t){return ol(this.builder,e,(n,i,r,u)=>G8(n,Jc.create(i),r,u),t),this}connectConnection(e){if(Sb(e)){let s=this.openStreamConnection(e);return this[Ns](s.connection),s}let[t,n]=Db(),i=e[Io]().connect(n),r=Tb(i),u=this.openStreamConnection(t);$o(u.rawConnection,r),$o(i,u.connection);try{e[Os](r),this[Ns](u.connection)}catch(s){throw r.close(s),u.connection.close(s),s}return u}openStreamConnection(e){let t=this.builder.connect(e);return{rawConnection:t,connection:Fb(t,this.connectHandlers)}}};function X8(e){switch(e.type){case"boolean":{let{id:t,...n}=e;return{configId:t,...n}}case"select":{let{id:t,options:n,...i}=e;return{configId:t,...i,options:Y8(n)}}}}function Yc(e){return e.map(X8)}function Y8(e){return Q8(e)?e.map(({group:t,...n})=>({groupId:t,...n})):e}function Q8(e){let t=e[0];return t!==void 0&&"group"in t}function e2(e){let t={sessionId:e.sessionId,configId:e.configId,...e._meta!==void 0?{_meta:e._meta}:{}},n=e.value;if(e.type==="id"&&typeof n=="string")return{...t,value:n};if(e.type==="boolean"&&typeof n=="boolean")return{...t,type:"boolean",value:n};throw k.invalidParams()}function Ii(e){let t=e.replace(/^(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[lc]+\s+)?/,"");return t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}var t2="codex-structured-plan";function Nb(e){return e.map(t=>{let{input:n,...i}=t;return n===void 0?i:{...t,input:n&&{...n,type:"text"}}})}function n2(e){if(e.sessionUpdate!=="tool_call"&&e.sessionUpdate!=="tool_call_update")return[Ul(e)];let{_meta:t,...n}=e;if(t==null||!u2.some(p=>p in t))return[Ul(e)];let{terminal_info:i,terminal_output:r,terminal_output_delta:u,terminal_exit:s,...o}=t,a=s2({info:i,output:r??u,exit:s},n.rawInput),{sessionUpdate:l,toolCallId:c,...m}=n;return Object.keys(m).length===0&&Object.keys(o).length===0?a:[...a,Ul({...n,...Object.keys(o).length>0?{_meta:o}:{}})]}function Ul(e){switch(e.sessionUpdate){case"plan_update":case"plan_removed":case"session_info_update":case"usage_update":case"notice":case"compaction_update":case"compaction_summary_chunk":return e;case"config_option_update":return{...e,configOptions:Yc(e.configOptions)};case"plan":{let{entries:t,_meta:n}=e;return{sessionUpdate:"plan_update",plan:{type:"items",planId:t2,entries:t},...n!=null?{_meta:n}:{}}}case"available_commands_update":return{...e,availableCommands:Nb(e.availableCommands)};case"current_mode_update":throw k.internalError(void 0,"'current_mode_update' session update does not exist in ACP v2");case"user_message_chunk":{let{messageId:t}=e;if(t==null)throw k.internalError(void 0,"'user_message_chunk' session update without a messageId is not supported on an ACP v2 connection");return{...e,messageId:t}}case"agent_message_chunk":case"agent_thought_chunk":return{...e,messageId:e.messageId||K8()};case"tool_call":case"tool_call_update":{let{content:t,...n}=e;return{...n,sessionUpdate:"tool_call_update",...t!==void 0?{content:t&&t.map(Mb)}:{}}}case"subagent_update":return e;case"subagent_spawned":{let{subagentSessionId:t,name:n,task:i,_meta:r}=e;return{sessionUpdate:"_subagent_update",subagentSessionId:t,name:n,task:i,capabilities:{},...r!=null?{_meta:r}:{}}}case"subagent_state_update":{let{subagentSessionId:t,state:n,_meta:i}=e;return{sessionUpdate:"_subagent_update",subagentSessionId:t,state:n,...i!=null?{_meta:i}:{}}}case"async_task_spawned":return{...e,sessionUpdate:"_async_task_spawned"};case"async_task_state_update":return{...e,sessionUpdate:"_async_task_state_update"};case"async_task_progress":throw k.internalError(void 0,`'${e.sessionUpdate}' session update is not supported on an ACP v2 connection yet`)}}function Mb(e){switch(e.type){case"content":return e;case"terminal":return e;case"diff":return{type:"diff",...r2(e)}}}var ep="diff_git_patch";function r2(e){let{[ep]:t,...n}=e._meta??{},{oldPath:i,text:r}=i2(t),u=n.kind,s=e.path,o;switch(u){case"add":o={operation:"add",path:s};break;case"delete":o={operation:"delete",path:s};break;case"update":o=i===s?{operation:"modify",path:s}:{operation:"move",oldPath:i,path:s};break;default:throw k.internalError(void 0,`Diff content without a known 'kind': ${String(u)}`)}return{changes:[o],patch:{format:"git_patch",text:r},...Object.keys(n).length>0?{_meta:n}:{}}}function i2(e){let t=e;if(typeof t?.oldPath!="string"||typeof t.text!="string")throw k.internalError(void 0,`Malformed '${ep}' diff metadata`);return{oldPath:t.oldPath,text:t.text}}var u2=["terminal_info","terminal_output","terminal_output_delta","terminal_exit"];function s2(e,t){let n=e.info==null?null:jl(e.info,"terminal_info"),i=e.output==null?null:jl(e.output,"terminal_output"),r=e.exit==null?null:jl(e.exit,"terminal_exit"),u=(n??i??r).terminal_id,s={terminalId:u};if(n){let l=t?.command;typeof l=="string"&&(s.command=Ii(l)),typeof n.cwd=="string"&&Ob.isAbsolute(n.cwd)&&(s.cwd=n.cwd)}let o=i?o2(i.data,"terminal_output"):null;r&&(o!==null&&(s.output={data:o}),s.exitStatus={exitCode:typeof r.exit_code=="number"?r.exit_code:null,signal:typeof r.signal=="string"?r.signal:null});let a=[];return(n||r)&&a.push({sessionUpdate:"terminal_update",...s}),o!==null&&!r&&a.push({sessionUpdate:"terminal_output_chunk",terminalId:u,data:o}),a}function jl(e,t){if(typeof e!="object"||e===null||typeof e.terminal_id!="string")throw k.internalError(void 0,`Malformed '${t}' tool call metadata`);return e}function o2(e,t){if(typeof e!="string")throw k.internalError(void 0,`Malformed '${t}' tool call metadata`);return Buffer.from(e,"utf8").toString("base64")}var Bt="jetbrains",kt="air",du="version",Ub="capabilities",tp="diffPatch",Bo="sessionFailure",Ms="agentFileChangeReport",Qc="customInstructions",ed="nativeSubagentSessions",Us="asyncTasks",Qi="recommendedValue",a2="backgrounded",l2="agentFileChangeReportRequest",c2="phase",jb="goal",Zm="kind",Wm="commandAction",d2="skillPath",Lb="permission",h2="contextCompaction",qb="rawInputRendering",Zb="planContentDelta",f2="codexHooks",p2="contentDelta",m2="subagent",g2="customAnswer",v2="_askUserQuestionCustomAnswer",hu=1;function xt(e,t,n){let i=Jt(e),r=Jt(i[Bt]),u=Jt(r[kt]);return{...i,[Bt]:{...r,[kt]:{...u,[du]:hu,[t]:n}}}}function hi(e,t,n){return e?xt(void 0,t,n):void 0}function fu(e){let t=Jt(e?._meta),i=Jt(t[Bt])[kt];return i!==null&&typeof i=="object"&&!Array.isArray(i)}function yn(e,t){let n=Jt(e?._meta),i=Jt(n[Bt]),r=Jt(i[kt]),u=r[du],s=r[Ub];return typeof u=="number"&&Number.isInteger(u)&&u>=hu&&Array.isArray(s)&&s.includes(t)}function td(e){let t=Jt(e),n=Jt(t[Bt]),r=Jt(n[kt])[Qc];return typeof r=="string"?r:void 0}function Jt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}var C2="Run command?",y2="Allow network access?",E2="Make edits?",w2="Grant permissions?",np="permission_prompt";function Ll(e,t,n){let i=Wb(n),r={version:1,title:t,...i?{description:i}:{}},u={permission:r,...hi(e.airClient,Lb,r),...e.permissionPromptFields?{[np]:r}:{}};return Object.keys(u).length>0?{_meta:u}:{}}function _2(e){let t=e?.[np];if(typeof t!="object"||t===null)return;let{title:n,description:i}=t;if(typeof n=="string")return{version:1,title:n,...typeof i=="string"?{description:i}:{}}}function A2(e,t){let n=Wb(t);if(!n)return;let i={version:1,description:n};return{permission:i,...hi(e,Lb,i)}}function Wb(e){let t=e?.trim();return t||void 0}function b2(e){let t=_2(e._meta),{title:n,...i}=e.toolCall,r=t?.title??n;if(!r)throw k.internalError(void 0,"'session/request_permission' request has no title to send on ACP v2");let{content:u,...s}=t?e.toolCall:i,o={...s,...u!==void 0?{content:u&&u.map(Mb)}:{}},{[np]:a,...l}=e._meta??{};return{sessionId:e.sessionId,title:r,...t?.description?{description:t.description}:{},subject:{type:"tool_call",toolCall:o},options:e.options,...Object.keys(l).length>0?{_meta:l}:{}}}function S2(e){let t=e.sessionId;return typeof t=="string"?t:void 0}var Gb=class{constructor(e,t=!1){this.notify=e,this.activity=t==="unknown"?"unknown":t?"running":"idle"}notify;activity;items=new Set;actions=new Map;sending=Promise.resolve();async update(e){if(e.state==="idle"||e.state==="unknown"){if(this.items.clear(),this.actions.clear(),this.activity===e.state)return this.sending;this.activity=e.state}else if(e.state==="running"||e.state==="requires_action"){if(this.activity===e.state)return this.sending;this.activity=e.state}await this.publish(e)}async start(){(this.activity==="idle"||this.actions.size===0)&&await this.update({state:"running"})}snapshot(){switch(this.activity){case"idle":return this.publish({state:"idle"});case"running":return this.publish({state:"running"});case"requires_action":return this.publish({state:"requires_action"});case"unknown":return this.publish({state:"unknown"})}}async startItem(e){this.activity!=="idle"&&(this.items.add(e),await this.reportActionState())}async completeItem(e){this.items.delete(e),this.activity!=="idle"&&this.actions.size>0&&await this.reportActionState()}async withUserAction(e,t,n){if(n?.aborted)return t();let i=Symbol();this.actions.set(i,e),this.activity==="idle"&&(this.activity="running");try{return await this.reportActionStateSafely(),await t()}finally{this.actions.delete(i)&&!n?.aborted&&await this.reportActionStateSafely()}}dispose(){this.activity="idle",this.items.clear(),this.actions.clear()}invalidate(){this.activity="unknown",this.items.clear(),this.actions.clear()}reportActionState(){let e=new Set(this.actions.values());return[...this.items].some(n=>!e.has(n))?this.update({state:"running"}):this.actions.size>0?this.update({state:"requires_action"}):this.sending}async reportActionStateSafely(){try{await this.reportActionState()}catch(e){D.error("Failed to report foreground user-action state",e)}}publish(e){return this.serializePublication(()=>this.notify(e))}serializePublication(e){let t=this.sending.then(e);return this.sending=t.catch(()=>{}),t}},nn=class{client;isTurnRunning=()=>!0;foreground=new Map;constructor(e){this.client=e}setTurnRunningCheck(e){this.isTurnRunning=e}async withUserAction(e,t,n,i){return this.isTurnRunning(e)?this.foregroundFor(e).withUserAction(t,n,i):n()}async updateSession(e,t){for(let n of n2(t))await this.client.notify(Ve.client.session.update,{sessionId:e,update:n})}async updateState(e,t){await this.foregroundFor(e).update(t)}startForegroundWork(e){return this.foregroundFor(e).start()}snapshotForegroundState(e){return this.foregroundFor(e).snapshot()}startForegroundItem(e,t){return this.foregroundFor(e).startItem(t)}completeForegroundItem(e,t){return this.foregroundFor(e).completeItem(t)}restoreForegroundState(e,t){this.foregroundFor(e,t)}forgetSession(e){this.foreground.get(e)?.dispose(),this.foreground.delete(e)}foregroundFor(e,t=!1){let n=this.foreground.get(e);return n||(n=new Gb(i=>this.client.notify(Ve.client.session.update,{sessionId:e,update:{sessionUpdate:"state_update",...i}}),t),this.foreground.set(e,n)),n}async startReplayMessage(e,t,n){let i;switch(t){case"user_message":i={sessionUpdate:"user_message",messageId:n,content:[]};break;case"agent_message":i={sessionUpdate:"agent_message",messageId:n,content:[]};break;case"agent_thought":i={sessionUpdate:"agent_thought",messageId:n,content:[]};break}await this.client.notify(Ve.client.session.update,{sessionId:e,update:i})}async requestPermission(e,t){return this.withUserAction(e.sessionId,e.toolCall.toolCallId,async()=>{let n=await this.client.request(Ve.client.session.requestPermission,b2(e),t);return n},t?.cancellationSignal)}async createElicitation(e,t){let n=async()=>{let u=await this.client.request(Ve.client.elicitation.create,e,t);return u},i=S2(e);if(i===void 0)return n();let r="toolCallId"in e&&typeof e.toolCallId=="string"?e.toolCallId:void 0;return this.withUserAction(i,r,n,t?.cancellationSignal)}async completeElicitation(e){await this.client.notify(Ve.client.elicitation.complete,e)}extensionOnlyV1View(){let e={notify:(t,n)=>{if(t.startsWith("_"))return this.client.notify(t,n);if(t===ae.client.session.update){let i=n;return this.updateSession(i.sessionId,i.update)}return t===ae.client.elicitation.complete?this.completeElicitation(n):Gm(t)},request:(t,n,i)=>t.startsWith("_")?this.client.request(t,n,i):t===ae.client.session.requestPermission?this.requestPermission(n,i):t===ae.client.elicitation.create?this.createElicitation(n,i):Gm(t)};return ql.set(e,this),e}registerView(e){ql.set(e,this)}static of(e){return ql.get(e)??null}},ql=new WeakMap;function Gm(e){return Promise.reject(k.internalError(void 0,`'${e}' is not supported on an ACP v2 connection yet`))}var Fe=class Vb{connection;v2Connection;sessionId;constructor(t,n){this.connection=t,this.v2Connection=nn.of(t),this.sessionId=n}get protocolVersion(){return this.v2Connection?2:1}async updateState(t){if(!this.v2Connection)throw k.internalError(void 0,"'state_update' does not exist in ACP v1");await this.v2Connection.updateState(this.sessionId,t)}async updateSubagentState(t,n,i){this.v2Connection&&await this.v2Connection.client.notify(Ve.client.session.update,{sessionId:t,update:{sessionUpdate:"state_update",...i}}),await this.update({sessionUpdate:"subagent_update",sessionId:t,state:i},n)}forSession(t){return new Vb(this.connection,t)}async startReplayMessage(t,n){if(!this.v2Connection)throw k.internalError(void 0,`'${t}' does not exist in ACP v1`);await this.v2Connection.startReplayMessage(this.sessionId,t,n)}async update(t,n=this.sessionId){await this.connection.notify(ae.client.session.update,{sessionId:n,update:t})}get clientConnection(){return this.connection}},yl="model",rp="reasoning_effort";function nd(e){return/^gpt-/i.test(e)?e.replace(/^gpt-/i,"").split(/[-/]+/).filter(Boolean).map(Hb).join(" "):e}function Hb(e){return e.charAt(0).toUpperCase()+e.slice(1)}var D2={low:"Low",medium:"Medium",high:"High",xhigh:"XHigh",max:"Max",ultra:"Ultra"};function I2(e){return D2[e]??Hb(e)}function eu(e,t){if(t)return e.find(n=>n.reasoningEffort===t)?.reasoningEffort}function Jb(e,t){let n=e.map(i=>({value:i.id,name:nd(i.displayName),description:i.description}));return t!==null&&!e.some(i=>i.id===t)&&n.unshift({value:t,name:nd(t),description:null}),n}function $2(e,t,n){let i=Jb(e,t),r=n&&i.some(u=>u.value===n)?n:void 0;return{id:yl,name:"Model",description:"Model Codex uses for the session",category:"model",type:"select",currentValue:t,options:i,...r?{_meta:xt(void 0,Qi,r)}:{}}}function Kb(e,t,n){let i=eu(e,n);return{id:rp,name:"Reasoning effort",description:"How much reasoning effort the model should use",category:"thought_level",type:"select",currentValue:t,options:e.map(r=>({value:r.reasoningEffort,name:I2(r.reasoningEffort),description:r.description})),...i?{_meta:xt(void 0,Qi,i)}:{}}}var B2=Q.object({version:Q.literal(1),modelId:Q.string().min(1).optional(),configOptionValues:Q.record(Q.string(),Q.union([Q.string(),Q.boolean()]))});function k2(e){if(typeof e!="object"||e===null)return{};let t=e.lody;if(typeof t!="object"||t===null)return{};let n=t.sessionConfig;if(n===void 0)return{};let i=B2.safeParse(n);if(!i.success)throw k.invalidParams(void 0,"Invalid sessionConfig version 1");let{modelId:r,configOptionValues:u}=i.data,s=r??u[yl],o=u[rp];if(s!==void 0&&(typeof s!="string"||!s.trim()))throw k.invalidParams(void 0,"Invalid sessionConfig model");let a=typeof s=="string"&&s.includes("[")?s.match(/^([^\[]+)\[([^\]]+)\]$/):void 0;if(typeof s=="string"&&s.includes("[")&&!a)throw k.invalidParams(void 0,"Invalid sessionConfig model");let l=o??a?.[2];if(l!==void 0&&(typeof l!="string"||!l.trim()))throw k.invalidParams(void 0,"Invalid sessionConfig reasoning effort");return{...s!==void 0?{model:a?.[1]??s}:{},...typeof l=="string"?{model_reasoning_effort:l}:{}}}function ip(e,t,n){let i=e.length>0?Jb(e,t):[],r=e.find(s=>s.id===n)?.id??e.find(s=>s.model===n)?.id??n,u=i.find(s=>s.value===r)??{value:n,name:n,description:null};return{id:yl,name:"Model",description:"Model Codex uses for the subagent",category:"model",type:"select",currentValue:u.value,options:[u]}}function is(e){switch(e){case"inProgress":return"in_progress";case"completed":return"completed";case"failed":case"declined":case"interrupted":return"failed"}}function El(e){return e==="completed"?"completed":"failed"}var pu=class{static started(e){return{...Vm(e,"start"),kind:"other",...e.prompt?{readableInput:e.prompt}:{}}}static completed(e){return Vm(e,"update")}};function Vm(e,t){let n={prompt:e.prompt,senderThreadId:e.senderThreadId,receiverThreadIds:e.receiverThreadIds,agentsStates:e.agentsStates,model:e.model,reasoningEffort:e.reasoningEffort};return{toolCallId:e.id,report:t,title:e.tool,status:is(e.status),input:n,...e.tool==="spawnAgent"?{subagent:!0}:{},standard:{content:null,rawInput:{...n,status:e.status},rawOutput:null}}}var mu=class{static activity(e,t,n){let i=e.agentPath.split("/").filter(Boolean).at(-1)??"subagent";return{toolCallId:e.id,report:n,...n==="start"?{kind:"other",title:x2(e.kind,i)}:{},status:t,input:{agentThreadId:e.agentThreadId,agentPath:e.agentPath,activityKind:e.kind},subagent:!0}}};function x2(e,t){switch(e){case"started":return`Start subagent ${t}`;case"interacted":return`Interact with subagent ${t}`;case"interrupted":return`Interrupt subagent ${t}`;case"completed":return`Complete subagent ${t}`}}var T2={"item/agentMessage/delta":"delta","item/plan/delta":"delta","item/reasoning/summaryTextDelta":"delta","item/reasoning/textDelta":"delta","item/commandExecution/outputDelta":"delta","item/fileChange/outputDelta":"delta"},js=class Xb{constructor(t,n=Xb.MAX_BYTES){this.threadId=t,this.maxBytes=n}threadId;maxBytes;static MAX_BYTES=32*1024*1024;notifications=[];bytes=0;dropped=0;push(t){let n=T2[t.method],i=this.notifications.at(-1);if(n!==void 0&&i!==void 0&&P2(i,t,n)){let r=String(t.params[n]??"");if(!this.reserve(F2(r)))return;let u=i.params;i.params={...u,[n]:`${u[n]}${r}`};return}this.reserve(Buffer.byteLength(JSON.stringify(t),"utf8"))&&this.notifications.push({...t})}take(){return this.bytes=0,this.notifications.splice(0)}get droppedCount(){return this.dropped}get size(){return this.notifications.length}reserve(t){return this.bytes+t<=this.maxBytes?(this.bytes+=t,!0):(this.dropped+=1,this.dropped===1&&D.log(`Pending subagent ${this.threadId} exceeded the notification buffer of ${this.maxBytes} bytes; dropping updates`),!1)}};function F2(e){return Buffer.byteLength(JSON.stringify(e),"utf8")-2}function P2(e,t,n){return e.method!==t.method?!1:JSON.stringify({...e.params,[n]:null})===JSON.stringify({...t.params,[n]:null})}function rn(e){return e.trim().replace(/\/+$/,"")||"/root"}function fi(e){let t=rn(e);return t==="/root"||t==="root"}function pi(e,t){let n=rn(e),i=n.slice(n.lastIndexOf("/")+1).trim();if(!i)return t;let r=i.replace(/[_-]+/g," ").replace(/\s+/g," ").trim();return r?r.charAt(0).toUpperCase()+r.slice(1):t}var z2=class{constructor(e,t){this.root=e,this.connection=t}root;connection;runs=new Map;permissionTools=new Map;async emit(e){await this.connection.notify(pP,e)}async metadata(e,t){let n=this.runs.get(e);!n||!Object.entries(t).some(([i,r])=>n.snapshot[i]!==r)||(n.snapshot={...n.snapshot,...t},await this.emit({version:1,sessionId:this.root,runId:n.id,type:"snapshot",snapshot:n.snapshot}))}async update(e,t){if(e.sessionUpdate==="subagent_spawned"){let r=this.runs.get(t),u={state:"running",...t===this.root?{parentRunId:null}:r?{parentRunId:r.id}:{},name:e.name,description:e.task,support:{stream:["text","thought","tool","plan"],progress:!1,outputRead:"none",cancel:!1}},s=e._meta?.lody;(s?.initialState==="completed"||s?.initialState==="failed"||s?.initialState==="cancelled")&&(u.state=s.initialState),s?.initialState==="disconnected"&&(u.state="unknown",u.outputIncomplete=!0),typeof s?.parentToolCallId=="string"&&(u.parentToolCallId=s.parentToolCallId),s?.outputIncomplete===!0&&(u.outputIncomplete=!0);let o={id:R2(),snapshot:u};this.runs.set(e.subagentSessionId,o),this.permissionTools.delete(e.subagentSessionId),await this.emit({version:1,sessionId:this.root,runId:o.id,type:"snapshot",snapshot:u});return}if(e.sessionUpdate==="subagent_state_update"){let r=this.runs.get(e.subagentSessionId);if(!r)return;let u=e._meta?.lody;r.snapshot={...r.snapshot,state:e.state==="disconnected"?"unknown":e.state,...e.state==="disconnected"?{outputIncomplete:!0,reason:{code:u?.reasonCode==="timeout"?"timeout":"disconnected"}}:{}},await this.emit({version:1,sessionId:this.root,runId:r.id,type:"snapshot",snapshot:r.snapshot});return}if(t===this.root){await this.connection.notify(ae.client.session.update,{sessionId:t,update:e});return}let n=this.runs.get(t);if(!n||["completed","failed","cancelled"].includes(n.snapshot.state)||!vP(e))return;let i=e._meta?.lody;await this.emit({version:1,sessionId:this.root,runId:n.id,type:"output",update:e,...typeof i?.turnId=="string"?{nativeTurnId:i.turnId}:{},..."messageId"in e&&typeof e.messageId=="string"?{messageId:e.messageId}:{}}),(e.sessionUpdate==="tool_call"||e.sessionUpdate==="tool_call_update")&&this.permissionTools.get(t)?.has(e.toolCallId)&&await this.connection.notify(ae.client.session.update,{sessionId:this.root,update:{...e,toolCallId:this.toolId(n.id,e.toolCallId),_meta:{...e._meta,lody:{...i,subagentRunId:n.id}}}})}wrap(e){return{notify:(async(t,n)=>{if(t===ae.client.session.update&&typeof n.sessionId=="string"){await this.update(n.update,n.sessionId);return}await e.notify(t,n)}),request:(async(t,n,i)=>{let r=n.sessionId;if(typeof r!="string"||r===this.root)return await e.request(t,n,i);let u=this.runs.get(r);if(!u||u.snapshot.state!=="running")throw new Error("Unknown or inactive subagent interaction");let s=n._meta,o=n.toolCall,a=o?.toolCallId??(typeof n.toolCallId=="string"?n.toolCallId:void 0);if(a){let l=this.permissionTools.get(r)??new Set;l.add(a),this.permissionTools.set(r,l)}return await e.request(t,{...n,sessionId:this.root,...o?{toolCall:{...o,toolCallId:this.toolId(u.id,o.toolCallId)}}:{},...typeof n.toolCallId=="string"?{toolCallId:this.toolId(u.id,n.toolCallId)}:{},_meta:{...s,lody:{...s?.lody,subagentRunId:u.id,...a?{subagentToolCallId:a}:{}}}},i)})}}toolId(e,t){return`subagent:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}},ko={threadStarted:0,activity:1,settings:2};function Li(e,t){return!e||!t?e??t:ko[t.source]>=ko[e.source]?t:e}async function Yb(e,t,n,i){if(!(!i||!n))try{await e.update({sessionUpdate:"config_option_update",configOptions:[ip(n.availableModels,n.currentModel,i)]},t)}catch(r){D.error(`Failed to report the model of subagent session ${t}`,r)}}var Qb=class eS{constructor(t,n,i,r=!1,u=()=>{},s=typeof r=="function"?u:()=>null){this.rootSessionId=t,this.supported=n,this.session=i,this.rootModels=s,this.onChildSessionEnded=typeof r=="function"?r:u,r===!0&&(this.lodyEvents=new z2(t,i.clientConnection),this.session=new Fe(this.lodyEvents.wrap(i.clientConnection),t))}rootSessionId;supported;session;rootModels;onChildSessionEnded;lodyEvents;static DEFAULT_WAIT_TIMEOUT_MS=600*1e3;children=new Map;pendingSpawns=new Map;terminalPendingSpawns=new Map;waiters=new Set;materializationWaiters=new Map;replayQueue=[];activeLegacyActivities=new Set;earlyThreadModels=new Map;spawnsInFlight=new Set;appliedSettings=new WeakSet;connectionForEvents(t){return this.lodyEvents?.wrap(t)??t}async handle(t){if(t.method==="thread/started"){let u=t.params.thread,s=u.parentThreadId===this.rootSessionId||u.parentThreadId!==null&&this.children.has(u.parentThreadId)||this.spawnsInFlight.size>0;return u.model&&await this.applyThreadModel(u.id,{model:u.model,source:"threadStarted"},s),!1}if(t.method==="thread/settings/updated"&&!this.appliedSettings.delete(t.params)){let u=t.params.threadId;await this.applyThreadModel(u,{model:t.params.threadSettings.model,source:"settings"},this.spawnsInFlight.size>0),this.pendingSpawns.has(u)&&this.appliedSettings.add(t.params)}if(t.method==="turn/started"){let u=this.isKnownChild(t.params.threadId);return u&&await this.reopen(t.params.threadId),u}if(t.method==="turn/completed"){t.params.threadId===this.rootSessionId&&(this.earlyThreadModels.clear(),this.spawnsInFlight.clear());let u=this.isKnownChild(t.params.threadId),s=Hm(t.params.turn.status);return s&&(t.params.threadId===this.rootSessionId?s!=="completed"&&await this.finishOutstanding(s):this.pendingSpawns.has(t.params.threadId)?this.finishPending(t.params.threadId):await this.finish(t.params.threadId,s)),u}let n=t.params.threadId;if(typeof n=="string"&&this.pendingSpawns.has(n))return this.pendingSpawns.get(n).buffered.push(t),!0;if(t.method!=="item/started"&&t.method!=="item/completed")return!1;let i=t.params.item;if(!this.supported)return!1;if(i.type==="subAgentActivity"){if(fi(i.agentPath))return!0;if(this.terminalPendingSpawns.has(i.agentThreadId))return i.model&&await this.applyThreadModel(i.agentThreadId,{model:i.model,source:"activity"},!1),!0;let u=this.children.has(i.agentThreadId),s=this.children.get(i.agentThreadId);return s&&this.lodyEvents&&(s.name=pi(i.agentPath,s.name),s.path=rn(i.agentPath),await this.lodyEvents.metadata(s.sessionId,{name:s.name})),u||(await this.materialize(i.agentThreadId,i.agentPath,i.model),u=this.children.has(i.agentThreadId)),u&&i.kind==="interrupted"&&await this.finish(i.agentThreadId,"cancelled"),u}if(i.type!=="collabAgentToolCall")return!1;if(i.tool==="resumeAgent"||i.tool==="sendInput"||i.tool==="followupTask")for(let[u,s]of Object.entries(i.agentsStates))(s?.status==="running"||s?.status==="pendingInit")&&await this.reopen(u);let r=!1;if(i.tool==="spawnAgent"){t.method==="item/started"?this.spawnsInFlight.add(i.id):this.spawnsInFlight.delete(i.id);let u=this.children.get(i.senderThreadId),s=u||this.lodyEvents?i.senderThreadId:this.rootSessionId,o=u?.sessionId??(this.lodyEvents?i.senderThreadId:this.rootSessionId);for(let a of i.receiverThreadIds){if(a.trim().length===0){D.log("Ignoring spawned subagent with an empty thread id");continue}if(a===o||a===this.rootSessionId){D.log(`Ignoring self-referential spawned subagent ${a}`);continue}if(this.children.has(a)||this.pendingSpawns.has(a)||this.terminalPendingSpawns.has(a)){r=!0;continue}let l=i.agentsStates[a]?.status,c=this.lodyEvents?i.status==="failed"?"failed":l==="notFound"||l==="shutdown"?"disconnected":l?Zl(l):void 0:void 0,m=this.takeEarlyModel(a);this.pendingSpawns.set(a,{parentToolCallId:i.id,...c?{initialState:c}:{},parentThreadId:s,parentSessionId:o,task:i.prompt?.trim()||"Delegated task",...m?{model:m}:{},buffered:new js(a)}),this.lodyEvents&&(await this.materialize(a,"",i.model),i.model&&await this.lodyEvents.metadata(a,{modelId:i.model})),r=!0}}for(let[u,s]of Object.entries(i.agentsStates)){let o=this.children.get(u);o&&s?.message&&this.lodyEvents&&await this.lodyEvents.metadata(o.sessionId,{summary:s.message});let a=s&&this.lodyEvents&&(s.status==="notFound"||s.status==="shutdown")?"disconnected":s&&Zl(s.status);a&&(this.children.has(u)?await this.finish(u,a):this.pendingSpawns.has(u)&&this.finishPending(u))}if(i.tool==="spawnAgent"&&i.status==="failed")for(let u of i.receiverThreadIds)this.pendingSpawns.has(u)?this.finishPending(u):this.lodyEvents&&await this.finish(u,"failed");return this.lodyEvents!==void 0||i.tool==="spawnAgent"&&r}shouldIgnore(t){let n=t.params.threadId,i=typeof n=="string"&&(this.children.get(n)?.terminalState!==void 0||this.terminalPendingSpawns.has(n));return i&&D.log(`Ignoring update for terminal subagent ${n}`),i}isNativeSubagentThread(t){return t!==this.rootSessionId&&this.children.has(t)}notificationSessionId(t){let n=t.params.threadId;return typeof n=="string"&&this.children.has(n)?this.children.get(n).sessionId:this.rootSessionId}closingChildSessions(t){if(!this.supported)return[];if(t.method==="turn/completed"){let r=Hm(t.params.turn.status);return r===void 0?[]:t.params.threadId===this.rootSessionId&&r!=="completed"?[...this.children.keys()].flatMap(u=>this.closingChildSession(u,r)):this.closingChildSession(t.params.threadId,r)}if(t.method!=="item/started"&&t.method!=="item/completed")return[];let n=t.params.item;if(n.type==="subAgentActivity")return n.kind==="interrupted"?this.closingChildSession(n.agentThreadId,"cancelled"):[];if(n.type!=="collabAgentToolCall")return[];let i=new Map;for(let[r,u]of Object.entries(n.agentsStates)){let s=u&&Zl(u.status);if(s)for(let o of this.closingChildSession(r,s))i.set(r,o)}return[...i.values()]}childSessionIds(){return[...this.children.values()].filter(t=>t.terminalState===void 0).map(t=>t.sessionId)}takeBufferedNotifications(){return this.replayQueue.splice(0)}async waitForMaterializedSession(t){let n=this.children.get(t);return n?n.terminalState===void 0?n.sessionId:null:this.terminalPendingSpawns.has(t)||!this.pendingSpawns.has(t)?null:await new Promise(i=>{let r=this.materializationWaiters.get(t)??new Set;r.add(i),this.materializationWaiters.set(t,r)})}legacyActivityStarted(t){return this.activeLegacyActivities.add(t.id),mu.activity(t,"in_progress","start")}legacyCollaborationStarted(t){return pu.started(t)}legacyCollaborationCompleted(t){return pu.completed(t)}legacyActivityCompleted(t){let n=this.activeLegacyActivities.delete(t.id)?"update":"start";return mu.activity(t,"completed",n)}async wait(t,n=eS.DEFAULT_WAIT_TIMEOUT_MS){let i=Date.now()+n;for(;this.hasOutstanding();){if(t.aborted)return"aborted";let r=i-Date.now();if(r<=0)return D.log(`Timed out waiting for subagents in session ${this.rootSessionId}; marking them failed`),this.lodyEvents&&await this.finishOutstanding("disconnected","timeout"),"timed_out";if(!await new Promise(s=>{let o=setTimeout(()=>{this.waiters.delete(l),t.removeEventListener("abort",a),s(!1)},r),a=()=>{clearTimeout(o),this.waiters.delete(l),s(!0)},l=()=>{clearTimeout(o),t.removeEventListener("abort",a),s(!0)};this.waiters.add(l),t.addEventListener("abort",a,{once:!0})}))return D.log(`Timed out waiting for subagents in session ${this.rootSessionId}; marking them failed`),this.lodyEvents&&await this.finishOutstanding("disconnected","timeout"),"timed_out"}return"settled"}async finishOutstanding(t,n){this.lodyEvents&&(t="disconnected"),this.earlyThreadModels.clear(),this.spawnsInFlight.clear();for(let i of[...this.pendingSpawns.keys()])this.finishPending(i);for(let i of[...this.children.keys()].reverse())await this.finish(i,t,n)}isKnownChild(t){return t!==this.rootSessionId&&(this.children.has(t)||this.pendingSpawns.has(t)||this.terminalPendingSpawns.has(t))}closingChildSession(t,n){let i=this.children.get(t);return i&&i.terminalState===void 0?[{threadId:t,sessionId:i.sessionId,state:n}]:[]}async materialize(t,n,i){if(this.children.has(t))return;let r=this.pendingSpawns.get(t),u=n.trim()?pi(n,Wl(t)):Wl(t),s=this.parentForPath(n),o=r?.parentThreadId??s.threadId,a=r?.parentSessionId??s.sessionId,l=r?.task??`Delegated task for ${u}`,c=Li(r?r.model:this.takeEarlyModel(t),i?{model:i,source:"activity"}:void 0);await this.session.update({sessionUpdate:"subagent_spawned",subagentSessionId:t,name:u,task:l,capabilities:{},...r&&this.lodyEvents?{_meta:{lody:{parentToolCallId:r.parentToolCallId,...r.initialState?{initialState:r.initialState}:{},...r.buffered.droppedCount>0?{outputIncomplete:!0}:{}}}}:{}},a),this.children.set(t,{parentThreadId:o,parentSessionId:a,sessionId:t,name:u,task:l,...n.trim()?{path:rn(n)}:{},...c?{model:c}:{},generation:1,...r?.initialState?{terminalState:r.initialState}:{}}),this.pendingSpawns.delete(t);for(let m of r?.buffered.take()??[])this.replayQueue.push(m);this.resolveMaterialization(t,t),await this.reportModel(t,t)}finishPending(t){let n=this.pendingSpawns.get(t);n&&(this.pendingSpawns.delete(t),this.terminalPendingSpawns.set(t,{parentThreadId:n.parentThreadId,task:n.task,...n.model?{model:n.model}:{}}),this.onChildSessionEnded(t),this.resolveMaterialization(t,null),this.notifyWaiters())}async finish(t,n,i){let r=this.children.get(t);if(!(!r||r.terminalState!==void 0)){r.terminalState=n;try{await this.session.update({sessionUpdate:"subagent_state_update",subagentSessionId:r.sessionId,state:n,...this.lodyEvents&&i?{_meta:{lody:{reasonCode:i}}}:{}},r.parentSessionId)}catch(u){throw r.terminalState===n&&delete r.terminalState,u}this.onChildSessionEnded(r.sessionId),this.notifyWaiters()}}async reopen(t){let n=this.children.get(t);if(!n){let s=this.terminalPendingSpawns.get(t);if(!s)return;let o=this.children.get(s.parentThreadId)?.sessionId??this.rootSessionId,a={parentThreadId:s.parentThreadId,parentSessionId:o,sessionId:`${t}:generation:2`,name:Wl(t),task:s.task,...s.model?{model:s.model}:{},generation:2};await this.session.update({sessionUpdate:"subagent_spawned",subagentSessionId:a.sessionId,name:a.name,task:a.task,capabilities:{}},o),this.children.set(t,a),this.terminalPendingSpawns.delete(t),await this.reportModel(t,a.sessionId);return}if(!n.terminalState)return;let i=n.sessionId,r=n.parentSessionId,u=n.terminalState;n.parentSessionId=this.children.get(n.parentThreadId)?.sessionId??this.rootSessionId,n.generation+=1,n.sessionId=`${t}:generation:${n.generation}`,delete n.terminalState;try{await this.session.update({sessionUpdate:"subagent_spawned",subagentSessionId:n.sessionId,name:n.name,task:n.task,capabilities:{}},n.parentSessionId)}catch(s){throw n.generation-=1,n.sessionId=i,n.parentSessionId=r,n.terminalState=u,s}await this.reportModel(t,n.sessionId)}async applyThreadModel(t,n,i){if(!this.supported||t===this.rootSessionId)return;let r=this.pendingSpawns.get(t)??this.terminalPendingSpawns.get(t);if(r){r.model=Li(r.model,n);return}let u=this.children.get(t);if(!u){i&&this.earlyThreadModels.set(t,Li(this.earlyThreadModels.get(t),n));return}let s=u.model;u.model=Li(s,n),!(u.model===s||u.terminalState!==void 0)&&(s&&this.modelValue(s.model)===this.modelValue(n.model)||await this.reportModel(t,u.sessionId))}takeEarlyModel(t){let n=this.earlyThreadModels.get(t);return this.earlyThreadModels.delete(t),n}modelValue(t){let n=this.rootModels(),i=ip(n?.availableModels??[],n?.currentModel??null,t);return String(i.currentValue)}async reportModel(t,n){let i=this.children.get(t);!i||i.terminalState!==void 0||i.sessionId!==n||this.terminalPendingSpawns.has(t)||await Yb(this.session,n,this.rootModels(),i.model?.model)}resolveMaterialization(t,n){for(let i of this.materializationWaiters.get(t)??[])i(n);this.materializationWaiters.delete(t)}hasOutstanding(){return this.pendingSpawns.size>0||[...this.children.values()].some(t=>t.terminalState===void 0)}notifyWaiters(){for(let t of this.waiters)t();this.waiters.clear()}parentForPath(t){let n=rn(t),i=n.lastIndexOf("/");if(i<=0)return{threadId:this.rootSessionId,sessionId:this.rootSessionId};let r=n.slice(0,i);if(fi(r))return{threadId:this.rootSessionId,sessionId:this.rootSessionId};let u=[...this.children.entries()].find(([,s])=>s.path===r);return u?{threadId:u[0],sessionId:u[1].sessionId}:this.lodyEvents?{threadId:`unresolved:${r}`,sessionId:`unresolved:${r}`}:{threadId:this.rootSessionId,sessionId:this.rootSessionId}}};function Zl(e){switch(e){case"completed":return"completed";case"interrupted":return"cancelled";case"errored":case"shutdown":case"notFound":return"failed";case"pendingInit":case"running":return}}function Hm(e){switch(e){case"completed":return"completed";case"interrupted":return"cancelled";case"failed":return"failed";case"inProgress":return}}function Wl(e){return`Agent ${e.length>8?e.slice(-8):e}`}var Gr="_session/async_task/stop",N2="_auth/status_update",Jm="authStatus";function Km(){return{}}var M2="Not logged in",U2="Custom model gateway",j2="wire",L2="JetBrains Air Gateway",q2={free:"Free",go:"Go",plus:"Plus",pro:"Pro",team:"Team",business:"Business",enterprise:"Enterprise",edu:"Edu"};function Z2(e){return!e||e==="unknown"?null:q2[e]??W2(e)}function W2(e){return e.charAt(0).toUpperCase()+e.slice(1)}function tS(e){let t=Z2(e);return t===null?"ChatGPT":`ChatGPT ${t}`}function xo(e){let t=typeof e=="string"&&e.trim().length>0?e.trim():void 0;return{kind:"gateway",label:U2,...t===void 0?{}:{detail:t}}}function Xm(e){return e?.trim().toLowerCase()===j2?{kind:"gateway",label:L2}:xo(e)}function nS(){return{kind:"none",label:M2}}function Gl(e){if(e===null)return nS();switch(e.type){case"chatgpt":{let t={};return e.email&&(t.email=e.email),e.planType&&(t.plan=e.planType),{kind:"account",label:tS(e.planType),...Object.keys(t).length>0?{account:t}:{}}}case"apiKey":return{kind:"api_key",label:"OpenAI API key"};case"amazonBedrock":return{kind:"external",label:"AWS Bedrock"}}}function G2(e,t){let n=e.authMode;if(n===null)return nS();switch(n){case"chatgpt":case"chatgptAuthTokens":{let i={kind:"account",label:tS(e.planType)},r={},u=t?.kind==="account"?t.account?.email:void 0;return u&&(r.email=u),e.planType&&(r.plan=e.planType),Object.keys(r).length>0&&(i.account=r),i}case"apikey":return{kind:"api_key",label:"OpenAI API key"};case"personalAccessToken":return{kind:"api_key",label:"OpenAI personal access token"};case"bedrockApiKey":case"bedrockAccessKeys":return{kind:"external",label:"AWS Bedrock"};case"agentIdentity":return{kind:"external",label:"Agent identity"};case"headers":return xo()}}function V2(e,t){switch(e.authMode){case null:return null;case"chatgpt":case"chatgptAuthTokens":{let n=t?.type==="chatgpt"?t:null;return{type:"chatgpt",email:n?.email??null,planType:e.planType??n?.planType??"unknown"}}case"apikey":case"personalAccessToken":return{type:"apiKey"};default:return t}}function H2(e,t){return e?e.kind===t.kind&&e.label===t.label&&e.detail===t.detail&&e.account?.email===t.account?.email&&e.account?.organization===t.account?.organization&&e.account?.plan===t.account?.plan&&JSON.stringify(e.vendor)===JSON.stringify(t.vendor):!1}var To="session/set_model",J2=Kn.sessionUsageUpdate,K2=Kn.rateLimitsUpdate,X2=Kn.sessionSteerApplied,Vr=Kn.sessionSteer,Ym=Kn.sessionHistoryRead,Qm=Kn.rateLimitsGet,eg={promptSuggestions:{version:1},subagentEvents:{version:1},usage:{version:1},rateLimits:{version:1,query:!0},forkAtTurn:{version:1},steering:{version:1,transport:"request",upstreamTurn:"same",configPolicy:"active"},tasks:{version:1,background:!0},subagents:{version:1,lifecycle:!0},goal:{version:1,actions:["set","pause","resume","clear"],controlActions:["pause","clear"],promptActions:["set","pause","resume","clear"]},compaction:{version:1},sessionHistory:{version:1},worktreeProject:{version:1}};function Y2(e){if(typeof e!="object"||e===null)return null;let t=e.lody;if(typeof t!="object"||t===null)return null;let n=t.forkAtTurn;if(typeof n!="object"||n===null)return null;let i=n.version,r=n.turnId;return i===1&&typeof r=="string"&&r.length>0?r:null}function Q2(e){return e.method==="authentication/status"||e.method==="authentication/logout"||e.method===To||e.method===mr||e.method===Vr||e.method===Gr}var tg=256;function vn(e){let t=qi(e);if(t===null||t.length<=tg)return t;let n=t.slice(0,tg-1);return/[\uD800-\uDBFF]$/.test(n)&&(n=n.slice(0,-1)),`${n.trimEnd()}\u2026`}function rS(e){return qi(e.name)??qi(e.title)??qi(e.summary)??qi(e.preview)}function qi(e){let t=e?.replace(/\s+/g," ").trim()??"";return t.length===0?null:t}function ng(e){return{totalTokens:e.totalTokens,inputTokens:Math.max(0,e.inputTokens-e.cachedInputTokens-e.cacheWriteInputTokens),cachedInputTokens:e.cachedInputTokens,cacheWriteInputTokens:e.cacheWriteInputTokens,outputTokens:e.outputTokens,reasoningOutputTokens:e.reasoningOutputTokens}}function ez(e){return{totalTokens:e.totalTokens,inputTokens:e.inputTokens,cachedReadTokens:e.cachedInputTokens,cachedWriteTokens:e.cacheWriteInputTokens,outputTokens:e.outputTokens,thoughtTokens:e.reasoningOutputTokens}}var tz=Object.freeze({totalTokens:0,inputTokens:0,cachedInputTokens:0,cacheWriteInputTokens:0,outputTokens:0,reasoningOutputTokens:0}),up=["totalTokens","inputTokens","cachedInputTokens","cacheWriteInputTokens","outputTokens","reasoningOutputTokens"];function rg(e,t,n){let i={};for(let r of up)i[r]=n(e[r],t[r]);return i}function nz(e,t){return up.every(n=>e[n]===t[n])}var rz=class{startTotal;previousTotal;latestTotal=null;summedLast=null;totalWentBack=!1;modelOutputSeen=!1;constructor(e){this.startTotal=e,this.previousTotal=e}observeModelOutput(){this.modelOutputSeen=!0}observe(e,t){let n=this.previousTotal;if(!(n!==null&&nz(e,n))){if(n===null&&!this.modelOutputSeen){this.startTotal=e,this.previousTotal=e;return}n!==null&&up.some(i=>e[i]<n[i])&&(this.totalWentBack=!0),this.summedLast=this.summedLast===null?{...t}:rg(this.summedLast,t,(i,r)=>i+r),this.previousTotal=e,this.latestTotal=e}}usage(){let e=this.startTotal,t=this.latestTotal;return t===null?null:e!==null&&!this.totalWentBack?rg(t,e,(n,i)=>n-i):this.summedLast}},Vl=["inputTokens","outputTokens","cacheReadInputTokens","cacheCreationInputTokens","reasoningOutputTokens"],Hl=()=>({inputTokens:0,outputTokens:0,cacheReadInputTokens:0,cacheCreationInputTokens:0,reasoningOutputTokens:0});function ig(e){return{inputTokens:Math.max(0,e.inputTokens-e.cachedInputTokens-e.cacheWriteInputTokens),outputTokens:Math.max(0,e.outputTokens-e.reasoningOutputTokens),cacheReadInputTokens:e.cachedInputTokens,cacheCreationInputTokens:e.cacheWriteInputTokens,reasoningOutputTokens:e.reasoningOutputTokens}}var Fo=class{previous;turn;requestedModel;constructor(e=!1,t){this.previous=t?ig(t):e?Hl():void 0}prepare(e){this.requestedModel=e}start(e,t){this.turn?.id!==e&&(this.turn={id:e,model:this.requestedModel??t,usage:Hl()})}update(e){let t=ig(e.tokenUsage.total),n=this.turn;if(!n){this.previous=t;return}if(e.turnId!==n.id)return;if(!this.previous){this.previous=t;return}let i=Hl();for(let r of Vl)i[r]=Math.max(0,(t[r]??0)-(this.previous[r]??0));if(this.previous=t,!!Vl.some(r=>(i[r]??0)>0)){for(let r of Vl)n.usage[r]=(n.usage[r]??0)+(i[r]??0);return{sessionId:e.threadId,usage:{...n.usage,...e.tokenUsage.modelContextWindow!==null&&{contextWindow:e.tokenUsage.modelContextWindow}},modelUsage:{[n.model]:{...n.usage}},delta:{usage:{...i},modelUsage:{[n.model]:{...i}}},_meta:{lody:{usageScopeId:n.id},codex:{usageTurnId:n.id}}}}}};function iS(e){let t=e.split(/\n/),n=[],i=0;function r(g){return/^diff --git /.test(g)}function u(g){return r(g)||/^Index:\s/.test(g)||/^diff(?: -r \w+)+\s/.test(g)}function s(g){return/^(---|\+\+\+)\s/.test(g)}function o(g){return/^@@\s/.test(g)}function a(){var g;let C={};C.hunks=[],n.push(C);let y=!1;for(;i<t.length;){let b=t[i];if(s(b)||o(b))break;if(r(b)){if(y)return;y=!0,C.isGit=!0;let A=l(b);for(A&&(C.oldFileName=A.oldFileName,C.newFileName=A.newFileName),i++;i<t.length;){let S=t[i];if(s(S)||o(S)||u(S))break;let z=/^rename from (.*)/.exec(S);z&&(C.oldFileName="a/"+c(z[1]),C.isRename=!0);let M=/^rename to (.*)/.exec(S);M&&(C.newFileName="b/"+c(M[1]),C.isRename=!0);let T=/^copy from (.*)/.exec(S);T&&(C.oldFileName="a/"+c(T[1]),C.isCopy=!0);let G=/^copy to (.*)/.exec(S);G&&(C.newFileName="b/"+c(G[1]),C.isCopy=!0);let re=/^new file mode (\d+)/.exec(S);re&&(C.isCreate=!0,C.newMode=re[1]);let Z=/^deleted file mode (\d+)/.exec(S);Z&&(C.isDelete=!0,C.oldMode=Z[1]);let oe=/^old mode (\d+)/.exec(S);oe&&(C.oldMode=oe[1]);let te=/^new mode (\d+)/.exec(S);te&&(C.newMode=te[1]),/^Binary files /.test(S)&&(C.isBinary=!0),i++}continue}else if(u(b)){if(y)return;y=!0;let A=/^(?:Index:|diff(?: -r \w+)+)\s+/.exec(b);A&&(C.index=b.substring(A[0].length).trim())}i++}if(p(C),p(C),C.oldFileName===void 0!=(C.newFileName===void 0))throw new Error("Missing "+(C.oldFileName!==void 0?'"+++ ..."':'"--- ..."')+" file header for "+((g=C.oldFileName)!==null&&g!==void 0?g:C.newFileName));for(;i<t.length;){let b=t[i];if(u(b)||s(b)||/^===================================================================/.test(b))break;o(b)?C.hunks.push(v()):i++}}function l(g){let C=g.substring(11);if(C.startsWith('"')){let b=m(C);if(b===null)return null;let A=C.substring(b.rawLength+1),S;if(A.startsWith('"')){let z=m(A);if(z===null)return null;S=z.fileName}else S=A;return{oldFileName:b.fileName,newFileName:S}}let y=C.indexOf('"');if(y>0){let b=C.substring(0,y-1),A=m(C.substring(y));return A===null?null:{oldFileName:b,newFileName:A.fileName}}if(C.startsWith("a/")){let b=[],A=0;for(;A=C.indexOf(" b/",A+1),A!==-1;)b.push(A);if(b.length>0){let S=b[Math.floor(b.length/2)];return{oldFileName:C.substring(0,S),newFileName:C.substring(S+1)}}}return null}function c(g){if(g.startsWith('"')){let C=m(g);if(C)return C.fileName}return g}function m(g){if(!g.startsWith('"'))return null;let C="",y=1;for(;y<g.length;){if(g[y]==='"')return{fileName:C,rawLength:y+1};if(g[y]==="\\"&&y+1<g.length)switch(y++,g[y]){case"a":C+="\x07";break;case"b":C+="\b";break;case"f":C+="\f";break;case"n":C+=`
|
|
77
|
+
`;break;case"r":C+="\r";break;case"t":C+=" ";break;case"v":C+="\v";break;case"\\":C+="\\";break;case'"':C+='"';break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{if(y+2>=g.length||g[y+1]<"0"||g[y+1]>"7"||g[y+2]<"0"||g[y+2]>"7")return null;let b=[parseInt(g.substring(y,y+3),8)];for(y+=3;g[y]==="\\"&&g[y+1]>="0"&&g[y+1]<="7";){if(y+3>=g.length||g[y+2]<"0"||g[y+2]>"7"||g[y+3]<"0"||g[y+3]>"7")return null;b.push(parseInt(g.substring(y+1,y+4),8)),y+=4}C+=new TextDecoder("utf-8").decode(new Uint8Array(b));continue}default:return null}else C+=g[y];y++}return null}function p(g){let C=/^(---|\+\+\+)\s+/.exec(t[i]);if(C){let y=C[1],b=t[i].substring(3).trim().split(" ",2),A=(b[1]||"").trim(),S=b[0];S.startsWith('"')?S=c(S):S=S.replace(/\\\\/g,"\\"),y==="---"?(g.oldFileName=S,g.oldHeader=A):(g.newFileName=S,g.newHeader=A),i++}}function v(){var g;let C=i,y=t[i++],b=y.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/),A={oldStart:+b[1],oldLines:typeof b[2]>"u"?1:+b[2],newStart:+b[3],newLines:typeof b[4]>"u"?1:+b[4],lines:[]};A.oldLines===0&&(A.oldStart+=1),A.newLines===0&&(A.newStart+=1);let S=0,z=0;for(;i<t.length&&(z<A.oldLines||S<A.newLines||!((g=t[i])===null||g===void 0)&&g.startsWith("\\"));i++){let M=t[i].length==0&&i!=t.length-1?" ":t[i][0];if(M==="+"||M==="-"||M===" "||M==="\\")A.lines.push(t[i]),M==="+"?S++:M==="-"?z++:M===" "&&(S++,z++);else throw new Error(`Hunk at line ${C+1} contained invalid line ${t[i]}`)}if(!S&&A.newLines===1&&(A.newLines=0),!z&&A.oldLines===1&&(A.oldLines=0),S!==A.newLines)throw new Error("Added line count did not match for hunk at line "+(C+1));if(z!==A.oldLines)throw new Error("Removed line count did not match for hunk at line "+(C+1));if(i<t.length&&t[i]&&/^[+ -]/.test(t[i])&&!s(t[i]))throw new Error("Hunk at line "+(C+1)+" has more lines than expected (expected "+A.oldLines+" old lines and "+A.newLines+" new lines)");return A}for(;i<t.length;)a();return n}var iz=class{addedFile(e){return{version:1,added:this.lineCount(e),removed:0}}deletedFile(e){return{version:1,added:0,removed:this.lineCount(e)}}update(e){if(e.isBinary||e.hunks.length===0)return null;let t=0,n=0,i=1,r=1;for(let u of e.hunks){let{oldStart:s,oldLines:o,newStart:a,newLines:l}=u;if(![s,o,a,l].every(Number.isSafeInteger)||s<i||a<r||o<0||l<0||a-s!==t-n)return null;let c=0,m=0,p=!1;for(let v of u.lines)switch(v[0]){case"+":t++,m++,p=!0;break;case"-":n++,c++,p=!0;break;case" ":case void 0:c++,m++,p=!0;break;case"\\":if(!p||v.replace(/\r$/,"")!=="\")return null;p=!1;break;default:return null}if(c!==o||m!==l)return null;i=s+o,r=a+l}return{version:1,added:t,removed:n}}lineCount(e){let t=0;for(let n=e.indexOf(`
|
|
78
|
+
`);n>=0;n=e.indexOf(`
|
|
79
|
+
`,n+1))t++;for(let n=e.indexOf("\r");n>=0;n=e.indexOf("\r",n+1))e[n+1]!==`
|
|
80
|
+
`&&t++;return e.length>0&&!e.endsWith(`
|
|
81
|
+
`)&&!e.endsWith("\r")&&t++,t}};function uz(e){return e?._meta?.terminal_output===!0?"terminal_output":"terminal_output_delta"}function sz(e,t,n){switch(e){case"terminal_output":return{terminal_output:{data:n,terminal_id:t}};case"terminal_output_delta":return{terminal_output_delta:{data:n,terminal_id:t}}}}function uS(e={}){return{lody:{activity:{version:1,kind:"context_compaction",...e.trigger===void 0?{}:{automatic:e.trigger==="automatic"},...e.preTokens===void 0?{}:{usedTokensBefore:e.preTokens},...e.postTokens===void 0?{}:{usedTokensAfter:e.postTokens},...e.durationMs===void 0?{}:{durationMs:e.durationMs},...e.error===void 0?{}:{failureReason:e.error}}}}}var oz=1;function az(e={}){return{version:oz,...e}}function rd(e,t){return`${t??""}${e}`}function sp(e){switch(e){case"unifiedExecStartup":return"exec_command";case"unifiedExecInteraction":return"write_stdin";case"agent":case"userShell":return}}var xG={lody:{toolName:zs.imageGeneration}},TG=uS(),FG=new iz;function lz(e){switch(e){case"inProgress":return"in_progress";case"completed":return"completed";case"failed":case"declined":case"interrupted":return"failed"}}function cz(e,t,n,i){let r=lz(t);switch(i.type){case"read":return{sessionUpdate:"tool_call",toolCallId:e,status:r,kind:"read",title:`Read file '${i.path}'`,locations:[{path:i.path}]};case"search":return{sessionUpdate:"tool_call",toolCallId:e,status:r,kind:"search",title:hz(i.query,i.path)};case"listFiles":{let u=i.path?`List files in '${i.path}'`:"List files";return{sessionUpdate:"tool_call",toolCallId:e,status:r,kind:"read",title:u}}case"unknown":return dz({sessionUpdate:"tool_call",toolCallId:e,status:r,kind:"execute",title:Ii(i.command),rawInput:{command:i.command,cwd:n}},e,n)}}function dz(e,t,n){let{rawInput:i,...r}=e;return{...r,content:[{type:"terminal",terminalId:t}],...i===void 0?{}:{rawInput:i},_meta:{terminal_info:{cwd:n,terminal_id:t}}}}function hz(e,t){return e&&t?`Search for '${e}' in ${t}`:e?`Search for '${e}'`:t?`Search in '${t}'`:"Search"}var sS=/^<!--\s*(?:\*\/\s*)?-->\s*$/u,fz=/^\s*(?:\*\/?\s*)?$/u,pz=/^\s*(?:\*\/\s*)?-{1,2}$/u,mz=e=>e===" "||e===" ",gz=e=>{if(e==="<"||e==="<!"||e==="<!-")return!0;if(!e.startsWith("<!--"))return!1;let t=e.slice(4);return sS.test(e)||fz.test(t)||pz.test(t)},oS=class{pending="";lineHasContent=!1;push(e){let t="",n=i=>{t+=i;for(let r of i)r===`
|
|
82
|
+
`||r==="\r"?this.lineHasContent=!1:mz(r)||(this.lineHasContent=!0)};for(let i of e){if(this.pending){if(this.pending+=i,gz(this.pending))continue;n(this.pending),this.pending="";continue}i==="<"&&!this.lineHasContent?this.pending=i:n(i)}return t}finish(){let e=sS.test(this.pending)?"":this.pending;return this.pending="",this.lineHasContent=!1,e}};function aS(e){let t=new oS;return t.push(e)+t.finish()}function op(e,t){let n=e.length>0;return(n?e:t).map(r=>n?aS(r):r).filter(r=>r.length>0)}function lS(e){if(e)return{lody:{messagePhase:e}}}function cS(e,t){return{lody:{turnId:t,...e?{messagePhase:e}:{}}}}function ws(e,t,n){return t?{sessionUpdate:"user_message_chunk",messageId:t,content:e,...n?{_meta:n}:{}}:{sessionUpdate:"user_message_chunk",content:e,...n?{_meta:n}:{}}}function dS(e,t,n){return t?{sessionUpdate:"agent_message_chunk",messageId:t,content:e,...n?{_meta:n}:{}}:{sessionUpdate:"agent_message_chunk",content:e,...n?{_meta:n}:{}}}function vz(e,t,n){return t?{sessionUpdate:"agent_thought_chunk",messageId:t,content:e,...n?{_meta:n}:{}}:{sessionUpdate:"agent_thought_chunk",content:e,...n?{_meta:n}:{}}}function Un(e,t,n){return dS({type:"text",text:e},t,n)}function id(e,t,n){return vz({type:"text",text:e},t,n)}function Po(e,t=!1){if(e)return{...lS(e),...hi(t,c2,e)}}function Cz(e){switch(e){case"active":case"paused":case"blocked":case"complete":return e;case"usageLimited":case"budgetLimited":return"limited"}}function Zi(e){return{objective:e.objective.trim(),status:Cz(e.status),tokenBudget:e.tokenBudget,tokensUsed:e.tokensUsed,timeUsedSeconds:e.timeUsedSeconds,createdAtEpochSeconds:e.createdAt,updatedAtEpochSeconds:e.updatedAt}}function hS(e,t){return e===void 0?!1:e===null||t===null?e===t:e.objective===t.objective&&e.status===t.status&&e.tokenBudget===t.tokenBudget&&e.createdAtEpochSeconds===t.createdAtEpochSeconds}function ug(e,t){return{sessionUpdate:"session_info_update",_meta:{...t?xt(void 0,jb,e):{},lody:{goal:e}}}}function fS(e){return{limitId:e.limitId??e.limitName??"codex",scope:{providerId:"codex"},limitName:e.limitName,planName:e.planType,windows:[e.primary,e.secondary].filter(n=>n!==null).map(n=>({usedPercent:n.usedPercent,windowDurationSeconds:n.windowDurationMins===null?null:n.windowDurationMins*60,resetsAtEpochSeconds:n.resetsAt}))}}function yz(e){let t=Object.values(e.rateLimitsByLimitId??{}).filter(i=>i!==void 0);return{rateLimits:(t.length>0?t:[e.rateLimits]).map(fS),fetchedAtEpochSeconds:Math.floor(Date.now()/1e3)}}var Hr=class{constructor(e){this.capabilities=e}capabilities;render(e){let t={toolCallId:e.toolCallId,...e.name===void 0?{}:{name:e.name},...e.kind===void 0?{}:{kind:e.kind},...e.title===void 0?{}:{title:e.title},...e.status===void 0?{}:{status:e.status},...this.contentField(e),...e.locations===void 0?{}:{locations:e.locations.map(r=>({path:r}))},...e.input===void 0?{}:{rawInput:e.input},...e.opaqueResult===void 0?{}:{rawOutput:e.opaqueResult}},n=this.capabilities.airToolCallContract?this.airMeta(e):this.standardMeta(e);if(!this.capabilities.airToolCallContract){lg(t,e.standard);let r=e.standard?.commandEnd;if(r!==void 0){let u=this.commandEndRawOutput(r);u!==void 0?t.rawOutput=u:delete t.rawOutput;let s=this.commandEndContent(r);s!==void 0&&(t.content=s)}}e.contextCompaction!==void 0&&Object.assign(n,uS(e.contextCompaction)),e.lodyToolName!==void 0&&(n.lody={...n.lody,toolName:e.lodyToolName}),e.report==="start"&&t.title===void 0&&(t.title="");let i={...t,...Object.keys(n).length>0?{_meta:n}:{}};return e.report==="start"?{sessionUpdate:"tool_call",...i}:{sessionUpdate:"tool_call_update",...i}}renderPermissionToolCall(e){let t={toolCallId:e.toolCallId,...e.name===void 0?{}:{name:e.name},...e.kind===void 0?{}:{kind:e.kind},...e.status===void 0?{}:{status:e.status},...e.title===void 0?{}:{title:e.title},...e.input===void 0?{}:{rawInput:e.input},...pS(e.locations),...this.contentField(e)};return this.capabilities.airToolCallContract||lg(t,e.standard),t}contentField(e){let t=e.readableInput!==void 0&&!this.capabilities.air.rawInputRendering?[Ar(e.readableInput)]:[];return e.terminal===void 0&&t.length===0&&e.result===void 0?{}:{content:[...e.terminal===void 0?[]:[{type:"terminal",terminalId:e.toolCallId}],...t,...e.result??[]]}}airMeta(e){let t=e.toolCallId,n={...sg(e),...e.terminalInput===void 0?{}:{terminal_input:{data:e.terminalInput,terminal_id:t}},...e.terminalOutput===void 0?{}:this.outputChunk(t,e.terminalOutput,!0),...e.terminalExit===void 0?{}:og(t,e.terminalExit.exitCode),...ag(e)};return e.subagent&&(n=xt(n,m2,!0)),e.contextCompaction!==void 0&&(n=xt(n,h2,e.contextCompaction)),n}standardMeta(e){let t=e.toolCallId,n=e.standard?.commandOutput,i=e.standard?.commandEnd;return{...sg(e),...n===void 0?{}:this.outputChunk(t,n.data,n.terminal),...i===void 0?{}:this.commandEndMeta(t,i),...e.standard?.mcpProgress===void 0?{}:{mcp_output_delta:{data:e.standard.mcpProgress}},...ag(e)}}outputChunk(e,t,n){let i=this.capabilities.terminalOutputKey(n);return i===null?{}:{[i]:{data:t,terminal_id:e}}}commandEndRawOutput(e){return e.terminal?void 0:{exit_code:e.exitCode}}commandEndContent(e){if(!(this.capabilities.terminalOutputKey(e.terminal)!==null||e.output.length===0))return[Ar(e.output)]}commandEndMeta(e,t){return{...t.output.length>0&&!t.streamed?this.outputChunk(e,t.output,t.terminal):{},...t.terminal?og(e,t.exitCode):{}}}};function sg(e){return e.terminal===void 0?{}:{terminal_info:{cwd:e.terminal.cwd,terminal_id:e.toolCallId}}}function og(e,t){return{terminal_exit:{exit_code:t,signal:null,terminal_id:e}}}function ag(e){return e.mcp?{is_mcp_tool_call:!0}:{}}function lg(e,t){if(t===void 0)return;let n=t.locations===void 0||t.locations===null?t.locations:pS(t.locations).locations??null,i=[["title",t.title],["kind",t.kind],["status",t.status],["locations",n],["content",t.content],["rawInput",t.rawInput],["rawOutput",t.rawOutput]];for(let[r,u]of i)u!==void 0&&(u===null?delete e[r]:e[r]=u)}function Ar(e){return{type:"content",content:{type:"text",text:e}}}function pS(e){return e===void 0||e.length===0?{}:{locations:e.map(t=>({path:t}))}}var Ez=class{static permission(e,t,n,i){let r=mS(i);return{toolCallId:e,name:"request_permissions",kind:"other",status:"pending",title:"Additional sandbox permissions",input:{permissions:i,cwd:t,environmentId:n},locations:ud(i),...r.length>0?{result:r}:{}}}};function ud(e){let t=e?.fileSystem;return[...new Set([...t?.read??[],...t?.write??[],...(t?.entries??[]).flatMap(n=>n.path.type==="path"?[n.path.path]:[])])]}function mS(e){let t=[],n=e.network?.enabled;n!=null&&t.push(n?"Enable network access":"Disable network access");for(let i of e.fileSystem?.entries??[])switch(i.path.type){case"glob_pattern":t.push(`${i.access} filesystem pattern ${i.path.pattern}`);break;case"special":t.push(`${i.access} Codex filesystem scope ${JSON.stringify(i.path.value)}`);break;case"path":break}return t.length>0?[Ar(t.join(`
|
|
83
|
+
`))]:[]}var ap=class{nonTerminalCommands=new Set;terminalCommands=new Set;streamedCommands=new Set;standardStreamedCommands=new Set;started(e){return gu(e)?(this.nonTerminalCommands.delete(e.id),this.terminalCommands.add(e.id)):(this.nonTerminalCommands.add(e.id),this.terminalCommands.delete(e.id)),this.streamedCommands.delete(e.id),this.standardStreamedCommands.delete(e.id),cg(e)}restore(e){e.status==="inProgress"?!this.terminalCommands.has(e.id)&&!this.nonTerminalCommands.has(e.id)&&this.started(e):(this.nonTerminalCommands.delete(e.id),this.terminalCommands.delete(e.id),this.streamedCommands.delete(e.id),this.standardStreamedCommands.delete(e.id))}outputDelta(e,t){t.length>0&&this.standardStreamedCommands.add(e);let n={commandOutput:{data:t,terminal:this.terminalCommands.has(e)}};return this.nonTerminalCommands.has(e)?{toolCallId:e,report:"update",standard:n}:(t.length>0&&this.streamedCommands.add(e),{toolCallId:e,report:"update",terminalOutput:t,standard:n})}terminalInput(e,t){let n={commandOutput:{data:`
|
|
84
|
+
${t}
|
|
85
|
+
`,terminal:this.terminalCommands.has(e)}};return this.nonTerminalCommands.has(e)?{toolCallId:e,report:"update",standard:n}:{toolCallId:e,report:"update",terminalInput:t,standard:n}}completed(e,t=!1){this.nonTerminalCommands.delete(e.id);let n=this.streamedCommands.delete(e.id);return{...dg(e,n,t),standard:{content:null,commandEnd:{output:e.aggregatedOutput??"",exitCode:e.exitCode,terminal:this.terminalCommands.delete(e.id),streamed:this.standardStreamedCommands.delete(e.id)}}}}static permission(e,t,n){let i=e.networkApprovalContext,r=i?.protocol==="http"||i?.protocol==="https"?`${i.protocol}://${i.host}`:void 0,u={...e.command?{command:Ii(e.command)}:{},...e.cwd?{cwd:e.cwd}:{},...r?{url:r}:{},...e.additionalPermissions?{additionalPermissions:e.additionalPermissions}:{}},s=e.commandActions??[],o=e.additionalPermissions?mS(e.additionalPermissions):[],a=[...i?[Ar(`${i.protocol} access to ${i.host}`)]:[],...o];return{toolCallId:e.itemId,...n===void 0?{}:{name:n},...t?{}:{kind:"execute",status:"pending"},title:i?`${i.protocol} network access to ${i.host}`:t?wz(e,s):hg(s),...Object.keys(u).length>0?{input:u}:{},locations:[...new Set([...t?[]:fg(s),...ud(e.additionalPermissions)])],...a.length>0?{result:a}:{},standard:{kind:"execute",status:"pending",title:i?`${i.protocol} network access to ${i.host}`:hg(s),locations:[...new Set([...fg(s),...ud(e.additionalPermissions)])]}}}static history(e){let t=cg(e);return e.status==="inProgress"?[t]:[t,{...dg(e,!1,!1),standard:{content:null,commandEnd:{output:e.aggregatedOutput??"",exitCode:e.exitCode,terminal:gu(e),streamed:!1}}}]}};function gu(e){let t=wl(e.commandActions);return t===void 0||t.type==="unknown"}function cg(e){let t=sp(e.source),n=wl(e.commandActions);return{...gS(e.id,e.status,e.cwd,n??{type:"unknown",command:e.command}),...t===void 0?{}:{name:t}}}function gS(e,t,n,i){let r={toolCallId:e,report:"start",status:is(t)};switch(i.type){case"read":return{...r,kind:"read",title:`Read file '${i.path}'`,locations:[i.path]};case"search":return{...r,kind:"search",title:vS(i.query,i.path)};case"listFiles":return{...r,kind:"read",title:i.path?`List files in '${i.path}'`:"List files"};case"unknown":return{...r,kind:"execute",title:Ii(i.command),input:{command:i.command,cwd:n},terminal:{cwd:n}}}}function dg(e,t,n){let i=n?sp(e.source):void 0,r=e.aggregatedOutput??"",u={toolCallId:e.id,report:"update",...i===void 0?{}:{name:i},status:El(e.status)};if(!gu(e)){let s=wl(e.commandActions)?.type==="read";return r.length===0||s?u:{...u,opaqueResult:r}}return{...u,...!t&&r.length>0?{terminalOutput:r}:{},terminalExit:{exitCode:e.exitCode}}}function wl(e){return e.length===1?e[0]:void 0}function vS(e,t){return e&&t?`Search for '${e}' in ${t}`:e?`Search for '${e}'`:t?`Search in '${t}'`:"Search"}function wz(e,t){let n=wl(t)??(e.command?{type:"unknown",command:e.command}:void 0);return n===void 0?"Run command":gS(e.itemId,"inProgress",e.cwd??"",n).title??"Run command"}function hg(e){let t=e[0];if(!t)return"Run command";switch(t.type){case"read":return e.length===1?"Read file":"Run command with file reads";case"listFiles":return"List files";case"search":return"Search files";case"unknown":return"Run command"}}function fg(e){return e.flatMap(t=>{switch(t.type){case"read":return[t.path];case"listFiles":case"search":return t.path?[t.path]:[];case"unknown":return[]}})}var _z="Compact conversation",sd=class{static started(e){return{...Jl(e,"start"),kind:"think",status:"in_progress"}}static completed(e){return{...Jl(e,"update"),status:"completed"}}static history(e){return{...Jl(e,"start"),kind:"think",status:"completed"}}};function Jl(e,t){return{toolCallId:e.id,report:t,title:_z,contextCompaction:az()}}var od=class{static started(e){return{toolCallId:e.id,report:"start",name:rd(e.tool,e.namespace),kind:"execute",title:e.tool,status:is(e.status),input:{arguments:e.arguments},...pg(e)}}static completed(e){return{toolCallId:e.id,report:"update",name:rd(e.tool,e.namespace),status:El(e.status),...pg(e)}}};function pg(e){return e.contentItems===null?{}:{result:e.contentItems.map(t=>({type:"content",content:Az(t)}))}}function Az(e){switch(e.type){case"inputText":return{type:"text",text:e.text};case"inputImage":return{type:"resource_link",uri:e.imageUrl,name:"image"};case"inputAudio":return{type:"resource_link",uri:e.audioUrl,name:"audio"}}}var ad=1024*1024,bz=8e3,ld="\",Sz=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,CS="100644";function yS(e,t,n){let i=Iz(n);if(i===null||AS(i))return null;let r=mi(e),u=mi(t),s=[`diff --git ${It("a/",r)} ${It("b/",u)}`];return r!==u&&s.push(`rename from ${It("",r)}`,`rename to ${It("",u)}`),s.push(Ro("---","a/",r),Ro("+++","b/",u)),lp(`${s.join(`
|
|
86
|
+
`)}
|
|
87
|
+
${i}`)}function Dz(e,t){let n=mi(e),i=mi(t);return n===i?null:lp([`diff --git ${It("a/",n)} ${It("b/",i)}`,"similarity index 100%",`rename from ${It("",n)}`,`rename to ${It("",i)}`,""].join(`
|
|
88
|
+
`))}function ES(e,t){return _S(e,t,"added")}function wS(e,t){return _S(e,t,"deleted")}function mg(e,t){let n=mi(e);return[`diff --git ${It("a/",n)} ${It("b/",n)}`,`${t==="added"?"new":"deleted"} file mode ${CS}`,""].join(`
|
|
89
|
+
`)}function _S(e,t,n){if(t.length===0||AS(t))return null;let i=mi(e),r=t.split(`
|
|
90
|
+
`),u=r.at(-1)==="";u&&r.pop();let s=n==="added"?"+":"-",o=`1${r.length===1?"":`,${r.length}`}`,a=[`diff --git ${It("a/",i)} ${It("b/",i)}`,`${n==="added"?"new":"deleted"} file mode ${CS}`,n==="added"?"--- /dev/null":Ro("---","a/",i),n==="added"?Ro("+++","b/",i):"+++ /dev/null",n==="added"?`@@ -0,0 +${o} @@`:`@@ -${o} +0,0 @@`,...r.map(l=>`${s}${l}`),...u?[]:[ld],""].join(`
|
|
91
|
+
`);return lp(a)}function Iz(e){let t=e.split(`
|
|
92
|
+
`);t.at(-1)===""&&t.pop();let n=t.findIndex(a=>a.startsWith("@@"));if(n<0||!t.slice(0,n).every($z))return null;let r=t.slice(n),u=0,s=1,o=0;for(;u<r.length;){let a=Sz.exec(r[u]);if(a===null)return null;let l=gg(a[1],a[2]),c=gg(a[3],a[4]);if(l===null||c===null||l.first<s||c.first-l.first!==o)return null;s=l.first+l.count,o+=c.count-l.count;let m=l.count,p=c.count;for(u++;m>0||p>0;){let v=r[u];if(v===void 0)return null;switch(v[0]){case" ":case void 0:m--,p--;break;case"-":m--;break;case"+":p--;break;case"\\":if(v!==ld)return null;break;default:return null}u++}if(m!==0||p!==0)return null;for(;r[u]===ld;)u++}return`${r.join(`
|
|
93
|
+
`)}
|
|
94
|
+
`}function gg(e,t){let n=Number(e),i=t===void 0?1:Number(t);return!Number.isSafeInteger(n)||!Number.isSafeInteger(i)?null:i===0?{first:n+1,count:0}:n===0?null:{first:n,count:i}}function $z(e){return e.length===0||e.startsWith("diff --git ")||e.startsWith("index ")||e.startsWith("--- ")||e.startsWith("+++ ")}function AS(e){return e.slice(0,bz).includes("\0")}function lp(e){return Buffer.byteLength(e,"utf8")<=ad?e:null}function mi(e){return(/^[A-Za-z]:\\/.test(e)?e.replace(/\\/g,"/"):e).replace(/^\/+/,"")}function Ro(e,t,n){let i=It(t,n);return`${e} ${i}${!i.startsWith('"')&&i.includes(" ")?" ":""}`}function It(e,t){let n=`${e}${t}`;if(!/["\\\x00-\x1f\x7f]/.test(n))return n;let i="";for(let r of n)switch(r){case'"':i+='\\"';break;case"\\":i+="\\\\";break;case"\x07":i+="\\a";break;case"\b":i+="\\b";break;case" ":i+="\\t";break;case`
|
|
95
|
+
`:i+="\\n";break;case"\v":i+="\\v";break;case"\f":i+="\\f";break;case"\r":i+="\\r";break;default:{let u=r.codePointAt(0);i+=u<32||u===127?`\\${u.toString(8).padStart(3,"0")}`:r}}return`"${i}"`}var vg="Editing files",zo=class{static started(e,t){let n=[];for(let i of e.changes)n.push(...Bz(i,t));return{toolCallId:e.id,report:"start",title:vg,kind:"edit",status:is(e.status),result:n}}static completed(e){return{toolCallId:e.id,report:"update",status:El(e.status)}}static permission(e,t){return{toolCallId:e.itemId,title:vg,...t===void 0?{kind:"edit",status:"pending"}:{},locations:[...new Set(t?.changes.map(n=>n.path)??[])],standard:{kind:"edit",status:"pending",title:"Edit files"}}}};function Bz(e,t){let n=t==="air";try{if(t==="acpV2")return xz(e);switch(e.kind.type){case"add":return Cg(e,"add",n);case"delete":return Cg(e,"delete",n);case"update":return kz(e,e.kind.move_path,n)}}catch(i){return D.log(`Error processing file update change: ${i}`),[]}}function Cg(e,t,n){if(!cp(e.diff))return D.log("Skipped the diff of a file that is too large",{path:e.path}),[];let i=n?t==="add"?ES(e.path,e.diff):wS(e.path,e.diff):null;return i!==null?[bS(e.path,t,i)]:[{type:"diff",oldText:t==="add"?null:e.diff,newText:t==="add"?e.diff:"",path:e.path,_meta:{kind:t}}]}function kz(e,t,n){let i=SS(e.diff),r=t??e.path;if(!cp(i))return D.log("Skipped the diff of a file change that is too large",{path:r}),[];let u=n?yS(e.path,r,i):null;if(u!==null)return[bS(r,"update",u)];if(t!==null&&i.trim().length===0)return[{type:"diff",oldText:"",newText:"",path:r,_meta:{kind:"update"}}];let s=Fz(i);return s===null?(D.log("Skipped a file change whose diff has no single valid patch",{path:e.path}),[]):s.hunks.map(o=>{let{oldText:a,newText:l}=Tz(o.lines);return{type:"diff",oldText:a,newText:l,path:r,_meta:{kind:"update"}}})}function xz(e){let t=e.kind,n=e.path,i=t.type==="update"?t.move_path??e.path:e.path,r=t.type==="update"?SS(e.diff):e.diff;if(!cp(r))return D.log("Skipped the diff of a file change that is too large",{path:i}),[];let u;switch(t.type){case"add":u=r.length===0?mg(i,"added"):ES(i,r);break;case"delete":u=r.length===0?mg(i,"deleted"):wS(i,r);break;case"update":u=t.move_path!==null&&r.trim().length===0?Dz(n,i):yS(n,i,r);break}return u===null?(D.log("Skipped a file change without a valid Git patch",{path:i}),[]):[{type:"diff",oldText:null,newText:"",path:i,_meta:{kind:t.type,[ep]:{oldPath:n,text:u}}}]}function Tz(e){let t=[],n=[],i=" ";for(let r of e){let u=r[0]??" ";if(u==="\\"){i!=="+"&&yg(t),i!=="-"&&yg(n);continue}let s=`${r.slice(1)}
|
|
96
|
+
`;u!=="+"&&t.push(s),u!=="-"&&n.push(s),i=u}return{oldText:t.join(""),newText:n.join("")}}function yg(e){let t=e.at(-1);t!==void 0&&(e[e.length-1]=t.slice(0,-1))}function cp(e){return e.length<=ad&&Buffer.byteLength(e,"utf8")<=ad}function Fz(e){try{let t=iS(e);return t.length===1?t[0]:null}catch{return null}}function bS(e,t,n){return{type:"diff",oldText:null,newText:"",path:e,_meta:xt({kind:t},tp,{version:1,format:"git_patch",text:n})}}function SS(e){return e.replace(/\n\nMoved to: .*$/,"")}var Pz=class{activeSessions=new Set;updated(e){let t=wg(e.sessionId),n=!this.activeSessions.has(t);this.activeSessions.add(t);let i={toolCallId:t,report:n?"start":"update",title:vS(e.query,null),status:"in_progress",locations:e.files.map(r=>Eg.isAbsolute(r.path)?r.path:Eg.join(r.root,r.path))};return n?{...i,kind:"search",input:{query:e.query}}:i}completed(e){let t=wg(e.sessionId);return this.activeSessions.delete(t),{toolCallId:t,report:"update",status:"completed"}}};function wg(e){return`fuzzyFileSearch.${e}`}var Rz=class{activeReviews=new Set;started(e){return this.activeReviews.has(e.reviewId)?Kl(e,"update"):(this.activeReviews.add(e.reviewId),Kl(e,"start"))}completed(e){return Kl(e,this.activeReviews.delete(e.reviewId)?"update":"start")}};function zz(e){return`guardian_assessment:${e}`}function Kl(e,t){let n=Mz(e.action);return{toolCallId:zz(e.reviewId),report:t,...t==="start"?{kind:"think",title:"Guardian Review"}:{},status:Oz(e.review.status),input:{action:e.action},...n?{readableInput:`Action: ${n}`}:{},result:[_g(e.review,null)],standard:{content:[_g(e.review,n)],...t==="start"?{rawInput:e}:{rawInput:null,rawOutput:e}}}}function _g(e,t){let n=[`Status: ${Nz(e.status)}`];return t&&n.push(`Action: ${t}`),e.riskLevel&&n.push(`Risk: ${e.riskLevel}`),e.userAuthorization&&n.push(`Authorization: ${e.userAuthorization}`),e.rationale?.trim()&&n.push(`Rationale: ${e.rationale}`),Ar(n.join(`
|
|
97
|
+
`))}function Oz(e){switch(e){case"inProgress":return"in_progress";case"approved":return"completed";case"denied":case"aborted":case"timedOut":return"failed"}}function Nz(e){switch(e){case"inProgress":return"In progress";case"approved":return"Approved";case"denied":return"Denied";case"aborted":return"Aborted";case"timedOut":return"Timed out"}}function Mz(e){switch(e.type){case"command":return`${Ag(e.source)} ${e.command}`;case"execve":{let t=e.argv.length>0?e.argv:[e.program];return`${Ag(e.source)} ${Uz(t)}`}case"writeStdin":return`write stdin to process ${e.processId}`;case"applyPatch":return e.files.length===1?`apply_patch touching ${e.files[0]}`:`apply_patch touching ${e.files.length} files`;case"networkAccess":return`network access to ${e.target.length>0?e.target:e.host}`;case"mcpToolCall":{let t=e.connectorName??e.server;return`MCP ${e.toolName} on ${t}`}case"requestPermissions":return e.reason??"request additional permissions"}}function Ag(e){switch(e){case"shell":return"shell";case"unifiedExec":return"exec"}}function Uz(e){return e.map(jz).join(" ")}function jz(e){return e.length===0?"''":/^[A-Za-z0-9_/:=+.,@%-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}var DS=class{reasoningSummaryFilters=new Map;commands=new ap;fuzzySearches=new Pz;guardianReviews=new Rz;activeImageGenerationItems=new Set;emittedImageViewItems=new Set;seenReasoningDeltaItemIds=new Set;agentMessagePhases=new Map},IS=new Set(["fileChange","commandExecution","mcpToolCall","dynamicToolCall","webSearch","imageView","imageGeneration"]),cd=class{open=new Map;start(e,t,n){this.open.set(e,{hasTerminal:t,...n!==void 0?{turnId:n}:{}})}complete(e){this.open.delete(e)}restore(e,t,n){IS.has(e.type)&&(t?this.complete(e.id):this.open.has(e.id)||this.start(e.id,e.type==="commandExecution"&&gu(e),n))}clear(){this.open.clear()}finishOutstanding(e){let t=[];for(let[n,{hasTerminal:i,turnId:r}]of this.open)e!==void 0&&r!==void 0&&r!==e||(t.push({sessionUpdate:"tool_call_update",toolCallId:n,status:"failed",...i?{_meta:{terminal_exit:{exit_code:null,signal:null,terminal_id:n}}}:{}}),this.open.delete(n));return t}},bg="Image generation",Ls=class{static started(e){return{toolCallId:e.id,lodyToolName:zs.imageGeneration,report:"start",kind:"other",title:bg,status:"in_progress",standard:{rawInput:{id:e.id}}}}static completed(e){return{toolCallId:e.id,lodyToolName:zs.imageGeneration,report:"update",status:Dg(e.status),result:dd(e),standard:Sg(e)}}static whole(e){return{toolCallId:e.id,lodyToolName:zs.imageGeneration,report:"start",kind:"other",title:bg,status:Dg(e.status),result:dd(e),standard:Sg(e)}}};function Sg(e){let t={status:e.status,revisedPrompt:e.revisedPrompt,..."result"in e?{result:e.result}:{fileId:e.fileId}};return"savedPath"in e&&(t.savedPath=e.savedPath??null),{content:dd(e).filter(n=>n.type!=="content"||n.content.type!=="resource_link"),rawOutput:t}}function dd(e){let t=[];e.revisedPrompt&&e.revisedPrompt.trim()!==""&&t.push(Ar(`Revised prompt: ${e.revisedPrompt}`));let n=e.savedPath&&e.savedPath.trim()!==""?e.savedPath:void 0;return"result"in e&&e.result.trim()!==""?t.push({type:"content",content:{type:"image",data:e.result,mimeType:"image/png",...n===void 0?{}:{uri:n}}}):n!==void 0&&t.push({type:"content",content:{type:"resource_link",name:n,uri:n}}),t}function Dg(e){return e==="failed"?"failed":"completed"}var hd=class{static viewed(e){return{toolCallId:e.id,report:"start",name:"view_image",kind:"read",title:`View Image ${e.path}`,status:"completed",result:[{type:"content",content:{type:"resource_link",name:e.path,uri:e.path}}],locations:[e.path],input:{path:e.path}}}},qs=class{static started(e){return{toolCallId:e.id,report:"start",kind:"execute",title:`mcp.${e.server}.${e.tool}`,status:is(e.status),input:Ig(e),...$g(e),mcp:!0}}static completed(e){return{toolCallId:e.id,report:"update",status:El(e.status),input:Ig(e),...$g(e)}}static progress(e,t){return{toolCallId:e,report:"update",standard:{mcpProgress:t.trim()}}}};function Ig(e){return{server:e.server,tool:e.tool,arguments:e.arguments}}function $g(e){return e.result===null&&e.error===null?{}:{opaqueResult:{result:e.result,error:e.error}}}var fd=class{static started(e){return{...Xl(e,"start"),kind:"search",status:"in_progress"}}static completed(e){return{...Xl(e,"update"),status:"completed"}}static history(e){let{standard:t,...n}=Xl(e,"start");return{...n,kind:"search",status:"completed"}}};function Xl(e,t){return{toolCallId:e.id,report:t,title:Lz(e),input:{query:e.query,action:e.action},standard:{rawInput:{type:e.type,id:e.id,query:e.query,action:e.action}}}}function Lz(e){let t=e.action;if(!t)return e.query?`Web search: ${e.query}`:"Web search";switch(t.type){case"search":{let n=t.queries?.filter(r=>r&&r.length>0)??[],i=t.query??(n.length>0?n.join(", "):null)??e.query;return i?`Web search: ${i}`:"Web search"}case"openPage":return t.url?`Open page: ${t.url}`:"Open page";case"findInPage":{let n=t.pattern?` for '${t.pattern}'`:"",i=t.url?` in ${t.url}`:"";return`Find in page${n}${i}`.trim()}case"other":return"Web search"}}var $S=class BS{constructor(t,n){this.session=t,this.capabilities=n}session;capabilities;static UPDATE_INTERVAL_MS=150;streamedText=new Map;reportedText=new Map;pendingItemIds=new Set;timer=null;chain=Promise.resolve();disposed=!1;delta(t,n){if(n.length===0)return null;let i=(this.streamedText.get(t)??"")+n;return this.streamedText.set(t,i),this.capabilities.planUpdates?(this.pendingItemIds.add(t),this.schedule(),null):this.capabilities.airClient?(this.reportedText.set(t,i),Yl(n,t,!0)):null}async completed(t,n){let i=n.length>0?n:this.streamedText.get(t)??"";return this.pendingItemIds.delete(t),this.pendingItemIds.size===0&&this.cancelTimer(),this.streamedText.delete(t),i.length===0?null:this.capabilities.planUpdates?(await this.enqueue(t,i),{text:i,update:null}):{text:i,update:this.remainingMessageText(t,i)}}async flush(){this.cancelTimer();do{let t=[...this.pendingItemIds];this.pendingItemIds.clear(),await Promise.all(t.map(n=>{let i=this.streamedText.get(n)??"";return i.length>0?this.enqueue(n,i):Promise.resolve()})),await this.chain}while(this.pendingItemIds.size>0)}clearTurn(){this.cancelTimer(),this.pendingItemIds.clear(),this.streamedText.clear(),this.reportedText.clear()}async dispose(){this.disposed||(await this.flush(),this.disposed=!0,this.clearTurn())}remainingMessageText(t,n){let i=this.reportedText.get(t)??"";if(this.reportedText.delete(t),i.length===0)return Yl(n,t,this.capabilities.airClient);if(n.startsWith(i)){let r=n.slice(i.length);return r.length>0?Yl(r,t,this.capabilities.airClient):null}return D.log("The completed plan differs from the streamed plan text",{itemId:t}),null}schedule(){this.disposed||this.timer!==null||(this.timer=setTimeout(()=>{this.timer=null,this.flush().catch(t=>{D.error("Failed to flush throttled plan updates",t)})},BS.UPDATE_INTERVAL_MS))}cancelTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}enqueue(t,n){let i=async()=>{let u=this.planUpdate(t,n);u!==null&&(await this.session.update(u),this.reportedText.set(t,n))},r=this.chain.then(i);return this.chain=r.catch(()=>{}),r}planUpdate(t,n){let i=this.reportedText.get(t);return i===n?null:this.capabilities.air.planContentDelta&&i!==void 0&&n.startsWith(i)?{sessionUpdate:"plan_update",plan:{type:"markdown",planId:t,content:""},_meta:xt(void 0,p2,n.slice(i.length))}:{sessionUpdate:"plan_update",plan:{type:"markdown",planId:t,content:n}}}};function Yl(e,t,n){return Un(e,t,Po("final_answer",n))}var Zs=class Ws{promptSuggestions;static DEFAULT=new Ws({promptSuggestions:!1,airClient:!1,airToolCallContract:!1,terminalOutput:!1,terminalOutputDelta:!1,planUpdates:!1,air:{rawInputRendering:!1,planContentDelta:!1,diffPatch:!1},diffPatchFormat:"none",permissionPromptFields:!1});airClient;airToolCallContract;terminalOutput;terminalOutputDelta;planUpdates;air;diffPatchFormat;permissionPromptFields;constructor(t){this.promptSuggestions=t.promptSuggestions,this.airClient=t.airClient,this.airToolCallContract=t.airToolCallContract,this.terminalOutput=t.terminalOutput,this.terminalOutputDelta=t.terminalOutputDelta,this.planUpdates=t.planUpdates,this.air=t.air,this.diffPatchFormat=t.diffPatchFormat,this.permissionPromptFields=t.permissionPromptFields}static from(t){let n=fu(t),i=yn(t,tp);return new Ws({promptSuggestions:Rm(t),airClient:n,airToolCallContract:n,terminalOutput:t?._meta?.terminal_output===!0,terminalOutputDelta:t?._meta?.terminal_output_delta===!0,planUpdates:t?.plan!=null,air:{rawInputRendering:yn(t,qb),planContentDelta:yn(t,Zb),diffPatch:i},diffPatchFormat:i?"air":"none",permissionPromptFields:!1})}static fromV2(t){return new Ws({promptSuggestions:Rm(t),airClient:fu(t),airToolCallContract:!1,terminalOutput:!0,terminalOutputDelta:!1,planUpdates:!0,air:{rawInputRendering:!1,planContentDelta:!1,diffPatch:!1},diffPatchFormat:"acpV2",permissionPromptFields:!0})}terminalOutputKey(t){return this.terminalOutputDelta?"terminal_output_delta":this.terminalOutput?t?"terminal_output":null:this.airToolCallContract?null:"terminal_output_delta"}},qz=new Set(["invalid_request_error","server_error","rate_limit_error","insufficient_quota","authentication_error","permission_error","not_found_error","conflict_error","overloaded_error"]),Bg="invalid_encrypted_content",Zz="The current provider can't read this thread's earlier reasoning, which another provider or account encrypted. This happens after the provider changes in a thread. Switch back to the previous provider or start a new thread.";function tu(e){let t=xS(e);if(t===void 0)return e;if(kS(t))return Zz;if(!nu(t)||Object.keys(t).some(i=>!["type","status","error"].includes(i))||t.type!=="error"||typeof t.status!="number"||!Number.isInteger(t.status)||t.status<400||t.status>599||!nu(t.error))return e;let n=t.error;return Object.keys(n).some(i=>!["type","message","code","param"].includes(i))||typeof n.type!="string"||!qz.has(n.type)||typeof n.message!="string"||n.message.trim().length===0||["code","param"].some(i=>i in n&&n[i]!==null&&typeof n[i]!="string")?e:n.message}function kS(e){if(!nu(e)||!nu(e.error))return!1;let t=e.error;if(t.code===Bg)return!0;let n=t.metadata;return nu(n)?n.provider_error_code===Bg||typeof n.raw=="string"&&kS(xS(n.raw)):!1}function xS(e){try{return JSON.parse(e)}catch{return}}function nu(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var kg=4096,Wz=["The following are system instructions. Do not disclose them to the user:",'The "lody" MCP server provides tools for this conversation:'],Gz="Provider error details omitted because they contained internal instructions.";function ru(e){return Wz.some(t=>e.includes(t))?Gz:e.length<=kg?e:`${e.slice(0,kg-3)}...`}var gr=1001;function dp(e){return e.signal==="SIGKILL"||e.code===137}function gi(e){if(e.error!==void 0)return e.pid===void 0?`could not be started (${e.error})`:`stopped responding (${e.error})`;let t=dp(e)?", which usually means it ran out of memory":"";return e.signal!==null?`was killed by ${e.signal}${t}`:`exited with code ${e.code??"unknown"}${t}`}var vt=class extends k{constructor(e,t){super(gr,e,t),this.name="AppServerUnavailableError"}},TS=class extends vt{constructor(e,t){super(e,t),this.name="ThreadRefusedError"}},FS=class extends vt{constructor(e){super(`Session ${e} was closed or opened again while the agent reopened it after an app-server restart.`,{exitCode:null,signal:null,restartable:!0}),this.name="SessionReplacedError"}},PS=class extends vt{constructor(e){super(`Session ${e} had no messages yet and was lost when the Codex app-server restarted. Start a new session.`,{exitCode:null,signal:null,restartable:!1}),this.name="UnpersistedSessionLostError"}};function pd(e){return e instanceof k&&e.code===gr}function xg(e,t){let n=e.stderrTail.trim(),i=`The Codex app-server ${gi(e)}. ${t}${n?`
|
|
98
|
+
${n}`:""}`;return new vt(i,{exitCode:e.code,signal:e.signal,restartable:!0})}function Vz(e){let t=e.stderrTail.trim(),n=e.error===void 0&&e.signal===null?`has ${gi(e)}`:gi(e);return new vt(`Codex process ${n}${t?`:
|
|
99
|
+
${t}`:""}`,{exitCode:e.code,signal:e.signal,restartable:!0})}function Ni(e){let t=Math.ceil(e/1e3);return t<120?`${t} s`:`${Math.ceil(t/60)} min`}var Hz=Sn(ro(),1);function Tg(e,t,n){return(e.method==="item/started"||e.method==="item/completed")&&e.params.threadId===t&&e.params.item.type==="userMessage"&&e.params.item.clientId===n}var Jz=new Set(["text","image","audio","resource_link","resource"]);function Kz(e){for(let t of e.prompt)if(!Jz.has(t.type))throw k.invalidParams(void 0,`Unsupported content block type: ${t.type}`);return e}function iu(e,t){let n={state:"idle",...e.usage!=null?{usage:e.usage}:{},...e._meta!=null?{_meta:e._meta}:{}};if(t!=null&&e.stopReason!=="cancelled")return{...n,stopReason:"error",error:t};switch(e.stopReason){case"end_turn":return{...n,stopReason:"end_turn"};case"max_tokens":return{...n,stopReason:"max_tokens"};case"max_turn_requests":return{...n,stopReason:"max_turn_requests"};case"refusal":return{...n,stopReason:"refusal"};case"cancelled":return{...n,stopReason:"cancelled"}}}function Fg(e){return e instanceof k||e instanceof Hz.ResponseError?e.code===gr?{code:e.code,message:"Connection to Codex was lost."}:{code:e.code,message:ru(tu(e.message))}:{code:-32603,message:"Codex encountered an internal error."}}function Xz(e,t){let n=e instanceof Error&&e.message.length>0?e.message:null;return t!==void 0?n===null?`The '/${t}' command failed.`:`The '/${t}' command failed: ${n}`:n??"The prompt failed."}function RS(e,t){if(!e)return[];let n=[];if(t.model&&n.push(ip(e.availableModels,e.currentModel,t.model)),t.effort!=null){let r=e.availableModels.find(u=>u.id===t.model||u.model===t.model)?.supportedReasoningEfforts.find(u=>u.reasoningEffort===t.effort)??{reasoningEffort:t.effort,description:"Current reasoning effort"};n.push(Kb([r],t.effort))}return n}var Yz=class{associations=new Map;childThreads=new Set;interactionSequences=new Map;sessionId(e,t){return`${encodeURIComponent(e)}:subagent:${encodeURIComponent(t)}`}register(e,t,n){let i=this.sessionId(e,n);if(n===e||i===t)throw k.internalError(void 0,"A subagent cannot own itself");if(t!==e&&this.associations.get(t)?.rootSessionId!==e)throw k.internalError(void 0,"A subagent's immediate parent must be known first");let r=this.associations.get(i);if(r){if(r.parentSessionId!==t)throw k.internalError(void 0,"A subagent association cannot change parents");return r}let u={rootSessionId:e,parentSessionId:t,threadId:n,sessionId:i};return this.associations.set(i,u),this.childThreads.add(n),u}isRestricted(e){return this.associations.has(e)||this.childThreads.has(e)}nextToolCallId(e,t){let n=(this.interactionSequences.get(e)??0)+1;return this.interactionSequences.set(e,n),`${e}:elicitation:${encodeURIComponent(t)}:${n}`}get(e){return this.associations.get(e)}forRoot(e){return[...this.associations.values()].filter(t=>t.rootSessionId===e)}},_l=new Qz;function eO(e,t){return _l.run(e,t)}function md(e,t){let n=_l.getStore();return n?.sessionId===e?n.signal:t}function tO(e,t){let n=_l.getStore();return n?.sessionId===e?n.nextToolCallId(t):void 0}function Wi(e,t,n,i){let r=_l.getStore();if(r?.sessionId!==e)return t();let u=i??r.signal,s=async()=>{u.throwIfAborted(),await r.beforeRequest(),u.throwIfAborted();let o,a=new Promise((l,c)=>{o=()=>c(u.reason),u.addEventListener("abort",o,{once:!0})});try{return await Promise.race([Promise.resolve().then(()=>(u.throwIfAborted(),t())),a])}finally{u.removeEventListener("abort",o)}};return r.foreground?r.foreground.withUserAction(n??r.itemId,s,u):s()}var Ue=class{constructor(e,t,n,i,r=Zs.DEFAULT,u=!1,s=Promise.resolve(),o=()=>{},a=()=>null,l){this.rootSessionId=e,this.session=t,this.associations=n,this.onChildWorkEnded=i,this.capabilities=r,this.deferLive=u,this.ready=s,this.runningTurnId=o,this.rootModels=a,this.configurationRuntime=l,this.deferredLive=new js(e)}rootSessionId;session;associations;onChildWorkEnded;capabilities;deferLive;ready;runningTurnId;rootModels;configurationRuntime;children=new Map;pending=new Map;replayQueue=[];deferredLive;legacyActivities=new Set;announced=new Set;replayedItems=new Map;completedItems=new Map;configurations=new Map;pendingConfigurations=new Set;configurationRequests=new Map;spawnsInFlight=new Set;appliedSettings=new WeakSet;unobservable=new Set;receivedTurnEnds=new Map;retired=!1;attachment=0;cancellationReady=!0;snapshotting=!1;snapshots=new Map;interactionObserver;async prepareNotification(e){let t=e.params.threadId;if(typeof t!="string"||t===this.rootSessionId)return!0;if(this.retired)return!1;if(e.method==="thread/settings/updated"&&!this.appliedSettings.has(e.params)){this.appliedSettings.add(e.params);let i=e.params.threadSettings;await this.observeConfiguration(t,{model:i.model,effort:i.effort},"settings")}if(this.deferLive)return this.deferredLive.push(e),!1;let n=this.children.get(t);if(!n){let i=this.pendingFor(t);return i.notifications.push(e),await this.restoreKnown(t)&&(this.pending.delete(t),this.replayQueue.push(...i.notifications.take())),!1}return await this.ensureAnnounced(n),!this.retired}async handle(e){if(e.method==="thread/started"){let i=e.params.thread,r=this.children.get(i.id),u=this.children.get(i.parentThreadId??"");return(i.parentThreadId===this.rootSessionId||u?.live||r?.live||!r&&this.spawnsInFlight.size>0)&&await this.observeConfiguration(i.id,{model:i.model,effort:i.reasoningEffort},"threadStarted"),!1}let t=e.params.threadId;if(typeof t!="string")return!1;if(this.retired)return t!==this.rootSessionId||(e.method==="item/started"||e.method==="item/completed")&&(e.params.item.type==="subAgentActivity"||e.params.item.type==="collabAgentToolCall");if(e.method==="item/started"||e.method==="item/completed"){let i=e.params.item;if(i.type==="collabAgentToolCall"&&i.tool==="spawnAgent"){e.method==="item/started"?this.spawnsInFlight.add(i.id):this.spawnsInFlight.delete(i.id);for(let r of i.receiverThreadIds){if(!r.trim()||r===i.senderThreadId||r===this.rootSessionId||this.children.has(r))continue;let u=this.pendingFor(r);u.parentThreadId=i.senderThreadId,i.prompt&&(u.description=i.prompt)}return await this.materializePending(),!0}if(i.type==="subAgentActivity"){if(fi(i.agentPath))return!0;let r=this.children.get(i.agentThreadId);if(r){await this.ensureAnnounced(r),r.path=rn(i.agentPath);let u=pi(i.agentPath,r.title??"Agent");u!==r.title&&(r.title=u,await this.session.update({sessionUpdate:"subagent_update",sessionId:r.sessionId,title:u},r.parentSessionId))}else this.pendingFor(i.agentThreadId).path=rn(i.agentPath);return await this.observeConfiguration(i.agentThreadId,{model:i.model,effort:i.reasoningEffort},"activity"),await this.materializePending(),!0}}if(t===this.rootSessionId&&e.method==="turn/completed"){this.spawnsInFlight.clear();for(let i of this.configurations.keys())this.children.has(i)||this.configurations.delete(i)}let n=this.children.get(t);if(!n)return!1;if(await this.ensureAnnounced(n),this.retired)return!0;await this.interactionObserver?.(e,n.sessionId),n.live=!0;try{return await this.handleChild(e,n,t)}finally{await this.publishCancellation(n)}}async handleChild(e,t,n){let i=e.params,r=i.itemId??i.item?.id,u=r===void 0?void 0:this.replayedItems.get(n)?.get(r),s=e.params.turnId,o=e.method==="item/agentMessage/delta"||e.method==="item/plan/delta"||e.method==="item/reasoning/textDelta"||e.method==="item/reasoning/summaryTextDelta";switch(u!==!0&&s!==void 0&&o&&!t.endedTurns.has(s)&&(t.turnId===null||t.turnId===s)&&(t.turnId??=s,this.isCurrentForeground(t,s)&&(this.beginForegroundTurn(t,s),await t.foreground.start())),e.method){case"turn/started":return t.endedTurns.has(e.params.turn.id)||(t.turnId!==null&&t.turnId!==e.params.turn.id&&this.endWorkRequests(t,t.turnId),t.turnId=e.params.turn.id,this.isCurrentForeground(t,t.turnId)&&(this.beginForegroundTurn(t,t.turnId),await t.foreground.start()),this.refreshConfiguration(t)),!0;case"thread/settings/updated":return!0;case"thread/name/updated":{let a=vn(e.params.threadName);return t.title=a,await this.session.update({sessionUpdate:"session_info_update",title:a},t.sessionId),await this.session.update({sessionUpdate:"subagent_update",sessionId:t.sessionId,title:a},t.parentSessionId),!0}case"thread/closed":case"thread/archived":return await this.unknown(t),!0;case"error":case"thread/unarchived":case"thread/goal/updated":case"thread/goal/cleared":case"model/rerouted":return!0;case"turn/completed":{let a=e.params.turn,l=Pg(a);return l===void 0||t.endedTurns.has(a.id)||(this.endWorkRequests(t,a.id),t.endedTurns.add(a.id),t.turnId!==null&&t.turnId!==a.id)||(t.turnId=null,t.foregroundTurnId!==null&&t.foregroundTurnId!==a.id)||(await t.foreground.update(l),t.foregroundTurnId=null,this.onChildWorkEnded(t.sessionId)),!0}case"thread/status/changed":return e.params.status.type==="notLoaded"?await this.unknown(t):e.params.status.type==="active"&&e.params.status.activeFlags.length===0&&await t.foreground.start(),!0;case"item/started":if(u===!0||e.params.item.type==="userMessage"||(t.turnId!==null&&t.foregroundTurnId===e.params.turnId&&await t.foreground.startItem(e.params.item.id),e.params.item.type==="plan")||u===!1)return!0;break;case"item/completed":{t.foregroundTurnId===e.params.turnId&&await t.foreground.completeItem(e.params.item.id);let a=e.params.item;if(this.rememberCompletedItem(n,a.id),u===!0)return t.toolCalls.complete(a.id),a.type==="commandExecution"&&t.streams.commands.restore(a),!0;if(a.type==="userMessage")return!0;if(a.type==="plan"){let c=await new $S(this.session.forSession(t.sessionId),this.capabilities).completed(a.id,a.text);return c?.update&&await this.session.update(c.update,t.sessionId),!0}break}case"item/plan/delta":return!0}return u===!0}pendingFor(e){let t=this.pending.get(e);return t||(t={notifications:new js(e)},this.pending.set(e,t)),t}parentFor(e){if(e.parentThreadId!==void 0)return e.parentThreadId===this.rootSessionId?this.rootSessionId:this.children.get(e.parentThreadId)?.sessionId;if(e.path===void 0)return;let t=e.path.slice(0,e.path.lastIndexOf("/"));return fi(t)||t===this.rootSessionId||t===`/${this.rootSessionId}`?this.rootSessionId:[...this.children.values()].find(n=>n.path===t)?.sessionId}async materializePending(){let e;do{e=!1;for(let[t,n]of this.pending){let i=this.parentFor(n);i!==void 0&&(await this.announce(t,i,n.path,n.description,!0),this.pending.delete(t),this.replayQueue.push(...n.notifications.take()),e=!0)}}while(e)}async restoreKnown(e){if(this.children.has(e))return!0;let t=this.associations.forRoot(this.rootSessionId).find(n=>n.threadId===e);if(!t)return!1;if(t.parentSessionId!==this.rootSessionId){let n=this.associations.get(t.parentSessionId);if(!n||!await this.restoreKnown(n.threadId))return!1}return await this.announce(e,t.parentSessionId),!0}async ensureAnnounced(e){if(await this.ready,this.retired||this.announced.has(e.threadId))return;let t=[...this.children.values()].find(n=>n.sessionId===e.parentSessionId);t&&await this.ensureAnnounced(t),await this.session.update({sessionUpdate:"subagent_update",sessionId:e.sessionId,capabilities:{},...e.title!==void 0?{title:e.title}:{},...e.description!==void 0?{description:e.description}:{}},e.parentSessionId),this.announced.add(e.threadId),this.configurations.has(e.threadId)&&(this.pendingConfigurations.add(e.threadId),!this.deferLive&&!this.snapshotting&&await this.publishConfiguration(e))}async announce(e,t,n,i,r=!1){let u=this.children.get(e);if(u)return u.live||=r,await this.ensureAnnounced(u),u.sessionId;let s=this.associations.register(this.rootSessionId,t,e),o={...s,turnId:null,foregroundTurnId:null,...n!==void 0?{path:rn(n),title:pi(n,"Agent")}:{},...i!==void 0?{description:i}:{},foreground:new Gb(async a=>{if(this.retired){a.state==="unknown"&&this.announced.has(e)&&await this.session.updateSubagentState(s.sessionId,t,a);return}if(this.deferLive||this.snapshotting){this.snapshots.set(e,{child:o,state:a});return}await this.session.updateSubagentState(s.sessionId,t,a)},"unknown"),toolCalls:new cd,streams:new DS,requests:new AbortController,workRequests:new Map,closedRequestTurns:new Set,endedTurns:new Set,live:r,cancelAdvertised:!1};return this.children.set(e,o),await this.ensureAnnounced(o),r&&await this.publishCancellation(o),r&&this.refreshConfiguration(o),o.sessionId}async announceHistory(e,t){if(e===this.rootSessionId)return null;if(await this.restoreKnown(e)){let i=this.children.get(e);return i.path??=rn(t),i.sessionId}let n=this.parentFor({path:rn(t),notifications:new js(e)});return n===void 0?null:this.announce(e,n,t)}async observeConfiguration(e,t,n){let i=this.configurations.get(e);if(this.retired||!i&&!t.model&&t.effort===null&&n!=="settings")return;this.configurationRequests.delete(e);let r={...i};t.model&&(r.model=Li(i?.model,{model:t.model,source:n})),(r.model?.model!==i?.model?.model||!i?.effort||ko[n]>=ko[i.effort.source])&&(r.effort={value:t.effort,source:n}),this.configurations.set(e,r);let s=this.children.get(e);s&&(this.pendingConfigurations.add(e),!this.deferLive&&!this.snapshotting&&await this.publishConfiguration(s))}async publishConfiguration(e){this.pendingConfigurations.delete(e.threadId),await this.ensureAnnounced(e);let t=this.configurations.get(e.threadId);if(!t||this.retired)return;let n=RS(this.rootModels(),{model:t.model?.model??null,effort:t.effort?.value??null}),i=JSON.stringify(n);if(!(i===t.published||n.length===0&&t.published===void 0))try{await this.session.update({sessionUpdate:"config_option_update",configOptions:n},e.sessionId),t.published=i}catch(r){D.error(`Failed to report subagent configuration ${e.threadId}`,r)}}async refreshConfiguration(e){let t=this.configurationRuntime,n=this.parentThreadId(e.threadId);if(!t||n===void 0||this.retired)return;let i={};this.configurationRequests.set(e.threadId,i);try{let r=await t.read(e.threadId,n);if(r===null)return;await t.enqueuePublication(async()=>{this.retired||this.configurationRequests.get(e.threadId)!==i||await this.observeConfiguration(e.threadId,r,"threadStarted")})}catch(r){D.log(`Configuration unavailable for subagent ${e.threadId}`,{error:String(r)})}finally{this.configurationRequests.get(e.threadId)===i&&this.configurationRequests.delete(e.threadId)}}releaseReplay(){return this.snapshotting=this.deferLive,this.deferLive=!1,this.cancellationReady=!0,this.deferredLive.take()}async publishReplaySnapshots(){try{for(let e of this.children.values())e.live&&this.refreshConfiguration(e);for(;this.snapshots.size>0||this.pendingConfigurations.size>0;){for(let{child:e}of[...this.snapshots.values()])await e.foreground.serializePublication(async()=>{let t=this.snapshots.get(e.threadId);this.snapshots.delete(e.threadId),!(!t||this.retired)&&(await this.ensureAnnounced(e),await this.session.updateSubagentState(e.sessionId,e.parentSessionId,t.state))});for(let e of[...this.pendingConfigurations]){let t=this.children.get(e);t&&!this.retired?await this.publishConfiguration(t):this.pendingConfigurations.delete(e)}}for(let e of this.children.values())await this.publishCancellation(e,!0)}finally{this.snapshotting=!1}}pauseForSetup(){this.deferLive=!0,this.suspendCancellation(),this.attachment++,this.announced.clear(),this.configurations.clear(),this.pendingConfigurations.clear(),this.configurationRequests.clear();for(let e of this.children.values())e.cancelAdvertised=!1,e.live&&e.foreground.snapshot().catch(t=>D.error("Failed to snapshot child work",t))}async withUserAction(e,t,n,i){let r=[...this.children.values()].find(c=>c.sessionId===e);if(!r)return n();await this.ensureAnnounced(r);let u=typeof i=="string"?r.workRequests.get(i)??{controller:new AbortController,count:0}:void 0;u&&typeof i=="string"&&(r.workRequests.set(i,u),u.count++);let s=typeof i=="string"&&(r.closedRequestTurns.has(i)||r.endedTurns.has(i));!s&&!this.retired&&(r.live=!0);let o=this.retired||s?AbortSignal.abort():u?AbortSignal.any([r.requests.signal,u.controller.signal]):r.requests.signal,a=this.runningTurnId(r.threadId)??r.turnId??r.foregroundTurnId,l=!this.retired&&!s&&typeof i=="string"&&(a===null||a===i);l&&this.beginForegroundTurn(r,i),await this.publishCancellation(r);try{return await eO({sessionId:e,signal:o,nextToolCallId:c=>this.associations.nextToolCallId(e,c),beforeRequest:()=>this.ensureAnnounced(r),...l?{foreground:r.foreground}:{},...t!==void 0?{itemId:t}:{}},n)}finally{u&&--u.count===0&&typeof i=="string"&&r.workRequests.get(i)===u&&r.workRequests.delete(i)}}endWorkRequests(e,t){e.workRequests.get(t)?.controller.abort(),e.workRequests.delete(t)}beginForegroundTurn(e,t){e.foregroundTurnId!==t&&(e.foregroundTurnId=t,e.foreground.invalidate())}isCurrentForeground(e,t){let n=this.runningTurnId(e.threadId);return n===void 0||n===t}observeWorkEnd(e){if((e.method==="turn/started"||e.method==="thread/status/changed"&&e.params.status.type!=="notLoaded")&&this.unobservable.delete(e.params.threadId),!this.retired&&(e.method==="thread/closed"||e.method==="thread/archived"||e.method==="thread/status/changed"&&e.params.status.type==="notLoaded")){this.unobservable.add(e.params.threadId);let t=this.children.get(e.params.threadId);t&&(t.live=!1)}if(!this.retired&&e.method==="turn/completed"&&e.params.turn.status!=="inProgress"){let t=this.receivedTurnEnds.get(e.params.threadId)??new Set;t.add(e.params.turn.id),this.receivedTurnEnds.set(e.params.threadId,t),this.closeWorkRequests(e.params.threadId,e.params.turn.id)}}closeWorkRequests(e,t){let n=this.children.get(e);n&&(n.closedRequestTurns.add(t),this.endWorkRequests(n,t))}cancelInteractions(){for(let e of this.children.values())this.cancelChildInteractions(e)}cancelChildInteractions(e){e.turnId!==null&&e.closedRequestTurns.add(e.turnId),e.requests.abort(),e.requests=new AbortController;for(let[t,n]of e.workRequests)e.closedRequestTurns.add(t),n.controller.abort();e.workRequests.clear()}currentTurn(e){if(this.retired||!e.live||this.unobservable.has(e.threadId))return null;let n=this.runningTurnId(e.threadId)??e.turnId??e.foregroundTurnId;return n===null||e.endedTurns.has(n)||this.receivedTurnEnds.get(e.threadId)?.has(n)?null:n}async publishCancellation(e,t=!1){if(this.deferLive||this.snapshotting&&!t)return;let n=this.attachment;if(await this.ensureAnnounced(e),!!this.announced.has(e.threadId))for(;;){let i=this.cancellationReady&&this.currentTurn(e)!==null;if(i===e.cancelAdvertised||(await this.session.update({sessionUpdate:"subagent_update",sessionId:e.sessionId,capabilities:{cancel:i?{}:null}},e.parentSessionId),n!==this.attachment))return;e.cancelAdvertised=i}}async cancelChild(e,t){let n=[...this.children.values()].find(s=>s.sessionId===e);if(!n||!this.cancellationReady||this.deferLive||!n.cancelAdvertised||this.currentTurn(n)===null)return;let i=new Set([e]),r;do{r=i.size;for(let s of this.children.values())i.has(s.parentSessionId)&&i.add(s.sessionId)}while(i.size!==r);let u=[...this.children.values()].filter(s=>i.has(s.sessionId)).map(s=>({child:s,turnId:this.currentTurn(s)}));await Promise.all(u.map(async({child:s,turnId:o})=>{if(!(o===null||s.cancellingTurn===o)){s.cancellingTurn=o,this.cancelChildInteractions(s),this.closeWorkRequests(s.threadId,o);try{await t(s.threadId,o)}catch(a){D.error(`Failed to interrupt child ${s.threadId}`,a)}finally{s.cancellingTurn===o&&delete s.cancellingTurn}}}))}suspendCancellation(){this.cancellationReady=!1}async unknown(e){e.live=!1,this.configurations.delete(e.threadId),this.pendingConfigurations.delete(e.threadId),this.configurationRequests.delete(e.threadId),e.requests.abort(),e.requests=new AbortController;for(let t of e.workRequests.values())t.controller.abort();e.workRequests.clear(),await e.foreground.update({state:"unknown"}),e.turnId=null,e.foregroundTurnId=null,await this.publishCancellation(e)}async finishOutstanding(e){if(e==="disconnected"){this.retired=!0,this.cancelInteractions();for(let t of this.children.values())this.announced.has(t.threadId)?await this.unknown(t):t.foreground.invalidate(),t.turnId=null}}activeTurns(){return[...this.children.values()].filter(e=>e.live).map(e=>({threadId:e.threadId,turnId:e.turnId}))}setInteractionObserver(e){this.interactionObserver=e}isRetired(){return this.retired}openToolCalls(e){return this.children.get(e)?.toolCalls}itemStreams(e){return this.children.get(e)?.streams}parentThreadId(e){let t=this.children.get(e)?.parentSessionId;return t===this.rootSessionId?t:t===void 0?void 0:this.associations.get(t)?.threadId}async reconcileHistoryItem(e,t,n,i){let r=this.children.get(e);if(!r||this.retired||!n&&(this.completedItems.get(e)?.has(t.id)||i!==void 0&&r.endedTurns.has(i)))return!1;r.toolCalls.restore(t,n,i),t.type==="commandExecution"&&r.streams.commands.restore(t),t.type==="agentMessage"&&r.streams.agentMessagePhases.set(t.id,t.phase);let u=this.replayedItems.get(e)??new Map;return u.set(t.id,n),this.replayedItems.set(e,u),n&&(this.rememberCompletedItem(e,t.id),await r.foreground.completeItem(t.id)),!0}rememberCompletedItem(e,t){let n=this.completedItems.get(e)??new Set;n.add(t),this.completedItems.set(e,n)}async restoreRuntime(e,t){let n=this.children.get(e.id);!n||this.retired||(n.live=!0,await this.observeConfiguration(e.id,{model:e.model,effort:e.reasoningEffort},"threadStarted"),e.status.type==="idle"?(n.turnId=null,n.foregroundTurnId=null,await n.foreground.update({state:"idle"})):e.status.type==="active"&&e.status.activeFlags.length===0&&(n.turnId??=t??null,n.turnId!==null&&this.beginForegroundTurn(n,n.turnId),await n.foreground.start()),await this.publishCancellation(n))}async replayTurnOutcome(e,t){let n=this.children.get(e),i=Pg(t);!n||i===void 0||this.retired||(await this.ensureAnnounced(n),!this.retired&&await this.session.updateSubagentState(n.sessionId,n.parentSessionId,i))}childSessionIds(){return[...this.children.values()].map(e=>e.sessionId)}isNativeSubagentThread(e){return this.children.has(e)}shouldIgnore(){return!1}notificationSessionId(e){let t=e.params.threadId;return typeof t=="string"?this.children.get(t)?.sessionId??this.rootSessionId:this.rootSessionId}takeBufferedNotifications(){return this.replayQueue.splice(0)}async waitForMaterializedSession(e){if(this.retired)return null;await this.materializePending();let t=this.children.get(e);return t&&await this.ensureAnnounced(t),t?.sessionId??null}closingChildSessions(e){if(e.method!=="turn/completed")return[];let t=this.children.get(e.params.threadId),n=e.params.turn;return!t||n.status==="inProgress"||t.endedTurns.has(n.id)||t.turnId!==null&&t.turnId!==n.id?[]:[{threadId:t.threadId,sessionId:t.sessionId,state:n.status==="interrupted"?"cancelled":n.status==="failed"?"failed":"completed"}]}async wait(e){return"settled"}hasOutstanding(){return[...this.children.values()].some(e=>e.turnId!==null)}legacyActivityStarted(e){return this.legacyActivities.add(e.id),mu.activity(e,"in_progress","start")}legacyActivityCompleted(e){return mu.activity(e,"completed",this.legacyActivities.delete(e.id)?"update":"start")}legacyCollaborationStarted(e){return pu.started(e)}legacyCollaborationCompleted(e){return pu.completed(e)}};function Pg(e){switch(e.status){case"inProgress":return;case"completed":return iu({stopReason:"end_turn"});case"interrupted":return iu({stopReason:"cancelled"});case"failed":return iu({stopReason:"end_turn"},{code:-32603,message:e.error?tu(e.error.message):"Subagent work failed"})}}function Rg(e,t="codex"){return e.limitId??t}function nO(e){let t=new Map,n=Object.entries(e.rateLimitsByLimitId??{}).filter(i=>i[1]!==void 0);n.length===0&&n.push([Rg(e.rateLimits),e.rateLimits]);for(let[i,r]of n){let u=Rg(r,i);t.set(u,{limitId:u,limitName:r.limitName??u,snapshot:r})}return t}function rO(e,t){return{...t,limitId:t.limitId??"codex",normalModelSlug:t.normalModelSlug??e.normalModelSlug,credits:t.credits??e.credits,individualLimit:t.individualLimit??e.individualLimit,spendControlReached:t.spendControlReached??e.spendControlReached,planType:t.planType??e.planType}}var Oo=1,iO=1024,zg=4096,OS=256*1024,gd=8*1024*1024,Og="Codex turn diffs may omit same-content renames and changes made outside apply_patch, including shell commands, version-control commands, generators, and child processes.";function uO(e,t){let n=No(e);return{cwd:e,additionalDirectories:[...t],diffRoot:n===null?e:pO(n).value}}function sO(e){let t=Ql(e?.[Bt]),n=Ql(t?.[kt]),i=Ql(n?.[l2]);if(i===null||!CO(i,["version","requestId"])||i.version!==Oo)return null;let r=i.requestId;return typeof r!="string"||!/^[A-Za-z0-9._:-]{1,128}$/.test(r)?null:{version:Oo,requestId:r}}function oO(e,t,n){if(Buffer.byteLength(t,"utf8")>gd)throw new En("invalidOutput","The turn diff exceeds the parser input limit");let i=aO(t),r=dO(i,n);return cO({version:Oo,requestId:e,status:"reported",...r})}function Ng(e,t){return{version:Oo,requestId:e,status:"unavailable",reason:t}}var En=class extends Error{reason;constructor(e,t){super(t),this.name="AgentFileChangeReportError",this.reason=e}};function aO(e){if(e.trim()==="")return{paths:[],complete:!1,uncertainty:Og};let t;try{t=iS(e)}catch(r){throw new En("invalidOutput",`The turn diff is not valid unified diff: ${r instanceof Error?r.message:String(r)}`)}if(t.length===0)throw new En("invalidOutput","The turn diff contains no parseable file patches");let n=lO(e),i=[];for(let[r,u]of t.entries()){let s=n[r],o=Ug(Mg(s?.oldFileName,u.oldFileName)),a=Ug(Mg(s?.newFileName,u.newFileName));if(o===null&&a===null)throw new En("invalidOutput","The turn diff contains a patch without a file path");o!==null&&i.push(o),a!==null&&i.push(a)}return{paths:i,complete:!1,uncertainty:Og}}function lO(e){return e.split(/(?=^diff --git )/m).filter(t=>t.trim()!=="").map(t=>{let n=t.split(/\r?\n/);for(let i=0;i<n.length;i+=1){let r=n[i];if(r?.startsWith("@@ "))return null;let u=n[i+1];if(r?.startsWith("--- ")&&u?.startsWith("+++ "))return{oldFileName:r.slice(4),newFileName:u.slice(4)}}return null})}function Mg(e,t){return e===void 0||e.startsWith('"')?t:e}function Ug(e){return e===void 0||e==="/dev/null"?null:e.startsWith("a/")||e.startsWith("b/")?e.slice(2):e}function cO(e){let t=[...e.paths],n=e.truncated,i=e;for(;Buffer.byteLength(JSON.stringify(i),"utf8")>OS;){if(t.length===0)throw new En("invalidOutput","The audit report exceeds the wire limit");t.pop(),n=!0,i={...e,paths:[...t],declaredComplete:!1,truncated:n}}return i}function dO(e,t){let n=No(t.cwd);if(n===null)throw new En("providerError","The session working directory is not absolute");let i=hp(n),r=No(t.diffRoot);if(r===null||r.flavor!==i.flavor)throw new En("providerError","The captured turn-diff root is invalid");let u=[i,...t.additionalDirectories.flatMap(c=>{let m=hO(c);return m===null||m.flavor!==i.flavor?[]:[m]})],s=[],o=new Set,a=0,l=!1;for(let c of e.paths){if(c.length>zg){l=!0;continue}let m=fO(c,r,u);if(m===null||m.value.length>zg){l=!0;continue}let p=m.flavor==="windows"?m.value.toLowerCase():m.value;if(o.has(p))continue;let v=Buffer.byteLength(m.value,"utf8");if(s.length>=iO||a+v>OS){l=!0;continue}o.add(p),s.push(m.value),a+=v}return{paths:s,declaredComplete:e.complete&&!l,truncated:l,...e.uncertainty?{uncertainty:e.uncertainty}:{}}}function hO(e){let t=No(e);return t===null?null:hp(t)}function No(e){let t=e.trim();return MS(t)?vd(t)?{value:Qe.win32.normalize(t.replace(/\//g,"\\")),flavor:"windows"}:Qe.posix.isAbsolute(t)?{value:Qe.posix.normalize(t.replace(/\\/g,"/")),flavor:"posix"}:null:null}function fO(e,t,n){if(!MS(e)||/^[A-Za-z]:[^\\/]/.test(e)||/^\\\\[?.]\\/.test(e)||/^(?:\\\\|\/\/)/.test(e)&&!vd(e)||t.flavor==="windows"&&/^\\(?!\\)/.test(e)||/^[A-Za-z][A-Za-z0-9+.-]*:\/\//.test(e))return null;let i;return vd(e)?i={value:Qe.win32.normalize(e.replace(/\//g,"\\")),flavor:"windows"}:Qe.posix.isAbsolute(e)?i={value:Qe.posix.normalize(e.replace(/\\/g,"/")),flavor:"posix"}:t.flavor==="windows"?i={value:Qe.win32.resolve(t.value,e.replace(/\//g,"\\")),flavor:"windows"}:i={value:Qe.posix.resolve(t.value,e.replace(/\\/g,"/")),flavor:"posix"},i=mO(i),n.some(r=>vO(r,i))?i:null}function pO(e){if(!fp(e.flavor))return e;let t=e.flavor==="windows"?Qe.win32:Qe.posix,n=e.value;for(;;){if(zS.existsSync(t.join(n,".git")))return hp({value:n,flavor:e.flavor});let i=t.dirname(n);if(i===n)return e;n=i}}function hp(e){return fp(e.flavor)?{...e,value:NS(e.value)}:e}function mO(e){if(!fp(e.flavor))return e;let t=NS(Qe.dirname(e.value));return{...e,value:Qe.resolve(t,Qe.basename(e.value))}}function NS(e){let t=Qe.resolve(e),n=t,i=[];for(;;){try{let u=zS.realpathSync.native(n);return Qe.resolve(u,...i.reverse())}catch(u){if(!gO(u))return t}let r=Qe.dirname(n);if(r===n)return t;i.push(Qe.basename(n)),n=r}}function gO(e){return typeof e!="object"||e===null||!("code"in e)?!1:e.code==="ENOENT"||e.code==="ENOTDIR"}function fp(e){return process.platform==="win32"?e==="windows":e==="posix"}function vO(e,t){if(e.flavor!==t.flavor)return!1;let n=e.flavor==="windows"?Qe.win32:Qe.posix,i=n.relative(e.value,t.value);return i.length>0&&!n.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${n.sep}`)}function vd(e){let t=e.replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)||/^\/\/[^/]+\/[^/]+(?:\/|$)/.test(t)}function MS(e){return e.length>0&&!/[\u0000-\u001F\u007F-\u009F]/.test(e)}function Ql(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function CO(e,t){let n=new Set(t);return Object.keys(e).every(i=>n.has(i))}function Xt(e){return e instanceof Error?e.message:typeof e=="string"?e:e!==null&&typeof e=="object"&&"message"in e?String(e.message):""}function vi(e){return Xt(e).includes("no rollout found for thread id")}function yO(e){return Xt(e).includes("not materialized")}function EO(e){return Xt(e).includes("no archived rollout found for thread id")}function wO(e){return Xt(e).includes("thread not loaded:")}function US(e){return Xt(e).includes("thread not found:")}function jS(e){let t=Xt(e);return t.includes("invalid thread id:")||t.includes("invalid session id:")}function _O(e){return Xt(e).includes("no active turn to interrupt")}function AO(e){let t=Xt(e).match(/expected active turn id (\S+) but found (\S+)/);return t?{expected:t[1],found:t[2]}:null}function pp(e){return vi(e)||wO(e)||jS(e)}function LS(e){return/\bthread \S+ already has an active writer\b/.test(Xt(e))}function qS(e,t){return k.invalidRequest({reason:"thread_active_writer",threadId:e,details:Xt(t)},"This Codex session is in use by another Codex client (the Codex app, the CLI or an IDE extension). Close the session there or quit that client, then try again.")}var bO=-32002;function Cd(e){return new k(bO,`Session not found: ${e}`,{sessionId:e})}var SO="archived";function DO(e){return k.invalidRequest({reason:SO,sessionId:e},`Session is archived: ${e}`)}var IO=-32603,$O=new Set(["workspace routing discovery failed","workspace routing discovery timed out"]),BO=new Set(["workspace routing discovery unauthorized (401)","selected workspace missing from routing discovery","workspace routing requires a ChatGPT account id"]),kO="account changed during workspace routing discovery";function mp(e){return e===null||typeof e!="object"||e.code!==IO?null:Xt(e)}function yd(e){let t=mp(e);return t!==null&&$O.has(t)}function Gs(e){let t=mp(e);return t!==null&&BO.has(t)}function xO(e){return mp(e)===kO}var jg="archived_sessions";function Al(e){return pp(e)||US(e)}function Mo(e,t){return LS(t)?qS(e,t):Al(t)?Cd(e):t}async function TO(e,t,n,i){if(vi(n)){let r;try{r=await ZS(e,t,i)}catch(u){return D.log("Cannot tell why the rename found no rollout",{threadId:t,error:String(u)}),Mo(t,n)}if(r===!0)return DO(t)}return Mo(t,n)}async function FO(e,t,n,i){try{return n?await e.threadArchive({threadId:t}):await e.threadUnarchive({threadId:t}),"done"}catch(r){if(jS(r))return"missing";if(!(n?vi(r):EO(r)))throw r;let s=await ZS(e,t,i);if(s==="missing")return"missing";if(s===n)return D.log("Thread already in the requested archive state",{threadId:t,archived:n}),"unchanged";throw r}}async function PO(e,t){try{return await e.threadDelete({threadId:t}),"done"}catch(n){if(Al(n))return"missing";throw n}}async function ZS(e,t,n){let i;try{i=(await e.threadRead({threadId:t})).thread.path}catch(r){if(Al(r))return"missing";throw r}return i===null?"missing":WS(i,n)}function WS(e,t){if(t!==null){let n=ec.relative(ec.join(t,jg),e);if(n!==""&&!n.startsWith("..")&&!ec.isAbsolute(n))return!0}return e.replace(/\\/g,"/").split("/").includes(jg)}function RO(e,t){let n=e.sessionIndexExplicitTitle;return e.automaticTitleEcho!==void 0&&t===e.automaticTitleEcho&&(delete e.automaticTitleEcho,n!==void 0&&t!==n)?!0:(n!==void 0&&t===n&&(delete e.sessionIndexExplicitTitle,delete e.automaticTitleEcho),!1)}var zO=class{constructor(e,t){this.host=e,this.writes=t}host;writes;explicitTitles=new Map;async rename(e,t){let n=vn(t);if(n===null)throw k.invalidParams({sessionId:e},"title must be a non-empty string");let i=this.host.session(e),r=i?.sessionTitleSource;i&&(i.sessionTitleSource="explicit");let u=this.explicitTitles.get(e)??{confirmed:!1,pending:0};this.explicitTitles.set(e,u),u.pending++;try{await this.writes.run(e,async()=>{try{await this.host.runWithProcessCheck(()=>this.host.client().renameSession(e,n))}catch(o){throw u.pending--,!u.confirmed&&u.pending===0&&this.explicitTitles.get(e)===u&&this.explicitTitles.delete(e),i&&r!==void 0&&i.sessionTitleSource==="explicit"&&(i.sessionTitleSource=r),this.explicitTitles.has(e),o}u.pending--,u.confirmed=!0})}catch(o){let a=this.host.client();throw await TO(a.appServerClient,e,o,a.getHomePath())}let s=this.host.session(e);s&&(s.sessionTitle=n,s.sessionTitleSource="explicit",s.sessionIndexExplicitTitle=n,await new Fe(this.host.connection(),e).update({sessionUpdate:"session_info_update",title:n,_meta:{lody:{titleSource:"explicit"}}}))}writeAutomaticTitle(e,t,n){return this.writes.run(e,async()=>{if(this.explicitTitles.has(e))return!1;let i=vn(t)??void 0,r=this.host.session(e);r&&i!==void 0&&(r.automaticTitleEcho=i);let u=!1;try{return u=await n(),u}finally{!u&&r?.automaticTitleEcho===i&&delete r?.automaticTitleEcho}})}forget(e){this.explicitTitles.delete(e)}},OO=240,NO={transport_lost:{category:"connection",actions:["retry","new_session"]},auth_required:{category:"access",actions:["login"]},rate_limited:{category:"limit",actions:["retry"]},quota_exhausted:{category:"limit",actions:[]},overloaded:{category:"service",actions:["retry"]},context_exhausted:{category:"limit",actions:["new_session"]},budget_exhausted:{category:"limit",actions:["new_session"]},policy_denied:{category:"request",actions:[]},bad_request:{category:"request",actions:[]},provider_error:{category:"service",actions:["retry"]},internal_error:{category:"service",actions:["retry","new_session"]}},MO={transport_lost:"Connection to Codex was lost.",internal_error:"Codex encountered an internal error."};function Lg(e,t){return e?.id===t?e.revision+1:1}var qg={contextWindowExceeded:"context_exhausted",sessionBudgetExceeded:"budget_exhausted",usageLimitExceeded:"quota_exhausted",rateLimitExceeded:"rate_limited",flexUnavailable:"provider_error",serverOverloaded:"overloaded",cyberPolicy:"policy_denied",misalignmentPolicyViolation:"policy_denied",tooManyDenials:"provider_error",internalServerError:"internal_error",unauthorized:"auth_required",badRequest:"bad_request",threadRollbackFailed:"provider_error",sandboxError:"provider_error",other:"provider_error"},Zg={httpConnectionFailed:"transport_lost",responseStreamConnectionFailed:"transport_lost",responseStreamDisconnected:"transport_lost",responseTooManyFailedAttempts:"transport_lost",activeTurnNotSteerable:"provider_error"},GS=new WeakSet;function UO(e){return e instanceof k&&GS.has(e)}var tc=class{constructor(e,t,n=!1,i=O2(),r=new Qb(t.sessionId,!1,new Fe(e,t.sessionId)),u,s=!1,o=!1,a=!1){this.supportsCompaction=o,this.supportsNotices=a,e=r.connectionForEvents?.(e)??e,this.connection=e,this.onAccountUpdated=u,this.sessionState=t,this.supportsTypedSessionFailures=n,this.sessionFailureEpoch=i,this.session=new Fe(e,t.sessionId),this.renderer=new Hr(t.clientCapabilities),this.plans=new $S(this.session,t.clientCapabilities),this.subagents=r,this.collectTurnDiffs=s,t.sessionFailure!==void 0&&this.failuresById.set(t.sessionFailure.id,t.sessionFailure)}supportsCompaction;supportsNotices;static PLAN_UPDATE_INTERVAL_MS=150;connection;sessionState;supportsTypedSessionFailures;sessionFailureEpoch;pendingErrors=[];failuresById=new Map;activeFailureIdByScope=new Map;failureTurnIdById=new Map;allocatedFailureScopes=new Set;lastSessionNotice;nextNoticeId=1;failure=null;terminalTurnError=null;completedPlan=null;session;renderer;itemStreams=new DS;plans;disposed=!1;turnDiffs=new Map;oversizedTurnDiffs=new Set;childTurnDiffs=new Map;latestRootTurnId=null;collectTurnDiffs;subagents;onAccountUpdated;getFailure(){return this.failure}getTurnFailure(e){if(e.status!=="failed")return null;let t=e.error??(this.terminalTurnError?.turnId===e.id?this.terminalTurnError.error:null);return this.isAuthenticationRequiredError(t?.codexErrorInfo??null)?{code:-32e3,message:"Authentication required"}:{code:-32603,message:ru(tu(t?.message??"Codex turn failed."))}}recordTerminalTurnError(e){e.method==="error"&&e.params.threadId===this.sessionState.sessionId&&!e.params.willRetry&&(this.terminalTurnError={turnId:e.params.turnId,error:e.params.error})}getTurnDiff(e){let t=[this.turnDiffs.get(e)??""];for(let n of this.childTurnDiffs.values())n.rootTurnId===e&&n.diff!==null&&t.push(n.diff);return t.filter(n=>n.trim()!=="").reduce((n,i)=>n===""||n.endsWith(`
|
|
100
|
+
`)?n+i:`${n}
|
|
101
|
+
${i}`,"")}isTurnDiffOversized(e){return this.oversizedTurnDiffs.has(e)||[...this.childTurnDiffs.values()].some(t=>t.rootTurnId===e&&t.diff===null)}getTerminalSessionFailureMeta(e,t=!1){let n=this.sessionState.sessionFailure;return!this.supportsTypedSessionFailures||n===void 0||(this.failureTurnIdById.get(n.id)===void 0?!t:e===null||this.failureTurnIdById.get(n.id)!==e)?null:this.createSessionFailureMeta(n)}recordSyntheticTerminalFailure(e,t){this.recordSessionFailure(e,t??void 0,"error",MO[e])}async handleSessionScopedNotification(e){let t=e.params.threadId;if(this.subagents instanceof Ue&&typeof t=="string"&&t!==this.sessionState.sessionId){await this.handleNotification(e);return}if(this.recordTerminalTurnError(e),e.method!=="error"){await this.handleNotification(e);return}if(!this.supportsTypedSessionFailures){await this.handleNotification(e);return}let n={...e.params,error:this.sanitizeTurnError(e.params.error)};if(await this.finishCompactionsForNotification({method:"error",params:n}),n.willRetry){await this.session.update(this.createSessionFailureUpdate(this.recordRetryWarning(n,!1)));return}let i=this.recordSessionFailure(this.sessionFailureKind(n.error.codexErrorInfo),n.turnId,"error",n.error.message,void 0,!1);await this.session.update(this.createSessionFailureUpdate(i))}async flushPendingErrors(){if(this.sessionState.currentTurnId===null||this.pendingErrors.length===0)return;let e=this.pendingErrors.splice(0);for(let t of e){let n=await this.createErrorEvent(t);n&&await this.session.update(n)}}async flushPendingErrorsAsSessionScoped(){if(!this.supportsTypedSessionFailures||this.pendingErrors.length===0)return;let e=this.pendingErrors.splice(0);for(let t of e)await this.handleSessionScopedNotification({method:"error",params:t})}async clearSessionFailure(){delete this.sessionState.sessionFailure}async completeSuccessfulTurn(e){if(this.lastSessionNotice=void 0,!this.supportsTypedSessionFailures||e===null)return;let t=this.sessionState.sessionFailure;t?.id!==this.activeFailureIdByScope.get(e)||t?.severity!=="warning"||(this.activeFailureIdByScope.delete(e),delete this.sessionState.sessionFailure)}async handleFailedTurn(e){let t=this.sessionState.sessionFailure;if(!this.supportsTypedSessionFailures||e.status!=="failed"||this.failure!==null||this.failureTurnIdById.get(t?.id??"")===e.id&&t?.severity==="error")return;let n=this.sanitizeTurnError(e.error??{message:"Turn failed",codexErrorInfo:null,additionalDetails:null,misalignment:null});if(this.isAuthenticationRequiredError(n.codexErrorInfo)&&!this.sessionState.authConfigured){this.failure=k.authRequired();return}this.recordTypedSessionFailure({threadId:this.sessionState.sessionId,turnId:e.id,willRetry:!1,error:n})}takeCompletedPlan(){let e=this.completedPlan;return this.completedPlan=null,e}async handleNotification(e){let t=e.params.threadId;if(this.subagents instanceof Ue&&this.subagents.isRetired()&&typeof t=="string"&&t!==this.sessionState.sessionId)return;if(this.recordTerminalTurnError(e),e.method==="item/started"&&e.params.threadId===this.sessionState.sessionId&&LO(e.params.item)&&this.sessionState.promptTokenUsage?.observeModelOutput(),e.method==="account/rateLimits/updated"){await this.handleRateLimitsSnapshot(e.params.rateLimits,!0);return}if(e.method==="turn/diff/updated"&&e.params.threadId!==this.sessionState.sessionId&&this.recordChildTurnDiff(e.params),this.subagents instanceof Ue&&!await this.subagents.prepareNotification(e)){for(let s of this.subagents.takeBufferedNotifications())await this.handleNotification(s);return}await this.flushPendingErrors(),await this.finishCompactionsForNotification(e);let n=this.subagents.closingChildSessions(e);for(let s of n){if(this.subagents instanceof Ue){let o=e.method==="turn/completed"?e.params.turn.id:void 0;for(let a of this.subagents.openToolCalls(s.threadId)?.finishOutstanding(o)??[])await this.session.update(a,s.sessionId)}await this.finishOutstandingCompactions(s.state==="cancelled"?"cancelled":"failed",s.sessionId),await this.sessionState.asyncTasks.reconcile(s.threadId,s.sessionId)}let i=await this.subagents.handle(e);for(let s of this.subagents.takeBufferedNotifications())await this.handleNotification(s);let r=!i&&this.subagents.shouldIgnore(e),u;if(!i&&!r&&e.method==="item/started"&&e.params.item.type==="commandExecution"&&(u=await this.createUpdateEvent(e)),i||await this.sessionState.asyncTasks.handleNotification(e,this.subagents.notificationSessionId(e),qO(u)),i){await this.emitExtNotification(e);return}if(r){await this.emitExtNotification(e);return}u===void 0&&(u=await this.createUpdateEvent(e)),u&&await this.session.update(u,this.subagents.notificationSessionId(e)),await this.emitExtNotification(e)}async waitForNativeSubagentSession(e){return await this.subagents.waitForMaterializedSession(e)}async waitForNativeSubagents(e){await this.subagents.wait(e)==="timed_out"&&await this.finishOutstandingNativeSubagents("failed")}async finishOutstandingNativeSubagents(e){await this.finishOutstandingCompactions(e==="cancelled"?"cancelled":"failed"),await this.subagents.finishOutstanding(e)}async finishOutstandingCompactions(e,t){if(this.supportsCompaction)for(let{sessionId:n,update:i}of this.sessionState.compactions.finishOutstanding(e,t))await this.session.update(i,n)}async finishCompactionsForNotification(e){if(!this.supportsCompaction)return;let t,n=this.subagents.notificationSessionId(e);if(e.method==="turn/completed"){let i=e.params.turn;if(i.status==="inProgress")return;t=this.sessionState.compactions.finishTurn(n,i.id,i.status==="interrupted"?"cancelled":"failed",i.error?this.sanitizeTurnError(i.error).message:"Codex ended the turn before compaction completed.")}else if(e.method==="error"&&!e.params.willRetry)t=this.sessionState.compactions.finishTurn(n,e.params.turnId,"failed",this.sanitizeTurnError(e.params.error).message);else return;for(let i of t)await this.session.update(i,n)}async flushPendingPlanUpdates(){await this.plans.flush()}async dispose(){this.disposed||(await this.plans.dispose(),this.pendingErrors.length>0&&(D.log("Discarding app-server errors that arrived before a turn started",{sessionId:this.sessionState.sessionId,count:this.pendingErrors.length,turnIds:this.pendingErrors.map(e=>e.turnId)}),this.pendingErrors.splice(0)),this.disposed=!0,this.turnDiffs.clear(),this.oversizedTurnDiffs.clear(),this.childTurnDiffs.clear())}recordChildTurnDiff(e){if(this.disposed||!this.collectTurnDiffs)return;let t=`${e.threadId}
|
|
102
|
+
${e.turnId}`,n=this.childTurnDiffs.get(t)?.rootTurnId??this.sessionState.currentTurnId??this.latestRootTurnId;if(n===null)return;let i=Buffer.byteLength(e.diff,"utf8")>gd;this.childTurnDiffs.set(t,{rootTurnId:n,diff:i?null:e.diff})}async createUpdateEvent(e){switch(e.method){case"item/agentMessage/delta":return this.completeRetryIncidentOnTurnProgress(e.params.threadId),await this.createTextEvent(e.params);case"item/plan/delta":return this.completeRetryIncidentOnTurnProgress(e.params.threadId),this.plans.delta(e.params.itemId,e.params.delta);case"item/started":{this.completeRetryIncidentOnTurnProgress(e.params.threadId);let t=await this.createItemEvent(e.params);return this.trackOpenToolCall(e.params.item,e.params.threadId,e.params.turnId),t}case"item/completed":return this.completeRetryIncidentOnTurnProgress(e.params.threadId),this.openToolCalls(e.params.threadId).complete(e.params.item.id),await this.completeItemEvent(e.params);case"turn/plan/updated":return this.completeRetryIncidentOnTurnProgress(e.params.threadId),await this.updatePlan(e.params);case"turn/diff/updated":return e.params.threadId===this.sessionState.sessionId&&(this.completeRetryIncidentOnTurnProgress(e.params.threadId),!this.disposed&&this.collectTurnDiffs&&(Buffer.byteLength(e.params.diff,"utf8")>gd?(this.turnDiffs.delete(e.params.turnId),this.oversizedTurnDiffs.add(e.params.turnId)):(this.oversizedTurnDiffs.delete(e.params.turnId),this.turnDiffs.set(e.params.turnId,e.params.diff)))),null;case"error":return await this.createErrorEvent(e.params);case"turn/started":return e.params.threadId===this.sessionState.sessionId&&(this.sessionState.turnUsage??=new Fo,this.sessionState.turnUsage.start(e.params.turn.id,this.sessionState.currentModelId.replace(/\[.*?]$/,""))),this.sessionState.interruptTurnId=e.params.turn.id,this.sessionState.currentTurnId??=e.params.turn.id,await this.flushPendingErrors(),null;case"turn/completed":if(await this.plans.flush(),this.plans.clearTurn(),this.latestRootTurnId=this.sessionState.currentTurnId??this.latestRootTurnId,this.sessionState.currentTurnId=null,this.sessionState.interruptTurnId=null,this.session.protocolVersion===2&&e.params.turn.status==="failed")for(let t of this.sessionState.openToolCalls.finishOutstanding())await this.session.update(t,this.subagents.notificationSessionId(e));return this.sessionState.toolCallReports.releaseOpen(this.subagents.notificationSessionId(e)),this.sessionState.openToolCalls.clear(),null;case"thread/tokenUsage/updated":return this.createUsageUpdate(e.params);case"thread/name/updated":return RO(this.sessionState,vn(e.params.threadName))?null:(this.sessionState.sessionTitle=vn(e.params.threadName),this.sessionState.sessionTitleSource=e.params.threadName==null?"unset":"explicit",{sessionUpdate:"session_info_update",title:this.sessionState.sessionTitle,_meta:{lody:{titleSource:this.sessionState.sessionTitleSource}}});case"thread/status/changed":return this.createCodexSessionInfoUpdate({threadStatus:e.params.status});case"thread/archived":return this.createCodexSessionInfoUpdate({archived:!0});case"thread/unarchived":return this.createCodexSessionInfoUpdate({archived:!1});case"thread/closed":return this.createCodexSessionInfoUpdate({closed:!0});case"item/commandExecution/outputDelta":return this.completeRetryIncidentOnTurnProgress(e.params.threadId),this.renderer.render(this.streamsFor(e.params.threadId).commands.outputDelta(e.params.itemId,e.params.delta));case"item/mcpToolCall/progress":return this.completeRetryIncidentOnTurnProgress(e.params.threadId),this.renderer.capabilities.airToolCallContract?null:this.renderer.render(qs.progress(e.params.itemId,e.params.message));case"account/rateLimits/updated":return null;case"account/updated":return this.onAccountUpdated?.(e.params),null;case"configWarning":return await this.createConfigWarningEvent(e.params);case"warning":return this.createWarningEvent(e.params);case"guardianWarning":return null;case"deprecationNotice":return this.createDeprecationNoticeEvent(e.params);case"item/autoApprovalReview/started":return this.renderer.render(this.streamsFor(e.params.threadId).guardianReviews.started(e.params));case"item/autoApprovalReview/completed":return this.renderer.render(this.streamsFor(e.params.threadId).guardianReviews.completed(e.params));case"thread/compacted":return this.supportsCompaction?this.sessionState.compactions.completeLegacy(this.subagents.notificationSessionId(e),e.params.turnId):this.createContextCompactedEvent();case"item/reasoning/summaryTextDelta":return this.completeRetryIncidentOnTurnProgress(e.params.threadId),this.createReasoningSummaryDeltaEvent(e.params);case"item/reasoning/textDelta":return this.completeRetryIncidentOnTurnProgress(e.params.threadId),this.createRawReasoningDeltaEvent(e.params);case"item/reasoning/summaryPartAdded":return this.completeRetryIncidentOnTurnProgress(e.params.threadId),this.createReasoningSectionBreakEvent(e.params);case"model/rerouted":return this.createModelReroutedEvent(e.params);case"fuzzyFileSearch/sessionUpdated":return this.renderer.render(this.itemStreams.fuzzySearches.updated(e.params));case"fuzzyFileSearch/sessionCompleted":return this.renderer.render(this.itemStreams.fuzzySearches.completed(e.params));case"thread/goal/updated":return this.createThreadGoalUpdatedEvent(e.params);case"thread/goal/cleared":return this.createThreadGoalClearedEvent(e.params);case"item/commandExecution/terminalInteraction":return this.renderer.render(this.streamsFor(e.params.threadId).commands.terminalInput(e.params.itemId,e.params.stdin));case"thread/attachment/updated":return null;case"account/gatewayOAuth/changed":return null;case"skills/changed":return null;case"thread/readState/changed":case"thread/prediction/updated":case"thread/deleted":case"thread/reverted":case"thread/queue/changed":case"project/changed":case"thread/project/updated":case"thread/environment/connected":case"thread/environment/disconnected":case"command/exec/outputDelta":case"hook/started":case"hook/completed":case"turn/moderationMetadata":case"item/fileChange/outputDelta":case"item/fileChange/patchUpdated":case"fs/changed":case"mcpServer/startupStatus/updated":case"mcpServer/event/stream/notification":case"serverRequest/resolved":case"model/verification":case"modelProvider/authRecoveryStarted":case"modelProvider/authRecoveryCompleted":case"model/safetyBuffering/updated":case"windows/worldWritableWarning":case"thread/realtime/started":case"thread/realtime/itemAdded":case"thread/realtime/item/started":case"thread/realtime/item/transcript/delta":case"thread/realtime/item/completed":case"thread/realtime/transcript/delta":case"thread/realtime/transcript/done":case"thread/realtime/outputAudio/delta":case"thread/realtime/sdp":case"thread/realtime/error":case"thread/realtime/closed":case"windowsSandbox/setupCompleted":case"account/login/completed":case"mcpServer/oauthLogin/completed":case"externalAgentConfig/import/completed":case"rawResponseItem/completed":case"rawResponse/completed":case"thread/started":case"remoteControl/status/changed":case"app/list/updated":case"thread/settings/updated":case"externalAgentConfig/import/progress":case"process/outputDelta":case"process/exited":case"autoApprovalReview/strictReviewRequired":return null}}async emitExtNotification(e){if(e.method==="thread/prediction/updated"&&e.params.threadId===this.sessionState.sessionId&&this.sessionState.clientCapabilities.promptSuggestions){let t={sessionId:this.sessionState.sessionId,sourceTurnId:e.params.sourceTurnId,result:e.params.result};await this.notifyExt(Kn.sessionPromptSuggestion,t)}if(e.method==="thread/tokenUsage/updated"&&e.params.threadId===this.sessionState.sessionId){this.sessionState.turnUsage??=new Fo;let t=this.sessionState.turnUsage.update(e.params);t&&await this.notifyExt(J2,t)}}async notifyExt(e,t){let n=e.startsWith("_")?e:`_${e}`;await this.connection.notify(n,t)}createSessionRateLimitsExtNotification(e){return{rateLimits:[fS(e)],fetchedAtEpochSeconds:Math.floor(Date.now()/1e3)}}createCodexSessionInfoUpdate(e){return{sessionUpdate:"session_info_update",_meta:{codex:e}}}async createTextEvent(e){let t=this.streamsFor(e.threadId).agentMessagePhases.get(e.itemId)??null;return Un(e.delta,e.itemId,{...Po(t,this.sessionState.clientCapabilities.airClient),...cS(t,e.turnId)})}async createConfigWarningEvent(e){let t=e.details?`
|
|
103
|
+
|
|
104
|
+
${e.details}`:"";return{sessionUpdate:"session_info_update",_meta:{lody:{notice:{level:"warning",message:`${e.summary}${t}`,source:"configWarning"}}}}}createWarningEvent(e){return{sessionUpdate:"session_info_update",_meta:{lody:{notice:{level:"warning",message:e.message,source:"warning"}}}}}createDeprecationNoticeEvent(e){return this.supportsNotices?Ml("warning",e.summary.trim()||"Deprecated configuration",e.details):this.supportsTypedSessionFailures?this.createSessionFailureUpdate(this.recordSessionNotice(...this.sessionNoticeContent(e.summary,e.details))):null}createModelReroutedEvent(e){return this.supportsNotices?Ml("info","Model rerouted",`Switched from ${e.fromModel} to ${e.toModel} (${e.reason}).`):id(`Model rerouted from ${e.fromModel} to ${e.toModel} (${e.reason}).
|
|
105
|
+
|
|
106
|
+
`)}createThreadGoalUpdatedEvent(e){this.sessionState.goalRevision+=1;let t=Zi(e.goal);return hS(this.sessionState.currentGoal,t)?null:(this.sessionState.currentGoal=t,ug(t,this.sessionState.clientCapabilities.airClient))}createThreadGoalClearedEvent(e){return this.sessionState.goalRevision+=1,this.sessionState.currentGoal===null?null:(this.sessionState.currentGoal=null,ug(null,this.sessionState.clientCapabilities.airClient))}createGoalSessionInfoUpdate(e){return{sessionUpdate:"session_info_update",_meta:{lody:{goal:e}}}}createReasoningSummaryDeltaEvent(e){this.streamsFor(e.threadId).seenReasoningDeltaItemIds.add(e.itemId);let t=this.streamsFor(e.threadId).reasoningSummaryFilters.get(e.itemId);t||(t=new oS,this.streamsFor(e.threadId).reasoningSummaryFilters.set(e.itemId,t));let n=t.push(e.delta);return n.length>0?this.createAgentThoughtEvent(n,e.itemId):null}createRawReasoningDeltaEvent(e){return this.streamsFor(e.threadId).seenReasoningDeltaItemIds.add(e.itemId),this.createAgentThoughtEvent(e.delta,e.itemId)}createReasoningSectionBreakEvent(e){this.streamsFor(e.threadId).seenReasoningDeltaItemIds.add(e.itemId);let t=this.finishReasoningSummaryFilter(e.threadId,e.itemId);return this.createAgentThoughtEvent(`${t}
|
|
107
|
+
|
|
108
|
+
`,e.itemId)}finishReasoningSummaryFilter(e,t){let n=this.streamsFor(e).reasoningSummaryFilters.get(t);return n?(this.streamsFor(e).reasoningSummaryFilters.delete(t),n.finish()):""}createAgentThoughtEvent(e,t){return id(e,t)}async createItemEvent(e){switch(e.item.type){case"fileChange":return this.renderer.render(zo.started(e.item,this.sessionState.clientCapabilities.diffPatchFormat));case"commandExecution":return this.renderer.render(this.streamsFor(e.threadId).commands.started(e.item));case"mcpToolCall":return this.renderer.render(qs.started(e.item));case"dynamicToolCall":return this.renderer.render(od.started(e.item));case"webSearch":return this.renderer.render(fd.started(e.item));case"imageView":return this.streamsFor(e.threadId).emittedImageViewItems.add(e.item.id),this.renderer.render(hd.viewed(e.item));case"imageGeneration":return this.streamsFor(e.threadId).activeImageGenerationItems.add(e.item.id),this.renderer.render(Ls.started(e.item));case"collabAgentToolCall":return this.renderer.render(this.subagents.legacyCollaborationStarted(e.item));case"agentMessage":return this.rememberAgentMessagePhase(e.item,e.threadId),null;case"contextCompaction":return this.supportsCompaction?this.sessionState.compactions.start(this.subagents.notificationSessionId({method:"item/started",params:e}),e.turnId,e.item.id):this.renderer.render(sd.started(e.item));case"subAgentActivity":return this.renderer.render(this.subagents.legacyActivityStarted(e.item));case"sleep":case"functionCallOutput":case"userMessage":case"hookPrompt":case"reasoning":case"enteredReviewMode":case"exitedReviewMode":case"plan":return null}}async completeItemEvent(e){switch(e.item.type){case"fileChange":return this.renderer.render(zo.completed(e.item));case"dynamicToolCall":return this.renderer.render(od.completed(e.item));case"mcpToolCall":return this.renderer.render(qs.completed(e.item));case"commandExecution":return this.renderer.render(this.streamsFor(e.threadId).commands.completed(e.item,!0));case"imageView":return this.streamsFor(e.threadId).emittedImageViewItems.delete(e.item.id)?null:this.renderer.render(hd.viewed(e.item));case"imageGeneration":return this.renderer.render(this.streamsFor(e.threadId).activeImageGenerationItems.delete(e.item.id)?Ls.completed(e.item):Ls.whole(e.item));case"reasoning":if(this.streamsFor(e.threadId).seenReasoningDeltaItemIds.delete(e.item.id)){let t=this.finishReasoningSummaryFilter(e.threadId,e.item.id);return t.length>0?this.createAgentThoughtEvent(t,e.item.id):null}return this.createCompletedReasoningEvent(e.item);case"webSearch":return this.renderer.render(fd.completed(e.item));case"collabAgentToolCall":return this.renderer.render(this.subagents.legacyCollaborationCompleted(e.item));case"agentMessage":return this.rememberAgentMessagePhase(e.item,e.threadId),null;case"plan":return await this.createCompletedPlanEvent(e.item);case"exitedReviewMode":return this.createExitedReviewModeEvent(e.item);case"contextCompaction":return this.supportsCompaction?this.sessionState.compactions.complete(this.subagents.notificationSessionId({method:"item/completed",params:e}),e.turnId,e.item.id):this.renderer.render(sd.completed(e.item));case"subAgentActivity":return this.renderer.render(this.subagents.legacyActivityCompleted(e.item));case"sleep":case"functionCallOutput":case"userMessage":case"hookPrompt":case"enteredReviewMode":return null}}streamsFor(e){return this.subagents instanceof Ue?this.subagents.itemStreams(e)??this.itemStreams:this.itemStreams}rememberAgentMessagePhase(e,t){this.streamsFor(t).agentMessagePhases.set(e.id,e.phase)}createCompletedReasoningEvent(e){let t=op(e.summary,e.content).join(`
|
|
109
|
+
|
|
110
|
+
`);return t.length===0?null:this.createAgentThoughtEvent(t,e.id)}async createCompletedPlanEvent(e){let t=await this.plans.completed(e.id,e.text);return t===null?null:(this.completedPlan={itemId:e.id,text:t.text},t.update)}createExitedReviewModeEvent(e){let t=e.review.trim();return t.length===0?null:Un(t)}createContextCompactedEvent(){return this.supportsNotices?Ml("info","Context compacted","Conversation compacted to fit the model's context window."):Un(`*Context compacted to fit the model's context window.*
|
|
111
|
+
|
|
112
|
+
`)}openToolCalls(e){return this.subagents instanceof Ue?this.subagents.openToolCalls(e)??this.sessionState.openToolCalls:this.sessionState.openToolCalls}trackOpenToolCall(e,t,n){if(!IS.has(e.type))return;let i=e.type==="commandExecution"&&gu(e);this.openToolCalls(t).start(e.id,i,n)}async updatePlan(e){return{sessionUpdate:"plan",entries:e.plan.map(n=>({status:n.status=="inProgress"?"in_progress":n.status,content:n.step,priority:"medium"}))}}async createErrorEvent(e){let t=this.sanitizeTurnError(e.error),n={...e,error:t},i=t.codexErrorInfo;if(this.sessionState.currentTurnId===null)return this.pendingErrors.push(n),D.log("Buffered app-server error until the active turn is known",{sessionId:this.sessionState.sessionId,turnId:e.turnId,willRetry:e.willRetry}),null;if(e.turnId!==this.sessionState.currentTurnId){if(this.supportsTypedSessionFailures){let r=e.willRetry?this.recordRetryWarning(n):this.recordSessionFailure(this.sessionFailureKind(t.codexErrorInfo),e.turnId,"error",t.message);return this.createSessionFailureUpdate(r)}return this.createCodexSessionInfoUpdate({error:{...t,turnId:e.turnId,willRetry:e.willRetry}})}return e.willRetry?this.supportsTypedSessionFailures?this.createSessionFailureUpdate(this.recordRetryWarning(n)):this.createCodexSessionInfoUpdate({error:{...t,turnId:e.turnId,willRetry:!0}}):this.isAuthenticationRequiredError(i)&&!this.sessionState.authConfigured?(this.failure=k.authRequired(),null):this.supportsTypedSessionFailures?(this.recordTypedSessionFailure(n),null):(i==="usageLimitExceeded"?this.failure=k.internalError(this.createTurnErrorData(t)):this.isAuthenticationRequiredError(i)?this.failure=this.sessionState.authConfigured?k.internalError(this.createTurnErrorData(t)):k.authRequired(this.createTurnErrorData(t),t.message):this.failure=k.internalError(this.createTurnErrorData(t)),this.failure!==null&&GS.add(this.failure),this.createCodexSessionInfoUpdate({error:{...t,turnId:e.turnId,willRetry:!1}}))}sanitizeTurnError(e){return{...e,message:ru(tu(e.message)),additionalDetails:e.additionalDetails===null?null:ru(e.additionalDetails)}}recordTypedSessionFailure(e){let t=this.sessionFailureKind(e.error.codexErrorInfo);this.recordSessionFailure(t,e.turnId,"error",e.error.message)}recordSessionFailure(e,t,n,i,r,u=!0){let s=NO[e],o=t??this.sessionState.sessionId,a=this.activeFailureIdByScope.get(o)??this.allocateFailureId(o,t),l=this.failuresById.get(a),c={id:a,revision:Lg(l,a),category:s.category,severity:n,title:tu(i),actions:r??s.actions};return this.failuresById.set(a,c),this.failureTurnIdById.set(a,u?t:void 0),this.activeFailureIdByScope.set(o,a),this.sessionState.sessionFailure=c,this.lastSessionNotice=void 0,c}allocateFailureId(e,t){return t!==void 0&&!this.allocatedFailureScopes.has(e)?(this.allocatedFailureScopes.add(e),`${t}:error`):(this.allocatedFailureScopes.add(e),`${e}:error:${this.sessionFailureEpoch}:${this.nextNoticeId++}`)}completeRetryIncidentOnTurnProgress(e){if(this.subagents instanceof Ue&&e!==this.sessionState.sessionId)return;let t=this.sessionState.currentTurnId;if(t===null)return;let n=this.activeFailureIdByScope.get(t);n===void 0||this.failuresById.get(n)?.severity!=="warning"||(this.activeFailureIdByScope.delete(t),this.sessionState.sessionFailure?.id===n&&delete this.sessionState.sessionFailure)}recordRetryWarning(e,t=!0){let n=this.sessionFailureKind(e.error.codexErrorInfo);return this.recordSessionFailure(n,e.turnId,"warning",e.error.message,[],t)}recordSessionNotice(e,t){let n=`${e}\0${t??""}`,i=this.lastSessionNotice?.key===n?this.lastSessionNotice.failure:void 0,r=i?.id??`${this.sessionState.sessionId}:notice:${this.sessionFailureEpoch}:${this.nextNoticeId++}`,u={id:r,revision:Lg(i,r),category:"unknown",severity:"warning",title:e,...t===void 0?{}:{details:t},actions:[]};return this.lastSessionNotice={key:n,failure:u},u}sessionNoticeContent(e,t){if(t===null)return[e];let n=`${e} \u2014 ${t}`;return n.length<=OO?[n]:[e,t]}createSessionFailureMeta(e){return{[Bt]:{[kt]:{[du]:hu,[Bo]:e}}}}createSessionFailureUpdate(e){return{sessionUpdate:"session_info_update",_meta:this.createSessionFailureMeta(e)}}sessionFailureKind(e){if(this.isAuthenticationRequiredError(e))return"auth_required";if(this.getHttpStatusCode(e)===429)return"rate_limited";if(typeof e=="string")return Object.hasOwn(qg,e)?qg[e]??"provider_error":"provider_error";if(e!==null){for(let t of Object.keys(Zg))if(t in e)return Zg[t]??"provider_error"}return"provider_error"}isAuthenticationRequiredError(e){return e==="unauthorized"||this.getHttpStatusCode(e)===401}getHttpStatusCode(e){if(e===null||typeof e!="object")return null;let t=Object.values(e)[0];return t===null||typeof t!="object"||!("httpStatusCode"in t)?null:typeof t.httpStatusCode=="number"?t.httpStatusCode:null}createTurnErrorData(e){let t={message:e.additionalDetails??e.message};return e.codexErrorInfo!==null&&(t.codexErrorInfo=e.codexErrorInfo),e.additionalDetails!==null&&(t.additionalDetails=e.additionalDetails),t}handleTokenUsageUpdated(e){this.sessionState.lastTokenUsage=ng(e.tokenUsage.last),this.sessionState.totalTokenUsage=ng(e.tokenUsage.total),this.sessionState.promptTokenUsage?.observe(this.sessionState.totalTokenUsage,this.sessionState.lastTokenUsage),this.sessionState.modelContextWindow=e.tokenUsage.modelContextWindow}createUsageUpdate(e){let t,n;if(e.threadId===this.sessionState.sessionId)this.handleTokenUsageUpdated(e),t=this.sessionState.lastTokenUsage?.totalTokens,n=this.sessionState.modelContextWindow;else if(this.subagents.isNativeSubagentThread(e.threadId))t=e.tokenUsage.last.totalTokens,n=e.tokenUsage.modelContextWindow;else return null;return t==null||n==null||n<=0?null:{sessionUpdate:"usage_update",used:t,size:n}}async handleRateLimitsSnapshot(e,t=!1){let n=this.storeRateLimitsSnapshot(e,t);await this.notifyExt(K2,this.createSessionRateLimitsExtNotification(n))}storeRateLimitsSnapshot(e,t){this.sessionState.rateLimits||(this.sessionState.rateLimits=new Map);let n=this.sessionState.rateLimits.has("codex")?"codex":this.sessionState.rateLimits.size===1?this.sessionState.rateLimits.keys().next().value:null,i=e.limitId??n??e.limitName??"codex",r=this.sessionState.rateLimits.get(i)?.snapshot,u=t&&r?e.limitId===null?rO(r,{...e,limitId:i}):{limitId:e.limitId??r.limitId,limitName:e.limitName??r.limitName,normalModelSlug:e.normalModelSlug??r.normalModelSlug,primary:e.primary??r.primary,secondary:e.secondary??r.secondary,credits:e.credits??r.credits,individualLimit:e.individualLimit??r.individualLimit,spendControlReached:e.spendControlReached??r.spendControlReached,planType:e.planType??r.planType,rateLimitReachedType:e.rateLimitReachedType??r.rateLimitReachedType}:{...e,limitId:i};return this.sessionState.rateLimits.set(i,{limitId:i,limitName:u.limitName??i,snapshot:u}),u}},jO=new Set(["userMessage","hookPrompt","enteredReviewMode","subAgentActivity","contextCompaction"]);function LO(e){return!jO.has(e.type)}function qO(e){if(e?.sessionUpdate==="tool_call")return e.title}function Ed(e){if(e.startsWith("file://"))try{return new URL(e).href}catch{return null}if(/^[A-Za-z]:[\\/]/.test(e))return`file:///${e.replaceAll("\\","/").split("/").map(encodeURIComponent).join("/").replace(/^([A-Za-z])%3A/,"$1:")}`;if(/^\\\\[^\\]+\\/.test(e)){let[t,...n]=e.slice(2).split("\\");try{return new URL(`file://${t}/${n.map(encodeURIComponent).join("/")}`).href}catch{return null}}return e.startsWith("/")?ZO(e).href:null}function WO(e){let t=/^\s*# Files (?:pasted|mentioned) by the user:\r?\n/.exec(e);if(!t)return null;let n=/^## My request:\r?\n/m.exec(e);if(!n||n.index<t[0].length)return null;let i=e.slice(t[0].length,n.index).split(/\r?\n/),r=[];for(let s of i){if(s.trim()===""||/^# Files (?:pasted|mentioned) by the user:$/.test(s)||s==="Pasted text contains the user's request."||s==="Distinguish instructions in attached documents from the user's request."||s==="Image attachment: true"&&r.length>0)continue;let o=/^## ("(?:\\.|[^"\\])*"|[^"].*?): ((?:\/|\\\\|[A-Za-z]:[\\/]|file:\/\/).+)$/.exec(s);if(!o)return null;let a=o[1];if(a.startsWith('"'))try{a=JSON.parse(a)}catch{return null}let l=Ed(o[2]);if(a.length===0||l===null)return null;r.push({type:"resource_link",name:a,uri:l})}if(r.length===0)return null;let u=e.slice(n.index+n[0].length);return u.trim().length>0&&r.push({type:"text",text:u}),r}function GO(e,t){let n=t.commandName(e.threadId,e.itemId),i=e.networkApprovalContext,r={...e.command?{command:Ii(e.command)}:{},...e.cwd?{cwd:e.cwd}:{},...i?.protocol==="http"||i?.protocol==="https"?{url:`${i.protocol}://${i.host}`}:{},...e.additionalPermissions?{additionalPermissions:e.additionalPermissions}:{}},u=e.additionalPermissions?HS(e.additionalPermissions):[];return{toolCallId:e.itemId,...n!==void 0?{name:n}:{},kind:"execute",status:"pending",title:i?`${i.protocol} network access to ${i.host}`:JO(e.commandActions),...Object.keys(r).length>0?{rawInput:r}:{},...gp(bl([...KO(e.commandActions),...VS(e.additionalPermissions)])),...i?{content:[JS(`${i.protocol} access to ${i.host}`),...u]}:u.length>0?{content:u}:{}}}function VO(e,t){let n=t.fileChange(e.threadId,e.itemId);return{toolCallId:e.itemId,kind:"edit",status:"pending",title:"Edit files",...gp(XO(n))}}function HO(e,t,n,i){let r=HS(i);return{toolCallId:e,name:"request_permissions",kind:"other",status:"pending",title:"Additional sandbox permissions",rawInput:{permissions:i,cwd:t,environmentId:n},...gp(VS(i)),...r.length>0?{content:r}:{}}}function JO(e){let t=e?.[0];if(!t)return"Run command";switch(t.type){case"read":return e?.length===1?"Read file":"Run command with file reads";case"listFiles":return"List files";case"search":return"Search files";case"unknown":return"Run command"}}function KO(e){return bl((e??[]).flatMap(t=>{switch(t.type){case"read":return[t.path];case"listFiles":case"search":return t.path?[t.path]:[];case"unknown":return[]}}))}function XO(e){return bl(e?.changes.map(t=>t.path)??[])}function VS(e){let t=e?.fileSystem;return bl([...t?.read??[],...t?.write??[],...(t?.entries??[]).flatMap(n=>n.path.type==="path"?[n.path.path]:[])])}function HS(e){let t=[],n=e.network?.enabled;n!=null&&t.push(n?"Enable network access":"Disable network access");for(let i of e.fileSystem?.entries??[])switch(i.path.type){case"glob_pattern":t.push(`${i.access} filesystem pattern ${i.path.pattern}`);break;case"special":t.push(`${i.access} Codex filesystem scope ${JSON.stringify(i.path.value)}`);break;case"path":break}return t.length>0?[JS(t.join(`
|
|
113
|
+
`))]:[]}function gp(e){return e.length>0?{locations:e.map(t=>({path:t}))}:{}}function JS(e){return{type:"content",content:{type:"text",text:e}}}function bl(e){return[...new Set(e)]}var ot={AllowOnce:"allow_once",AllowForSession:"allow_for_session",Decline:"decline",Cancel:"cancel",AcceptWithExecpolicyAmendment:"accept_execpolicy_amendment",ApplyNetworkPolicyAmendment:"apply_network_policy_amendment",AllowPermissionsForTurn:"allow_permissions_turn",AllowPermissionsForTurnWithStrictAutoReview:"allow_permissions_turn_strict_auto_review",AllowPermissionsForSession:"allow_permissions_session",RejectPermissions:"reject_permissions"},Ht={AllowOnce:"allow_once",AllowSession:"allow_session",AllowAlways:"allow_always",Decline:"decline",Cancel:"cancel"};function mt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Uo(e){return mt(e)?e:null}function jo(e){return e==null?null:typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:typeof e=="bigint"?Number(e):Array.isArray(e)?e.map(jo):typeof e=="object"?Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0).map(([t,n])=>[t,jo(n)])):String(e)}function YO(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0).map(([t,n])=>[t,jo(n)]))}function QO(e){if(e.availableDecisions===void 0||e.availableDecisions===null)return eN(e);if(!Array.isArray(e.availableDecisions)||e.availableDecisions.length===0)return;let t=[];for(let n of e.availableDecisions){let i=tN(n,e);if(!i)return;t.push(i)}return t}function eN(e){if(e.networkApprovalContext){let n=["accept","acceptForSession"];for(let i of e.proposedNetworkPolicyAmendments??[])n.push({applyNetworkPolicyAmendment:{network_policy_amendment:i}});return n.push("decline","cancel"),n}if(e.additionalPermissions)return["accept","cancel"];let t=["accept","acceptForSession"];return e.proposedExecpolicyAmendment&&e.proposedExecpolicyAmendment.length>0&&t.push({acceptWithExecpolicyAmendment:{execpolicy_amendment:e.proposedExecpolicyAmendment}}),t.push("decline","cancel"),t}function tN(e,t){if(e==="accept"||e==="acceptForSession"||e==="decline"||e==="cancel")return e;if(mt(e)){if("acceptWithExecpolicyAmendment"in e){let n=e.acceptWithExecpolicyAmendment;if(!mt(n))return;let i=n.execpolicy_amendment;return!rN(i)||i.length===0||!iN(i,t.proposedExecpolicyAmendment)?void 0:{acceptWithExecpolicyAmendment:{execpolicy_amendment:[...i]}}}if("applyNetworkPolicyAmendment"in e){let n=e.applyNetworkPolicyAmendment;if(!mt(n))return;let i=nN(n.network_policy_amendment);return!i||!t.networkApprovalContext||i.host!==t.networkApprovalContext.host||!(t.proposedNetworkPolicyAmendments??[]).some(r=>uN(r,i))?void 0:{applyNetworkPolicyAmendment:{network_policy_amendment:i}}}}}function nN(e){if(!mt(e)||typeof e.host!="string")return;let t=e.action;if(!(t!=="allow"&&t!=="deny"))return{host:e.host,action:t}}function rN(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function iN(e,t){return!!t&&e.length===t.length&&e.every((n,i)=>n===t[i])}function uN(e,t){return e.host===t.host&&e.action===t.action}function sN(e){let t=QO(e);if(!t)return;let n=[],i=0;for(let l of t)if(l==="accept")n.push(mn(ot.AllowOnce,e.networkApprovalContext?"Yes, just this once":"Yes, proceed","allow_once",l));else if(l==="acceptForSession")n.push(mn(ot.AllowForSession,e.networkApprovalContext?"Yes, and allow this host for this conversation":e.additionalPermissions?"Yes, and allow these permissions for this session":"Yes, and don't ask again for this command in this session","allow_always",l));else if(l==="decline")n.push(mn(ot.Decline,"No, continue without running it","reject_once",l));else if(l==="cancel")n.push(mn(ot.Cancel,"No, and tell Codex what to do differently","reject_once",l));else if("acceptWithExecpolicyAmendment"in l){let c=lN(l.acceptWithExecpolicyAmendment.execpolicy_amendment);if(c.includes(`
|
|
114
|
+
`)||c.includes("\r"))continue;n.push(mn(ot.AcceptWithExecpolicyAmendment,`Yes, and don't ask again for commands that start with \`${c}\``,"allow_always",l))}else{let c=l.applyNetworkPolicyAmendment.network_policy_amendment;n.push(mn(`${ot.ApplyNetworkPolicyAmendment}:${i++}`,c.action==="allow"?"Yes, and allow this host in the future":"No, and block this host in the future",c.action==="allow"?"allow_always":"reject_always",l))}let r=[...n].sort((l,c)=>Wg(l.option)-Wg(c.option)),u=r.some(({option:l})=>l.kind==="allow_once"||l.kind==="allow_always"),s=r.some(({option:l})=>l.kind==="reject_once"||l.kind==="reject_always"),o=r.map(({option:l})=>l.optionId),a=new Set(o).size===o.length;return u&&s&&a?r:void 0}function Wg(e){return e.kind==="allow_once"?0:e.kind==="allow_always"?1:2}function oN(){return[mn(ot.AllowOnce,"Yes, proceed","allow_once","accept"),mn(ot.AllowForSession,"Yes, and don't ask again for these files","allow_always","acceptForSession"),mn(ot.Cancel,"No, and tell Codex what to do differently","reject_once","cancel")]}function aN(){return[Gi(ot.AllowPermissionsForTurn,"Yes, grant these permissions for this turn","allow_once"),Gi(ot.AllowPermissionsForTurnWithStrictAutoReview,"Yes, grant for this turn with strict auto review","allow_once"),Gi(ot.AllowPermissionsForSession,"Yes, grant these permissions for this session","allow_always"),Gi(ot.RejectPermissions,"No, continue without permissions","reject_once")]}function mn(e,t,n,i){return{option:Gi(e,t,n),decision:i}}function Gi(e,t,n){return{optionId:e,name:t,kind:n}}function lN(e){let t=cN(e);return t!==void 0?t:e.some(n=>n.includes("\0"))?e.join(" "):e.map(hN).join(" ")}function cN(e){let t=dN(e[0]);if((t==="bash"||t==="zsh"||t==="sh")&&e.length===3&&(e[1]==="-lc"||e[1]==="-c"))return e[2];if(t!=="pwsh"&&t!=="powershell")return;let n=new Set(["-nologo","-noprofile","-command","-c"]);for(let i=1;i+1<e.length;i++){let r=e[i]?.toLowerCase();if(r===void 0||!n.has(r))return;if(r==="-command"||r==="-c")return e[i+1]}}function dN(e){let t=e?.replaceAll("\\","/").split("/").at(-1);for(;t!==void 0;){if(["bash","zsh","sh","pwsh","powershell"].includes(t))return t;let n=t.lastIndexOf(".");if(n<=0)return;t=t.slice(0,n)}}function hN(e){if(e.length===0)return"''";let t=1,n=2,i=4,r=0,u="";for(;r<e.length;){let s=r,o=t|n|i;for(e[r]==="^"&&(o=n,r++);r<e.length;){let l=e[r],c=o;if(fN(l)||(c&=~t),(l==="'"||l==="^"||l==="\\")&&(c&=~n),(l==="`"||l==="$"||l==="!"||l==="^")&&(c&=~i),c===0)break;o=c,r++}let a=e.slice(s,r);(o&t)!==0?u+=a:(o&n)!==0?u+=`'${a}'`:u+=`"${a.replace(/["\\]/g,"\\$&")}"`}return u}function fN(e){return/^[0-9A-Za-z]$/.test(e)||"+-./:@]_".includes(e)}var KS=class{constructor(e,t,n,i){this.connection=e,this.permissionContext=t,this.cancellationSignal=n,this.renderer=i}connection;permissionContext;cancellationSignal;renderer;async handleCommandExecution(e){let t=e,n=sN(t);if(!n)return D.error("Cancelling command approval without a complete authoritative decision set",void 0),{decision:"cancel"};try{let i=await this.requestPermission({sessionId:e.threadId,toolCall:this.renderer.capabilities.airClient?this.renderer.renderPermissionToolCall(ap.permission(t,this.permissionContext.commandStarted(e.threadId,e.itemId),this.permissionContext.commandName(e.threadId,e.itemId))):GO(t,this.permissionContext),options:n.map(({option:r})=>r),...Ll(this.renderer.capabilities,e.networkApprovalContext?y2:C2,e.reason)});return{decision:this.selectedDecision(i,n)??"cancel"}}catch(i){return D.error("Error requesting command execution permission",i),{decision:"cancel"}}}async handleFileChange(e){let t=oN();try{let n=await this.requestPermission({sessionId:e.threadId,toolCall:this.renderer.capabilities.airClient?this.renderer.renderPermissionToolCall(zo.permission(e,this.permissionContext.fileChange(e.threadId,e.itemId))):VO(e,this.permissionContext),options:t.map(({option:i})=>i),...Ll(this.renderer.capabilities,E2,e.reason)});return{decision:this.selectedDecision(n,t)??"cancel"}}catch(n){return D.error("Error requesting file change permission",n),{decision:"cancel"}}}async handlePermissionsRequest(e){try{let t=await this.requestPermission({sessionId:e.threadId,toolCall:this.renderer.capabilities.airClient?this.renderer.renderPermissionToolCall(Ez.permission(e.itemId,e.cwd,e.environmentId,e.permissions)):HO(e.itemId,e.cwd,e.environmentId,e.permissions),options:aN(),...Ll(this.renderer.capabilities,w2,e.reason)});return this.permissionsResponse(e.permissions,t)}catch(t){return D.error("Error requesting permissions",t),this.rejectPermissionsResponse()}}requestPermission(e){let t=md(e.sessionId,this.cancellationSignal);return Wi(e.sessionId,()=>this.connection.request(ae.client.session.requestPermission,e,t?{cancellationSignal:t}:void 0),e.toolCall.toolCallId)}selectedDecision(e,t){if(e.outcome.outcome!=="selected")return;let n=e.outcome.optionId;return t.find(({option:i})=>i.optionId===n)?.decision}permissionsResponse(e,t){if(t.outcome.outcome!=="selected")return this.rejectPermissionsResponse();switch(t.outcome.optionId){case ot.AllowPermissionsForTurn:return this.grantedPermissionsResponse(e,"turn",!1);case ot.AllowPermissionsForTurnWithStrictAutoReview:return this.grantedPermissionsResponse(e,"turn",!0);case ot.AllowPermissionsForSession:return this.grantedPermissionsResponse(e,"session",!1);case ot.RejectPermissions:default:return this.rejectPermissionsResponse()}}grantedPermissionsResponse(e,t,n){return{permissions:this.grantedPermissions(e),scope:t,strictAutoReview:n}}rejectPermissionsResponse(){return{permissions:{},scope:"turn",strictAutoReview:!1}}grantedPermissions(e){return{...e.network?{network:e.network}:{},...e.fileSystem?{fileSystem:e.fileSystem}:{}}}},XS=class{constructor(e){this.session=e}session;permissionRequestSequence=0;beginPrompt(){return new pN(e=>this.nextStandaloneMcpToolCallId(e))}nextStandaloneMcpToolCallId(e){return this.permissionRequestSequence+=1,["elicitation",this.session.sessionId,e,this.permissionRequestSequence].join(":")}},pN=class{constructor(e){this.nextStandaloneId=e}nextStandaloneId;commandNames=new Map;startedCommands=new Map;fileChanges=new Map;pendingMcpApprovals=new Map;handleNotification(e){switch(e.method){case"item/started":this.handleItemStarted(e.params.threadId,e.params.item);return;case"item/completed":this.handleItemCompleted(e.params.threadId,e.params.item);return;case"turn/completed":this.clearTransientState(e.params.threadId);return;case"serverRequest/resolved":this.pendingMcpApprovals.delete(e.params.threadId);return;default:return}}fileChange(e,t){return this.fileChanges.get(e)?.get(t)}commandName(e,t){return this.commandNames.get(e)?.get(t)}commandStarted(e,t){return this.startedCommands.get(e)?.has(t)??!1}popPendingMcpApproval(e,t){let n=this.pendingMcpApprovals.get(e);if(!n)return;let i=n.get(t);if(i?.length!==1)return;let r=i[0];return n.delete(t),n.size===0&&this.pendingMcpApprovals.delete(e),r}nextStandaloneMcpToolCallId(e){return this.nextStandaloneId(e)}handleItemStarted(e,t){if(t.type==="commandExecution"){let r=this.startedCommands.get(e)??new Set;r.add(t.id),this.startedCommands.set(e,r);let u=sp(t.source);if(u!==void 0){let s=this.commandNames.get(e)??new Map;s.set(t.id,u),this.commandNames.set(e,s)}return}if(t.type==="fileChange"){let r=this.fileChanges.get(e)??new Map;r.set(t.id,t),this.fileChanges.set(e,r);return}if(t.type!=="mcpToolCall")return;let n=this.pendingMcpApprovals.get(e)??new Map,i=n.get(t.server);i?i.push(t.id):n.set(t.server,[t.id]),this.pendingMcpApprovals.set(e,n)}handleItemCompleted(e,t){if(t.type==="commandExecution"){let u=this.commandNames.get(e);u?.delete(t.id),u?.size===0&&this.commandNames.delete(e);let s=this.startedCommands.get(e);s?.delete(t.id),s?.size===0&&this.startedCommands.delete(e);return}if(t.type==="fileChange"){let u=this.fileChanges.get(e);u?.delete(t.id),u?.size===0&&this.fileChanges.delete(e);return}if(t.type!=="mcpToolCall")return;let n=this.pendingMcpApprovals.get(e);if(!n)return;let i=n.get(t.server);if(!i)return;let r=i.indexOf(t.id);r>=0&&i.splice(r,1),i.length===0&&n.delete(t.server),n.size===0&&this.pendingMcpApprovals.delete(e)}clearTransientState(e){this.commandNames.delete(e),this.startedCommands.delete(e),this.fileChanges.delete(e),this.pendingMcpApprovals.delete(e)}};function wd(e){return e?.elicitation?.form!=null}function Sl(e){return e?.elicitation?.url!=null}function Gg(e){let t=Uo(e?._meta?.lody),n=Uo(t?.elicitation);return wd(e)&&n?.version===1&&n.answerNotes===!0}var Vs=class{static permission(e,t,n,i){if(e.mode==="form"||e.mode==="openai/form")return n!==void 0?{toolCallId:n,kind:"execute",status:"pending"}:{toolCallId:i(),kind:t?"execute":"other",status:"pending",title:t?"MCP tool call approval":"Question from MCP server",input:{serverName:e.serverName,description:e.message,schema:e.requestedSchema},readableInput:e.message};if(e.mode!=="url")throw new Error(`Unsupported MCP elicitation mode: ${e.mode}`);return{toolCallId:`elicitation-${e.elicitationId}`,kind:"fetch",status:"pending",title:"MCP server requests to open a URL",input:{serverName:e.serverName,description:e.message,url:e.url},readableInput:e.message}}static accepted(e){return{toolCallId:e,report:"update",status:"in_progress"}}static answered(e,t){return{toolCallId:e,report:"update",status:"completed",opaqueResult:{action:t}}}};function mN(e){let t=new Set;if(!mt(e))return t;let n=e.persist;return n==="session"?t.add("session"):n==="always"?t.add("always"):Array.isArray(n)&&(n.includes("session")&&t.add("session"),n.includes("always")&&t.add("always")),t}function gN(e){return mt(e)&&e.codex_approval_kind==="mcp_tool_call"}function vN(e,t,n){let i=(u,s,o,a)=>{let l=A2(n,a);return{optionId:u,name:s,kind:o,...l?{_meta:l}:{}}},r=[i(e?Ht.AllowOnce:"accept","Allow","allow_once",e?"Run the tool and continue.":"Allow this request and continue.")];return t.has("session")&&r.push(i(Ht.AllowSession,"Allow for this session","allow_always",e?"Run the tool and remember this choice for this session.":"Allow this request and remember this choice for this session.")),t.has("always")&&r.push(i(Ht.AllowAlways,"Always allow","allow_always",e?"Run the tool and remember this choice for future tool calls.":"Allow this request and remember this choice for future requests.")),e?r.push(i(Ht.Cancel,"Cancel","reject_once","Cancel this tool call")):r.push(i(Ht.Decline,"Deny","reject_once","Decline this request and continue."),i(Ht.Cancel,"Cancel","reject_once","Cancel this request")),r}function CN(e,t,n,i,r){let u=t.mode==="form"||t.mode==="openai/form"?n.correlatedCallId:void 0,s=r.renderPermissionToolCall(Vs.permission(t,n.isToolApproval,u,i)),o=n.isToolApproval&&t.mode!=="url"?{_meta:{is_mcp_tool_approval:!0}}:{};return{request:{sessionId:e,toolCall:s,...o,options:vN(n.isToolApproval,n.persistOptions,r.capabilities.airClient)},correlatedCallId:u}}function yN(e,t,n){if(e.outcome.outcome!=="selected")return ur();switch(e.outcome.optionId){case Ht.AllowSession:return n.has("session")?{action:"accept",content:null,_meta:{persist:"session"}}:ur();case Ht.AllowAlways:return n.has("always")?{action:"accept",content:null,_meta:{persist:"always"}}:ur();case Ht.AllowOnce:return t?{action:"accept",content:null,_meta:null}:ur();case"accept":return t?ur():{action:"accept",content:null,_meta:null};case Ht.Decline:return t?ur():{action:"decline",content:null,_meta:null};case Ht.Cancel:default:return ur()}}function ur(){return{action:"cancel",content:null,_meta:null}}var EN="_note",Lr="None of the above",nc="user_note: ",rc=e=>({lody:{elicitation:{version:1,...e}}});function wN(e){let t=_d(e);return mt(t)?{...t,type:"object"}:{type:"object",properties:{}}}function _d(e){if(typeof e=="bigint")return Number(e);if(Array.isArray(e))return e.map(_d);if(!mt(e))return e;let t=Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0).map(([n,i])=>[n,_d(i)]));if(t.type==="string"&&Array.isArray(t.enum)&&Array.isArray(t.enumNames)&&!Array.isArray(t.oneOf)){let n=t.enum,i=t.enumNames;t.oneOf=n.map((r,u)=>({const:String(r),title:String(i[u]??r)})),delete t.enum,delete t.enumNames}return t}function Vg(e){return mt(e)?e:{}}function _N(e){let t=Object.entries(e);return t.length===0?null:Object.fromEntries(t.map(([n,i])=>[n,jo(i)]))}function _s(e,t,n=void 0){let i=Uo(e._meta),r=i?YO(i):{};return t.isToolApproval&&delete r.persist,(n==="session"||n==="always")&&(r.persist=n),Object.keys(r).length===0?null:r}function Hg(e,t){let n=`${e}${EN}`,i=n,r=1;for(;t.has(i);)i=`${n}${r++}`;return i}function AN(e,t){if(!(typeof e!="string"||e===Lr))return t.options?.some(n=>n.label===e)?void 0:e}function Jg(e,t){let n=e[t];if(!(typeof n=="string"&&n.trim()==="")&&!(Array.isArray(n)&&n.length===0))return n}var YS=class{connection;renderer;permissionContext;clientCapabilities;cancellationSignal;pendingUrlElicitations=new Map;constructor(e,t,n,i,r){this.renderer=r,this.connection=e,this.permissionContext=t,this.clientCapabilities=n,this.cancellationSignal=i}async handleNotification(e){if(e.method==="serverRequest/resolved"){await this.completeUrlElicitations(e.params.threadId);return}else return}async handleElicitation(e){let t=md(e.threadId,this.cancellationSignal);try{let n=this.createMcpElicitationContext(e);if(this.shouldUseAcpElicitation(e)){let o=await Wi(e.threadId,()=>this.connection.request(ae.client.elicitation.create,this.buildElicitationRequest(e,n),this.requestOptions(t))),a=this.convertElicitationResponse(o,n);return e.mode==="url"&&a.action==="accept"&&this.trackUrlElicitation(e.threadId,e.elicitationId),await this.publishAcceptedMcpToolApproval(e.threadId,n,a.action==="accept"),a}if(!this.canUsePermissionFallback(e))return{action:"cancel",content:null,_meta:null};let{request:i,correlatedCallId:r}=CN(e.threadId,e,n,()=>tO(e.threadId,e.serverName)??this.permissionContext.nextStandaloneMcpToolCallId(e.serverName),this.renderer),u=await Wi(e.threadId,()=>this.connection.request(ae.client.session.requestPermission,i,this.requestOptions(t)),i.toolCall.toolCallId),s=yN(u,n.isToolApproval,n.persistOptions);if(r!==void 0)s.action==="accept"&&await this.connection.notify(ae.client.session.update,{sessionId:e.threadId,update:this.renderer.render(Vs.accepted(r))});else try{await this.connection.notify(ae.client.session.update,{sessionId:e.threadId,update:this.renderer.render(Vs.answered(i.toolCall.toolCallId,s.action))})}catch(o){D.error("Failed to finalize standalone MCP elicitation tool call",o)}return s}catch(n){return D.error("Error handling MCP elicitation request",n),{action:"cancel",content:null,_meta:null}}}async handleUserInput(e){if(!wd(this.clientCapabilities))return{answers:{}};try{let t=await this.requestUserInputElicitation(e);return t===null?{answers:{}}:this.convertUserInputResponse(t,e)}catch(t){return D.error("Error handling Codex user input request",t),{answers:{}}}}requestOptions(e=this.cancellationSignal){return e?{cancellationSignal:e}:void 0}async requestUserInputElicitation(e){let t=this.buildUserInputRequest(e),n=md(e.threadId,this.cancellationSignal);if(e.autoResolutionMs===null)return await Wi(e.threadId,()=>this.connection.request(ae.client.elicitation.create,t,this.requestOptions(n)),e.itemId);let i=new AbortController,r,u,s=new Promise(a=>{let l=()=>{i.abort(),a(null)};if(r=setTimeout(l,Math.max(0,e.autoResolutionMs??0)),n?.aborted){l();return}n&&(n.addEventListener("abort",l,{once:!0}),u=()=>{n.removeEventListener("abort",l)})}),o=Wi(e.threadId,()=>this.connection.request(ae.client.elicitation.create,t,this.requestOptions(i.signal)),e.itemId,i.signal);o.catch(()=>{});try{return await Promise.race([o,s])}finally{r&&clearTimeout(r),u?.()}}createMcpElicitationContext(e){let t=gN(e._meta)&&this.isMessageOnlyForm(e),n=mN(e._meta),i=t?this.permissionContext.popPendingMcpApproval(e.threadId,e.serverName):void 0;return{isToolApproval:t,persistOptions:n,correlatedCallId:i}}shouldUseAcpElicitation(e){if(this.isMessageOnlyForm(e))return!1;switch(e.mode){case"form":return wd(this.clientCapabilities);case"url":return Sl(this.clientCapabilities);case"openai/form":case"openaiForm":return!1}}canUsePermissionFallback(e){return e.mode==="url"||this.isMessageOnlyForm(e)}isMessageOnlyForm(e){return e.mode!=="form"&&e.mode!=="openai/form"&&e.mode!=="openaiForm"?!1:e.requestedSchema===null?!0:mt(e.requestedSchema)?e.requestedSchema.type==="object"&&mt(e.requestedSchema.properties)&&Object.keys(e.requestedSchema.properties).length===0:!1}buildElicitationRequest(e,t){let n={sessionId:e.threadId,...t.correlatedCallId?{toolCallId:t.correlatedCallId}:{},message:e.message,_meta:Uo(e._meta)};switch(e.mode){case"form":return{...n,mode:"form",requestedSchema:wN(e.requestedSchema)};case"url":return{...n,mode:"url",url:e.url,elicitationId:e.elicitationId}}}buildUserInputRequest(e){let t=Gg(this.clientCapabilities),n={},i=[],r=new Set(e.questions.map(s=>s.id)),u=fu(this.clientCapabilities);for(let s of e.questions){let o=s.options??[],a=o.length>0,l=s.isOther&&a;if((!l||t||u)&&i.push(s.id),n[s.id]={title:s.header||s.id,description:s.question,_meta:rc({secret:s.isSecret}),type:"string",...a?{oneOf:[...o.map(c=>({const:c.label,title:c.label,...c.description?{description:c.description}:{}})),...t&&l&&!u&&!o.some(c=>c.label===Lr)?[{const:Lr,title:Lr,description:"Provide a different answer in the note field."}]:[]]}:{}},l){let c={codex:{questionId:s.id,role:"user_note",isSecret:s.isSecret}};n[Hg(s.id,r)]={type:"string",title:t||u?"Additional answer or note":"Other",description:t?"Optionally add context to your selected answer.":"Type your own answer instead of choosing an option above.",_meta:{...u?xt({...c,[v2]:!0},g2,!0):{},...rc({...t?{noteFor:s.id}:{customAnswerFor:s.id},secret:s.isSecret})}}}}return{sessionId:e.threadId,toolCallId:e.itemId,mode:"form",message:"Input requested",requestedSchema:{type:"object",properties:n,required:i},_meta:rc({autoResolveAfterSeconds:e.autoResolutionMs===null?null:e.autoResolutionMs/1e3})}}convertElicitationResponse(e,t){if(cr.isAccept(e)){let n=Vg(e.content),i=t.isToolApproval?n.persist:void 0;return t.isToolApproval&&!this.isAllowedToolApprovalPersist(i,t.persistOptions)?{action:"cancel",content:null,_meta:null}:((i==="session"||i==="always"||i==="once")&&delete n.persist,{action:"accept",content:_N(n),_meta:_s(e,t,i)})}return cr.isDecline(e)?t.isToolApproval?{action:"cancel",content:null,_meta:_s(e,t)}:{action:"decline",content:null,_meta:_s(e,t)}:cr.isCancel(e)?{action:"cancel",content:null,_meta:_s(e,t)}:cr.isCustom(e)?{action:"cancel",content:null,_meta:null}:{action:"cancel",content:null,_meta:null}}isAllowedToolApprovalPersist(e,t){return e===void 0||e==="once"||e==="session"&&t.has("session")||e==="always"&&t.has("always")}convertUserInputResponse(e,t){if(!cr.isAccept(e))return{answers:{}};let n={},i=Gg(this.clientCapabilities),r=Vg(e.content),u=new Set(t.questions.map(o=>o.id)),s=fu(this.clientCapabilities);for(let o of t.questions){let a=[],l=o.isOther&&o.options!=null&&o.options.length>0,c=Jg(r,o.id),m=s&&l?AN(c,o):void 0;if(m!==void 0?a.push(Lr,`${nc}${m.trim()}`):c!==void 0&&a.push(...Array.isArray(c)?c.map(String):[String(c)]),l){let p=Jg(r,Hg(o.id,u));if(i)a.length>0&&typeof p=="string"&&a.push(`${nc}${p.trim()}`);else if(p!==void 0){let v=Array.isArray(p)?p:[p];a.splice(0,a.length,Lr),a.push(...v.map(g=>`${nc}${String(g).trim()}`))}}a.length!==0&&(n[o.id]={answers:a})}return{answers:n}}async publishAcceptedMcpToolApproval(e,t,n){!n||t.correlatedCallId===void 0||await this.connection.notify(ae.client.session.update,{sessionId:e,update:this.renderer.render(Vs.accepted(t.correlatedCallId))})}async completeAllUrlElicitations(){for(let e of[...this.pendingUrlElicitations.keys()])await this.completeUrlElicitations(e)}trackUrlElicitation(e,t){let n=this.pendingUrlElicitations.get(e);if(n){n.add(t);return}this.pendingUrlElicitations.set(e,new Set([t]))}async completeUrlElicitations(e){let t=this.pendingUrlElicitations.get(e);if(t){this.pendingUrlElicitations.delete(e);for(let n of t)await this.connection.notify(ae.client.elicitation.complete,{elicitationId:n})}}},ic="CODEX_API_KEY",uc="OPENAI_API_KEY",bN={id:"api-key",name:"API Key",description:"Use an API key to authenticate",_meta:{"api-key":{provider:"openai"}}},SN={id:"chat-gpt",name:"ChatGPT",description:"Use ChatGPT to authenticate"},DN={id:"chat-gpt-device-code",name:"ChatGPT (device code)",description:"Sign in to ChatGPT by opening a verification page and entering a one-time code"},QS={id:"gateway",name:"Custom model gateway",description:"Use a custom gateway to authenticate and access models",_meta:{gateway:{protocol:"openai",restartRequired:"false"}}};function eD(e,t=process.env){let n=[bN];return t.NO_BROWSER||n.push(SN),Sl(e)&&n.push(DN),e?.auth?._meta?.gateway===!0&&n.push(QS),n}function IN(e,t=process.env){return eD(e,t).map(({id:n,name:i,description:r,_meta:u})=>({methodId:n,type:"agent",name:i,...r!=null?{description:r}:{},...u!=null?{_meta:u}:{}}))}function vp(e){return e.methodId==="api-key"||e.methodId==="chat-gpt"||e.methodId==="chat-gpt-device-code"||e.methodId==="gateway"}function BN(e,t,n){return async(i,r,u)=>{if(!Sl(n()))return"unsupported";try{return await kN(e,t(),i,r,u)?"signedIn":"failed"}catch(s){return u?.aborted||D.error(`Failed to authenticate MCP server ${r}`,s),"failed"}}}async function kN(e,t,n,i,r){r?.throwIfAborted();let u=new AbortController,s=()=>u.abort(r?.reason);r?.addEventListener("abort",s,{once:!0});let o=new Promise((c,m)=>{u.signal.addEventListener("abort",()=>m(u.signal.reason),{once:!0})});o.catch(()=>{});let a=`mcp-oauth-${$N()}`,l=!1;try{let c=t.awaitMcpServerOauthLoginCompleted(i,n,u.signal);c.catch(()=>{});let m=await Promise.race([t.mcpServerOauthLogin({name:i,threadId:n}),o]),p=Promise.resolve(e.request(ae.client.elicitation.create,{mode:"url",sessionId:n,message:`Authenticate with MCP server ${i}`,url:m.authorizationUrl,elicitationId:a}));p.catch(()=>{}),l=!0;let v=await Promise.race([c.then(C=>({type:"completed",result:C})),p.then(C=>({type:"elicitation",response:C})),o]);return v.type==="elicitation"&&!cr.isAccept(v.response)?(l=!1,!1):(v.type==="completed"?v.result:await Promise.race([c,o])).success}finally{u.abort(),r?.removeEventListener("abort",s),l&&await e.notify(ae.client.elicitation.complete,{elicitationId:a})}}var xN=new RegExp("\\p{White_Space}","gu");function tD(e){return e.replace(xN,"_")}function nD(e){return typeof e.name=="string"?e.name:""}function TN(e){if(!("type"in e))return{type:"stdio",name:e.name,command:e.command,args:e.args,env:e.env};switch(e.type){case"stdio":{let t=e;return{type:"stdio",name:t.name,command:t.command,args:t.args??[],env:t.env??[]}}case"http":{let t=e;return{type:"http",name:t.name,url:t.url,headers:t.headers??[]}}case"acp":throw k.invalidRequest("Codex doesn't support MCP ACP transport protocol");case"sse":throw k.invalidRequest("Codex doesn't support MCP SSE transport protocol");default:throw k.invalidRequest(`Codex doesn't support MCP '${e.type}' transport protocol`)}}function FN(e){switch(e.type){case"stdio":return{command:e.command,args:e.args,env:Object.fromEntries(e.env.map(t=>[t.name,t.value]))};case"http":return{url:e.url,http_headers:Object.fromEntries(e.headers.map(t=>[t.name,t.value]))}}}var Kg=class{static skipped(e){return e.map(t=>sc(t,`[codex-acp] MCP server \`${t}\` was not started, because the Codex config already defines an MCP server with this name. Codex uses its own entry, or no server if that entry is disabled.`))}static failures(e){return[...e.failed.map(t=>sc(t.server,`[codex-acp forwarded startup error] MCP server \`${t.server}\` failed to start: ${t.error}`)),...e.cancelled.map(t=>sc(t,`[codex-acp forwarded startup error] MCP server \`${t}\` startup was cancelled.`))]}};function sc(e,t){return{toolCallId:`mcp_startup.${encodeURIComponent(e)}.${PN()}`,report:"start",kind:"other",title:`mcp__${e}__startup`,status:"failed",result:[Ar(t)]}}var RN=class{connection;codexAcpClient;runWithProcessCheck;signIn;capabilities;isSessionOpen;pendingSessions=new Map;constructor(e,t,n,i,r,u){this.connection=e,this.codexAcpClient=t,this.runWithProcessCheck=n,this.signIn=i,this.capabilities=r,this.isSessionOpen=u}begin(e,t,n,i){let r=this.createPendingSession(e,t,n,i.skippedServers??[]);i.publish&&this.pendingSessions.set(e,r);let u=i.awaitTimeoutMs;if(u!==void 0&&u>0){let s=Zc(r.startup,u).then(()=>{});return s.then(()=>this.publishOrAbort(e,r,i.publish),()=>this.forget(e,r)),s}return this.publishOrAbort(e,r,i.publish),null}close(e){this.pendingSessions.get(e)?.abort.abort(),this.pendingSessions.delete(e)}isPending(e){return this.pendingSessions.has(e)}publishOrAbort(e,t,n){n?this.publishAsync(e):t.abort.abort()}forget(e,t){this.pendingSessions.get(e)===t&&this.pendingSessions.delete(e)}publishAsync(e){this.doPublish(e)}createPendingSession(e,t,n,i){let r=new Set(rD(t).filter(o=>!i.includes(o))),u=new AbortController,s=this.runWithProcessCheck(()=>this.codexAcpClient().awaitMcpServerStartup(Array.from(r),n,{threadId:e,signal:u.signal}));return s.catch(()=>{}),{requestedServers:r,skippedServers:i,startup:s,abort:u}}async doPublish(e){let t=this.pendingSessions.get(e);if(t)try{let n=await t.startup;if(!this.isSessionOpen(e)||this.pendingSessions.get(e)!==t)return;await this.publish(e,n,t)}catch(n){t.abort.signal.aborted||D.error(`Failed to publish MCP startup status for session ${e}`,n)}finally{this.forget(e,t)}}async publish(e,t,n){let{requestedServers:i,skippedServers:r,abort:{signal:u}}=n,s={ready:t.ready.filter(c=>i.has(c)),failed:t.failed.filter(c=>i.has(c.server)),cancelled:t.cancelled.filter(c=>i.has(c))},o=[],a=[...s.ready];for(let c of s.failed)(c.failureReason==="reauthenticationRequired"?await this.signIn(e,c.server,u):"unsupported")==="signedIn"?a.push(c.server):o.push(c);if(u.aborted)return;let l=new Hr(this.capabilities());for(let c of[...Kg.skipped(r),...Kg.failures({...s,ready:a,failed:o})])await this.connection.notify(ae.client.session.update,{sessionId:e,update:l.render(c)})}};function rD(e){return Array.from(new Set(e.map(t=>tD(nD(t)))))}var zN="mcpStartupAwaitTimeoutMs";function ON(e){let t=e?.[zN];return typeof t=="number"&&Number.isFinite(t)?t:void 0}async function MN(e,t){let n=Ad.resolve(t),i=await NN(n),r=await e.configRead({includeLayers:!0}),u=[r.config.projects,...(r.layers??[]).filter(a=>a.name.type==="user"&&!a.disabledReason).map(a=>Nr(a.config)?a.config.projects:void 0)];for(let a of u)if(Nr(a)){for(let[l,c]of Object.entries(a))if(Nr(c)&&c.trust_level==="untrusted"&&(oc(l,n)||oc(l,i)))return"untrusted"}let s=r.layers?.find(a=>a.name.type==="user"&&!a.name.profile&&!a.disabledReason);if(!s||s.name.type!=="user")throw new Error("Codex did not return its writable user configuration layer");let o=Nr(s.config)?s.config.projects:void 0;return Nr(o)&&Object.entries(o).some(([a,l])=>oc(a,i)&&Nr(l)&&l.trust_level==="trusted")||await e.configBatchWrite({filePath:s.name.file,expectedVersion:s.version,edits:[{keyPath:"projects",value:{[i]:{trust_level:"trusted"}},mergeStrategy:"upsert"}]}),"trusted"}function Nr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function oc(e,t){let n=Ad.normalize(e),i=Ad.normalize(t);return process.platform==="win32"?n.toLowerCase()===i.toLowerCase():n===i}var Xg=Sn(Sr(),1),ac=32;function Hs(e){if(typeof e!="object"||e===null)return;let t=e.lody;if(typeof t!="object"||t===null)return;let n=t.worktreeProject;if(n!==void 0){if(typeof n=="object"&&n!==null){let i=n;if(i.version===1&&typeof i.originProjectPath=="string"&&Cp.isAbsolute(i.originProjectPath)&&!i.originProjectPath.includes("\0"))return{version:1,originProjectPath:i.originProjectPath}}throw k.invalidParams(void 0,"worktreeProject requires version 1 and an absolute originProjectPath")}}var LN=class{constructor(e){this.client=e}client;async resolve(e){if(!e)return;let t=await jN(e.originProjectPath),n=qN(t),i=`acp-project-v1:${UN("sha256").update(n).digest("hex")}`;for(let r=0;r<=ac;r++){let u=r===0?i:`${i}:g${r}`;try{return(await this.client.projectCreate({idempotencyKey:u,name:Cp.basename(t)||t,roots:[{path:t}]})).project.id}catch(s){if(!ZN(s,u))throw s}}throw k.internalError({originProjectPath:t,maxGeneration:ac},`Codex project recovery for ${t} exhausted generations 0 through ${ac}`)}async backfill(e,t){if(!t||e.projectId)return;let n=await this.resolve(t);n&&await this.client.threadProjectUpdate({threadId:e.id,projectId:n})}};function qN(e){let t=Cp.resolve(e);return process.platform==="win32"?t.toLowerCase():t}function ZN(e,t){return e instanceof Xg.ResponseError&&e.code===Xg.ErrorCodes.InternalError&&e.message.includes(`idempotency key refers to deleted project: ${t}`)}var cc;function eM(){try{return oD.statSync("/.dockerenv"),!0}catch{return!1}}function tM(){try{return oD.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function nM(){return cc===void 0&&(cc=eM()||tM()),cc}var dc,rM=()=>{try{return QN.statSync("/run/.containerenv"),!0}catch{return!1}};function Js(){return dc===void 0&&(dc=rM()||nM()),dc}var Yg=()=>{if(sD.platform!=="linux")return!1;if(YN.release().toLowerCase().includes("microsoft"))return!Js();try{if(lc.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!Js()}catch{}return lc.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||lc.existsSync("/run/WSL")?!Js():!1},hr=sD.env.__IS_WSL_TEST__?Yg:Yg(),oM=uM(sM.execFile),aD=()=>`${Qg.env.SYSTEMROOT||Qg.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,lD=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"],cD=e=>iM.from(e,"utf16le").toString("base64"),aM=e=>`'${String(e).replaceAll(/['‘’‚‛]/g,t=>t+t)}'`,dD=e=>[...lD,cD(e)],lM=e=>({encoding:"utf8",...e,shell:!1}),un=async(e,t={})=>{let{powerShellPath:n,...i}=t;return oM(n??aD(),dD(e),lM(i))};un.argumentsPrefix=lD;un.encodeCommand=cD;un.escapeArgument=aM;un.createArguments=dD;function cM(e){for(let t of e.split(`
|
|
115
|
+
`)){if(/^\s*#/.test(t))continue;let n=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(t);if(n)return n.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,"")}}var dM=KN(XN.execFile),hM=(()=>{let e="/mnt/",t;return async function(){if(t)return t;let n="/etc/wsl.conf",i=!1;try{await bd.access(n,uD.F_OK),i=!0}catch{}if(!i)return e;let r=await bd.readFile(n,{encoding:"utf8"}),u=cM(r);return u===void 0?e:(t=u,t=t.endsWith("/")?t:`${t}/`,t)}})(),fM=async()=>`${await hM()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,Ep=hr?fM:aD,e4,pM=async()=>(e4??=(async()=>{try{let e=await Ep();return await bd.access(e,uD.X_OK),!0}catch{return!1}})(),e4),mM=async()=>{let e=await Ep(),t=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:n}=await un(t,{powerShellPath:e,cwd:JN.dirname(e)});return n.trim()},gM=e=>/^[a-z]+:\/\//i.test(e),vM=async(e,t)=>{let n=t.startsWith("-")?[e,"--",t]:[e,t];try{let{stdout:i}=await dM("wslpath",n,{encoding:"utf8"});return i.replace(/\r?\n$/,"")||t}catch{return t}},CM=async e=>{let t=Array.isArray(e),n=t?e:[e],i=await Promise.all(n.map(r=>gM(r)?r:vM("-aw",r)));return t?i:i[0]};function us(e,t,n){let i=r=>Object.defineProperty(e,t,{value:r,enumerable:!0,writable:!0});return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let r=n();return i(r),r},set(r){i(r)}}),e}var bM=wM(AM);async function SM(){if(_M.platform!=="darwin")throw new Error("macOS only");let{stdout:e}=await bM("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),n=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??"com.apple.Safari";return n==="com.apple.safari"?"com.apple.Safari":n}var BM=IM($M);async function kM(e,{humanReadableOutput:t=!0,signal:n}={}){if(DM.platform!=="darwin")throw new Error("macOS only");let i=t?[]:["-ss"],r={};n&&(r.signal=n);let{stdout:u}=await BM("osascript",["-e",e,i],r);return u.trim()}var xM=/^[^\n\r"\\]+$/u;async function TM(e){if(typeof e!="string")throw new TypeError("Expected a string bundle identifier");if(!xM.test(e))throw new TypeError(`Invalid bundle identifier: ${JSON.stringify(e)}`);return kM(`tell application "Finder" to set app_path to application file id "${e}" as string
|
|
116
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var RM=FM(PM),Ks={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},zM=new Map(Object.entries(Ks)),OM=class extends Error{};async function NM(e=RM){let t=`${t4.env.SYSTEMROOT??t4.env.windir??"C:\\Windows"}\\System32\\reg.exe`,{stdout:n}=await e(t,["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),i=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(n);if(!i)throw new OM(`Cannot find Windows browser in stdout: ${JSON.stringify(n)}`);let{id:r}=i.groups,u=r.lastIndexOf("."),s=r.lastIndexOf("-"),o=u===-1?void 0:r.slice(0,u),a=s===-1?void 0:r.slice(0,s);return Ks[r]??Ks[o]??Ks[a]??{name:r,id:r}}var MM=yM(EM),UM=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,t=>t.toUpperCase());async function jM(){if(hc.platform==="darwin"){let e=await SM();return{name:await TM(e),id:e}}if(hc.platform==="linux"){let{stdout:e}=await MM("xdg-mime",["query","default","x-scheme-handler/http"]),t=e.trim();return{name:UM(t.replace(/.desktop$/,"").replace("-"," ")),id:t}}if(hc.platform==="win32")return NM();throw new Error("Only macOS, Linux, and Windows are supported")}var LM=!!(fc.env.SSH_CONNECTION||fc.env.SSH_CLIENT||fc.env.SSH_TTY),qM=LM,As=Symbol("fallbackAttempt"),Sd=import.meta.url?yp.dirname(WN(import.meta.url)):"",n4=yp.join(Sd,"xdg-open"),{platform:fr,arch:r4}=iD,i4=async(e,t)=>{if(e.length===0)return;let n=[];for(let i of e)try{return await t(i)}catch(r){n.push(r)}throw new AggregateError(n,"Failed to open in all supported apps")},Xs=async e=>{e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e};let t=e[As]===!0;if(delete e[As],Array.isArray(e.app))return i4(e.app,l=>Xs({...e,app:l,[As]:!0}));let{name:n,arguments:i=[]}=e.app??{};if(i=[...i],Array.isArray(n))return i4(n,l=>Xs({...e,app:{name:l,arguments:i},[As]:!0}));if(n==="browser"||n==="browserPrivate"){let l={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},c={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},m;if(hr){let v=await mM();m=zM.get(v)??{}}else m=await jM();let p=m.id?.toLowerCase();if(Object.hasOwn(l,p)){let v=l[p];if(n==="browserPrivate"){if(v==="safari")throw new Error("Safari doesn't support opening in private mode via command line");i.push(c[v])}return Xs({...e,app:{name:$i[v],arguments:i}})}throw new Error(`${m.name} is not supported as a default browser`)}let r,u=[],s={},o=!1;if(hr&&!Js()&&!qM&&!n&&(o=await pM()),fr==="darwin")r="open",e.wait&&u.push("--wait-apps"),e.background&&u.push("--background"),e.newInstance&&u.push("--new"),n&&u.push("-a",n);else if(fr==="win32"||o){r=await Ep(),u.push(...un.argumentsPrefix),hr||(s.windowsVerbatimArguments=!0),hr&&e.target&&(e.target=await CM(e.target));let l=["$ProgressPreference = 'SilentlyContinue';","Start"];e.wait&&l.push("-Wait"),n?(l.push(un.escapeArgument(n)),e.target&&i.push(e.target)):e.target&&l.push(un.escapeArgument(e.target)),i.length>0&&(i=i.map(c=>un.escapeArgument(c)),l.push("-ArgumentList",i.join(","))),e.target=un.encodeCommand(l.join(" ")),e.wait||(s.stdio="ignore"),hr&&(s.cwd=yp.dirname(r))}else{if(n)r=n;else{let l=!Sd||Sd==="/",c=!1;try{await VN.access(n4,HN.X_OK),c=!0}catch{}r=iD.versions.electron??(fr==="android"||l||!c)?"xdg-open":n4}i.length>0&&u.push(...i),e.wait||(s.stdio="ignore",s.detached=!0)}fr==="darwin"&&i.length>0&&u.push("--args",...i),e.target&&u.push(e.target);let a=GN.spawn(r,u,s);return e.wait?new Promise((l,c)=>{a.once("error",c),a.once("close",m=>{if(!e.allowNonzeroExitCode&&m!==0){c(new Error(`Exited with code ${m}`));return}l(a)})}):t||fr==="win32"||o?new Promise((l,c)=>{a.once("error",c),a.once("spawn",()=>{a.once("close",m=>{if(a.off("error",c),t&&m!==0){c(new Error(`Exited with code ${m}`));return}a.unref(),l(a)})})}):(a.unref(),new Promise((l,c)=>{a.once("error",c),a.once("spawn",()=>{a.off("error",c),l(a)})}))},ZM=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a `target`");return Xs({...t,target:e})};function u4(e){if(typeof e=="string"||Array.isArray(e))return e;let{[r4]:t}=e;if(!t)throw new Error(`${r4} is not supported`);return t}function ss({[fr]:e},{wsl:t}={}){if(t&&hr)return u4(t);if(!e)throw new Error(`${fr} is not supported`);return u4(e)}var $i={browser:"browser",browserPrivate:"browserPrivate"};us($i,"chrome",()=>ss({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));us($i,"brave",()=>ss({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));us($i,"firefox",()=>ss({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));us($i,"edge",()=>ss({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));us($i,"safari",()=>ss({darwin:"Safari"}));var hD=ZM,tt=class Ys{constructor(t,n){this.model=t,this.effort=n}model;effort;static fromComponents(t,n){return new Ys(t.id,n)}static create(t,n){return new Ys(t,n)}static fromString(t){let n=t.match(/^(?<model>[^\[]+?)(?:\[(?<effort>[^\]]+)\])?$/),i=n?.groups?.model,r=n?.groups?.effort;if(!i||!r)throw new Error(`Unsupported format of modelId: ${t}. Expected: modelId[effort].`);if(i)return new Ys(i,r);throw new Error(`Invalid modelId format: ${t}`)}toString(){return`${this.model}[${this.effort}]`}},fD="mode",pc=class ut{id;name;description;kind;approvalPolicy;approvalsReviewer;sandboxPolicy;sandboxMode;constructor(t,n,i,r,u,s,o,a){this.id=t,this.name=n,this.description=i,this.kind=r,this.approvalPolicy=u,this.approvalsReviewer=s,this.sandboxPolicy=o,this.sandboxMode=a}static ReadOnly=new ut("read-only","Read-only","Requires approval to edit files and run commands.","standard","on-request","user",{type:"readOnly",networkAccess:!1},"read-only");static Agent=new ut("agent","Agent","Read and edit files, and run commands.","standard","on-request","user",{type:"workspaceWrite",writableRoots:[],networkAccess:!1,excludeTmpdirEnvVar:!1,excludeSlashTmp:!1},"workspace-write");static get WorkspaceWrite(){return ut.Agent}static AgentAutoReview=new ut("agent-auto-review","Agent (auto review)","Read and edit files, and run commands. Approval requests are reviewed automatically by a Codex subagent.","auto_review","on-request","auto_review",{type:"workspaceWrite",writableRoots:[],networkAccess:!1,excludeTmpdirEnvVar:!1,excludeSlashTmp:!1},"workspace-write");static AgentFullAccess=new ut("agent-full-access","Agent (full access)","Codex can edit files outside this workspace and run commands with network access. Exercise caution when using.","full_access","never","user",{type:"dangerFullAccess"},"danger-full-access");static DEFAULT_AGENT_MODE=ut.Agent;toSessionMode(t=!1){return{id:this.id,name:this.name,description:this.description,_meta:{kind:this.kind,...hi(t,Zm,this.kind)}}}toSessionModeState(t=!1){return{availableModes:ut.all().map(n=>n.toSessionMode(t)),currentModeId:this.id}}toConfigOption(t=!1){return{id:fD,name:"Mode",description:"Approval and sandboxing preset for the session",category:"mode",type:"select",currentValue:this.id,options:ut.all().map(n=>({value:n.id,name:n.name,description:n.description,_meta:{kind:n.kind,...hi(t,Zm,n.kind)}}))}}static all(){return[ut.ReadOnly,ut.Agent,ut.AgentAutoReview,ut.AgentFullAccess]}static find(t){return ut.all().find(i=>i.id===t)??null}static getInitialAgentMode(){let t=process.env.INITIAL_AGENT_MODE;return t?ut.find(t)??ut.DEFAULT_AGENT_MODE:ut.DEFAULT_AGENT_MODE}},Et={name:"acp-extension-codex",publishConfig:{access:"public"},version:"1.12.0",description:"An ACP-compatible coding agent powered by Codex",main:"dist/index.js",bin:{"acp-extension-codex":"dist/index.js"},files:["dist/index.js","README.md","LICENSE","package.json"],scripts:{prepublishOnly:"npm run build",build:"node build.mjs","bundle:all":"npm run bundle:linux-x64 && npm run bundle:linux-arm64 && npm run bundle:darwin-x64 && npm run bundle:darwin-arm64 && npm run bundle:win-x64 && npm run bundle:win-arm64","bundle:linux-x64":"bun build src/index.ts --minify --sourcemap --compile --target=bun-linux-x64-baseline --outfile dist/bin/acp-extension-codex-x64-linux","bundle:linux-arm64":"bun build src/index.ts --minify --sourcemap --compile --target=bun-linux-arm64 --outfile dist/bin/acp-extension-codex-arm64-linux","bundle:darwin-x64":"bun build src/index.ts --minify --sourcemap --compile --target=bun-darwin-x64-baseline --outfile dist/bin/acp-extension-codex-x64-darwin","bundle:darwin-arm64":"bun build src/index.ts --minify --sourcemap --compile --target=bun-darwin-arm64 --outfile dist/bin/acp-extension-codex-arm64-darwin","bundle:win-x64":"bun build src/index.ts --minify --sourcemap --compile --target=bun-windows-x64-baseline --outfile dist/bin/acp-extension-codex-x64-windows.exe","bundle:win-arm64":"bun build src/index.ts --minify --sourcemap --compile --target=bun-windows-arm64 --outfile dist/bin/acp-extension-codex-arm64-windows.exe","package:all":"npm run package:linux-x64 && npm run package:linux-arm64 && npm run package:darwin-x64 && npm run package:darwin-arm64 && npm run package:win-x64 && npm run package:win-arm64","package:linux-x64":"cd dist/bin && zip acp-extension-codex-x64-linux.zip acp-extension-codex-x64-linux","package:linux-arm64":"cd dist/bin && zip acp-extension-codex-arm64-linux.zip acp-extension-codex-arm64-linux","package:darwin-x64":"cd dist/bin && zip acp-extension-codex-x64-darwin.zip acp-extension-codex-x64-darwin","package:darwin-arm64":"cd dist/bin && zip acp-extension-codex-arm64-darwin.zip acp-extension-codex-arm64-darwin","package:win-x64":"cd dist/bin && zip acp-extension-codex-x64-windows.zip acp-extension-codex-x64-windows.exe","package:win-arm64":"cd dist/bin && zip acp-extension-codex-arm64-windows.zip acp-extension-codex-arm64-windows.exe",start:"node --import tsx src/index.ts","example:simple-client":"node --import tsx examples/simple-client.ts","example:steering":"node --import tsx examples/steering.ts","example:steering:multistep":"node --import tsx examples/steering.ts","generate-types":"./node_modules/.bin/codex app-server generate-ts --out src/app-server",test:"vitest run --no-file-parallelism --retry=2 --exclude 'src/__tests__/integration/**' --exclude '**/node_modules/**' --exclude '**/.git/**'","test:integration":"vitest run --no-file-parallelism --hookTimeout=30000 src/__tests__/integration","test:e2e":"npm run build && RUN_E2E_TESTS=true vitest run --no-file-parallelism --retry=2 src/__tests__/CodexACPAgent/e2e","test:watch":"vitest",typecheck:"tsc --noEmit && tsc --noEmit -p examples/tsconfig.json","codex-test":"tsx .agents/skills/run-codex/scripts/run-codex-test.ts"},homepage:"https://github.com/LodyAI/acp-extension-codex#readme",bugs:{url:"https://github.com/LodyAI/acp-extension-codex/issues"},repository:{type:"git",url:"git+https://github.com/LodyAI/acp-extension-codex.git"},keywords:["codex","acp","agent","coding","ai","assistant"],author:"lody <agent@lody.ai>",license:"Apache-2.0",type:"module",devDependencies:{"@types/cross-spawn":"^6.0.6","@types/node":"^26.1.0",esbuild:"^0.28.2","mcp-hello-world":"^1.1.2",tsx:"^4.23.12",typescript:"^7.0.2",vitest:"^5.0.1",ajv:"^8.20.0"},dependencies:{"@agentclientprotocol/sdk":"~2.0.2","@openai/codex":"^0.164.0","acp-extension-core":"0.3.0","cross-spawn":"^7.0.6",diff:"^9.0.0",open:"^11.0.1","vscode-jsonrpc":"^9.0.1",zod:"^4.0.0"}},Lo="default",Ci="plan";function WM(e){return fP(e===Ci)}function GM(e){return e===Lo?Lo:e===Ci?Ci:null}function VM(e,t){let n=tt.fromString(t);return{mode:e,settings:{model:n.model,reasoning_effort:n.effort,developer_instructions:null}}}function qo(e){let t=e.trim();return Qr.isAbsolute(t)||wp(t)}function HM(e,t){return Zo(e)===Zo(t)}function pD(e,t){let n=Qr.posix.basename(Zo(e)),i=Qr.posix.basename(Zo(t));return s4(e)||s4(t)?n.toLowerCase()===i.toLowerCase():n===i}function Zo(e){let t=e.trim();if(t.length===0)return"";if(wp(t)){let r=Qr.win32.normalize(t).replace(/\\/g,"/");return o4(r).toLowerCase()}let n=Qr.isAbsolute(t)?t:t.replace(/\\/g,"/"),i=Qr.posix.normalize(n);return o4(i)}function wp(e){let t=e.replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)||/^\/\/[^/]+\/[^/]+/.test(t)}function s4(e){return wp(e)||/^[A-Za-z]:/.test(e)||e.includes("\\")}function o4(e){let t=e;for(;t.endsWith("/")&&!JM(t);)t=t.slice(0,-1);return t}function JM(e){return e==="/"||/^[A-Za-z]:\/$/.test(e)||/^\/\/[^/]+\/[^/]+\/$/.test(e)}var KM=class{constructor(e){this.client=e}client;sessions=new Map;subscribe(e){let t=this.sessions.get(e.rootSessionId);if(t){t.current=e;return}let n={current:e,children:new Set};this.sessions.set(e.rootSessionId,n),this.client.onServerNotification(e.rootSessionId,i=>{this.discover(n,i),n.current.observeWorkEnd?.(i),n.current.dispatch(i)}),this.registerInteractiveHandlers(n,e.rootSessionId)}clear(e){for(let t of this.sessions.get(e)?.children??[])this.client.clearThreadHandlers(t);this.sessions.delete(e)}redispatch(e,t){let n=this.sessions.get(e);if(n)for(let i of t)n.current.dispatch(i)}isChildThread(e){return[...this.sessions.values()].some(t=>t.children.has(e))}async restoreChild(e,t,n){let i=this.sessions.get(e);if(!i||i.children.has(n.id)||n.parentThreadId!==t||t!==e&&!i.children.has(t)||!this.attachChild(i,n.id)||n.status.type==="notLoaded")return null;try{let r=await this.client.threadResume({threadId:n.id,excludeTurns:!0});if(this.sessions.get(e)===i&&r.thread.id===n.id&&r.thread.parentThreadId===t&&r.thread.status.type!=="notLoaded")return r.thread}catch(r){throw this.detachChild(i,n.id),r}return this.detachChild(i,n.id),null}discover(e,t){if(t.method!=="item/started"&&t.method!=="item/completed")return;let n=t.params.item,i=n.type==="collabAgentToolCall"&&n.tool==="spawnAgent"?n.receiverThreadIds:n.type==="subAgentActivity"&&n.kind!=="interrupted"&&!fi(n.agentPath)?[n.agentThreadId]:[];for(let r of i)r.trim()!==""&&(r===e.current.rootSessionId||r===t.params.threadId||e.children.has(r)||this.attachChild(e,r))}attachChild(e,t){return[...this.sessions.values()].some(n=>n!==e&&(n.current.rootSessionId===t||n.children.has(t)))?!1:(e.children.add(t),this.client.onServerNotification(t,n=>{n.params.threadId===t&&(this.discover(e,n),e.current.observeWorkEnd?.(n),e.current.supportsSubagents?e.current.dispatch(n):e.current.enqueueInteraction(this.rootAttributed(n,e.current.rootSessionId)))}),this.registerInteractiveHandlers(e,t),!0)}detachChild(e,t){this.sessions.get(e.current.rootSessionId)!==e||!e.children.delete(t)||this.sessions.has(t)||this.client.clearThreadHandlers(t)}registerInteractiveHandlers(e,t){this.client.onApprovalRequest(t,{handleCommandExecution:async n=>{let i=e.current;await i.waitForRootNotifications();let r=await this.interactionSessionId(i,t);if(r===null)return{decision:"cancel"};let u=()=>i.approvalHandler.handleCommandExecution({...n,threadId:r});return i.withUserAction?i.withUserAction(r,n.itemId,u,n.turnId):u()},handleFileChange:async n=>{let i=e.current;await i.waitForRootNotifications();let r=await this.interactionSessionId(i,t);if(r===null)return{decision:"cancel"};let u=()=>i.approvalHandler.handleFileChange({...n,threadId:r});return i.withUserAction?i.withUserAction(r,n.itemId,u,n.turnId):u()},handlePermissionsRequest:async n=>{let i=e.current;await i.waitForRootNotifications();let r=await this.interactionSessionId(i,t);if(r===null)return{permissions:{},scope:"turn",strictAutoReview:!1};let u=()=>i.approvalHandler.handlePermissionsRequest({...n,threadId:r});return i.withUserAction?i.withUserAction(r,n.itemId,u,n.turnId):u()}}),this.client.onElicitationRequest(t,{handleElicitation:async n=>{let i=e.current;await i.waitForRootNotifications();let r=await this.interactionSessionId(i,t);if(r===null)return{action:"cancel",content:null,_meta:null};let u=()=>i.elicitationHandler.handleElicitation({...n,threadId:r});return i.withUserAction?i.withUserAction(r,void 0,u,n.turnId):u()},handleUserInput:async n=>{let i=e.current;await i.waitForRootNotifications();let r=await this.interactionSessionId(i,t);if(r===null)return{answers:{}};let u=()=>i.elicitationHandler.handleUserInput({...n,threadId:r});return i.withUserAction?i.withUserAction(r,n.itemId,u,n.turnId):u()}})}async interactionSessionId(e,t){return t===e.rootSessionId?t:e.supportsSubagents?await e.waitForChildSession(t):e.rootSessionId}rootAttributed(e,t){return typeof e.params.threadId!="string"?e:{...e,params:{...e.params,threadId:t}}}};async function YM(e,t,n,i){let r=Hs(e._meta),u=await QM(e,n.codexClient),s=await n.createSessionConfig(e.cwd,t,e.mcpServers??[],e._meta),o=await n.codexClient.threadFork({excludeTurns:!0,config:s.config,cwd:e.cwd,...u!==void 0&&{lastTurnId:u},modelProvider:await n.getResumeModelProvider(),threadId:e.sessionId,...i?.text!==void 0?{developerInstructions:i.developerInstructions}:{}});n.forkCreated(o.thread.id);let a;try{await n.backfillProject(o.thread,r),a=await n.fetchAvailableModels()}catch(l){throw await n.releaseFailedFork(o.thread.id),l}return{sessionId:o.thread.id,currentModelId:n.createCurrentModelId(a,o.model,o.reasoningEffort),models:a,collaborationMode:n.getCollaborationMode(o.thread.id),modelProvider:o.modelProvider,currentServiceTier:o.serviceTier??null,additionalDirectories:t,skippedMcpServers:s.skippedMcpServers,...i?{instructions:i}:{}}}async function QM(e,t){let n=Y2(e._meta);if(n!==null)return n;let i=eU(e._meta);if(!i)return;let r=await t.threadReadWithHistory(e.sessionId),s=nU(i.messageId).map(o=>r.thread.turns.find(a=>a.items.some(l=>l.id===o))?.id).find(o=>o!==void 0);if(s)return s;if(i.messageFingerprint){let a=r.thread.turns.flatMap(l=>l.items.filter(c=>c.type==="agentMessage"&&tU(c.text)===i.messageFingerprint).map(()=>l.id))[i.messageOccurrence-1];if(a)return a}throw k.invalidParams({messageId:i.messageId},`Fork point message ${i.messageId} was not found in session ${e.sessionId}`)}function eU(e){let t=e?.jetbrains;if(!mc(t))return;let n=t.air;if(!mc(n))return;let i=n.fork;if(!mc(i)||i.version!==1)return;let r=i.messageId;if(typeof r!="string"||r.trim().length===0)throw k.invalidParams(void 0,"AIR fork messageId must be a non-empty string");let u=i.messageFingerprint;if(u!==void 0&&(typeof u!="string"||!/^sha256:[0-9a-f]{64}$/.test(u)))throw k.invalidParams(void 0,"AIR fork messageFingerprint must be a SHA-256 fingerprint");let s=i.messageOccurrence??1;if(!Number.isSafeInteger(s)||s<1)throw k.invalidParams(void 0,"AIR fork messageOccurrence must be a positive integer");return{messageId:r.trim(),...typeof u=="string"&&{messageFingerprint:u},messageOccurrence:s}}function tU(e){return`sha256:${XM("sha256").update(e,"utf8").digest("hex")}`}function nU(e){let t=/:segment:\d+$/,n=e.replace(t,"");return n===e?[e]:[e,n]}function mc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ei(e){if(e==null)return;if(typeof e!="object"||Array.isArray(e)||!("mode"in e)||e.mode!=="append"||!("content"in e)||!Array.isArray(e.content))throw k.invalidParams(void 0,"systemPrompt requires append mode and text content");let t=[];for(let n of e.content){if(n===null||typeof n!="object"||n.type!=="text"||typeof n.text!="string")throw k.invalidParams(void 0,"systemPrompt content must contain only text blocks");t.push(n.text)}return t.join(`
|
|
117
|
+
|
|
118
|
+
`)}function gc(e){let t=ei(e);return t===void 0?null:{mode:"append",content:[{type:"text",text:t}]}}function Id(e,t){let n=ei(e.systemPrompt),i=td(e._meta);return n!==void 0&&(n!==t?.text||i!==void 0&&i!==t?.airInstructions)}var rU=1e4,iU=500,$d=class extends Error{name="GatewayListingError"};async function uU(e,t){let n=`${e.replace(/\/+$/,"")}/models`,i=URL.canParse(n)?new URL(n):null,r=i?.pathname??n;if(i?.username||i?.password)throw D.log("[WARN] The gateway model listing failed",{path:r,reason:"the base URL carries credentials"}),new $d(`Model listing GET ${r} failed: the base URL carries credentials`);let u=(c,m)=>(D.log("[WARN] The gateway model listing failed",{url:n,reason:c,...m}),new $d(`Model listing GET ${r} ${c}`)),s={...t,Accept:"application/json"};for(let[c,m]of Object.entries(s))try{new Headers([[c,m]])}catch{throw u(`failed: the header "${c}" is invalid`,{})}let o,a;try{o=await fetch(n,{method:"GET",headers:s,signal:AbortSignal.timeout(rU)}),a=await o.text()}catch(c){throw u(`failed: ${c instanceof Error?c.message:String(c)}`,{})}if(o.status>=400&&o.status<500)return D.log("The gateway has no model listing; models are not narrowed",{path:r,status:o.status}),null;if(!o.ok)throw u(`returned ${o.status}: ${a.slice(0,iU)}`,{status:o.status});let l;try{l=sU(JSON.parse(a))}catch{l=null}if(l===null)throw u("returned a malformed body",{});return D.log("The gateway listed its models",{url:n,models:l}),new Set(l.map(mD))}function sU(e){if(typeof e!="object"||e===null)return null;let t=e.data;if(!Array.isArray(t))return null;let n=t.map(i=>typeof i=="object"&&i!==null?i.id:void 0).filter(i=>typeof i=="string"&&i.length>0);return n.length===t.length?n:null}function mD(e){return e.toLowerCase().replace(/-(\d{8}|\d{4}-\d{2}-\d{2})$/,"")}function oU(e,t){return Bd(e.model,t)||Bd(e.id,t)}function Bd(e,t){return t.has(mD(e))}function aU(e,t){let n=e.filter(r=>oU(r,t));if(n.length===0)return D.log("[WARN] The gateway lists none of the Codex models; no model is available",{codexModels:e.map(r=>r.id)}),[];let i=Math.max(0,n.findIndex(r=>r.isDefault));return n.map((r,u)=>r.isDefault===(u===i)?r:{...r,isDefault:u===i})}var gD=new Set(["visualize:visualize"]);function lU(e){let t=dU(e.skills)?e.skills:{},n=Array.isArray(t.config)?t.config:[];return{...e,skills:{...t,config:[...n,...Array.from(gD,i=>({name:i,enabled:!1}))]}}}function cU(e){return{...e,data:e.data.map(t=>({...t,skills:t.skills.filter(n=>!gD.has(n.name))}))}}function dU(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var kd="custom-gateway",pn="openai",hU="https://api.openai.com/v1",fU=100,Wo={openai:"responses"},pU=class vD{codexClient;config;modelProvider;gatewayConfig;gatewayConfigSource;pendingLoginCompleted=null;pendingAccountUpdated=null;sessionNotificationQueues=new Map;subagents;worktreeProjects;skillExtraRoots=[];configPath=null;constructor(t,n,i){this.codexClient=t,this.worktreeProjects=new LN(t),this.config=n??{},this.modelProvider=i??null,this.gatewayConfig=null,this.gatewayConfigSource=null,this.subagents=new KM(t)}get appServerClient(){return this.codexClient}withAppServer(t){let n=new vD(t,this.config,this.modelProvider??void 0);return n.adoptRoutingFrom(this),n}adoptRoutingFrom(t){this.gatewayConfig=t.gatewayConfig,this.gatewayConfigSource=t.gatewayConfigSource}defaultClientInfo={name:`${Et.name}`,title:"Codex ACP",version:`${Et.version}`};async initialize(t){let n=await this.codexClient.initialize({capabilities:{experimentalApi:!0,requestAttestation:!1},clientInfo:{name:t.clientInfo?.name??this.defaultClientInfo.name,version:t.clientInfo?.version??this.defaultClientInfo.version,title:t.clientInfo?.title??this.defaultClientInfo.title}});this.configPath=n?.codexHome??null,this.isInitialized=!0}isInitialized=!1;get initialized(){return this.isInitialized}getHomePath(){return this.configPath}async authenticate(t,n){if(!vp(t))throw k.invalidRequest();switch(this.gatewayConfig=null,this.gatewayConfigSource=null,t.methodId){case"api-key":return await this.authenticateWithApiKey(t);case"chat-gpt":return await this.authenticateWithChatGpt();case"chat-gpt-device-code":return await this.authenticateWithChatGptDeviceCode(n);case"gateway":return this.authenticateWithGateway(t)}}async authenticateWithApiKey(t){let n=t._meta?.["api-key"]?.apiKey??this.readApiKeyFromEnv(),i=this.awaitNextLoginCompleted();return i.catch(()=>{}),await this.codexClient.accountLogin({type:"apiKey",apiKey:n}),(await i).success}async authenticateWithChatGpt(){if(await this.hasWorkingChatGptLogin())return!0;let t=this.awaitNextLoginCompleted();t.catch(()=>{});let n=await this.codexClient.accountLogin({type:"chatgpt"});return n.type=="chatgpt"&&await hD(n.authUrl),(await t).success}async hasWorkingChatGptLogin(){try{return(await this.codexClient.accountRead({refreshToken:!0})).account?.type==="chatgpt"}catch(t){if(yd(t))return D.log("Account read unavailable, so the stored ChatGPT login stays",{error:String(t)}),!0;if(Gs(t))return D.log("The stored ChatGPT login does not work, so a new login starts",{error:String(t)}),!1;throw t}}async authenticateWithChatGptDeviceCode(t){if(await this.hasWorkingChatGptLogin())return!0;if(!t)throw k.invalidRequest(void 0,"Device code authentication requires URL elicitation support");let n=this.awaitNextLoginCompleted();n.catch(()=>{});let i=await this.codexClient.accountLogin({type:"chatgptDeviceCode"});if(i.type!=="chatgptDeviceCode")return!1;let r=Promise.resolve(t.elicitUrl({url:i.verificationUrl,message:`Sign in to ChatGPT and enter this code: ${i.userCode}`,elicitationId:i.loginId}));try{let u=await Promise.race([n.then(o=>({type:"loginCompleted",result:o})),r.then(o=>({type:"elicitationResponse",response:o}))]);if(u.type==="loginCompleted")return await t.completeElicitation(),u.result.success;if(!cr.isAccept(u.response))throw await this.codexClient.accountLoginCancel({loginId:i.loginId}),k.requestCancelled({methodId:"chat-gpt-device-code",action:u.response.action},"ChatGPT device code sign-in was cancelled");let s=await n;return await t.completeElicitation(),s.success}catch(u){throw this.codexClient.connectionLoss.lost&&await Promise.resolve(t.completeElicitation()).catch(()=>{}),u}}authenticateWithGateway(t){if(!t._meta)throw k.invalidRequest();let n=t._meta.gateway;if(!n)throw k.invalidRequest();return this.applyGatewayConfig({baseUrl:n.baseUrl,apiType:QS._meta.gateway.protocol,headers:n.headers,providerName:n.providerName},"authentication"),!0}readApiKeyFromEnv(){for(let t of[ic,uc]){let n=process.env[t]?.trim();if(n)return n}throw k.internalError({envVars:[ic,uc]},`${ic} or ${uc} is not set`)}async getAuthenticationStatus(){let t=await this.getCurrentModelProvider();if(t)return{type:"gateway",name:t};let n=(await this.getAccount()).account;if(n===null)return{type:"unauthenticated"};switch(n.type){case"apiKey":return{type:"api-key"};case"chatgpt":return{type:"chat-gpt",email:n.email??""};case"amazonBedrock":return{type:"gateway",name:"amazonBedrock"}}}async getCurrentModelProvider(){let t=this.getModelProvider();return t!==null?t:(await this.codexClient.configRead({includeLayers:!1}))?.config?.model_provider??null}async logout(){let t=this.awaitNextAccountUpdated();t.catch(()=>{}),await this.codexClient.accountLogout(),await t}async readAuthRequirement(){if(this.gatewayConfig!=null)return{required:!1,account:null};let t=await this.codexClient.accountRead({refreshToken:!1});return{required:t.requiresOpenaiAuth&&!t.account,account:t}}applyGatewayConfig(t,n){let i=l4(t);this.gatewayConfigSource=n,this.gatewayConfig=i}async prepareProvider(t){if(t.providerId!==pn)throw k.invalidParams({providerId:t.providerId},`Unknown providerId "${t.providerId}"; only "${pn}" is configurable`);let n=l4({apiType:t.apiType,baseUrl:t.baseUrl,headers:t.headers});if(!URL.canParse(t.baseUrl)||!["http:","https:"].includes(new URL(t.baseUrl).protocol))throw k.invalidParams({baseUrl:t.baseUrl},"baseUrl must be an http(s) URL");let i=this.gatewayConfigSource==="acpProviders"?this.gatewayConfig:null;try{n.listedModels=i?.listedModels&&yU(i,n)?i.listedModels:await uU(n.config.base_url,n.config.http_headers)}catch(r){throw r instanceof $d?k.internalError({providerId:t.providerId,apiType:t.apiType,baseUrl:t.baseUrl},`Model discovery for provider "${pn}" failed: ${r.message}`):r}return n}setProvider(t){this.gatewayConfigSource="acpProviders",this.gatewayConfig=t,D.log("providers/set applied",{providerId:pn,apiType:Ss(t),baseUrl:t.config.base_url,headerNames:Object.keys(t.config.http_headers)})}listProviders(){let t=this.gatewayConfig,n=t?{apiType:Ss(t),baseUrl:t.config.base_url}:this.getNativeProviderConfig();return D.log("providers/list",{providerId:pn,overrideActive:t!==null,apiType:n.apiType,baseUrl:n.baseUrl}),[{providerId:pn,supported:Object.keys(Wo),required:!1,current:n}]}getNativeProviderConfig(){let t=this.modelProvider??(typeof this.config.model_provider=="string"?this.config.model_provider:null),n=this.config.model_providers;if(t&&n&&typeof n=="object"&&!Array.isArray(n)){let i=n[t];if(i&&typeof i=="object"&&!Array.isArray(i)){let r=i.base_url;if(typeof r=="string"&&r.length>0)return{apiType:"openai",baseUrl:r}}}return{apiType:"openai",baseUrl:hU}}disableProvider(t){let n=this.gatewayConfig!==null;t.providerId===pn&&(this.gatewayConfig=null,this.gatewayConfigSource=null);let i=this.gatewayConfig?{apiType:Ss(this.gatewayConfig),baseUrl:this.gatewayConfig.config.base_url}:this.getNativeProviderConfig();D.log("providers/disable applied",{providerId:t.providerId,knownProvider:t.providerId===pn,overrideWasActive:n,overrideActive:this.gatewayConfig!==null,restoredApiType:i.apiType,restoredBaseUrl:i.baseUrl})}async getAccount(){return this.codexClient.accountRead({refreshToken:!1})}async getRateLimits(){return this.codexClient.accountRateLimitsRead()}async readSessionHistory(t){return(await this.codexClient.threadReadWithHistory(t)).thread}getAuthGatewayProviderName(){return this.gatewayConfigSource==="authentication"?this.gatewayConfig?.config.name??null:null}isClientConfiguredProvider(t){return t===kd&&this.gatewayConfigSource==="acpProviders"}async getAgentConfiguredModelProvider(){let t=this.getModelProvider(),n=this.isClientConfiguredProvider(t)?this.modelProvider:t;return n!==null?n:(await this.codexClient.configRead({includeLayers:!1}))?.config?.model_provider??null}async resumeThread(t){try{let n=await this.codexClient.threadResume(t);return{thread:n.thread,model:n.model,modelProvider:n.modelProvider,reasoningEffort:n.reasoningEffort,serviceTier:n.serviceTier,itemsBackwardsCursor:n.itemsBackwardsCursor??null,materialized:!0,collaborationMode:n.collaborationMode?.mode??null}}catch(n){if(LS(n))throw qS(t.threadId,n);if(!vi(n))throw n;let i;try{i=await this.codexClient.threadRead({threadId:t.threadId})}catch{throw n}return D.log("Thread has no rollout yet; resumed it from its live app-server state",{threadId:t.threadId}),{thread:i.thread,model:i.thread.model,modelProvider:i.thread.modelProvider,reasoningEffort:i.thread.reasoningEffort,serviceTier:null,itemsBackwardsCursor:null,materialized:!1,collaborationMode:null}}}async resumeSession(t,n,i){let r=await this.resolveSessionInstructions(t,i),u=Hs(t._meta),s=bs(t.cwd,t.additionalDirectories,t._meta),o=await this.createSessionConfig(t.cwd,s,t.mcpServers??[],t._meta),a=await this.resumeThreadWithInstructions({excludeTurns:!0,config:o.config,cwd:t.cwd,modelProvider:await this.getResumeModelProvider(),threadId:t.sessionId,...r?.text!==void 0?{developerInstructions:r.developerInstructions}:{}},t,i);await n?.(t.sessionId),await this.worktreeProjects.backfill(a.thread,u);let l=await this.fetchAvailableModels(),c=this.createModelId(l,a.model,a.reasoningEffort).toString();return{sessionId:t.sessionId,currentModelId:c,models:l,collaborationMode:a.collaborationMode??this.getCollaborationMode(a.thread.id),threadStatus:a.thread.status,modelProvider:a.modelProvider,currentServiceTier:a.serviceTier??null,additionalDirectories:s,skippedMcpServers:o.skippedMcpServers,...r?{instructions:r}:{}}}async forkSession(t,n=u=>this.closeSession(u),i=()=>{},r){let u=await this.resolveSessionInstructions(t,r),s=bs(t.cwd,t.additionalDirectories,t._meta);return await YM(t,s,{codexClient:this.codexClient,backfillProject:(o,a)=>this.worktreeProjects.backfill(o,a),createSessionConfig:(o,a,l,c)=>this.createSessionConfig(o,a,l,c),getResumeModelProvider:()=>this.getResumeModelProvider(),fetchAvailableModels:()=>this.fetchAvailableModels(),createCurrentModelId:(o,a,l)=>this.createModelId(o,a,l).toString(),getCollaborationMode:o=>this.getCollaborationMode(o),releaseFailedFork:n,forkCreated:i},u)}async loadSession(t,n,i){let r=await this.resolveSessionInstructions(t,i),u=Hs(t._meta),s=bs(t.cwd,t.additionalDirectories,t._meta),o=await this.createSessionConfig(t.cwd,s,t.mcpServers??[],t._meta),a=await this.resumeThreadWithInstructions({excludeTurns:!0,config:o.config,cwd:t.cwd,modelProvider:await this.getResumeModelProvider(),threadId:t.sessionId,...r?.text!==void 0?{developerInstructions:r.developerInstructions}:{}},t,i);n?.(),await this.worktreeProjects.backfill(a.thread,u);let l={...a.thread,turns:[]},c=DU();if(a.materialized&&a.thread.historyMode==="paginated")a.itemsBackwardsCursor!==null&&(c=this.codexClient.threadItemEntryPages(a.thread.id,{lastItemCursor:a.itemsBackwardsCursor}));else if(a.materialized){let v=(await this.codexClient.threadReadWithHistory(a.thread.id)).thread;l=v,c=c4((v.turns??[]).flatMap(g=>g.items.map(C=>({turnId:g.id,item:C,startedAtMs:null,completedAtMs:null}))))}let m=await this.fetchAvailableModels(),p=this.createModelId(m,a.model,a.reasoningEffort).toString();return{sessionId:t.sessionId,currentModelId:p,models:m,collaborationMode:a.collaborationMode??this.getCollaborationMode(a.thread.id),modelProvider:a.modelProvider,currentServiceTier:a.serviceTier??null,thread:l,history:c,additionalDirectories:s,skippedMcpServers:o.skippedMcpServers,...r?{instructions:r}:{}}}async readSessionThread(t){return await this.readSessionHistory(t)}async readSessionTurnItems(t,n){if((await this.codexClient.threadRead({threadId:t})).thread.historyMode==="legacy"){let o=(await this.codexClient.threadRead({threadId:t,includeTurns:!0})).thread.turns[n];return o?c4(o.items):null}let r=0,u=this.codexClient.threadTurnPages({threadId:t,limit:50,sortDirection:"asc",itemsView:"notLoaded"});for await(let s of u){let o=s[n-r];if(o)return this.codexClient.threadItemPages(t,{turnId:o.id});r+=s.length}return null}async readSubagentHistory(t){let{thread:n}=await this.codexClient.threadRead({threadId:t});if(n.id!==t)throw new Error("Subagent history metadata names a different thread");return{thread:n,items:n.historyMode==="legacy"?IU(this.codexClient,t):$U(this.codexClient,t)}}restoreSubagentSubscription(t,n,i){return this.subagents.restoreChild(t,n,i)}isSubagentThread(t){return this.subagents.isChildThread(t)}async newSession(t,n){let i=await this.resolveSessionInstructions(t,void 0,!0),r=bs(t.cwd,t.additionalDirectories,t._meta),u=i?.developerInstructions,s=Hs(t._meta),o=await this.worktreeProjects.resolve(s),a=await this.createSessionConfig(t.cwd,r,t.mcpServers??[],t._meta),l=await this.codexClient.threadStart({...o?{projectId:o}:{},config:a.config,modelProvider:this.getModelProvider(),cwd:t.cwd,...u!==void 0&&{developerInstructions:u}});await n?.(l.thread.id);let c=await this.fetchAvailableModels();if(c.length===0&&!this.isNarrowedByGateway())throw new Error("Codex did not return any models");let m=this.createModelId(c,l.model,l.reasoningEffort).toString();return{sessionId:l.thread.id,currentModelId:m,models:c,collaborationMode:this.getCollaborationMode(l.thread.id),modelProvider:l.modelProvider,currentServiceTier:l.serviceTier??null,additionalDirectories:r,skippedMcpServers:a.skippedMcpServers,...i?{instructions:i}:{}}}async resolveSessionInstructions(t,n,i=!1){let r=ei(t.systemPrompt);if(r===void 0){if(!i)return n;let o=td(t._meta);return o===void 0?void 0:{airInstructions:o,developerInstructions:o}}if(!Id(t,n))return n;let u=td(t._meta)??n?.airInstructions,s=u??this.config.developer_instructions??(await this.codexClient.configRead({cwd:t.cwd,includeLayers:!1}))?.config?.developer_instructions??"";if(typeof s!="string")throw k.invalidParams(void 0,"Configured developer instructions must be text");return{text:r,...u!==void 0?{airInstructions:u}:{},developerInstructions:[s,r].filter(o=>o.length>0).join(`
|
|
119
|
+
|
|
120
|
+
`)}}async resumeThreadWithInstructions(t,n,i){if(!Id(n,i))return this.resumeThread(t);let{thread:r}=await this.codexClient.threadRead({threadId:n.sessionId});if(r.status.type==="notLoaded")return this.resumeThread(t);if(r.status.type!=="idle"||r.path===null)throw k.invalidParams(void 0,"Changing systemPrompt requires an idle, persisted session; finish the turn or create a new session");if((await this.codexClient.threadBackgroundTerminalsList({threadId:n.sessionId,limit:1})).data.length>0)throw k.invalidParams(void 0,"Cannot change systemPrompt while background terminals are running");try{await this.codexClient.threadTurnsList({threadId:n.sessionId,limit:1,itemsView:"notLoaded"})}catch(c){throw!vi(c)&&!yO(c)?c:k.invalidParams(void 0,"Changing systemPrompt requires a persisted session; create a new session instead")}let s=!1,o=!1,a=!1,l=this.codexClient.onClientTransportEvent(c=>{c.eventType==="notification"&&c.method==="thread/status/changed"&&c.params.threadId===n.sessionId&&c.params.status.type==="notLoaded"&&(s=!0)});try{await this.codexClient.threadUnsubscribe({threadId:n.sessionId}),o=!0;let c=await this.resumeThread(t);if(a=!0,!s)throw k.invalidParams(void 0,"Codex kept the existing thread loaded; systemPrompt could not be changed. Retry when idle");return c}catch(c){throw o&&!a&&await this.resumeThread({threadId:n.sessionId,excludeTurns:!0}).catch(m=>{D.error(`Failed to restore session ${n.sessionId} after an instruction update`,m)}),c}finally{l()}}async closeSession(t){try{await this.codexClient.threadUnsubscribe({threadId:t})}finally{this.codexClient.clearThreadHandlers(t),this.subagents.clear(t)}}discardSessionSubscription(t){this.codexClient.clearThreadHandlers(t),this.subagents.clear(t)}async deleteSession(t){try{await this.codexClient.threadArchive({threadId:t})}catch(n){if(!pp(n))throw n;D.log("Delete request for a session Codex has no persisted thread for; treating as deleted",{sessionId:t,reason:n instanceof Error?n.message:String(n)})}}async renameSession(t,n){await this.codexClient.threadSetName({threadId:t,name:n})}async runReview(t,n,i,r,u){return await this.codexClient.runReview({threadId:t,target:n,delivery:"inline"},i,r,u)}async runCompact(t,n,i){return await this.codexClient.runCompact({threadId:t},n,i)}async getGoal(t){return(await this.codexClient.threadGoalGet({threadId:t}))?.goal??null}async setGoal(t,n,i,r,u){let s={threadId:t,objective:n,status:"active"};return r===void 0&&u===void 0?await this.codexClient.runGoalSet(s,i):await this.codexClient.runGoalSet(s,i,void 0,r,u)}async setGoalStatus(t,n){let i=null;if(await this.codexClient.runGoalSet({threadId:t,status:n},void 0,void 0,r=>{i=r}),i===null)throw new Error(`Goal update for session ${t} returned no goal`);return i}async resumeGoal(t,n,i,r){let u={threadId:t,status:"active"};return i===void 0&&r===void 0?await this.codexClient.runGoalSet(u,n):await this.codexClient.runGoalSet(u,n,void 0,i,r)}async clearGoal(t){await this.codexClient.runGoalClear({threadId:t})}async awaitMcpServerStartup(t,n,i){return await this.codexClient.mcpStartup.await(t,n,i)}getMcpServerStartupVersion(){return this.codexClient.mcpStartup.version()}async createSessionConfig(t,n,i,r){let u=await MN(this.codexClient,t);await this.refreshSkills(t,n);let s=[t,...n],o=this.gatewayConfig?{apiType:Ss(this.gatewayConfig),baseUrl:this.gatewayConfig.config.base_url}:this.getNativeProviderConfig();D.log("Creating session config",{projectPath:t,overrideActive:this.gatewayConfig!==null,modelProvider:this.getModelProvider(),apiType:o.apiType,baseUrl:o.baseUrl});let a={...lU(_U(SU(this.config,this.gatewayConfig))),...k2(r),projects:Object.fromEntries(s.map(v=>[v,{trust_level:v===t?u:"trusted"}]))},l=wU(a,n);if(i.length===0)return{config:l,skippedMcpServers:[]};let c=i.map(v=>({name:tD(nD(v)),server:v})),m=c;if(CU()){let v=await this.getConfigMcpServerNames(t);m=c.filter(g=>!v.has(g.name))}let p=c.filter(v=>!m.includes(v)).map(v=>v.name);return p.length>0&&D.log("Skipping requested MCP servers that the Codex config already defines",{projectPath:t,skippedMcpServers:p}),m.length===0?{config:l,skippedMcpServers:p}:{config:{...l,mcp_servers:Object.fromEntries(m.map(v=>[v.name,FN(TN(v.server))]))},skippedMcpServers:p}}async getConfigMcpServerNames(t){let n=await this.codexClient.configRead({includeLayers:!0,cwd:t}),i=n?.config?.mcp_servers,u=(n?.layers??[]).map(o=>Go(o.config)?o.config.mcp_servers:void 0),s=[i,...u].filter(Go);return s.length===0?new Set:new Set(s.flatMap(o=>Object.keys(o)))}getModelProvider(){return this.gatewayConfig?.modelProvider??this.modelProvider}async getResumeModelProvider(){return await this.getCurrentModelProvider()??"openai"}async refreshSkills(t,n){if(!t)return;let i=n.map(r=>Dd.join(r,".agents","skills"));bU(this.skillExtraRoots,i)||(await this.codexClient.skillsExtraRootsSet({extraRoots:i}),this.skillExtraRoots=i)}createModelId(t,n,i){let r=t.find(a=>a.id===n);if(r)return tt.create(r.id,i??r.defaultReasoningEffort);let u=t.find(a=>a.isDefault)??t[0],s=this.getGatewayListedModels();if(n&&u&&s!==null&&!Bd(n,s)){let a=u;D.log("The gateway does not list the model of the thread; using the default model",{model:n,defaultModel:a.id});let l=eu(a.supportedReasoningEfforts,i??void 0)??a.defaultReasoningEffort;return tt.create(a.id,l)}if(n)return tt.create(n,i??"medium");let o=t.find(a=>a.isDefault);if(!o)throw new Error(`Model selection failed: No model found for ID "${n}" and no default model is defined.`);return tt.create(o.id,i??o.defaultReasoningEffort)}async subscribeToSessionEvents(t,n,i,r,u,s,o,a,l){let c=m=>{this.enqueueSessionNotification(t,()=>n(m))};this.subagents.subscribe({rootSessionId:t,supportsSubagents:u,dispatch:c,enqueueInteraction:m=>{this.enqueueSessionNotification(t,()=>s(m))},approvalHandler:i,elicitationHandler:r,waitForRootNotifications:()=>this.waitForSessionNotifications(t),waitForChildSession:o,...a?{withUserAction:a}:{},...l?{observeWorkEnd:l}:{}})}redispatchSessionNotifications(t,n,i){this.subagents.redispatch(t,n),i&&this.enqueueSessionNotification(t,i)}enqueueSessionTransition(t,n){return new Promise((i,r)=>{this.enqueueSessionNotification(t,async()=>{try{await n(),i()}catch(u){r(u)}})})}async waitForSessionNotifications(t){for(;;){let n=this.sessionNotificationQueues.get(t);if(!n)return;await n}}onConnectionClosed(t){return this.codexClient.connectionLoss.onLost(t)}enqueueSessionNotification(t,n){let i=async()=>{try{await n()}catch(s){D.error("Error handling Codex session notification",s)}},r=this.sessionNotificationQueues.get(t),u=r?r.then(i,i):i();this.sessionNotificationQueues.set(t,u),u.finally(()=>{this.sessionNotificationQueues.get(t)===u&&this.sessionNotificationQueues.delete(t)})}async sendPrompt(t,n,i,r,u,s,o,a,l,c){let m=a4(t.prompt),p=i.effort;if(await this.refreshSkills(s,o),l?.())return null;let v={threadId:t.sessionId,input:m,approvalPolicy:n.approvalPolicy,approvalsReviewer:n.approvalsReviewer,sandboxPolicy:AU(n.sandboxPolicy,o),summary:u?"none":"auto",effort:p,model:i.model,serviceTier:r,...c!==void 0?{clientUserMessageId:c}:{}};return await this.codexClient.runTurn(v,a)}async setCollaborationMode(t,n,i){await this.codexClient.threadSettingsUpdate({threadId:t,collaborationMode:VM(n,i)})}getCollaborationMode(t){return this.codexClient.getThreadSettings(t)?.collaborationMode.mode??"default"}resolveTurnInterrupted(t){this.codexClient.resolveTurnInterrupted(t.threadId,t.turnId)}markTurnStale(t){this.codexClient.markTurnStale(t.threadId,t.turnId)}async listSkills(t){return cU(await this.codexClient.listSkills(t??{}))}async awaitNextLoginCompleted(){if(this.pendingLoginCompleted!==null)return await this.pendingLoginCompleted;this.pendingLoginCompleted=this.awaitSingleNotification("account/login/completed",t=>t);try{return await this.pendingLoginCompleted}finally{this.pendingLoginCompleted=null}}async awaitNextAccountUpdated(){if(this.pendingAccountUpdated!==null)return await this.pendingAccountUpdated;this.pendingAccountUpdated=this.awaitSingleNotification("account/updated",t=>t);try{return await this.pendingAccountUpdated}finally{this.pendingAccountUpdated=null}}async awaitSingleNotification(t,n){let i,r=new Promise(u=>{i=this.codexClient.connection.onNotification(t,s=>{i?.dispose(),u(n(s))})});return await this.codexClient.waitWhileConnected(t,r,()=>i?.dispose())}async listMcpServers(t){return this.codexClient.listMcpServerStatus(t)}async reloadMcpServers(){await this.codexClient.mcpServerReload()}async mcpServerOauthLogin(t){return await this.codexClient.mcpServerOauthLogin(t)}async awaitMcpServerOauthLoginCompleted(t,n,i){return await this.codexClient.mcpOauthCompletions.await(t,n,i)}async listSessions(t){let n=["cli","vscode","appServer","unknown"],i=t.cwd?.trim()??null,r=c=>i?qo(i)?HM(c.cwd,i):pD(c.cwd,i):!0,u=this.getModelProvider(),s=u?[u]:[],o=await this.codexClient.threadList({cursor:t.cursor??null,limit:fU,sortKey:"updated_at",sortDirection:"desc",modelProviders:s,sourceKinds:n,...i&&Dd.isAbsolute(i)?{cwd:i}:{},useStateDbOnly:!0}),a=c=>({sessionId:c.id,cwd:c.cwd,title:rS(c),updatedAt:new Date(c.updatedAt*1e3).toISOString()});if(o.data.length===0&&!i){let c=await this.runSessionListDiagnostics();D.log("Session list diagnostics",c)}let l=o.data.map(a);if(i){let c=o.data.filter(r).map(a);c.length>0||qo(i)?l=c:D.log("Ignoring non-absolute cwd filter for session/list",{cwd:i})}return{sessions:l,nextCursor:o.nextCursor??null}}async turnInterrupt(t){await this.codexClient.turnInterrupt({threadId:t.threadId,turnId:t.turnId})}async steerTurn(t){return await this.codexClient.turnSteer({threadId:t.threadId,expectedTurnId:t.turnId,input:a4(t.prompt),clientUserMessageId:t.steerId})}async fetchAvailableModels(){let t=[],n=null;do{let r=await this.codexClient.listModels({cursor:n,limit:null});t.push(...r.data),n=r.nextCursor}while(n);let i=this.getGatewayListedModels();return i===null?t:aU(t,i)}getGatewayListedModels(){return this.gatewayConfigSource==="acpProviders"?this.gatewayConfig?.listedModels??null:null}isNarrowedByGateway(){return this.getGatewayListedModels()!==null}async runSessionListDiagnostics(){let[t,n,i]=await Promise.all([this.codexClient.threadList({}),this.codexClient.threadList({archived:!0}),this.codexClient.threadList({modelProviders:[kd]})]);return{allProviders:{count:t.data.length,nextCursor:t.nextCursor??null},archivedAllProviders:{count:n.data.length,nextCursor:n.nextCursor??null},customGateway:{count:i.data.length,nextCursor:i.nextCursor??null}}}};function a4(e){return e.map(t=>{switch(t.type){case"text":return{type:"text",text:t.text,text_elements:[]};case"image":return{type:"image",url:vU(t.uri)?t.uri:mU(t)};case"resource_link":return{type:"text",text:vc(t.name,t.uri),text_elements:[]};case"resource":{let n=t.resource;if("text"in n){let s=vc(null,n.uri),o=`<context ref="${n.uri}">
|
|
121
|
+
${n.text}
|
|
122
|
+
</context>`;return{type:"text",text:`${s}
|
|
123
|
+
${o}`,text_elements:[]}}if(gU(n.mimeType))return{type:"image",url:`data:${n.mimeType};base64,${n.blob}`};let i=vc(null,n.uri),r=n.mimeType??"application/octet-stream",u=`<context ref="${n.uri}" mimeType="${r}" encoding="base64">
|
|
124
|
+
${n.blob}
|
|
125
|
+
</context>`;return{type:"text",text:`${i}
|
|
126
|
+
${u}`,text_elements:[]}}case"audio":return null}}).filter(t=>t!==null)}function mU(e){return`data:${e.mimeType};base64,${e.data}`}function gU(e){return e?.startsWith("image/")??!1}function vU(e){if(!e)return!1;try{let t=new URL(e).protocol;return t==="http:"||t==="https:"||t==="data:"}catch{return!1}}function vc(e,t){if(e&&e.length>0)return`[@${e}](${t})`;if(t.startsWith("file://")){let n=t.replace("file://","");return`[@${n.split("/").pop()??n}](${t})`}return t}function CU(){return!(process.env.DISABLE_MCP_CONFIG_FILTERING==="true")}function l4(e){let t=e.apiType,n=Wo[t];if(!n)throw k.invalidParams({apiType:t},`Unsupported provider apiType "${t}"; supported: ${Object.keys(Wo).join(", ")}`);if(typeof e.baseUrl!="string"||e.baseUrl.trim().length===0)throw k.invalidParams(void 0,"baseUrl must be a non-empty string");let i=typeof e.providerName=="string"&&e.providerName.trim().length>0?e.providerName:"User-provided gateway",r={"X-Client-Feature-ID":"codex",...e.headers};return{modelProvider:kd,config:{name:i,base_url:e.baseUrl,http_headers:r,wire_api:n},listedModels:null}}function yU(e,t){let n=Object.entries(e.config.http_headers),i=t.config.http_headers;return e.config.base_url===t.config.base_url&&e.config.wire_api===t.config.wire_api&&n.length===Object.keys(i).length&&n.every(([r,u])=>i[r]===u)}function EU(e){let t=e?.additionalRoots;if(Array.isArray(t))return _p(t.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0))}function bs(e,t,n){let i=t??EU(n);if(!i)return[];let r=[],u=new Set([e]);for(let s of i){if(typeof s!="string")throw k.invalidParams(void 0,"additionalDirectories entries must be strings");if(s.length===0)throw k.invalidParams(void 0,"additionalDirectories entries must not be empty");if(!Dd.isAbsolute(s))throw k.invalidParams(void 0,"additionalDirectories entries must be absolute paths");u.has(s)||(u.add(s),r.push(s))}return r}function wU(e,t){if(t.length===0)return e;let n=Go(e.sandbox_workspace_write)?e.sandbox_workspace_write:{},i=Array.isArray(n.writable_roots)?n.writable_roots.filter(r=>typeof r=="string"):[];return{...e,sandbox_workspace_write:{...n,writable_roots:_p([...i,...t])}}}function _U(e){let t=Go(e.features)?e.features:{};return{...e,features:{...t,cwd_relative_turn_diffs:!1}}}function AU(e,t){return t.length===0||e.type!=="workspaceWrite"?e:{...e,writableRoots:_p([...e.writableRoots,...t])}}function _p(e){return Array.from(new Set(e))}function bU(e,t){return e.length!==t.length?!1:e.every((n,i)=>n===t[i])}function Go(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ss(e){let t=e.config.wire_api;return Object.entries(Wo).find(([,i])=>i===t)?.[0]??"openai"}function SU(e,t){if(t!==null){let n={...e};return!n.model_providers||typeof n.model_providers!="object"?n.model_providers={}:n.model_providers={...n.model_providers},n.model_providers[t.modelProvider]=t.config,n}else return e}async function*DU(){}async function*c4(e){e.length>0&&(yield e)}async function*IU(e,t){let{thread:n}=await e.threadRead({threadId:t,includeTurns:!0});if(n.id!==t)throw new Error("Subagent history names a different thread");yield n.turns.flatMap(r=>r.items.map(u=>({item:u,turnId:r.id,completed:CD(u,r.status!=="inProgress")})));let i=n.turns.at(-1);i&&(yield[{turn:i}])}async function*$U(e,t){for await(let n of e.threadItemEntryPages(t))yield n.map(({item:i,turnId:r,completedAtMs:u})=>({item:i,turnId:r,completed:CD(i,u!==null)}));try{let{data:n}=await e.threadTurnsList({threadId:t,limit:1,sortDirection:"desc",itemsView:"notLoaded"});n[0]&&(yield[{turn:n[0]}])}catch(n){D.error(`Failed to read recorded outcome for subagent ${t}`,n),yield[{turn:null}]}}function CD(e,t){switch(e.type){case"commandExecution":case"fileChange":case"mcpToolCall":case"dynamicToolCall":case"collabAgentToolCall":return e.status!=="inProgress";default:return t}}var os=Sn(Sr(),1),yi=class extends Error{constructor(e){super(`The connection to the Codex app-server was lost while waiting for ${e}.`),this.name="AppServerConnectionLostError"}},BU=class{isLost=!1;listeners=new Set;constructor(e){let t=()=>this.lose();e.onClose?.(t),e.onDispose?.(t)}get lost(){return this.isLost}onLost(e){return this.isLost?(e(),()=>{}):(this.listeners.add(e),()=>{this.listeners.delete(e)})}lose(){if(this.isLost)return;this.isLost=!0;let e=[...this.listeners];this.listeners.clear();for(let t of e)t()}},d4=Sn(Sr(),1);function kU(e,t){for(let n of PU){let i=n(e,t);if(i!==null)return RU(e,i)}return e}function xU(e){return e.message.includes("log out")||e.message.includes("cloud requirements")}var xd="failed to resolve feature override precedence: ",yD="failed to load configuration: ",TU=({message:e})=>!(e.startsWith(xd)||e.startsWith(yD))||!e.includes("No such file or directory")||!zU()?null:`Codex cannot read its configuration: its working directory ${ED} was deleted or replaced after the agent started. Restart the agent.`,FU=(e,{codexHome:t})=>{if(xU(e))return null;let n=e.message.startsWith(xd)?yD+e.message.slice(xd.length):e.message;return n.includes("load config")?`${n}
|
|
127
|
+
|
|
128
|
+
Check ${t??"global"} and project .codex directories, especially their config.toml files, or any CODEX_CONFIG override.`:null},PU=[TU,FU];function RU(e,t){return e instanceof d4.ResponseError?new d4.ResponseError(e.code,t,e.data):new Error(t,{cause:e})}var ED=(()=>{try{return process.cwd()}catch{return""}})();function zU(){try{let e=h4("."),t=h4(ED);return e.ino!==t.ino||e.dev!==t.dev}catch{return!0}}var OU=class{waiters=new Map;closedError=null;complete(e){for(let t of[...this.waiters.get(e.name)??[]])(e.threadId===null||e.threadId===t.threadId)&&t.resolve(e)}async await(e,t,n){if(n?.throwIfAborted(),this.closedError!==null)throw this.closedError;return await new Promise((i,r)=>{let u=()=>o.reject(n?.reason),s=()=>{let l=this.waiters.get(e);l?.delete(o),l?.size===0&&this.waiters.delete(e),n?.removeEventListener("abort",u)},o={threadId:t,resolve:l=>{s(),i(l)},reject:l=>{s(),r(l)}};n?.addEventListener("abort",u,{once:!0});let a=this.waiters.get(e);a===void 0&&(a=new Set,this.waiters.set(e,a)),a.add(o)})}dispose(){this.closedError??=new Error("Codex connection closed during the MCP server sign-in.");for(let e of[...this.waiters.values()])for(let t of[...e])t.reject(this.closedError)}},NU=class{currentVersion=0;states=new Map;waiters=[];closedError=null;version(){return this.currentVersion}record(e){this.currentVersion+=1;let t=this.states.get(e.name);t===void 0&&(t=new Map,this.states.set(e.name,t)),t.set(e.threadId??null,{status:e.status,error:e.error,failureReason:e.failureReason??null,version:this.currentVersion});for(let n of[...this.waiters]){let i=this.tryBuildResult(n.serverNames,n.afterVersion,n.threadId);i!==null&&n.resolve(i)}}async await(e,t,n){let i=Array.from(new Set(e.map(o=>o.trim()).filter(o=>o.length>0)));if(i.length===0)return{ready:[],failed:[],cancelled:[]};let{threadId:r,signal:u}=n,s=this.tryBuildResult(i,t,r);if(s!==null)return s;if(u?.throwIfAborted(),this.closedError!==null)throw this.closedError;return await new Promise((o,a)=>{let l=()=>m.reject(u?.reason),c=()=>{let p=this.waiters.indexOf(m);p>=0&&this.waiters.splice(p,1),u?.removeEventListener("abort",l)},m={serverNames:i,afterVersion:t,threadId:r,resolve:p=>{c(),o(p)},reject:p=>{c(),a(p)}};u?.addEventListener("abort",l,{once:!0}),this.waiters.push(m)})}forgetThread(e){for(let[t,n]of this.states)n.delete(e),n.size===0&&this.states.delete(t)}dispose(){this.closedError??=new Error("Codex connection closed during the MCP server startup.");for(let e of[...this.waiters])e.reject(this.closedError)}latestState(e,t){let n;for(let[i,r]of this.states.get(e)??[])i!==null&&i!==t||(n===void 0||r.version>n.version)&&(n=r);return n}tryBuildResult(e,t,n){let i=[],r=[],u=[];for(let s of e){let o=this.latestState(s,n);if(!o||o.version<=t)return null;switch(o.status){case"starting":return null;case"ready":i.push(s);break;case"failed":r.push({server:s,error:o.error??"unknown MCP startup error",...o.failureReason===null?{}:{failureReason:o.failureReason}});break;case"cancelled":u.push(s);break}}return{ready:i,failed:r,cancelled:u}}},MU=new os.RequestType("item/commandExecution/requestApproval"),UU=new os.RequestType("item/fileChange/requestApproval"),jU=new os.RequestType("item/permissions/requestApproval"),LU=new os.RequestType("mcpServer/elicitation/request"),qU=new os.RequestType("item/tool/requestUserInput"),ZU=1e3,Ap=class{connection;approvalHandlers=new Map;elicitationHandlers=new Map;pendingTurnCompletionResolvers=new Map;pendingCompactTurns=new Map;mcpStartup=new NU;mcpOauthCompletions=new OU;turnCompletionCaptures=new Map;turnStartCaptures=new Set;turnRoutingCaptures=new Map;threadStatusCaptures=new Map;threadGoalUpdateCaptures=new Map;threadGoalClearedCaptures=new Map;threadSettings=new Map;tokenUsage=new Map;staleTurnIds=new Map;runningTurnIds=new Map;connectionLoss;turnCompletionTerminalError=null;codexHome=null;constructor(e){this.connection=e,this.connectionLoss=new BU(e),this.connection.onClose?.(()=>this.disposeMcpWaits()),this.connection.onDispose?.(()=>this.disposeMcpWaits());let t=()=>{let n=new yi("the end of the turn");this.rejectAllPendingTurnCompletions(n)};this.connection.onClose?.(t),this.connection.onDispose?.(t),this.connection.onUnhandledNotification(n=>{let i=n;if(i.method==="thread/tokenUsage/updated"&&this.tokenUsage.set(i.params.threadId,i.params),GU(i)&&this.mcpStartup.record(i.params),i.method==="mcpServer/oauthLogin/completed"&&this.mcpOauthCompletions.complete(i.params),f4(i)){i.params.turn.status!=="inProgress"&&this.runningTurnIds.get(i.params.threadId)===i.params.turn.id&&this.runningTurnIds.delete(i.params.threadId);let u=this.pendingCompactTurns.get(i.params.threadId);u?.turnId===i.params.turn.id&&u.resolve(i.params),this.recordTurnCompleted(i.params)}if(i.method==="turn/started"){let u=this.pendingCompactTurns.get(i.params.threadId);u&&u.turnId===null&&(u.turnId=i.params.turn.id,u.onTurnStarted?.(u.turnId)),this.runningTurnIds.set(i.params.threadId,i.params.turn.id),this.recordTurnStarted(i.params.threadId,i.params.turn.id)}VU(i)&&this.recordThreadStatusChanged(i.params),HU(i)&&this.recordThreadGoalUpdated(i.params),JU(i)&&this.recordThreadGoalCleared(i.params),i.method==="thread/settings/updated"&&this.threadSettings.set(i.params.threadId,i.params.threadSettings);let r=KU(i);if(!this.handleStaleTurnNotification(i,r)&&(this.recordTurnRouting(r,i),!this.handleStaleTurnNotification(i,r))){this.notify(i);for(let u of this.codexEventHandlers)u({eventType:"notification",...i})}}),this.connection.onRequest(MU,async n=>{if(this.isStaleTurn(n.threadId,n.turnId))return{decision:"cancel"};let i=this.approvalHandlers.get(n.threadId);return i?await i.handleCommandExecution(n):{decision:"cancel"}}),this.connection.onRequest(UU,async n=>{if(this.isStaleTurn(n.threadId,n.turnId))return{decision:"cancel"};let i=this.approvalHandlers.get(n.threadId);return i?await i.handleFileChange(n):{decision:"cancel"}}),this.connection.onRequest(jU,async n=>{if(this.isStaleTurn(n.threadId,n.turnId))return{permissions:{},scope:"turn",strictAutoReview:!1};let i=this.approvalHandlers.get(n.threadId);return i?await i.handlePermissionsRequest(n):{permissions:{},scope:"turn",strictAutoReview:!1}}),this.connection.onRequest(LU,async n=>{if(this.isStaleTurn(n.threadId,n.turnId))return{action:"cancel",content:null,_meta:null};let i=this.elicitationHandlers.get(n.threadId);return i?await i.handleElicitation(n):{action:"cancel",content:null,_meta:null}}),this.connection.onRequest(qU,async n=>{if(this.isStaleTurn(n.threadId,n.turnId))return{answers:{}};let i=this.elicitationHandlers.get(n.threadId);return i?await i.handleUserInput(n):{answers:{}}})}onApprovalRequest(e,t){this.approvalHandlers.set(e,t)}onElicitationRequest(e,t){this.elicitationHandlers.set(e,t)}clearThreadHandlers(e){this.tokenUsage.delete(e),this.notificationHandlers.delete(e),this.approvalHandlers.delete(e),this.elicitationHandlers.delete(e)}async initialize(e){let t=await this.sendRequest({method:"initialize",params:e});return this.codexHome=t?.codexHome??null,t}async turnStart(e){return await this.sendRequest({method:"turn/start",params:e})}async runTurn(e,t){let n=[],i=this.captureTurnCompletions(e.threadId,r=>{n.push(r)});try{let r=await this.turnStart(e);t?.(r.turn.id);let u=n.find(o=>o.turn.id===r.turn.id);if(u)return u;let s=this.awaitTurnCompleted(e.threadId,r.turn.id);return i(),await s}finally{i()}}async runReview(e,t,n,i){let r=[],u=null,s=null,o=[],a=new Set,l=[],c=[],m=A=>{r.push(A)},p=(A,S)=>{let z=`${A}\0${S}`;if(a.has(z))return;a.add(z);let M={threadId:A,turnId:S};if(u===null){o.push(M);return}A===u&&S!==s&&t?.(S,A)};l.push(this.captureTurnCompletions(e.threadId,m)),c.push(this.captureTurnStarts(p));let v=new Set,g=new Map,C=()=>{},y=new Promise((A,S)=>{C=S});y.catch(()=>{});let b=this.captureTurnRoutings(e.threadId,(A,S)=>{if((S.method==="item/started"||S.method==="item/completed")&&S.params.item.type==="enteredReviewMode"&&v.add(A),S.method==="error"&&!S.params.willRetry&&!v.has(A)){let z=new Error(S.params.error.message);g.set(A,z),A===s&&C(z)}});try{let A=await this.reviewStart(e);n?.(),u=A.reviewThreadId,s=A.turn.id,i?.(s);let S=g.get(s);if(S)throw S;u!==e.threadId&&l.push(this.captureTurnCompletions(u,m));for(let T of o)T.threadId===u&&T.turnId!==s&&t?.(T.turnId,T.threadId);let z=r.find(T=>T.threadId===u&&T.turn.id===s);if(z)return z;let M=this.awaitTurnCompleted(A.reviewThreadId,A.turn.id);return await Promise.race([M,y])}finally{b();for(let A of l)A();for(let A of c)A()}}async runGoalSet(e,t,n=ZU,i,r){let u=null,s=[],o=()=>{},a=new Promise(T=>{o=T}),l=this.captureTurnCompletions(e.threadId,T=>{s.push(T),u===T.turn.id&&o(T)}),c=()=>{},m=new Promise(T=>{c=T}),p=()=>{},v=new Promise(T=>{p=()=>T(null)}),g=!1,C=null,y=this.createNoGoalTurnStartedPromise(n),b=[],A=this.captureTurnRoutings(e.threadId,T=>{!g||u!==null||(u=T,t?.(T),c(T))}),S=this.captureThreadGoalUpdates(e.threadId,T=>{b.push(T),C!==null&&p4(T.goal,C)&&(g=!0,p(),y.goalUpdated())}),z=this.captureThreadStatuses(e.threadId,T=>{!g||u!==null||y.threadStatusChanged(T)}),M=T=>this.waitWhileConnected("the goal update",T);try{let T=await this.threadGoalSet(e);if(r?.(),C=T.goal,i?.(C),b.some(Z=>p4(Z.goal,C))&&(g=!0,p(),y.goalUpdated()),C.status!=="active")return await M(v),null;let G=u??await M(Promise.race([m,y.promise]));if(y.release(),A(),z(),S(),G===null)return null;let re=s.find(Z=>Z.turn.id===G);return re||await M(a)}finally{y.release(),l(),A(),z(),S()}}async runGoalClear(e){let t=!1,n=()=>{},i=new Promise(u=>{n=()=>u()}),r=this.captureThreadGoalClears(e.threadId,()=>{t=!0,n()});try{if(!(await this.threadGoalClear(e)).cleared||t)return;await this.waitWhileConnected("the goal clear",i)}finally{r()}}createNoGoalTurnStartedPromise(e){let t=!1,n=!1,i=!1,r=!1,u=null,s=()=>{},o=()=>{u!==null&&(clearTimeout(u),u=null)},a=()=>{t||n||(n=!0,o(),s())},l=()=>{t||n||!i||r||u!==null||(u=setTimeout(a,e))},c=()=>{t||(t=!0,o())};return{promise:new Promise(g=>{s=()=>{g(null)}}),release:c,goalUpdated:()=>{i=!0,l()},threadStatusChanged:g=>{if(!(!i||t||n)){if(g.type==="active"){r=!0,o();return}r&&a()}}}}async runCompact(e,t,n){if(this.turnCompletionTerminalError)throw this.turnCompletionTerminalError;if(this.pendingCompactTurns.has(e.threadId))throw new Error("A compaction request already owns this thread");let i=new Promise((r,u)=>{this.pendingCompactTurns.set(e.threadId,{turnId:null,onTurnStarted:t,resolve:r,reject:u})});try{let[,r]=await Promise.all([this.threadCompactStart(e).then(u=>(n?.(),u)),i]);return r}finally{this.pendingCompactTurns.delete(e.threadId)}}async turnInterrupt(e){return await this.sendRequest({method:"turn/interrupt",params:e})}async turnSteer(e){return await this.sendRequest({method:"turn/steer",params:e})}async reviewStart(e){return await this.sendRequest({method:"review/start",params:e})}markTurnStale(e,t){let n=this.staleTurnIds.get(e)??new Set;n.add(t),this.staleTurnIds.set(e,n)}async projectCreate(e){return await this.sendRequest({method:"project/create",params:e})}async threadProjectUpdate(e){await this.sendRequest({method:"thread/metadata/update",params:e})}getThreadTokenUsage(e){return this.tokenUsage.get(e)}async threadStart(e){return await this.sendRequest({method:"thread/start",params:e})}async threadSetName(e){return await this.sendRequest({method:"thread/name/set",params:e})}async threadResume(e){return await this.sendRequest({method:"thread/resume",params:e})}async threadFork(e){return await this.sendRequest({method:"thread/fork",params:e})}getThreadSettings(e){return this.threadSettings.get(e)}async threadSettingsUpdate(e){await this.connection.sendRequest("thread/settings/update",e)}async threadList(e){return await this.sendRequest({method:"thread/list",params:e})}async threadLoadedList(e){return await this.sendRequest({method:"thread/loaded/list",params:e})}async threadRead(e){return await this.sendRequest({method:"thread/read",params:e})}async threadTurnsList(e){return await this.sendRequest({method:"thread/turns/list",params:e})}async threadItemsList(e){return await this.sendRequest({method:"thread/items/list",params:e})}threadTurnPages({threadId:e,...t}){return g4(e,"thread/turns/list",n=>this.threadTurnsList({threadId:e,cursor:n,...t}))}async*threadItemPages(e,t={}){for await(let n of this.threadItemEntryPages(e,t))yield n.map(i=>i.item)}async*threadItemEntryPages(e,t={}){let n=t.turnId??null,r=(await Td(this.threadItemsList({threadId:e,turnId:n,cursor:t.lastItemCursor??null,limit:1,sortDirection:"desc"}),"thread/items/list",e)).data[0]?.item.id;if(r===void 0)return;let u=g4(e,"thread/items/list",s=>this.threadItemsList({threadId:e,turnId:n,cursor:s,limit:YU,sortDirection:"asc"}),s=>s.some(o=>o.item.id===r));for await(let s of u){let a=s.findIndex(l=>l.item.id===r);if(a>=0){yield s.slice(0,a+1);return}yield s}}async threadReadWithHistory(e){let t=await this.threadRead({threadId:e});if(t.thread.historyMode==="legacy")return await this.threadRead({threadId:e,includeTurns:!0});let n=[];for await(let i of this.threadHistoryPages(e))n.push(...i);return{...t,thread:{...t.thread,turns:n}}}async*threadHistoryPages(e){let n=(await Td(this.threadTurnsList({threadId:e,cursor:null,limit:1,sortDirection:"desc",itemsView:"notLoaded"}),"thread/turns/list",e)).data[0]?.id;if(n===void 0)return;let i=this.threadTurnPages({threadId:e,limit:XU,sortDirection:"asc",itemsView:"full"});for await(let r of i){let u=r.findIndex(s=>s.id===n);if(u>=0){yield r.slice(0,u+1);return}yield r}}async threadReadHistory(e,t=null){let n=[],i=new Set;t!==null&&i.add(t);let r=t;do{let u=await this.threadTurnsList({threadId:e,cursor:r,limit:50,sortDirection:"desc",itemsView:"full"});if(n.push(...u.data),r=u.nextCursor,r!==null){if(i.has(r))throw new Error("Codex returned a repeated thread history cursor");i.add(r)}}while(r!==null);return n.reverse()}async threadArchive(e){return await this.sendRequest({method:"thread/archive",params:e})}async threadUnarchive(e){return await this.sendRequest({method:"thread/unarchive",params:e})}async threadDelete(e){return await this.sendRequest({method:"thread/delete",params:e})}async threadUnsubscribe(e){return await this.sendRequest({method:"thread/unsubscribe",params:e})}async threadCompactStart(e){return await this.sendRequest({method:"thread/compact/start",params:e})}async threadBackgroundTerminalsList(e){return await this.sendRequest({method:"thread/backgroundTerminals/list",params:e})}async threadBackgroundTerminalsTerminate(e){return await this.sendRequest({method:"thread/backgroundTerminals/terminate",params:e})}async threadGoalSet(e){return await this.sendRequest({method:"thread/goal/set",params:e})}async threadGoalGet(e){return await this.sendRequest({method:"thread/goal/get",params:e})}async threadGoalClear(e){return await this.sendRequest({method:"thread/goal/clear",params:e})}async listMcpServerStatus(e){return await this.sendRequest({method:"mcpServerStatus/list",params:e})}async mcpServerReload(){return await this.sendRequest({method:"config/mcpServer/reload",params:void 0})}async mcpServerOauthLogin(e){return await this.sendRequest({method:"mcpServer/oauth/login",params:e})}async accountLogin(e){return await this.sendRequest({method:"account/login/start",params:e})}async accountLoginCancel(e){return await this.sendRequest({method:"account/login/cancel",params:e})}async accountLogout(){return await this.sendRequest({method:"account/logout",params:void 0})}async configRead(e){return await this.sendRequest({method:"config/read",params:e})}async hooksList(e){return await this.sendRequest({method:"hooks/list",params:e})}async configBatchWrite(e){return await this.sendRequest({method:"config/batchWrite",params:e})}async accountRead(e){return await this.sendRequest({method:"account/read",params:e})}async accountRateLimitsRead(){return await this.sendRequest({method:"account/rateLimits/read",params:void 0})}async awaitTurnCompleted(e,t){if(this.turnCompletionTerminalError)throw this.turnCompletionTerminalError;return await new Promise((n,i)=>{this.getOrCreatePendingTurnCompletionResolvers(e).set(t,{resolve:n,reject:i})})}waitWhileConnected(e,t,n=()=>{}){return new Promise((i,r)=>{let u=!1,s=()=>u?!1:(u=!0,o(),n(),!0),o=()=>{};o=this.connectionLoss.onLost(()=>{s()&&r(new yi(e))}),t.then(a=>{s()&&i(a)},a=>{s()&&r(a)})})}resolveTurnInterrupted(e,t){this.recordTurnCompleted({threadId:e,turn:{id:t,rootTurnId:null,items:[],itemsView:"notLoaded",status:"interrupted",error:null,startedAt:null,completedAt:null,durationMs:null}})}async listModels(e){return await this.sendRequest({method:"model/list",params:e})}async skillsExtraRootsSet(e){return await this.sendRequest({method:"skills/extraRoots/set",params:e})}async listSkills(e){return await this.sendRequest({method:"skills/list",params:e})}onServerNotification(e,t){this.notificationHandlers.set(e,t)}codexEventHandlers=[];onClientTransportEvent(e){return this.codexEventHandlers.push(e),()=>{let t=this.codexEventHandlers.indexOf(e);t!==-1&&this.codexEventHandlers.splice(t,1)}}notificationHandlers=new Map;notify(e){let t=wD(e);if(t!==null){let n=this.notificationHandlers.get(t);n&&n(e);return}for(let n of this.notificationHandlers.values())n(e)}runningTurnId(e){return this.runningTurnIds.get(e)}recordTurnCompleted(e){if(this.pendingTurnCompletionResolvers.get(e.threadId)?.get(e.turn.id)){this.resolvePendingTurnCompletion(e.threadId,e.turn.id,e);return}let i=this.turnCompletionCaptures.get(e.threadId);if(i)for(let r of i)r(e)}resolvePendingTurnCompletion(e,t,n){let i=this.pendingTurnCompletionResolvers.get(e),r=i?.get(t);return r?(i.delete(t),i.size===0&&this.pendingTurnCompletionResolvers.delete(e),r.resolve(n),!0):!1}recordTurnStarted(e,t){for(let n of this.turnStartCaptures)n(e,t)}recordThreadStatusChanged(e){let t=this.threadStatusCaptures.get(e.threadId);if(t)for(let n of t)n(e.status)}recordThreadGoalUpdated(e){let t=this.threadGoalUpdateCaptures.get(e.threadId);if(t)for(let n of t)n(e)}recordThreadGoalCleared(e){let t=this.threadGoalClearedCaptures.get(e.threadId);if(t)for(let n of t)n()}recordTurnRouting(e,t){if(e.threadId===null||e.turnId===null)return;let n=this.turnRoutingCaptures.get(e.threadId);if(n)for(let i of n)i(e.turnId,t)}handleStaleTurnNotification(e,t){if(!this.isStaleTurn(t.threadId,t.turnId))return!1;f4(e)&&t.threadId!==null&&t.turnId!==null&&this.clearStaleTurn(t.threadId,t.turnId);for(let n of this.codexEventHandlers)n({eventType:"notification",...e});return!0}isStaleTurn(e,t){return e===null||t===null?!1:this.staleTurnIds.get(e)?.has(t)??!1}clearStaleTurn(e,t){let n=this.staleTurnIds.get(e);n&&(n.delete(t),n.size===0&&this.staleTurnIds.delete(e))}getOrCreatePendingTurnCompletionResolvers(e){let t=this.pendingTurnCompletionResolvers.get(e);if(t)return t;let n=new Map;return this.pendingTurnCompletionResolvers.set(e,n),n}rejectAllPendingTurnCompletions(e){this.turnCompletionTerminalError??=e;for(let n of this.pendingCompactTurns.values())n.reject(e);this.pendingCompactTurns.clear();let t=[...this.pendingTurnCompletionResolvers.values()];this.pendingTurnCompletionResolvers.clear();for(let n of t)for(let i of n.values())i.reject(e)}captureTurnCompletions(e,t){let n=this.turnCompletionCaptures.get(e)??new Set;n.add(t),this.turnCompletionCaptures.set(e,n);let i=!1;return()=>{i||(i=!0,n.delete(t),n.size===0&&this.turnCompletionCaptures.delete(e))}}captureTurnStarts(e){this.turnStartCaptures.add(e);let t=!1;return()=>{t||(t=!0,this.turnStartCaptures.delete(e))}}captureTurnRoutings(e,t){let n=this.turnRoutingCaptures.get(e)??new Set;n.add(t),this.turnRoutingCaptures.set(e,n);let i=!1;return()=>{i||(i=!0,n.delete(t),n.size===0&&this.turnRoutingCaptures.delete(e))}}captureThreadStatuses(e,t){let n=this.threadStatusCaptures.get(e)??new Set;n.add(t),this.threadStatusCaptures.set(e,n);let i=!1;return()=>{i||(i=!0,n.delete(t),n.size===0&&this.threadStatusCaptures.delete(e))}}captureThreadGoalUpdates(e,t){let n=this.threadGoalUpdateCaptures.get(e)??new Set;n.add(t),this.threadGoalUpdateCaptures.set(e,n);let i=!1;return()=>{i||(i=!0,n.delete(t),n.size===0&&this.threadGoalUpdateCaptures.delete(e))}}captureThreadGoalClears(e,t){let n=this.threadGoalClearedCaptures.get(e)??new Set;n.add(t),this.threadGoalClearedCaptures.set(e,n);let i=!1;return()=>{i||(i=!0,n.delete(t),n.size===0&&this.threadGoalClearedCaptures.delete(e))}}disposeMcpWaits(){this.mcpStartup.dispose(),this.mcpOauthCompletions.dispose()}threadLoads=new Map;threadLoadGate=(e,t)=>t();threadLoadsInFlight(){return[...this.threadLoads.keys()]}async sendRequest(e){for(let i of this.codexEventHandlers)i({eventType:"request",...e});let t=WU(e),n;try{t===null?e.params?n=await this.connection.sendRequest(e.method,e.params):n=await this.connection.sendRequest(e.method):n=await this.threadLoadGate(t,()=>this.sendThreadLoad(t,e))}catch(i){throw i instanceof Error?kU(i,{codexHome:this.codexHome}):i}for(let i of this.codexEventHandlers)i({eventType:"response",...n});return n}async sendThreadLoad(e,t){this.threadLoads.set(e,(this.threadLoads.get(e)??0)+1);try{return await this.connection.sendRequest(t.method,t.params)}finally{let n=(this.threadLoads.get(e)??1)-1;n>0?this.threadLoads.set(e,n):this.threadLoads.delete(e)}}};function WU(e){let t=e.params;if(typeof t?.threadId!="string")return null;switch(e.method){case"thread/resume":case"thread/fork":case"thread/turns/list":case"thread/items/list":return t.threadId;case"thread/read":return t.includeTurns===!0?t.threadId:null;default:return null}}function GU(e){return e.method==="mcpServer/startupStatus/updated"}function f4(e){return e.method==="turn/completed"}function VU(e){return e.method==="thread/status/changed"}function HU(e){return e.method==="thread/goal/updated"}function JU(e){return e.method==="thread/goal/cleared"}function p4(e,t){return e.threadId===t.threadId&&e.objective===t.objective&&e.status===t.status&&e.tokenBudget===t.tokenBudget&&e.updatedAt===t.updatedAt}function wD(e){let t=e.params;return t&&typeof t.threadId=="string"?t.threadId:null}function KU(e){let t=e.params,n=wD(e);return t&&typeof t.turnId=="string"?{threadId:n,turnId:t.turnId}:t&&typeof t.turn?.id=="string"?{threadId:n,turnId:t.turn.id}:{threadId:n,turnId:null}}var XU=5,YU=100,m4=6e4;async function*g4(e,t,n,i){let r=a=>{let l=Td(n(a),t,e);return l.catch(()=>{}),l},u=new Set,s=null,o=null;do{let a=await(o??r(s));o=null,s=a.nextCursor;let l=s!==null&&u.has(s);if(s!==null&&!l&&(u.add(s),i&&!i(a.data)&&(o=r(s))),yield a.data,l)throw new Error("Codex returned a repeated thread history cursor")}while(s!==null)}async function Td(e,t,n){let i,r=new Promise((u,s)=>{i=setTimeout(()=>s(new Error(`Codex did not answer ${t} for thread ${n} within ${m4/1e3} s`)),m4)});try{return await Promise.race([e,r])}finally{clearTimeout(i)}}var qr=Sn(Sr(),1),v4=class{constructor(e,t,n=Date.now){this.limit=e,this.windowMs=t,this.now=n}limit;windowMs;now;crashes=new Map;record(e=""){let t=this.recent(e);t.push(this.now()),this.crashes.set(e,t)}count(e=""){return this.recent(e).length}tripped(e=""){return this.count(e)>=this.limit}retryAfterMs(e=""){let t=this.recent(e);if(t.length<this.limit)return 0;let n=t[t.length-this.limit]+this.windowMs;return Math.max(0,n-this.now())}lastCrashAt(e=""){return this.recent(e).at(-1)??null}recent(e){let t=this.now()-this.windowMs,n=(this.crashes.get(e)??[]).filter(i=>i>t);return n.length===0?this.crashes.delete(e):this.crashes.set(e,n),n}},C4=3221225781,_D={crashLimit:5,crashWindowMs:5*6e4,threadCrashLimit:2,threadWindowMs:30*6e4,backoffMs:[0,1e3,2e3,4e3],handshakeTimeoutMs:3e4};function QU(e=process.env){let t={..._D},n=Number(e.CODEX_ACP_APP_SERVER_CRASH_LIMIT);Number.isInteger(n)&&n>0&&(t.crashLimit=n);let i=Number(e.CODEX_ACP_APP_SERVER_CRASH_WINDOW_MS);return Number.isFinite(i)&&i>0&&(t.crashWindowMs=i),t}var ej=8,tj=class{constructor(e,t=_D,n=Date.now,i=r=>new Promise(u=>setTimeout(u,r))){this.host=e,this.limits=t,this.now=n,this.sleep=i,this.crashGuard=new v4(t.crashLimit,t.crashWindowMs,n),this.threadGuard=new v4(t.threadCrashLimit,t.threadWindowMs,n),this.readyGeneration=e.supervisor.generation,this.liveClient=e.currentClient(),this.clientGenerations.set(this.liveClient,this.readyGeneration),this.generationClients.set(this.readyGeneration,this.liveClient),this.gateThreadLoads(this.liveClient),e.supervisor.onExit((r,u)=>this.handleExit(r,u.generation)),e.supervisor.onDeath(r=>this.snapshotLoads(r.generation))}host;limits;now;sleep;state="ready";readyGeneration;clientGenerations=new WeakMap;generationClients=new Map;startupExits=new Set;loadedGenerations=new WeakMap;resumes=new WeakMap;resumesById=new Map;opens=new Map;crashGuard;threadGuard;generationLostListeners=new Map;transitions=Promise.resolve();respawning=null;liveClient;nonRestartableExit=null;loadsAtDeath=new Map;serializeLoadsUntil=0;loadQueue=Promise.resolve();pendingReplacement=null;get generation(){return this.readyGeneration}isReady(e=this.readyGeneration){return this.state==="ready"&&e===this.readyGeneration&&this.host.supervisor.isAlive(e)}ensureRunning(){if(!this.isReady())return this.respawn()}ensureSessionReady(e){if(this.sessionIsLive(e))return;let t=this.resumes.get(e);return t!==void 0?t.then(()=>this.ensureSessionReady(e)):this.track(e,this.runResume(e))}sessionIsLive(e){return e!==void 0&&this.isReady()&&this.loadedGenerations.get(e)===this.readyGeneration}markLoaded(e,t){this.loadedGenerations.set(e,t)}settleResume(e){return this.resumesById.get(e)?.catch(()=>{})}async trackOpen(e,t){this.opens.set(e,(this.opens.get(e)??0)+1);try{return await t()}finally{let n=(this.opens.get(e)??1)-1;n>0?this.opens.set(e,n):this.opens.delete(e)}}resumeForReplacement(e,t,n,i){return this.track(e,this.resumeInto(e,t,n,i,!1))}onGenerationLost(e,t){if(!this.host.supervisor.isAlive(e))return t(),()=>{};let n=this.generationLostListeners.get(e)??new Set;return n.add(t),this.generationLostListeners.set(e,n),()=>{n.delete(t),n.size===0&&this.generationLostListeners.get(e)===n&&this.generationLostListeners.delete(e)}}throwIfLost(e){if(!this.host.supervisor.isAlive(e))throw this.errorForGeneration(e)}mapError(e,t){if(pd(e)||!bD(e))return e;let n=t!==void 0?this.clientGenerations.get(t):void 0;return!AD(e)&&this.host.supervisor.isAlive(n)?e:this.errorForGeneration(n)}errorForGeneration(e){let t=this.host.supervisor,n=e!==void 0?t.exitOf(e):t.lastExit;return n!==void 0?this.exitError(n):t.shuttingDown?this.shuttingDownError():new vt("The connection to the Codex app-server was lost. The agent starts it again on the next request.",{exitCode:null,signal:null,restartable:!0})}loadThread(e,t){try{this.assertThreadMayLoad(e)}catch(n){return Promise.reject(n)}return this.now()>=this.serializeLoadsUntil?t():this.loadInTurn(e,t)}async loadInTurn(e,t){let n=this.loadQueue,i=()=>{};this.loadQueue=new Promise(r=>{i=r}),await n.catch(()=>{});try{return this.assertThreadMayLoad(e),await t()}finally{i()}}assertThreadMayLoad(e){if(!this.threadGuard.tripped(e))return;let t=this.host.supervisor.lastExit,n=t!==void 0&&dp(t)?"was killed (likely out of memory)":"crashed",i=this.threadGuard.count(e);throw new TS(`The Codex app-server ${n} ${i} times while opening session ${e}, so the agent does not open this session again for ${Ni(this.threadGuard.retryAfterMs(e))}, to keep the other sessions working. The session may be too large for the available memory.`,{exitCode:t?.code??null,signal:t?.signal??null,restartable:!1,retryAfterMs:this.threadGuard.retryAfterMs(e)})}async beginReplacement(){let e=()=>{},t=new Promise(i=>{e=i}),n=this.transitions.then(()=>{},()=>{});this.transitions=n.then(()=>t),await n;try{let i=this.host.supervisor;if(i.shuttingDown)throw this.shuttingDownError();if(this.nonRestartableExit!==null)throw this.exitError(this.nonRestartableExit);if(this.crashGuard.tripped())throw this.crashLoopError();let r=i.current;if(this.state="starting",this.loseGeneration(r.generation),await i.stop(r),i.shuttingDown)throw this.shuttingDownError();if(this.nonRestartableExit!==null)throw this.exitError(this.nonRestartableExit);if(this.crashGuard.tripped())throw this.crashLoopError();let{child:u,client:s}=this.spawnClient(),o=setTimeout(()=>{let a=this.pendingReplacement;a?.generation===u.generation&&(D.log("[APP-SERVER RESTART] The provider restart did not finish its handshake in time; stopping the new app-server",{generation:u.generation,ms:this.limits.handshakeTimeoutMs}),a.timedOut=!0,u.failing=!0,u.terminate())},this.limits.handshakeTimeoutMs);return this.pendingReplacement={generation:u.generation,release:e,watchdog:o,timedOut:!1},s}catch(i){throw this.state=this.host.supervisor.shuttingDown?"shutdown":"dead",e(),i}}completeReplacement(e){let t=this.pendingReplacement;if(t===null||this.clientGenerations.get(e)!==t.generation)return;this.pendingReplacement=null,clearTimeout(t.watchdog),this.readyGeneration=t.generation;let n=!t.timedOut&&this.host.supervisor.isAlive(t.generation);if(this.state=n?"ready":this.host.supervisor.shuttingDown?"shutdown":"dead",t.release(),t.timedOut)throw new vt(`The restarted Codex app-server did not answer initialize within ${Ni(this.limits.handshakeTimeoutMs)}. The agent starts it again on the next request.`,{exitCode:null,signal:null,restartable:!0})}settleReplacement(e){e.catch(()=>{let t=this.pendingReplacement;if(t===null)return;this.pendingReplacement=null,clearTimeout(t.watchdog),this.readyGeneration=t.generation,this.state=this.host.supervisor.shuttingDown?"shutdown":"dead";let n=this.host.supervisor.current;n.generation===t.generation&&!n.dead&&!t.timedOut&&(this.crashGuard.record(),D.log("[APP-SERVER RESTART] The provider restart failed before the new app-server was installed; stopping it"),this.host.supervisor.stop(n)),t.release()})}spawnClient(){let e,t;try{e=this.host.supervisor.spawn(),t=this.host.createClient(e.connection)}catch(n){this.state=this.host.supervisor.shuttingDown?"shutdown":"dead",this.crashGuard.record();let i=n instanceof Error?n.message:String(n);throw D.error("[APP-SERVER RESTART] The Codex app-server could not be started",n),new vt(`The Codex app-server could not be started: ${i}`,{exitCode:null,signal:null,restartable:!this.crashGuard.tripped()})}return this.liveClient=t,this.clientGenerations.set(t,e.generation),this.generationClients.set(e.generation,t),this.gateThreadLoads(t),{child:e,client:t}}gateThreadLoads(e){e.appServerClient.threadLoadGate=(t,n)=>this.loadThread(t,n)}track(e,t){this.resumes.set(e,t),this.resumesById.set(e.sessionId,t);let n=()=>{this.resumes.get(e)===t&&this.resumes.delete(e),this.resumesById.get(e.sessionId)===t&&this.resumesById.delete(e.sessionId)};return t.then(n,n),t}respawn(){if(this.host.supervisor.shuttingDown)return Promise.reject(this.shuttingDownError());if(this.nonRestartableExit!==null)return Promise.reject(this.exitError(this.nonRestartableExit));if(this.respawning!==null)return this.respawning;let e=this.enqueue(()=>this.restart());return this.respawning=e,e.then(()=>this.clearRespawning(e),()=>this.clearRespawning(e)),e}clearRespawning(e){this.respawning===e&&(this.respawning=null)}enqueue(e){let t=this.transitions.then(e,e);return this.transitions=t.catch(()=>{}),t}async restart(){if(this.isReady())return;let e=this.host.supervisor;if(e.shuttingDown)throw this.shuttingDownError();let t=e.current;if(t.exit===null&&await e.stop(t),this.isReady())return;if(e.shuttingDown)throw this.shuttingDownError();if(this.nonRestartableExit!==null)throw this.exitError(this.nonRestartableExit);if(this.crashGuard.tripped())throw this.crashLoopError();let n=this.crashGuard.count(),i=n===0?0:this.limits.backoffMs[Math.min(n,this.limits.backoffMs.length)-1],r=this.crashGuard.lastCrashAt()??0,u=Math.max(0,r+i-this.now());if(u>0&&(D.log("[APP-SERVER RESTART] waiting before the restart",{ms:u,crashes:n}),await this.sleep(u)),e.shuttingDown)throw this.shuttingDownError();let s=this.now();this.state="starting";let{child:o,client:a}=this.spawnClient(),l=!1;try{let c=this.host.handshake(a);if(c!==null&&await this.withHandshakeTimeout(c,()=>{l=!0,o.failing=!0,o.terminate()}),o.dead)throw this.errorForGeneration(o.generation);if(e.shuttingDown)throw this.shuttingDownError();this.host.install(a),this.readyGeneration=o.generation,this.state="ready",D.log("[APP-SERVER RESTARTED]",{generation:o.generation,ms:this.now()-s,crashesInWindow:this.crashGuard.count()})}catch(c){throw this.readyGeneration=o.generation,this.state=e.shuttingDown?"shutdown":"dead",!o.dead&&!l&&(this.crashGuard.record(),e.stop(o)),this.mapError(c,a)}}async withHandshakeTimeout(e,t){let n,i=new Promise((r,u)=>{n=setTimeout(()=>{t(),u(new vt(`The restarted Codex app-server did not answer initialize within ${Ni(this.limits.handshakeTimeoutMs)}. The agent starts it again on the next request.`,{exitCode:null,signal:null,restartable:!0}))},this.limits.handshakeTimeoutMs)});try{await Promise.race([e,i])}finally{clearTimeout(n)}}async runResume(e){let t=this.ensureRunning();if(t&&await t,this.sessionIsLive(e))return;let n=this.readyGeneration,i=this.host.currentClient();D.log("[APP-SERVER RECOVERY] resuming a session in the restarted app-server",{sessionId:e.sessionId,generation:n});let r=this.now();await this.resumeInto(e,n,i,u=>this.host.resumeSession(e,i,u),!0),this.host.resumed(e),D.log("[APP-SERVER RECOVERY] session resumed",{sessionId:e.sessionId,generation:n,ms:this.now()-r})}async resumeInto(e,t,n,i,r){let u=e.sessionId,s=this.host.sessionLifetime(e),o=()=>this.host.isCurrent(e,s)&&this.isReady(t)&&!(r&&this.opens.has(u)),a=()=>this.isReady(t)?nj(u):this.errorForGeneration(t),l=!1;try{if(!o())throw a();let c;try{c=await i(()=>{l=!0})}catch(p){throw this.resumeError(u,p,n)}if(!o())throw a();let m=c.collaborationMode;for(let p=0;m!==this.host.collaborationMode(e);p++){if(p>=ej)throw new Error("The collaboration mode kept changing while the session was reopened");let v=this.host.collaborationMode(e);if(await this.host.applyCollaborationMode(e,n),m=v,!o())throw a()}}catch(c){throw l&&this.releaseThread(e,t,n),this.mapError(c,n)}this.loadedGenerations.set(e,t)}releaseThread(e,t,n){let i=e.sessionId,r=this.host.installedSession(i);!this.isReady(t)||this.opens.has(i)||r!==void 0&&r!==e||n.closeSession(i).catch(u=>{D.log("Failed to unsubscribe the thread of a session that closed while it was resumed",{sessionId:i,error:String(u)})})}resumeError(e,t,n){if(pd(t))return t;let i=this.mapError(t,n);if(i!==t)return i;if(vi(t))return new PS(e);let r=t instanceof Error?t.message:String(t);return new vt(`Could not reopen session ${e} after the Codex app-server restarted: ${r}`,{exitCode:null,signal:null,restartable:!0})}handleExit(e,t){let n=this.loadsAtDeath.get(t)??[];this.loadsAtDeath.delete(t);let i=t===this.readyGeneration,r=this.generationClients.get(t);if(this.generationClients.delete(t),!e.intentional&&r?.initialized!==!0&&this.startupExits.add(t),i&&this.state==="ready"&&(this.state=this.host.supervisor.shuttingDown?"shutdown":"dead"),!e.intentional){this.crashGuard.record(),e.code===C4&&(this.nonRestartableExit=e),this.attribute(e,n);try{this.host.crashed(e)}catch(u){D.error("Failed to handle the app-server crash",u)}}this.loseGeneration(t)}snapshotLoads(e){this.clientGenerations.get(this.liveClient)===e&&this.loadsAtDeath.set(e,this.liveClient.appServerClient.threadLoadsInFlight())}attribute(e,t){t.length===1?(this.threadGuard.record(t[0]),D.error(`[APP-SERVER CRASH] The app-server ${gi(e)} while opening session ${t[0]}`,JSON.stringify({strikes:this.threadGuard.count(t[0]),limit:this.limits.threadCrashLimit}))):t.length>1&&(this.serializeLoadsUntil=this.now()+this.limits.crashWindowMs,D.error("[APP-SERVER CRASH] The app-server died while opening several sessions; opening them one at a time from now on",JSON.stringify({sessions:t})))}loseGeneration(e){let t=this.generationLostListeners.get(e);if(t!==void 0){this.generationLostListeners.delete(e);for(let n of t)try{n()}catch(i){D.error("App-server loss listener failed",i)}}}exitError(e){return e.code===C4?new vt("VC++ redistributable should be installed",{exitCode:e.code,signal:e.signal,restartable:!1}):this.host.supervisor.shuttingDown?xg(e,"The agent is shutting down."):e.intentional?new vt("The Codex app-server was restarted for a provider change while this request ran. Try again.",{exitCode:e.code,signal:e.signal,restartable:!0}):this.crashGuard.tripped()?this.crashLoopError(e):this.startupExits.has(e.generation)?Vz(e):xg(e,"The agent starts it again on the next request.")}crashLoopError(e=this.host.supervisor.lastExit){let t=this.crashGuard.retryAfterMs(),n=e!==void 0?` (last: it ${gi(e)})`:"",i=e?.stderrTail.trim()??"";return new vt(`The Codex app-server crashed ${this.crashGuard.count()} times in the last ${Ni(this.limits.crashWindowMs)}${n}, so the agent stopped restarting it. Restart the agent, or try again in ${Ni(t)}.${i?`
|
|
129
|
+
${i}`:""}`,{exitCode:e?.code??null,signal:e?.signal??null,restartable:!1,retryAfterMs:t})}shuttingDownError(){return new vt("The Codex app-server is not available: the agent is shutting down.",{exitCode:null,signal:null,restartable:!1})}};function nj(e){return new FS(e)}var rj=["Connection is disposed","Connection is closed","Pending response rejected since connection got disposed","Codex connection closed"];function AD(e){return e instanceof yi?!0:e instanceof qr.ConnectionError?e.code===qr.ConnectionErrors.Closed||e.code===qr.ConnectionErrors.Disposed:e instanceof qr.ResponseError&&e.code===qr.ErrorCodes.PendingResponseRejected}function bD(e){return AD(e)?!0:e instanceof qr.ResponseError||!(e instanceof Error)?!1:rj.some(t=>e.message.includes(t))}var ij={closeGraceMs:1e3,drainMs:50,terminateAfterMs:2e3,abandonAfterMs:5e3,wedgedAfterMs:5e3},uj=16,SD=class{constructor(e,t=(r,u)=>Lf(r,void 0,u,{disposeOnExit:!1}),n={},i=Date.now){this.state=e,this.spawnConnection=t,this.now=i,this.timings={...ij,...n},this.child=this.watch(e.connection)}state;spawnConnection;now;child;nextGeneration=1;isShuttingDown=!1;exitListeners=new Set;deathListeners=new Set;exits=new Map;timings;get current(){return this.child}get generation(){return this.child.generation}get shuttingDown(){return this.isShuttingDown}isAlive(e=this.child.generation){return e===this.child.generation&&!this.child.dead&&!this.isShuttingDown}exitOf(e){return this.exits.get(e)}get lastExit(){let e;for(let t of this.exits.values())e=t;return e}onExit(e){return this.exitListeners.add(e),()=>{this.exitListeners.delete(e)}}onDeath(e){return this.deathListeners.add(e),()=>{this.deathListeners.delete(e)}}spawn(){if(this.isShuttingDown)throw new Error("The agent is shutting down");if(this.child.exit===null)throw new Error("The Codex app-server is still running or draining");this.state.stderr="";let e=this.spawnConnection(this.state.codexPath,this.state.appServerStartupArgs);return this.state.connection=e,this.child=this.watch(e),D.log("[APP-SERVER START]",{generation:this.child.generation,pid:e.process.pid??null}),this.child}async stop(e=this.child){return e.dead||(e.failing||(e.intentional=!0),this.terminate(e)),await e.exited}shutdown(){this.isShuttingDown||(this.isShuttingDown=!0,D.log("[APP-SERVER SHUTDOWN]",{generation:this.child.generation}),this.stop(this.child))}watch(e){let t=e.process,n=this.nextGeneration++,i=()=>{},r=new Promise(C=>{i=C}),u={generation:n,connection:e,startedAt:this.now(),exit:null,dead:!1,intentional:!1,failing:!1,exited:r,terminate:()=>{}},s=!1,o=!1,a=!1,l=!1,c=null,m=()=>{u.dead=!0;for(let C of[...this.deathListeners])try{C(u)}catch(y){D.error("App-server death listener failed",y)}},p=C=>{if(!o){o=!0,c!==null&&clearTimeout(c),u.exit=C;for(let y of[...this.exitListeners])try{y(C,u)}catch(b){D.error("App-server exit listener failed",b)}sj(e),e.connection.dispose(),i(C)}},v=(C,y,b)=>{let A={generation:n,pid:t.pid,code:C,signal:y,...b!==void 0?{error:b}:{},intentional:u.intentional,at:this.now(),uptimeMs:this.now()-u.startedAt,stderrTail:this.state.connection===e?this.state.stderr:""};for(this.exits.set(n,A);this.exits.size>uj;)this.exits.delete(this.exits.keys().next().value);let S={generation:n,pid:A.pid??null,code:C,signal:y,uptimeMs:A.uptimeMs,intentional:A.intentional,...b!==void 0?{error:b}:{}};return A.intentional?D.log("[APP-SERVER EXIT] stopped by the adapter",S):D.error(`[APP-SERVER EXIT] The Codex app-server ${gi(A)}`,JSON.stringify({...S,likelyOutOfMemory:dp(A),stderrTail:A.stderrTail})),A};t.on("exit",(C,y)=>{if(s)return;s=!0,m();let b=v(C,y);if(e.drained!==void 0){let S;l||(S=setTimeout(()=>p(b),this.timings.closeGraceMs));let M=()=>clearTimeout(S);t.stdout?.once("end",M),e.drained.then(()=>{clearTimeout(S),t.stdout?.off("end",M),p(b)});return}if(a||!t.stdout){setTimeout(()=>p(b),a?this.timings.drainMs:0);return}let A=setTimeout(()=>p(b),this.timings.closeGraceMs);t.once("close",()=>{clearTimeout(A),setTimeout(()=>p(b),this.timings.drainMs)})}),t.on("close",()=>{a=!0}),t.on("error",C=>{if(t.pid!==void 0){D.log(`[APP-SERVER ERROR] ${C.message}`,{generation:n});return}s||(s=!0,m(),p(v(null,null,C.message)))}),t.stdout?.on("end",()=>{l=!0,!s&&(c=setTimeout(()=>{s||(D.error("[APP-SERVER WEDGED] stdout ended but the process runs on; stopping it",JSON.stringify({generation:n})),u.failing=!0,this.terminate(u))},this.timings.wedgedAfterMs))});let g=!1;return u.terminate=()=>{if(!(s||g)){g=!0;try{t.stdin?.end()}catch{}setTimeout(()=>{if(!s){D.log("[APP-SERVER STOP] still running after the end of stdin; sending SIGTERM",{generation:n});try{t.kill("SIGTERM")}catch{}setTimeout(()=>{s||(s=!0,m(),D.error("[APP-SERVER STOP] still running after SIGTERM; closing its pipes and moving on",JSON.stringify({generation:n})),p(v(null,null,"it did not stop after SIGTERM")))},this.timings.abandonAfterMs)}},this.timings.terminateAfterMs)}},u}terminate(e){e.terminate()}};function sj(e){let t=e.process;for(let n of[t.stdin,t.stdout,t.stderr])try{n?.destroy?.()}catch{}}function oj(e,t){return{notify:((n,i)=>e.notify(n,i)),request:((n,i,r)=>{if(t.aborted)return Promise.reject(new yi("an answer of the ACP client"));let u=r?.cancellationSignal?AbortSignal.any([r.cancellationSignal,t]):t,s=e.request(n,i,{...r,cancellationSignal:u});return new Promise((o,a)=>{let l=()=>a(new yi("an answer of the ACP client"));t.addEventListener("abort",l,{once:!0}),s.then(c=>{t.removeEventListener("abort",l),o(c)},c=>{t.removeEventListener("abort",l),a(c)})})})}}function aj(e){let t={plan:{},session:{compaction:{},notices:{}}};if(!e)return t;if(e.elicitation&&(t.elicitation=e.elicitation),e.auth){let{terminal:n,_meta:i}=e.auth;t.auth={...n!=null?{terminal:!0}:{},...i!=null?{_meta:i}:{}}}return e._meta!=null&&(t._meta=e._meta),t}async function y4(e,t){let n=[],i=new Set,r=null;do{let u=await e.listMcpServers({cursor:r,detail:"toolsAndAuthOnly",...t===void 0?{}:{threadId:t}});if(n.push(...u.data),r=u.nextCursor,r!==null){if(i.has(r)){D.log(`MCP server status list repeated the cursor ${r}`);break}i.add(r)}}while(r!==null);return n}var DD="No MCP servers are configured.",lj=["connected","starting","notStarted","authenticationRequired","failed","cancelled","disabled",null],ID=["failed","cancelled","authenticationRequired","notStarted","starting","connected",null];function E4(e){switch(e){case"connected":return"Connected";case"starting":return"Connecting";case"notStarted":return"Not started";case"authenticationRequired":return"Needs authentication";case"failed":return"Failed";case"cancelled":return"Cancelled";case"disabled":return"Disabled";case null:return"Unknown"}}var cj=new Set([...ID.filter(e=>e!==null),"disabled"]);function dj(e){let t=e.runtimeStatus;return{name:e.name,status:t!==null&&cj.has(t)?t:null,toolCount:Object.keys(e.tools??{}).length,toolsError:e.toolsError,authStatus:e.authStatus,listedByCodex:!0}}function w4(e,t){if(e.length===0)return DD;let n=lj.map(u=>({status:u,count:e.filter(s=>s.status===u).length})).filter(u=>u.count>0).map(u=>`${u.count} ${E4(u.status).toLowerCase()}`),i=[`**MCP servers:** ${e.length} (${n.join(", ")})`];for(let u of ID){let s=e.filter(o=>o.status===u);if(s.length!==0){i.push("",`**${E4(u)}**`);for(let o of s){let a=pj(o,t.get(o.name)??null);i.push(a===null?`- ${Qs(o.name)}`:`- ${Qs(o.name)}: ${a}`)}}}let r=e.filter(u=>u.status==="disabled");return r.length>0&&i.push("",`**Disabled:** ${r.map(u=>Qs(u.name)).join(", ")}`),e.some(u=>u.status!==null&&fj.has(u.status))&&i.push("",hj),i.join(`
|
|
130
|
+
`)}var hj="Run `/mcp reconnect` to restart the servers that are not connected.",fj=new Set(["failed","cancelled","authenticationRequired","notStarted"]);function pj(e,t){if(e.status==="authenticationRequired")return _4;let n=[],i=e.toolCount??0;(e.status==="connected"||i>0)&&n.push(`${i} ${i===1?"tool":"tools"}`),e.authStatus==="notLoggedIn"&&e.status!=="disabled"&&n.push(_4);let r=t??e.toolsError,u=r===null?"":Fd(r);return u.length>0&&n.push(u),n.length===0?null:n.join("; ")}var _4="not signed in",A4=160,mj=2,gj=2e3,vj=/^(?:tool discovery failed|mcp startup failed|handshaking with mcp server failed|json-rpc error|startup error|error|mcp client for .+ failed to start|-32\d{3})$/i,Cj=/\S*\w::\w+::\S*/g;function yj(e){let t=e.slice(0,gj).replace(/\s+/g," ").trim(),n=t.split(": ").map(i=>i.replace(Cj,"").replace(/\s+/g," ").trim()).filter(i=>i.length>0&&!vj.test(i)).join(": ");return n.length===0?b4(t):b4(n.split(/(?<=[.!?])\s+/).slice(0,mj).join(" "))}function b4(e){let t=Array.from(e);return t.length>A4?`${t.slice(0,A4).join("").trimEnd()}\u2026`:e}function Fd(e){return Ej(yj(e))}function Ej(e){return e.replace(/[\\`*_[\]<>~]/g,t=>`\\${t}`)}var wj="(unnamed)";function Qs(e){let t=e.replace(/\s+/g," ");if(t.length===0)return wj;let n=Math.max(0,...Array.from(t.matchAll(/`+/g),u=>u[0].length)),i="`".repeat(n+1),r=/^[` ]|[` ]$/.test(t)?" ":"";return`${i}${r}${t}${r}${i}`}var _j=3e4,Aj="[reconnect]",bj=class{codexAcpClient;runWithProcessCheck;signIn;constructor(e,t,n){this.codexAcpClient=e,this.runWithProcessCheck=t,this.signIn=n}async run(e,t,n){let i=e.split(/\s+/).filter(r=>r.length>0);if(i.length===0){let r=await this.listServers(t);return n?.aborted?null:w4(r.servers,new Map)}return i.length===1&&i[0].toLowerCase()==="reconnect"?await this.reconnect(t,n):'Command "/mcp" accepts no arguments, or `reconnect`.'}async reconnect(e,t){if((await this.listServers(e)).servers.length===0)return DD;let i=[],r=await this.reloadAndWait(e,t);if(r.error!==null)i.push(`Could not reload the MCP configuration: ${Fd(r.error)}`);else{i.push(Sj);let u=await this.signInServers(e,r,t);if(i.push(...u.notes),u.signedIn&&!t?.aborted){let s=await this.reloadAndWait(e,t);s.error!==null?(i.push(`Could not reload the MCP configuration after the sign-in: ${Fd(s.error)}`),r={...s,startup:r.startup}):r=s}}return t?.aborted?null:(r.startup===null&&i.push("Some MCP servers are still starting. Run `/mcp` again later to see their status."),`${$j(i)}
|
|
131
|
+
|
|
132
|
+
${w4(r.list.servers,Dj(r.startup))}`)}async reloadAndWait(e,t){let n=this.codexAcpClient.getMcpServerStartupVersion();try{await this.runWithProcessCheck(()=>this.codexAcpClient.reloadMcpServers())}catch(s){return D.error(`Failed to reload the MCP configuration for session ${e.sessionId}`,s),{error:Ij(s),startup:S4(),list:await this.listServers(e)}}let i=await this.listServers(e);if(!i.live)return{error:null,startup:S4(),list:i};let r=i.servers.filter(s=>s.listedByCodex&&s.status!=="disabled").map(s=>s.name),u=await this.waitForStartup(e.sessionId,r,n,t);return t?.aborted?{error:null,startup:u,list:i}:{error:null,startup:u,list:await this.listServers(e)}}async waitForStartup(e,t,n,i){if(i?.aborted)return null;let r=new AbortController,u=()=>r.abort();i?.addEventListener("abort",u,{once:!0});let s=setTimeout(()=>r.abort(),_j);try{return await this.runWithProcessCheck(()=>this.codexAcpClient.awaitMcpServerStartup(t,n,{threadId:e,signal:r.signal}))}catch(o){if(r.signal.aborted)return null;throw o}finally{clearTimeout(s),i?.removeEventListener("abort",u)}}async signInServers(e,t,n){let i=new Set(t.list.servers.filter(s=>s.status==="authenticationRequired").map(s=>s.name));for(let s of t.startup?.failed??[])s.failureReason==="reauthenticationRequired"&&i.add(s.server);let r=[],u=!1;for(let s of i){if(n?.aborted)break;let o=Qs(s);switch(await this.signIn(e.sessionId,s,n)){case"unsupported":r.push(`MCP server ${o} needs authentication, but this client cannot open a sign-in page.`);break;case"signedIn":r.push(`Signed in to MCP server ${o}.`),u=!0;break;case"failed":r.push(`The sign-in to MCP server ${o} failed or was cancelled.`);break}}return{notes:r,signedIn:u}}async listServers(e){let{servers:t,live:n}=await this.listServerStatus(e.sessionId),i=t.map(dj);for(let r of e.sessionMcpServers??[])i.some(u=>u.name===r)||i.push({name:r,status:null,toolCount:null,toolsError:null,authStatus:null,listedByCodex:!1});return{servers:i,live:n}}async listServerStatus(e){try{return{servers:await this.runWithProcessCheck(()=>y4(this.codexAcpClient,e)),live:!0}}catch(t){if(!US(t)&&!pp(t))throw t;return D.log(`Codex does not know thread ${e}, so the MCP server list has no live status`),{servers:await this.runWithProcessCheck(()=>y4(this.codexAcpClient)),live:!1}}}},Sj="Reloaded the MCP configuration of all open sessions. Codex restarted the servers that failed, stopped, or changed. A connected server with unchanged settings keeps its connection.";function Dj(e){return new Map((e?.failed??[]).map(t=>[t.server,t.error]))}function S4(){return{ready:[],failed:[],cancelled:[]}}function Ij(e){return e instanceof Error?e.message:String(e)}function $j(e){return["**Reconnect:**",...e.map(t=>`- ${t}`)].join(`
|
|
133
|
+
`)}var Ds=4e3;function Bj(e){return e!==null?{handled:!0,turnCompleted:e}:{handled:!0}}var kj=300,xj=2e3,Tj=class{connection;codexAcpClient;runWithProcessCheck;onLogout;mcpCommand;published=new WeakMap;pendingSkillsPublishes=new WeakMap;publishRevisions=new WeakMap;snapshots=new WeakMap;constructor(e,t,n,i,r){this.connection=e,this.codexAcpClient=t,this.runWithProcessCheck=n,this.onLogout=i,this.mcpCommand=new bj(t,n,r)}classifyPrompt(e){let t=this.parseCommand(e);if(t===null||t.name.startsWith("$"))return{kind:"prompt"};switch(t.name){case"plan":return this.planPrompt(e)===null?{kind:"localCommand",name:t.name}:{kind:"prompt"};case"status":case"rename":case"logout":case"skills":case"mcp":return{kind:"localCommand",name:t.name};case"compact":case"review":return{kind:"codexTurnCommand",name:t.name};case"review-branch":case"review-commit":return t.rest.length===0?{kind:"localCommand",name:t.name}:{kind:"codexTurnCommand",name:t.name};case"goal":{let n=t.rest.trim().toLowerCase();return n.length===0||n==="pause"||n==="clear"||n.length>4e3?{kind:"localCommand",name:t.name}:{kind:"codexTurnCommand",name:t.name}}default:return{kind:"prompt"}}}publishOnSkillsChanged(e,t){let n=this.pendingSkillsPublishes.get(e);clearTimeout(n?.timer);let i=n?.deadline??Date.now()+xj,r=Math.max(0,Math.min(kj,i-Date.now())),u=setTimeout(()=>{this.pendingSkillsPublishes.delete(e),this.publish(e,t,!0)},r);u.unref?.(),this.pendingSkillsPublishes.set(e,{timer:u,deadline:i})}cancelPendingSkillsPublish(e){let t=this.pendingSkillsPublishes.get(e);t!==void 0&&(clearTimeout(t.timer),this.pendingSkillsPublishes.delete(e))}async initialize(e,t){try{t()&&await this.loadCommands(e)}catch(n){t()&&D.error(`Failed to load initial commands for session ${e.sessionId}`,n)}}initialCommands(e){let t=this.snapshots.get(e)?.commands??[];return this.published.set(e,JSON.stringify(t)),t}async loadCommands(e){let t=(this.publishRevisions.get(e)??0)+1;this.publishRevisions.set(e,t);let n=await this.runWithProcessCheck(()=>this.codexAcpClient.listSkills(this.createSkillsListParams(e))),i=this.buildAvailableCommands(n?.data??[],e.clientCapabilities.airClient);if(e.clientCapabilities.airClient)for(let r of i){let u=r._meta?.commandAction;u&&(r._meta=xt(r._meta,Wm,u))}return(this.snapshots.get(e)?.revision??0)<t&&this.snapshots.set(e,{revision:t,commands:i}),{revision:t,commands:i}}async publish(e,t=()=>!0,n=!1){try{if(!t())return;let{revision:i,commands:r}=await this.loadCommands(e);if(this.publishRevisions.get(e)!==i||r.length===0||!t())return;let u=JSON.stringify(r);if(n&&this.published.get(e)===u)return;this.published.set(e,u),await new Fe(this.connection,e.sessionId).update({sessionUpdate:"available_commands_update",availableCommands:r})}catch(i){t()&&D.error(`Failed to publish available commands for session ${e.sessionId}`,i)}}async getAvailableCommands(e){let t=[];try{t=(await this.runWithProcessCheck(()=>this.codexAcpClient.listSkills(this.createSkillsListParams(e))))?.data??[]}catch(i){D.error(`Failed to resolve available commands for session ${e.sessionId}`,i)}let n=this.buildAvailableCommands(t,e.clientCapabilities.airClient);if(e.clientCapabilities.airClient)for(let i of n){let r=i._meta?.commandAction;r&&(i._meta=xt(i._meta,Wm,r))}return n}createSkillsListParams(e){return{cwds:[e.cwd,...e.additionalDirectories]}}buildAvailableCommands(e,t){let n=new Map;for(let i of this.getBuiltinCommands())n.set(i.name,i);for(let i of e)for(let r of i.skills){let u=`$${r.name}`;if(n.has(u))continue;let s=r.shortDescription??r.description??r.name,o=hi(t,d2,r.path);n.set(u,{name:u,description:s,input:null,...o?{_meta:o}:{}})}return Array.from(n.values())}getBuiltinCommands(){return[{name:"plan",description:"Turn plan mode on and optionally send a prompt.",input:{hint:"prompt (optional)"},_meta:{commandAction:{kind:"setConfigOption",configId:Eo,value:!0,resetValue:!1,presentation:"state"}}},{name:"mcp",description:"Show the status of the MCP servers, or reconnect them.",input:{hint:Aj}},{name:"skills",description:"List available skills.",input:null},{name:"status",description:"Display session configuration and token usage.",input:null},{name:"review",description:"Review uncommitted changes, or review with custom instructions.",input:{hint:"optional review instructions"}},{name:"review-branch",description:"Review changes relative to a base branch.",input:{hint:"branch name"}},{name:"review-commit",description:"Review a specific commit.",input:{hint:"commit sha"}},{name:"compact",description:"Summarize conversation to avoid hitting the context limit.",input:null},{name:"goal",description:"Set a goal to keep pursuing.",input:{hint:"[<objective>|clear|pause|resume]"},_meta:{commandAction:{kind:"prefixPrompt",presentation:"state"}}},{name:"rename",description:"Rename the current session.",input:{hint:"new name"}},{name:"logout",description:"Sign out of Codex. This option is available when you are logged in via ChatGPT.",input:null}]}parseCommand(e){let t=e[0];if(!t||t.type!="text")return null;let n=t.text.trim();if(!n.startsWith("/"))return null;let i=n.slice(1).trim();if(i.length===0)return null;let[r]=i.split(/\s+/);return r?{name:r.toLowerCase(),rest:i.slice(r.length).trim()}:null}planPrompt(e){let t=e[0];if(!t||t.type!=="text")return null;let n=t.text.replace(/^\s*\/\s*plan(?:\s+|$)/i,""),i=[...n.trim()?[{...t,text:n}]:[],...e.slice(1)];return i.some(r=>r.type!=="text"||r.text.trim().length>0)?i:null}async tryHandleCommand(e,t,n={}){let i=this.parseCommand(e);if(i===null)return{handled:!1};let r=i.name;if(r.startsWith("$"))return{handled:!1};let u=t.sessionId;switch(r){case"plan":{if(!n.setConfigOption)return{handled:!1};let s=this.planPrompt(e),o=s!==null||t.collaborationMode!==Ci;return await n.setConfigOption(Eo,o),s===null?{handled:!0}:{handled:!1,prompt:s}}case"compact":{n.onTurnStartPending?.(),n.onNativeCommandStarted?.();try{return{handled:!0,turnCompleted:await this.runWithProcessCheck(()=>this.codexAcpClient.runCompact(u,o=>{n.onTurnStarted?.(o,u)},n.onCommandAccepted))}}finally{n.onNativeCommandFinished?.()}}case"goal":return await this.runGoalCommand(t,i.rest,n);case"review":{let s=this.buildReviewTarget(i.rest);return{handled:!0,turnCompleted:await this.runReviewCommand(t,s,n),waitForGoalContinuation:!1}}case"review-branch":return i.rest.length===0?(await this.sendCommandUsageMessage(r,"branch name",u),{handled:!0}):{handled:!0,turnCompleted:await this.runReviewCommand(t,{type:"baseBranch",branch:i.rest},n),waitForGoalContinuation:!1};case"review-commit":return i.rest.length===0?(await this.sendCommandUsageMessage(r,"commit sha",u),{handled:!0}):{handled:!0,turnCompleted:await this.runReviewCommand(t,{type:"commit",sha:i.rest,title:null},n),waitForGoalContinuation:!1};case"status":{await this.refreshRateLimits(t);let s=this.buildStatusMessage(t);return await this.sendCommandMessage(s,u),{handled:!0}}case"rename":return i.rest.length===0?(await this.sendCommandUsageMessage(r,"new name",u),{handled:!0}):(delete t.sessionIndexExplicitTitle,await this.runWithProcessCheck(()=>this.codexAcpClient.renameSession(u,i.rest)),{handled:!0});case"logout":return await this.runWithProcessCheck(()=>this.codexAcpClient.logout()),await this.onLogout(),await this.sendCommandMessage("Logged out from Codex account.",u),{handled:!0};case"skills":{let a=((await this.runWithProcessCheck(()=>this.codexAcpClient.listSkills(this.createSkillsListParams(t))))?.data??[]).flatMap(c=>c.skills).map(c=>{let m=c.shortDescription??c.description??"";return m?`- ${c.name}: ${m}`:`- ${c.name}`}),l=a.length>0?["Available skills:",...a].join(`
|
|
134
|
+
`):"No skills configured.";return await this.sendCommandMessage(l,u),{handled:!0}}case"mcp":{let s=await this.mcpCommand.run(i.rest,t,n.signal);return s===null?{handled:!0}:(await new Fe(this.connection,u).update(Un(s)),{handled:!0})}default:return{handled:!1}}}async runReviewCommand(e,t,n){n.onTurnStartPending?.(),n.onNativeCommandStarted?.();try{return await this.runWithProcessCheck(()=>this.codexAcpClient.runReview(e.sessionId,t,(i,r)=>{let u=e.currentTurnId;this.handleCommandTurnStarted(e,n,i,r),e.interruptTurnId=i,e.currentTurnId=u??i},n.onCommandAccepted,i=>{e.currentTurnId=i}))}finally{n.onNativeCommandFinished?.()}}async runGoalCommand(e,t,n){let i=e.sessionId,r=t.trim();if(r.length===0)return await this.sendCommandUsageMessage("goal","[<objective>|clear|pause|resume]",i),{handled:!0};let u=r.toLowerCase();return u==="pause"||u==="resume"||u==="clear"?await this.runGoalPromptControl(e,{version:Kr,action:u},n):r.length>Ds?(await new Fe(this.connection,i).update(Un(`Command "/goal" requires goal text of at most ${Ds} characters.`)),{handled:!0}):await this.runGoalPromptControl(e,{version:Kr,action:"set",objective:r},n)}async runGoalPromptControl(e,t,n={}){let i=e.sessionId;if(t.action==="pause")return await this.runWithProcessCheck(()=>this.codexAcpClient.setGoalStatus(i,"paused")),{handled:!0};if(t.action==="clear")return await this.runWithProcessCheck(()=>this.codexAcpClient.clearGoal(i)),{handled:!0};if(t.action==="set"&&t.objective.trim().length>Ds)throw k.invalidParams(void 0,`A goal objective may be at most ${Ds} characters`);n.onTurnStartPending?.();let r=u=>{this.handleCommandTurnStarted(e,n,u,i)};return this.createGoalCommandResult(e.sessionId,await this.runWithProcessCheck(()=>t.action==="set"?this.codexAcpClient.setGoal(i,t.objective.trim(),r,void 0,n.onCommandAccepted):this.codexAcpClient.resumeGoal(i,r,void 0,n.onCommandAccepted)))}handleCommandTurnStarted(e,t,n,i){t.onTurnStarted?t.onTurnStarted(n,i):e.currentTurnId=n}createGoalCommandResult(e,t){return Bj(t)}buildReviewTarget(e){return e.length===0?{type:"uncommittedChanges"}:{type:"custom",instructions:e}}async sendCommandUsageMessage(e,t,n){await this.sendCommandMessage(`Command "/${e}" requires ${t}.`,n)}async sendCommandMessage(e,t){await new Fe(this.connection,t).update(Un(e))}buildStatusMessage(e){let t=e.agentMode,n=this.formatAccountInfo(e.account),i=this.formatTokenUsage(e.totalTokenUsage),r=this.formatContextWindow(e.lastTokenUsage,e.modelContextWindow);return[`**Model:** ${e.currentModelId}`,`**Directory:** ${e.cwd}`,`**Approval:** ${t.approvalPolicy}`,`**Sandbox:** ${t.sandboxMode}`,`**Account:** ${n}`,`**Session:** \`${e.sessionId}\``,"",`**Token usage:** ${i}`,`**Context window:** ${r}`,...this.formatRateLimitLines(e.rateLimits)].join(`
|
|
135
|
+
`)}async refreshRateLimits(e){try{let t=await this.runWithProcessCheck(()=>this.codexAcpClient.getRateLimits());t&&(e.rateLimits=nO(t))}catch(t){D.error(`Failed to refresh rate limits for session ${e.sessionId}`,t)}}formatAccountInfo(e){return e?e.type==="apiKey"?"API key configured":e.type==="chatgpt"?`ChatGPT ${e.planType} (${e.email})`:e.type==="amazonBedrock"?"Amazon Bedrock":"unknown":"not logged in"}formatTokenUsage(e){if(!e)return"data not available yet";let t=this.formatTokenCount(e.totalTokens),n=this.formatTokenCount(e.inputTokens),i=this.formatTokenCount(e.cachedInputTokens),r=this.formatTokenCount(e.outputTokens),u=e.cacheWriteInputTokens>0?` + ${this.formatTokenCount(e.cacheWriteInputTokens)} cache write`:"";return`${t} total (${n} input + ${i} cached input${u}, ${r} output)`}formatContextWindow(e,t){if(!e||!t)return"data not available yet";let n=e.totalTokens,i=Math.round(n/t*100),r=this.formatTokenCount(n),u=this.formatTokenCount(t);return`${i}% used (${r} used / ${u})`}formatRateLimitLines(e){if(!e||e.size===0)return["**Limits:** data not available yet"];let t=[];for(let[,n]of e)t.push(...this.formatSingleRateLimit(n.limitName,n.snapshot));return t.length>0?t:["**Limits:** data not available yet"]}formatSingleRateLimit(e,t){let n=[],i=e?`${e} `:"";if(t.primary){let r=Math.round(100-t.primary.usedPercent),u=this.formatResetTime(t.primary.resetsAt),s=this.formatWindowLabel(t.primary.windowDurationMins);n.push(`**${i}${s}:** ${r}% left${u}`)}if(t.secondary){let r=Math.round(100-t.secondary.usedPercent),u=this.formatResetTime(t.secondary.resetsAt),s=this.formatWindowLabel(t.secondary.windowDurationMins);n.push(`**${i}${s}:** ${r}% left${u}`)}if(t.credits&&(t.credits.unlimited?n.push(`**${i}Credits:** unlimited`):t.credits.balance&&n.push(`**${i}Credits:** ${t.credits.balance}`)),t.individualLimit){let r=t.individualLimit,u=this.formatCreditAmount(r.used),s=this.formatCreditAmount(r.limit);if(u!==null&&s!==null){let o=Math.round(Math.min(100,Math.max(0,r.remainingPercent))),a=new Date(r.resetsAt*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric"});n.push(`**${i}individual spend limit:** ${o}% left (${u} of ${s} credits used; resets ${a})`)}}return n}formatCreditAmount(e){let t=e.trim();if(t.length===0)return null;let n=Number(t);return!Number.isFinite(n)||n<0?null:Math.round(n).toLocaleString("en-US")}formatWindowLabel(e){return e===null?"Limit":e<60?`${e}m limit`:e<1440?`${Math.round(e/60)}h limit`:e<10080?`${Math.round(e/1440)}d limit`:"Weekly limit"}formatResetTime(e){if(e===null)return"";let t=new Date(e*1e3),n=new Date,i=t.toDateString()===n.toDateString(),r=t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});if(i)return` (resets ${r})`;let u=t.toLocaleDateString([],{day:"numeric",month:"short"});return` (resets ${r} on ${u})`}formatTokenCount(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}},Fj=class{constructor(e,t){this.sessionId=e,this.goalActive=t}sessionId;goalActive;currentTurnId=null;completed=null;failure=null;waiter=null;cancelled=!1;startTurn(e){this.currentTurnId!==e&&(this.currentTurnId=e,this.completed=null)}prepareTurn(){this.currentTurnId=null,this.completed=null}startSubmittedTurn(e){return this.currentTurnId!==null||this.completed!==null?!1:(this.startTurn(e),!0)}observe(e){if(e.method==="thread/goal/updated"&&e.params.threadId===this.sessionId)this.goalActive=e.params.goal.status==="active";else if(e.method==="thread/goal/cleared"&&e.params.threadId===this.sessionId)this.goalActive=!1;else if(e.method==="turn/started"&&e.params.threadId===this.sessionId)this.startTurn(e.params.turn.id);else if(e.method==="turn/completed"&&e.params.threadId===this.sessionId)this.recordCompletion(e.params);else return;this.waiter?.()}recordCompletion(e){this.completed=e,this.currentTurnId===e.turn.id&&(this.currentTurnId=null)}cancel(){this.cancelled=!0,this.waiter?.()}fail(e){this.failure=e,this.waiter?.()}async waitForCompletion(e){return e.threadId!==this.sessionId?e:(this.completed===null&&this.recordCompletion(e),await new Promise((n,i)=>{this.waiter=()=>{this.failure?i(this.failure):this.cancelled&&this.currentTurnId===null?n(null):this.completed&&this.currentTurnId===null&&(!this.goalActive||this.completed.turn.status!=="completed")&&n(this.completed)},this.waiter()}).finally(()=>{this.waiter=null}))}},Pj=class{constructor(e){this.handle=e}handle;pending=[];processing=!1;enqueue(e){return new Promise((t,n)=>{this.pending.push({params:e,resolve:t,reject:n}),this.startConsumer()})}get isIdle(){return!this.processing&&this.pending.length===0}startConsumer(){this.processing||(this.processing=!0,this.consume())}async consume(){try{for(;this.pending.length>0;){let e=this.pending.shift();try{e.resolve(await this.handle(e.params))}catch(t){e.reject(t)}}}finally{this.processing=!1}}};function zj(e){switch(e.sessionUpdate){case"user_message_chunk":case"agent_message_chunk":case"agent_thought_chunk":return`${e.sessionUpdate}:${e.messageId??""}:${JSON.stringify(e.content)}`;case"tool_call":return`tool_call:${e.toolCallId}:start`;case"tool_call_update":return`tool_call:${e.toolCallId}:update`;default:return null}}async function Oj(e,t){if(!e.path)return null;let n;try{n=await Rj(e.path,"utf8")}catch{return null}return Nj(n,t,Mj(e))}function Nj(e,t,n=new Set){let i=[],r=new Set,u=new Set,s=new Set,o=new Set,a=!1,l=null,c=m=>{for(let p of m){let v=zj(p);v&&v===l||(i.push(p),l=v)}};for(let m of e.split(/\r?\n/)){let p=jj(m);if(!p)continue;let v=Wj(p);if(v){c(v);continue}let g=Lj(p);if(g)switch(g.type){case"message":c(Zj(g));break;case"reasoning":c(Jj(g));break;case"function_call":{let C=qe(g.call_id);if(C&&n.has(C)){s.add(C);break}if(C&&o.has(C))break;let y=Kj(g);if(!y)break;a=!0,o.add(y.update.toolCallId),y.usesTerminal&&r.add(y.update.toolCallId),y.isExecCommand&&u.add(y.update.toolCallId),c([y.update]);break}case"function_call_output":{let C=qe(g.call_id);if(C&&s.has(C))break;let y=Xj(g,t,r,u);y&&c([y]);break}case"configuration_update":break;default:break}}return a?i:null}function Mj(e){let t=new Set;for(let n of e.turns)for(let i of n.items){let r=Uj(i);r&&t.add(r)}return t}function Uj(e){switch(e.type){case"commandExecution":case"fileChange":case"mcpToolCall":case"dynamicToolCall":case"collabAgentToolCall":case"webSearch":case"imageView":case"imageGeneration":case"contextCompaction":return e.id;case"userMessage":case"hookPrompt":case"functionCallOutput":case"agentMessage":case"plan":case"reasoning":case"subAgentActivity":case"enteredReviewMode":case"exitedReviewMode":case"sleep":return null}}function jj(e){if(e.trim().length===0)return null;try{let t=JSON.parse(e);return Yt(t)}catch{return null}}function Lj(e){if(e.type==="response_item")return Yt(e.payload);let t=e.type;return typeof t=="string"&&qj(t)?e:null}function qj(e){switch(e){case"message":case"reasoning":case"function_call":case"function_call_output":return!0;default:return!1}}function Zj(e){let t=e.role;if(t==="user")return[];if(t!=="assistant")return[];let n=qe(e.phase);return Hj(e.content).map(i=>dS(i,void 0,lS(n)))}function Wj(e){if(e.type!=="event_msg")return null;let t=Yt(e.payload);if(!t)return[];switch(t.type){case"user_message":return Gj(t);case"agent_reasoning":return Vj(t);default:return[]}}function Gj(e){let t=[],n=qe(e.message);return n!==null&&n.length>0&&t.push({type:"text",text:n}),t.push(...I4(e.images)),t.push(...I4(e.local_images)),t.map(i=>({sessionUpdate:"user_message_chunk",content:i}))}function Vj(e){let t=qe(e.text);if(t===null||t.length===0)return[];let n=aS(t);return n.length===0?[]:[{sessionUpdate:"agent_thought_chunk",content:{type:"text",text:n}}]}function I4(e){return Array.isArray(e)?e.flatMap(t=>{if(typeof t=="string")return[{type:"text",text:`[@image](${t})`}];let n=Yt(t),i=n?qe(n.path)??qe(n.url):null;return i?[{type:"text",text:`[@image](${i})`}]:[]}):[]}function Hj(e){return Array.isArray(e)?e.flatMap(t=>{let n=Yt(t);if(!n)return[];let i=qe(n.text);if(i!==null)return[{type:"text",text:i}];let r=qe(n.image_url);return r!==null?[{type:"text",text:`[@image](${r})`}]:[]}):[]}function Jj(e){return op($4(e.summary),$4(e.content)).map(t=>({sessionUpdate:"agent_thought_chunk",content:{type:"text",text:t}}))}function $4(e){return Array.isArray(e)?e.flatMap(t=>{if(typeof t=="string")return t.length>0?[t]:[];let n=Yt(t);if(!n)return[];let i=qe(n.text);return i!==null&&i.length>0?[i]:[]}):[]}function Kj(e){let t=qe(e.call_id),n=qe(e.name);if(!t||!n)return null;let i=rd(n,qe(e.namespace)),r=n==="exec_command",u=Yj(e.arguments),s=r?$D(u):null,o=r?rL(u):"",a=s?iL(s,o):null;if(a)return{update:{...cz(t,"inProgress",o,a),name:i},usesTerminal:!1,isExecCommand:r};let l={sessionUpdate:"tool_call",toolCallId:t,name:i,kind:tL(n),title:eL(n,u),status:"in_progress",rawInput:Qj(n,u)};return nL(e)?{update:EL(l,t,o),usesTerminal:!0,isExecCommand:r}:{update:l,usesTerminal:!1,isExecCommand:r}}function Xj(e,t,n,i){let r=qe(e.call_id);if(!r)return null;let u=wL(e.output),s=_L(e.output,u),o=AL(s,u,i.has(r));if(!n.has(r))return{sessionUpdate:"tool_call_update",toolCallId:r,status:o,rawOutput:{output:e.output}};let a={terminal_exit:{exit_code:s,signal:null,terminal_id:r}};return u.length>0&&Object.assign(a,sz(t,r,u)),{sessionUpdate:"tool_call_update",toolCallId:r,status:o,rawOutput:{formatted_output:u,exit_code:s},_meta:a}}function Yj(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function Qj(e,t){if(e==="exec_command"){let n=Yt(t);if(n)return{command:qe(n.cmd)??qe(n.command),cwd:qe(n.workdir)??qe(n.cwd),arguments:t}}return{name:e,arguments:t}}function eL(e,t){if(e==="exec_command"){let n=$D(t);return n?Ii(n):"Run command"}return e==="apply_patch"?"Apply patch":e==="multi_tool_use.parallel"?"Run tools in parallel":e==="view_image"?"View image":e}function tL(e){switch(e){case"exec_command":case"multi_tool_use.parallel":return"execute";case"apply_patch":return"edit";case"view_image":return"read";default:return"other"}}function nL(e){return e.name==="exec_command"}function $D(e){let t=Yt(e);return t?qe(t.cmd)??qe(t.command):null}function rL(e){let t=Yt(e);return t?qe(t.workdir)??qe(t.cwd)??"":""}function iL(e,t){let n=uL(e);if(!n||n.length===0)return null;let i=Sp(n[0]??"");switch(i){case"ls":case"dir":case"eza":case"exa":case"tree":case"du":return{type:"listFiles",command:e,path:kD(n.slice(1))};case"find":return{type:"listFiles",command:e,path:pL(n.slice(1))};case"cat":case"less":case"more":case"head":case"tail":case"nl":case"sed":{let r=xD(n.slice(1));return r?{type:"read",command:e,name:i,path:yL(t,r)}:null}case"rg":case"grep":return oL(e,n.slice(1));case"git":return aL(e,n.slice(1));default:return null}}function uL(e){let t=k4(e);if(!t||t.length===0)return null;if(t.length===1&&sL(t[0]??[])){let n=t[0]?.[2];if(!n)return null;let i=k4(n);return i?B4(i):null}return B4(t)}function B4(e){let t=e[0];return!t||t.length===0||e.length>1&&!e.slice(1).every(hL)?null:t}function sL(e){if(e.length<3)return!1;let t=Sp(e[0]??"");if(t!=="bash"&&t!=="zsh"&&t!=="sh")return!1;let n=e[1];return n!=="-lc"&&n!=="-c"?!1:!!e[2]&&e.length===3}function oL(e,t){if(t.includes("--files"))return{type:"listFiles",command:e,path:mL(t)??kD(t)};let n=as(t,BD()),i=n[0]??null,r=n[1]??null;return i===null&&r===null?null:{type:"search",command:e,query:i,path:r}}function aL(e,t){let n=t[0];if(n==="grep"){let i=as(t.slice(1),BD()),r=i[0]??null,u=i[1]??null;return r===null&&u===null?null:{type:"search",command:e,query:r,path:u}}return n==="ls-files"?{type:"listFiles",command:e,path:xD(t.slice(1))}:null}function k4(e){let t=[],n="",i=null;for(let u=0;u<e.length;u+=1){let s=e[u];if(s!==void 0){if(i){n+=s,s===i?i=null:s==="\\"&&i==='"'&&u+1<e.length&&(u+=1,n+=e[u]??"");continue}if(s==="'"||s==='"'){i=s,n+=s;continue}if(s==="\\"){n+=s,u+=1,n+=e[u]??"";continue}if(s==="|"){if(n.trim().length===0)return null;t.push(n.trim()),n="";continue}if(dL(s))return null;n+=s}}if(i||n.trim().length===0)return null;t.push(n.trim());let r=t.map(lL);return r.some(u=>u===null)?null:r.map(u=>u?.tokens??[])}function lL(e){let t=[],n="",i=null,r=!1;for(let u=0;u<e.length;u+=1){let s=e[u];if(s!==void 0){if(i){s===i?(i=null,r=!0):s==="\\"&&i==='"'&&u+1<e.length?(u+=1,n+=e[u]??""):n+=s;continue}if(s==="'"||s==='"'){i=s;continue}if(s==="\\"){u+=1,n+=e[u]??"";continue}if(/\s/.test(s)){(n.length>0||r)&&(t.push(n),n="",r=!1);continue}if(cL(s))return null;n+=s}}return i?null:((n.length>0||r)&&t.push(n),{tokens:t})}function cL(e){return e==="|"||e===";"||e==="&"||e==="<"||e===">"||e==="("||e===")"||e==="$"||e==="`"}function dL(e){return e===";"||e==="&"||e==="<"||e===">"||e==="("||e===")"||e==="$"||e==="`"}function hL(e){switch(Sp(e[0]??"")){case"sed":return gL(e.slice(1)).length===0;case"head":case"tail":return CL(e.slice(1)).length===0;case"nl":return as(e.slice(1),bp()).length===0;case"sort":case"uniq":case"wc":case"cut":case"tr":case"column":return!0;default:return!1}}function as(e,t){let n=[],i=!1;for(let r=0;r<e.length;r+=1){let u=e[r];if(u!==void 0){if(!i&&u==="--"){i=!0;continue}if(!(!i&&u.startsWith("--")&&u.includes("="))){if(!i&&t.has(u)){r+=1;continue}!i&&fL(u,t)||!i&&u.startsWith("-")&&u!=="-"||u!=="-"&&n.push(u)}}}return n}function fL(e,t){return!e.startsWith("-")||e.startsWith("--")||e.length<3?!1:t.has(e.slice(0,2))}function BD(){return new Set(["-A","-B","-C","-e","-f","-g","-m","-t","-T","--after-context","--before-context","--context","--glob","--iglob","--max-count","--regexp","--type","--type-not"])}function kD(e){return as(e,bp())[0]??null}function xD(e){let t=as(e,bp());return t[t.length-1]??null}function pL(e){return e.find(n=>n!==void 0&&!n.startsWith("-"))??null}function mL(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="-g"||n==="--glob"||n==="--iglob")return e[t+1]??null;let i=n?.match(/^--(?:i?glob)=(.+)$/);if(i?.[1])return i[1]}return null}function bp(){return new Set(["-I","-L","-c","-d","-e","-f","-g","-m","-s","-t","-u","--exclude","--exclude-from","--glob"])}function gL(e){let t=[],n=!1;for(let i=0;i<e.length;i+=1){let r=e[i];if(r!==void 0){if(!n&&r==="--"){n=!0;continue}if(!(!n&&r==="-n")){if(!n&&(r==="-e"||r==="-f")){i+=1;continue}!n&&r.startsWith("-")&&r!=="-"||vL(r)||r!=="-"&&t.push(r)}}}return t}function vL(e){return/^(\d+|\$)?(,(\d+|\$))?[pd]$/.test(e)}function CL(e){let t=[],n=!1;for(let i=0;i<e.length;i+=1){let r=e[i];if(r!==void 0){if(!n&&r==="--"){n=!0;continue}if(!n&&(r==="-n"||r==="-c")){i+=1;continue}!n&&(r.startsWith("-n")||r.startsWith("-c"))&&r.length>2||!n&&r.startsWith("-")&&r!=="-"&&!/^[+-]\d/.test(r)||/^[+-]\d/.test(r)||r!=="-"&&t.push(r)}}return t}function Sp(e){return e.split(/[\\/]/).pop()??e}function yL(e,t){return D4.isAbsolute(t)||e.length===0?t:D4.join(e,t)}function EL(e,t,n){let{rawInput:i,...r}=e;return{...r,content:[{type:"terminal",terminalId:t}],...i===void 0?{}:{rawInput:i},_meta:{terminal_info:{cwd:n,terminal_id:t}}}}function wL(e){return typeof e=="string"?e:Array.isArray(e)?e.flatMap(t=>{let n=Yt(t);if(!n)return[];let i=qe(n.text);if(i!==null)return[i];let r=qe(n.image_url);return r!==null?[`[@image](${r})`]:[]}).join(`
|
|
136
|
+
`):""}function _L(e,t){let n=Yt(e);if(n){let s=x4(n.exit_code)??x4(n.exitCode);if(s!==null)return s}let i=t.match(/Process exited with code (-?\d+)/);if(!i)return null;let r=i[1];if(r===void 0)return null;let u=Number.parseInt(r,10);return Number.isFinite(u)?u:null}function AL(e,t,n){return e!==null?e===0?"completed":"failed":n&&bL(t)?"failed":"completed"}function bL(e){let t=e.trim();return t.length===0?!1:/(^|\n)(Error|Failed|Command failed|Sandbox error|No such file or directory|Permission denied|Operation not permitted|ENOENT|EACCES)(:|\b)/i.test(t)}function Yt(e){return e===null||typeof e!="object"||Array.isArray(e)?null:e}function qe(e){return typeof e=="string"?e:null}function x4(e){return typeof e=="number"&&Number.isFinite(e)?e:null}var vu=class{constructor(e,t){this.keys=e,this.values=t}keys;values},Cu=class{constructor(e){this.text=e}text},F4=256,SL=Reflect.apply,DL=Object.getPrototypeOf,IL=JSON.isRawJSON??(()=>!1);function P4(e,t){return Dp(e,"",t,[],0)}function TD(e,t){return e===t?!0:e===void 0||t===void 0?!1:e instanceof Cu||t instanceof Cu?Vo(e)===Vo(t):e instanceof vu?t instanceof vu&&FD(e.keys,t.keys)&&R4(e.values,t.values):Array.isArray(e)&&Array.isArray(t)&&R4(e,t)}function Vo(e){return e instanceof Cu?e.text:e instanceof vu?`{${e.keys.map((n,i)=>`${JSON.stringify(n)}:${Vo(e.values[i])}`).join(",")}}`:Array.isArray(e)?`[${e.map(Vo).join(",")}]`:JSON.stringify(e)}function FD(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function R4(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!TD(e[n],t[n]))return!1;return!0}function Dp(e,t,n,i,r){switch(typeof e){case"string":case"boolean":return e;case"number":return Number.isFinite(e)?e:null;case"undefined":case"symbol":return;case"object":if(e===null)return null;if(r>=F4||!z4(e))return Is($s(e,String(t),!1),n);break;default:return Is($s(e,String(t),!1),n)}let u=e.toJSON;if(typeof u!="function")return O4(e,n,i,r);let s=SL(u,e,[String(t)]);switch(typeof s){case"string":case"boolean":return s;case"number":return Number.isFinite(s)?s:null;case"undefined":case"symbol":case"function":return;case"object":return s===null?null:z4(s)&&r<F4?O4(s,n,i,r):Is($s(s,String(t),!0),n);default:return Is($s(s,String(t),!0),n)}}function z4(e){if(T4.isProxy(e)||T4.isBoxedPrimitive(e)||IL(e))return!1;let t=DL(e);return Array.isArray(e)?t===Array.prototype:t===Object.prototype||t===null}function O4(e,t,n,i){if(n.includes(e))throw new TypeError("Converting circular structure to JSON");n.push(e);let r=Array.isArray(e)?$L(e,Array.isArray(t)?t:void 0,n,i):BL(e,t instanceof vu?t:void 0,n,i);return n.pop(),r}function $L(e,t,n,i){let r=e.length,u=t?.length===r?void 0:new Array(r);for(let s=0;s<r;s++){let o=t?.[s],a=Dp(e[s],s,o,n,i+1)??null;if(u===void 0){if(a===o)continue;u=t.slice(0,s),u.length=r}u[s]=a}return u??t}function BL(e,t,n,i){let r=Object.keys(e),u=t===void 0?new Array(r.length):void 0,s=0;for(let o=0;o<r.length;o++){let a=r[o],l=t?.keys[s]===a?t.values[s]:void 0,c=Dp(e[a],a,l,n,i+1);if(c!==void 0){if(s!==o&&(r[s]=a),u===void 0){if(c===l&&t.keys[s]===a){s++;continue}u=t.values.slice(0,s)}u[s++]=c}}if(r.length=s,u===void 0){if(s===t.keys.length)return t;u=t.values.slice(0,s)}return u.length=s,new vu(t!==void 0&&FD(r,t.keys)?t.keys:r,u)}function Is(e,t){return t instanceof Cu&&e?.text===t.text?t:e}function $s(e,t,n){let i={__proto__:null,[t]:n?null:e},r=n||t==="toJSON"?kL(i,t,e,n):JSON.stringify(i),u=`{${JSON.stringify(t)}:`;return r.startsWith(u)?new Cu(r.slice(u.length,-1)):void 0}function kL(e,t,n,i){let r=!0;return JSON.stringify(null,function(u,s){return r?(r=!1,e):i&&this===e&&u===t?n:s})}var PD=new Set(["terminal_output","terminal_output_delta","terminal_input","mcp_output_delta"]),xL=["title","kind","status","name","content","locations","rawInput","rawOutput"],Cc=new Set(["title","kind","status","name"]),Pd="_meta.",TL=1024,FL=class{openToolCalls=new Map;finishedToolCalls=new Map;compareMeta=!0;unfinishedToolCalls=new Map;prepare(e,t){if(t.sessionUpdate!=="tool_call"&&t.sessionUpdate!=="tool_call_update")return t;let n=`${e}\0${t.toolCallId}`;this.trackUnfinished(e,t);let i=t.sessionUpdate==="tool_call"?this.recordStart(n,t):this.recordUpdate(n,t);return i!==null&&(i.status==="completed"||i.status==="failed")&&this.finish(n),i}releaseOpen(e){let t=`${e}\0`;for(let n of[...this.openToolCalls.keys()])n.startsWith(t)&&this.openToolCalls.delete(n);this.unfinishedToolCalls.delete(e)}unfinished(e){return[...this.unfinishedToolCalls.get(e)??[]]}trackUnfinished(e,t){let n=t.status,i=this.unfinishedToolCalls.get(e);if(n==="completed"||n==="failed"){i?.delete(t.toolCallId),i?.size===0&&this.unfinishedToolCalls.delete(e);return}t.sessionUpdate!=="tool_call"&&n!=="pending"&&n!=="in_progress"||(i===void 0?this.unfinishedToolCalls.set(e,new Set([t.toolCallId])):i.add(t.toolCallId))}forgetOpen(e,t){this.openToolCalls.delete(`${e}\0${t}`)}recordStart(e,t){this.finishedToolCalls.delete(e);let n=new Map,i=t.status==="completed"||t.status==="failed",r=i?Cc:void 0;for(let[u,s]of N4(t,this.compareMeta&&!i,r))n.set(u,s);return this.openToolCalls.set(e,n),t}recordUpdate(e,t){let n=this.finishedToolCalls.get(e);if(n!==void 0){let r=this.withoutLateOutput(t);return r===null?null:this.withoutUnchangedFields(r,n,Cc)}let i=this.openToolCalls.get(e)??new Map;return this.openToolCalls.set(e,i),this.withoutUnchangedFields(t,i)}withoutUnchangedFields(e,t,n){let i={...e},r=mt(e._meta)?{...e._meta}:void 0;for(let[u,s]of N4(e,this.compareMeta&&n===void 0,n,t)){if(TD(t.get(u),s)){u.startsWith(Pd)?delete r?.[u.slice(Pd.length)]:delete i[u];continue}(n===void 0||n.has(u))&&t.set(u,s)}return r!==void 0&&(Object.keys(r).length>0?i._meta=r:delete i._meta),M4(i)?i:null}withoutLateOutput(e){if(e.status!=null||!mt(e._meta))return e;let t={...e._meta},n=Object.keys(t).filter(r=>PD.has(r));if(n.length===0)return e;for(let r of n)delete t[r];D.log("Dropped output for a finished tool call",{toolCallId:e.toolCallId,keys:n});let i={...e};return Object.keys(t).length>0?i._meta=t:delete i._meta,M4(i)?i:null}finish(e){let t=this.openToolCalls.get(e)??this.finishedToolCalls.get(e)??new Map;if(this.openToolCalls.delete(e),this.finishedToolCalls.delete(e),this.finishedToolCalls.set(e,new Map([...t].filter(([n])=>Cc.has(n)))),this.finishedToolCalls.size>TL){let n=this.finishedToolCalls.keys().next().value;n!==void 0&&this.finishedToolCalls.delete(n)}}};function N4(e,t,n,i){let r=[],u=e;for(let s of xL){if(n!==void 0&&!n.has(s))continue;let o=u[s];o!==void 0&&r.push([s,P4(o,i?.get(s))])}if(t&&mt(e._meta))for(let[s,o]of Object.entries(e._meta)){if(o===void 0||PD.has(s))continue;let a=`${Pd}${s}`;r.push([a,P4(o,i?.get(a))])}return r}function M4(e){return Object.keys(e).some(t=>t!=="sessionUpdate"&&t!=="toolCallId")}var U4=class{constructor(e){this.client=e}client;reports=new FL;asClientConnection(){return this}async notify(e,t){if(e===ae.client.session.update&&zL(t)){let n=this.reports.prepare(t.sessionId,t.update);if(n===null)return;await this.client.notify(e,{...t,update:n});return}await this.client.notify(e,t)}async request(e,t,n){if(e!==ae.client.session.requestPermission||!RL(t))return await this.client.request(e,t,n);this.reports.prepare(t.sessionId,{sessionUpdate:"tool_call_update",...t.toolCall});let i;try{i=await this.client.request(e,t,n)}catch(r){throw this.reports.forgetOpen(t.sessionId,t.toolCall.toolCallId),r}return PL(i)&&this.reports.forgetOpen(t.sessionId,t.toolCall.toolCallId),i}};function PL(e){return e?.outcome?.outcome==="cancelled"}function RL(e){if(e===null||typeof e!="object")return!1;let t=e,n=t.toolCall;return typeof t.sessionId=="string"&&n!==null&&typeof n=="object"&&typeof n.toolCallId=="string"}function zL(e){if(e===null||typeof e!="object")return!1;let t=e;return typeof t.sessionId=="string"&&t.update!==null&&typeof t.update=="object"}var j4="implement_plan",OL="revise_plan",yc=class{static permissionRequest(e,t,n){return{sessionId:e,toolCall:n.renderPermissionToolCall({toolCallId:L4(t),title:"Implement this plan?",kind:"switch_mode",status:"pending",input:{plan:t.text}}),options:[{optionId:j4,name:"Yes, implement this plan",kind:"allow_once"},{optionId:OL,name:"No, and tell Codex what to do differently",kind:"reject_once"}]}}static approved(e){return e.outcome.outcome==="selected"&&e.outcome.optionId===j4}static decided(e,t){return{toolCallId:L4(e),report:"update",status:"completed",opaqueResult:t?"User approved the plan.":"User kept the session in plan mode."}}};function L4(e){return`plan-review:${e.itemId}`}var Rd="fast-mode",q4="model_config",Ho="on",zd="off",Ec="1.5x speed, increased usage";function Mi(e){return e?.additionalSpeedTiers?.includes("fast")??!1}function NL(e,t){return e&&t?"fast":null}function ML(e){return e?.session?.configOptions?.boolean!=null}function UL(e,t=!1){return t?{id:Rd,name:"Fast mode",description:Ec,category:q4,type:"boolean",currentValue:e}:{id:Rd,name:"Fast mode",description:Ec,category:q4,type:"select",currentValue:e?Ho:zd,options:[{value:zd,name:"Off",description:"Default speed, normal usage"},{value:Ho,name:"On",description:Ec}]}}function jL(e){if(!e)return!1;let n=e._meta?.platform==="intellij",i=e.name.startsWith("JetBrains");return(n||i)&&e.version.startsWith("2026.1")}function Z4(e,t=1){if(p_(e))return"air";let n=e?.subagents,i=typeof n=="object"&&n!==null&&!Array.isArray(n),r=fu(e);return yn(e,ed)||t===1&&r&&i?"air":r?"hidden":t===2||i?"standard":"hidden"}var LL=class{context;approvals;elicitations;constructor(e,t,n,i){this.context=new XS({sessionId:t}).beginPrompt(),this.approvals=new KS(e,this.context,void 0,i),this.elicitations=new YS(e,this.context,n,void 0,i)}async observe(e,t){let n={...e,params:{...e.params,threadId:t}};this.context.handleNotification(n),await this.elicitations.handleNotification(n)}},qL="_codex/hooks/list",ZL="_codex/hooks/trust";async function Od(e,t){let[n]=(await e.hooksList({cwds:[t]})).data;if(n===void 0)throw new Error("Codex could not list hooks for the requested directory");return{...n,hooks:n.hooks.filter(i=>i.source==="sessionFlags")}}async function WL(e,t,n){let i=(o,a)=>o.find(l=>l.key===a.key&&l.currentHash===a.currentHash),r=(await Od(e,t)).hooks,u=n.map(o=>{let a=i(r,o);if(a===void 0)throw new Error("A Codex hook changed before trust was recorded");return a}).filter(o=>o.trustStatus!=="trusted").map(o=>({keyPath:`hooks.state.${JSON.stringify(o.key)}.trusted_hash`,value:o.currentHash,mergeStrategy:"replace"}));u.length>0&&await e.configBatchWrite({edits:u,reloadUserConfig:!0});let s=(await Od(e,t)).hooks;return n.every(o=>i(s,o)?.trustStatus==="trusted")}var W4="sessionIndex",VL="sessionBatchGet",Nd="_session/batch_get",HL="sessionArchive",JL="sessionRename",Md="_session/rename",Ud="_session/archive",jd="_session/unarchive",KL="sessionListSubscribe",Ld="_session/list/subscribe",qd="_session/list/unsubscribe",XL="_session/list/changes",YL="sessionWorktrees",QL="list",RD="state",zD="lastTurnEndedAt",OD="lastPromptAt",ND="model",Ip="forkedFrom",MD="agentWorktree",eq=50,UD=100,$p="archived",jD=["unarchived","archived","all"];function Zd(e){switch(e){case"unarchived":return[!1];case"archived":return[!0];case"all":return[!1,!0]}}function LD(e){return typeof e=="string"&&jD.includes(e)}function Wd(e){return e.source==="cli"||e.source==="vscode"}function tq(e){return!e.ephemeral&&Wd(e)&&e.preview!==""&&e.path!==null}function qD(e,t){return tq(e)?{thread:e,archived:e.path!==null&&WS(e.path,t)}:null}var G4=Q.strictObject({sessionIds:Q.array(Q.string().refine(e=>e.trim().length>0,"sessionIds must not be blank")).refine(e=>new Set(e).size===e.length,"sessionIds must be distinct")}),V4=Q.object({sessionId:Q.string(),title:Q.string()}).passthrough(),Bs=Q.object({sessionId:Q.string()}).passthrough(),ks=Q.preprocess(e=>e??{},Q.record(Q.string(),Q.unknown()));function nq(e){let t=on(on(e)[Bt]),n=on(on(t[kt])[QL]);return{limit:uq(n.limit),archived:iq(n.archived),includeWorktrees:rq(n,"includeWorktrees")}}function rq(e,t){let n=e[t]??!1;if(typeof n!="boolean")throw k.invalidParams({[t]:n},`${t} must be a boolean`);return n}function iq(e){if(e==null)return"unarchived";if(!LD(e))throw k.invalidParams({archived:e},`archived must be one of ${jD.map(t=>`"${t}"`).join(", ")}`);return e}function uq(e){if(e==null)return eq;if(typeof e!="number"||!Number.isInteger(e)||e<1)throw k.invalidParams({limit:e},"limit must be an integer of at least 1");return Math.min(UD,e)}function sq(e,t,n,i){return{cursor:i,limit:t,sortKey:"recency_at",archived:n,sourceKinds:[],modelProviders:[],...e===null?{}:{cwd:e.length===1?e[0]:e},useStateDbOnly:!0}}var oq=50,aq=300,Gd="air-list:";async function lq(e,t,n,i,r,u=null){let s=r!==void 0,o=i===null?{scope:u,archived:n.archived,includeWorktrees:n.includeWorktrees,filtered:s,sides:Zd(n.archived).map(()=>({codexCursor:null,done:!1})),after:null}:dq(i);if(o.scope!==u||o.archived!==n.archived||o.includeWorktrees!==n.includeWorktrees||o.filtered!==s)throw lr(i);let a=s?UD:n.limit,l=Zd(o.archived),c=A=>l[A],m=o.sides.map(A=>new Set(A.codexCursor===null?[]:[A.codexCursor])),p=new Map,v=(A,S)=>{let z=o.sides[A];S===null?z.done=!0:m[A].has(S)?(D.log("thread/list repeats its cursor; that list ends here",{cursor:S,archived:c(A)}),z.done=!0):(m[A].add(S),z.codexCursor=S)},g=[],C=Date.now(),y=()=>({threads:g,nextCursor:o.sides.every(A=>A.done)?null:cq(o)}),b=A=>A<oq&&Date.now()-C<aq?!1:(g.length===0&&D.log("The session list read its scan budget; the client continues from the cursor",{rounds:A}),!0);for(let A=1;;A++){await Promise.all([...o.sides.entries()].map(async([Z,oe])=>{if(oe.done||p.has(Z))return;let te=await e(sq(t,a,c(Z),oe.codexCursor)),ye=te.data.map(zn);p.set(Z,{rows:H4(r===void 0?te.data:te.data.filter(r),o.after),nextCursor:te.nextCursor??null,oldest:ye.length===0?null:Math.min(...ye)})}));let S=[...p].filter(([,Z])=>Z.oldest===null&&Z.nextCursor!==null);if(S.length>0){for(let[Z,oe]of S)p.delete(Z),v(Z,oe.nextCursor);if(o.sides.every(Z=>Z.done)||b(A))return y();continue}let z=-1/0;for(let[Z,oe]of p)!o.sides[Z].done&&oe.nextCursor!==null&&oe.oldest!==null&&(z=Math.max(z,oe.oldest));let M=[...p].sort(([Z],[oe])=>Z-oe).flatMap(([Z,oe])=>oe.rows.filter(te=>zn(te)>=z).map(te=>({thread:te,archived:c(Z),index:Z})));M.sort((Z,oe)=>zn(oe.thread)-zn(Z.thread));let T=M.slice(0,n.limit-g.length),G=new Set(T.map(Z=>Z.thread.id));for(let[Z,oe]of[...p])(oe.oldest===null||oe.oldest>=z)&&oe.rows.every(ye=>G.has(ye.id))&&(p.delete(Z),v(Z,oe.nextCursor));if(T.length>0){let Z=zn(T[T.length-1].thread),oe=T.filter(te=>zn(te.thread)===Z).map(te=>te.thread.id);o.after={recency:Z,ids:o.after?.recency===Z?[...o.after.ids,...oe]:oe},g.push(...T.map(({thread:te,archived:ye})=>({thread:te,archived:ye})));for(let te of p.values())te.rows=H4(te.rows,o.after)}if(o.sides.every(Z=>Z.done)||g.length>=n.limit||g.length>0&&!s||b(A))return y()}}function zn(e){return e.recencyAt??e.updatedAt}function H4(e,t){if(t===null)return e;let n=new Set(t.ids);return e.filter(i=>zn(i)<t.recency||zn(i)===t.recency&&!n.has(i.id))}function cq(e){let t=[e.scope,e.archived,e.includeWorktrees,e.filtered,e.sides.map(n=>n.done?0:[n.codexCursor]),e.after===null?null:[e.after.recency,e.after.ids]];return Gd+Buffer.from(JSON.stringify(t)).toString("base64url")}function dq(e){if(!e.startsWith(Gd))throw lr(e);let t;try{t=JSON.parse(Buffer.from(e.slice(Gd.length),"base64url").toString("utf8"))}catch{throw lr(e)}if(!Array.isArray(t)||t.length!==6)throw lr(e);let[n,i,r,u,s,o]=t;if(n!==null&&typeof n!="string"||!LD(i)||typeof r!="boolean"||typeof u!="boolean"||!Array.isArray(s)||s.length!==Zd(i).length)throw lr(e);let a=s.map(c=>{if(c===0)return{codexCursor:null,done:!0};if(Array.isArray(c)&&c.length===1&&(c[0]===null||typeof c[0]=="string"))return{codexCursor:c[0],done:!1};throw lr(e)}),l={scope:n,archived:i,includeWorktrees:r,filtered:u,sides:a};if(o===null)return{...l,after:null};if(Array.isArray(o)&&o.length===2&&typeof o[0]=="number"&&Number.isFinite(o[0])&&Array.isArray(o[1])&&o[1].every(c=>typeof c=="string"))return{...l,after:{recency:o[0],ids:o[1]}};throw lr(e)}function lr(e){return k.invalidParams({cursor:e},"invalid cursor")}function hq(e,t,n,i=!1){let r={[$p]:t};e.recencyAt!==null&&(r[OD]=J4(e.recencyAt)),e.model&&(r[ND]=e.model),e.forkedFromId&&(r[Ip]=e.forkedFromId),n?.state!==void 0&&(r[RD]=n.state),n?.lastTurnEndedAt!==void 0&&(r[zD]=n.lastTurnEndedAt),i&&(r[MD]=!0);let u;for(let[s,o]of Object.entries(r))u=xt(u,s,o);return{sessionId:e.id,cwd:e.cwd,title:rS(e),updatedAt:J4(e.updatedAt),...u?{_meta:u}:{}}}function J4(e){return new Date(e*1e3).toISOString()}function fq(e,t=!1,n=!1){if(e.type!=="notLoaded")return e.type==="active"&&e.activeFlags.length>0?"requires_action":e.type==="active"?n?"reviewing":"running":e.type==="systemError"||t?"error":"idle"}function pq(e){return e.status==="failed"||e.status!=="interrupted"&&e.status!=="inProgress"&&e.error!==null}var mq=class{constructor(e=()=>!0){this.isSession=e}isSession;lastTurnEndedAt=new Map;failed=new Set;reviewing=new Set;observe(e){if(e.method==="thread/deleted"){this.forget(e.params.threadId);return}if(e.method==="item/started"||e.method==="item/completed"){let i=e.params.item.type;i==="enteredReviewMode"&&this.reviewing.add(e.params.threadId),i==="exitedReviewMode"&&this.reviewing.delete(e.params.threadId);return}if(e.method==="turn/started"||e.method==="thread/closed"||e.method==="thread/status/changed"&&e.params.status.type==="notLoaded"){this.failed.delete(e.params.threadId),this.reviewing.delete(e.params.threadId);return}if(e.method!=="turn/completed"||(this.reviewing.delete(e.params.threadId),pq(e.params.turn)?this.failed.add(e.params.threadId):this.failed.delete(e.params.threadId),!this.isSession(e.params.threadId)))return;let t=e.params.turn.completedAt,n=t===null?new Date:new Date(t*1e3);this.lastTurnEndedAt.set(e.params.threadId,n.toISOString())}activityOf(e){let t=fq(e.status,this.failed.has(e.id),this.reviewing.has(e.id)),n=this.lastTurnEndedAt.get(e.id);return t===void 0&&n===void 0?null:{...t!==void 0?{state:t}:{},...n!==void 0?{lastTurnEndedAt:n}:{}}}resetLoaded(){let e=[...new Set([...this.failed,...this.reviewing])];return this.failed.clear(),this.reviewing.clear(),e}forget(e){this.lastTurnEndedAt.delete(e),this.failed.delete(e),this.reviewing.delete(e)}};function gq(e){let t=on(on(on(e._meta)[Bt])[kt]);return JSON.stringify([e.title??null,t[OD]??null,t[RD]??null,t[zD]??null,t[ND]??null,t[Ip]??null,t[$p]??null,t[MD]??null])}function vq(e){let t=on(on(on(e._meta)[Bt])[kt])[Ip];return typeof t=="string"?t:null}function on(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function K4(e){try{return Cq(e)??[e]}catch{return[e]}}function X4(e){let t=Dt(e);return t===null||t===e?[e]:[e,t]}function Cq(e){let t=ZD(e);if(t===null)return null;let n=Dt(e);if(n===null)return null;let i=[e],r=new Set([e]);r.has(n)||(r.add(n),i.push(n)),t.primaryRoot!==null&&Y4(i,r,t.primaryRoot,t);let u=he.join(t.commonDir,"worktrees");if(!wt.existsSync(u))return i;let s=Dt(u);if(s===null)return null;let o=wt.readdirSync(s,{withFileTypes:!0}).filter(a=>a.isDirectory()).map(a=>a.name).sort();for(let a of o){let l=Dt(he.join(s,a));if(l===null||he.dirname(l)!==s)continue;let c=eo(he.join(l,"gitdir"),l,"");c===null||he.basename(c)!==".git"||Y4(i,r,he.dirname(c),t)}return i}function Y4(e,t,n,i){let r=Dt(n);if(r===null)return;let u=Dt(he.join(r,i.relativeCwd));if(u===null||!jn(u)||!WD(u,r))return;let s=ZD(u);s!==null&&s.commonDir===i.commonDir&&s.relativeCwd===i.relativeCwd&&!t.has(u)&&(t.add(u),e.push(u))}function ZD(e){let t=Dt(e);if(t===null||!jn(t))return null;let n=Eq(t);if(n===null)return null;let i=Dt(n);if(i===null||!WD(t,i))return null;let r=he.relative(i,t),u=he.join(i,".git"),s=Dl(u);if(s===null||s.isSymbolicLink())return null;let o;if(s.isDirectory())o=Dt(u);else if(s.isFile()){let a=eo(u,i,"gitdir:");if(a===null||!jn(a)||(o=eo(he.join(a,"commondir"),a,""),o===null||!jn(o)))return null;let l=Dt(he.join(o,"worktrees"));if(l===null||he.dirname(a)!==l)return null;let c=eo(he.join(a,"gitdir"),a,"");if(c===null||c!==Dt(u))return null}else return null;return o===null?null:{commonDir:o,relativeCwd:r,primaryRoot:yq(o)}}function yq(e){if(he.basename(e)!==".git")return null;let t=he.dirname(e),n=he.join(t,".git"),i=Dl(n);return i===null||!i.isDirectory()||Dt(n)!==e?null:t}function Eq(e){let t=e;for(;;){let n=he.join(t,".git");if(wt.existsSync(n)&&(!jn(n)||wt.existsSync(he.join(n,"HEAD"))))return t;let i=he.dirname(t);if(i===t)return null;t=i}}function eo(e,t,n){let i=Dl(e);if(i===null||!i.isFile())return null;let r;try{r=wt.readFileSync(e,"utf8").trim()}catch{return null}if(!r.startsWith(n))return null;let u=r.slice(n.length).trim();return u.length===0||u.includes(`
|
|
137
|
+
`)||u.includes("\r")?null:Dt(he.resolve(t,u))}function Dt(e){if(!he.isAbsolute(e))return null;try{return wt.realpathSync.native(e)}catch{return null}}function Dl(e){try{return wt.lstatSync(e)}catch{return null}}function jn(e){try{return wt.statSync(e).isDirectory()}catch{return!1}}function WD(e,t){let n=he.relative(t,e);return n===""||!n.startsWith("..")&&!he.isAbsolute(n)}var wq="codex-thread.json",_q=6e4;function Aq(e){return e.startsWith("\\\\")||process.platform==="win32"&&e.startsWith("//")}var bq=class{mainRoots=new Map;madeWorktrees=new Map;ttlMs;maxEntries;clock;constructor(e={}){this.ttlMs=e.ttlMs??_q,this.maxEntries=e.maxEntries??4096,this.clock=e.clock??Date.now}isCodexWorktreeCwd(e){let t=Dq(e);if(t===null)return!1;let n=this.cached(this.mainRoots,t,()=>Iq(t));return n===null?!1:xq(t,this.cached(this.madeWorktrees,n,()=>kq(n)))}cached(e,t,n){let i=this.clock(),r=e.get(t);if(r!==void 0&&i-r.readAt<this.ttlMs)return r.value;let u=n();return e.size>=this.maxEntries&&e.clear(),e.set(t,{value:u,readAt:i}),u}},Jo=".git",Q4="gitdir:",Sq=4096;function Dq(e){return!Fq(e)||!VD(e)?null:he.resolve(e)}function Iq(e){try{let t=e;for(;;){let n=he.join(t,Jo),i=HD(n);if(i?.isDirectory())return null;if(i?.isFile())return $q(n,t);if(Dl(n)!==null)return null;let r=he.dirname(t);if(r===t)return null;t=r}}catch{return null}}function $q(e,t){let n=Bp(e);if(n===null||!n.startsWith(Q4))return null;let i=kp(t,GD(n.slice(Q4.length)));if(i===null||!Vd(Pq(i),"worktrees"))return null;let r=Bq(i);return r===null||!Vd(he.basename(r),Jo)||!jn(r)?null:he.dirname(r)}function Bq(e){let t=he.join(e,"commondir");if(!JD(t))return Ko(Ko(e));let n=Bp(t);return n===null?null:kp(e,n)}function kq(e){try{let t=he.join(e,Jo,"worktrees");if(!jn(t))return[];let n=new Set;for(let i of wt.readdirSync(t)){let r=he.join(t,i);if(!JD(he.join(r,wq)))continue;let u=Bp(he.join(r,"gitdir")),s=u===null?null:kp(r,u);if(s===null||!Vd(he.basename(s),Jo))continue;let o=Ko(s);o!==null&&jn(o)&&n.add(o)}return[...n].sort()}catch{return[]}}function xq(e,t){return t.some(n=>{let i=he.relative(n,e);return i===""||i!==".."&&!i.startsWith(`..${he.sep}`)&&!he.isAbsolute(i)})}function Bp(e){let t;try{if(t=wt.openSync(e,"r"),wt.fstatSync(t).size>Sq)return null;let n=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(wt.readFileSync(t)),i=GD(n.split(/\r\n|\n|\r/,1)[0]??"");return i.length===0?null:i}catch{return null}finally{t!==void 0&&wt.closeSync(t)}}var ev="[\\t\\n\\v\\f\\r\\u001c-\\u001f\\p{Zs}\\p{Zl}\\p{Zp}]",Tq=new RegExp(`^${ev}+|${ev}+$`,"gu");function GD(e){return e.replace(Tq,"")}function kp(e,t){return t.length===0||!VD(t)?null:he.resolve(e,t)}function Fq(e){return process.platform!=="win32"?he.isAbsolute(e):/^[a-zA-Z]:[\\/]/.test(e)||/^[\\/]{2}[^\\/]/.test(e)}function VD(e){return process.platform!=="win32"?!e.includes("\0"):!/[<>:"|?*\u0000-\u001f]/.test(e.replace(/^[a-zA-Z]:/,""))}function Vd(e,t){return e!==null&&e.toLowerCase()===t}function Ko(e){if(e===null)return null;let t=he.dirname(e);return t===e?null:t}function Pq(e){let t=Ko(e);return t===null?null:he.basename(t)}function HD(e){try{return wt.statSync(e)}catch{return null}}function JD(e){return HD(e)?.isFile()??!1}var zq=1024*1024,tv=64*1024,Oq=16384,nv=8,Nq=10,Mq=class{constructor(e){this.deps=e}deps;origins=new Map;pending=new Map;timer=null;running=!1;disposed=!1;originOf(e){if(e.forkedFromId)return e.forkedFromId;let t=this.origins.get(e.id);return typeof t=="string"||t===null?t:(e.path===null||(t===void 0||t.path!==e.path||t.updatedAt!==e.updatedAt)&&this.schedule(e),null)}remember(e,t){this.pending.delete(e),iv(this.origins,e,t)}dispose(){this.disposed=!0,this.pending.clear(),this.timer!==null&&clearTimeout(this.timer),this.timer=null}busy(){return this.running||this.timer!==null}schedule(e){this.disposed||(this.pending.set(e.id,e),!(this.timer!==null||this.running)&&(this.timer=setTimeout(()=>{this.timer=null,this.readPending()},0),this.timer.unref?.()))}async readPending(){this.running=!0;try{for(;this.pending.size>0&&!this.disposed;){let e=[...this.pending.values()];this.pending.clear();let t=[];for(let n=0;n<e.length&&!this.disposed;n+=nv)await Promise.all(e.slice(n,n+nv).map(async i=>{await this.read(i)&&t.push(i.id)}));t.length>0&&!this.disposed&&this.deps.onFound(t)}}finally{this.running=!1}}async read(e){if(e.path===null||rv(this.origins.get(e.id)))return!1;let t;try{t=await Uq(e.path)}catch(n){return D.log("Cannot read the fork parent of a thread",{threadId:e.id,error:String(n)}),!1}return rv(this.origins.get(e.id))?!1:(iv(this.origins,e.id,t===void 0?{path:e.path,updatedAt:e.updatedAt}:t),typeof t=="string")}};async function Uq(e){let t;try{t=await Rq.open(e,"r")}catch(u){if(u.code==="ENOENT")return;throw u}let n=null;try{let u=[];for(let s=0;s<zq;){let o=Buffer.alloc(tv),{bytesRead:a}=await t.read(o,0,tv,s);if(a===0)break;let l=o.subarray(0,a).indexOf(Nq);if(u.push(o.subarray(0,l<0?a:l)),l>=0){n=Buffer.concat(u).toString("utf8");break}s+=a}}finally{await t.close()}if(n===null)return;let i;try{i=JSON.parse(n)}catch{return null}let r=_c(_c(i,"payload"),"forked_from_id");return _c(i,"type")==="session_meta"&&typeof r=="string"&&r!==""?r:null}function rv(e){return typeof e=="string"||e===null}function _c(e,t){return e!==null&&typeof e=="object"?e[t]:void 0}function iv(e,t,n){if(e.delete(t),e.set(t,n),e.size<=Oq)return;let i=e.keys().next().value;i!==void 0&&e.delete(i)}var Xo="session_index.jsonl",Zq=1024*1024,Wq=class{file;offset;constructor(e){this.file=qq.join(e,Xo),this.offset=uv(this.file)}readRenamedThreads(){let e=uv(this.file);if(e<this.offset)return this.offset=e,[];if(e===this.offset)return[];if(e-this.offset>Zq)return D.log("Skipping a long append to the session name log",{bytes:e-this.offset}),this.offset=e,[];let t;try{let r=e-this.offset,u=Buffer.alloc(r),s=to.openSync(this.file,"r");try{to.readSync(s,u,0,r,this.offset)}finally{to.closeSync(s)}t=u.toString("utf8")}catch{return[]}let n=t.lastIndexOf(`
|
|
138
|
+
`);if(n<0)return[];this.offset+=Buffer.byteLength(t.slice(0,n+1),"utf8");let i=new Set;for(let r of t.slice(0,n).split(`
|
|
139
|
+
`))try{let u=JSON.parse(r).id;typeof u=="string"&&i.add(u)}catch{}return[...i]}};function uv(e){try{return to.statSync(e).size}catch{return 0}}var sv="archived_sessions",KD=/^state_\d+\.sqlite-wal$/,Gq=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/i,Vq=class{constructor(e,t,n){this.home=e,this.listener=t,this.walSnapshot=ov(e),this.refreshWalWatchers(),this.watchHome(),this.watchArchive(),this.watchNameLog(),this.fallbackTimer=setInterval(()=>this.pollWal(),n),this.fallbackTimer.unref?.()}home;listener;homeWatcher=null;archiveWatcher=null;nameLogWatcher=null;walWatchers=new Map;fallbackTimer=null;walSnapshot;stopped=!1;stop(){this.stopped=!0,this.fallbackTimer!==null&&clearInterval(this.fallbackTimer),this.fallbackTimer=null,this.homeWatcher?.close(),this.homeWatcher=null,this.archiveWatcher?.close(),this.archiveWatcher=null,this.nameLogWatcher?.close(),this.nameLogWatcher=null;for(let e of this.walWatchers.values())e.watcher.close();this.walWatchers.clear()}stateChanged(){this.stopped||this.listener.stateChanged()}watchHome(){try{this.homeWatcher=gn.watch(this.home,{persistent:!1},(e,t)=>{let n=t===null?null:t.toString();(n===null||KD.test(n))&&(e==="rename"&&this.refreshWalWatchers(),this.stateChanged()),(n===null||n===Xo)&&(e==="rename"&&this.watchNameLog(),this.stateChanged()),(n===null||n===sv)&&this.archiveWatcher===null&&this.watchArchive()}),this.homeWatcher.on("error",e=>{D.log("CODEX_HOME watch failed; the 30 s check remains",{error:String(e)}),this.homeWatcher?.close(),this.homeWatcher=null})}catch(e){D.log("Cannot watch CODEX_HOME; the 30 s check remains",{home:this.home,error:String(e)}),this.homeWatcher=null}}watchArchive(){if(this.stopped)return;let e=Zr.join(this.home,sv);if(gn.existsSync(e))try{let t=gn.watch(e,{persistent:!1},(n,i)=>{let r=i===null?null:Gq.exec(i.toString())?.[1];r&&!this.stopped&&this.listener.archiveMoved(r.toLowerCase())});t.on("error",()=>{t.close(),this.archiveWatcher===t&&(this.archiveWatcher=null)}),this.archiveWatcher=t}catch(t){D.log("Cannot watch archived_sessions",{dir:e,error:String(t)})}}watchNameLog(){if(this.stopped)return;this.nameLogWatcher?.close(),this.nameLogWatcher=null;let e=Zr.join(this.home,Xo);if(gn.existsSync(e))try{let t=gn.watch(e,{persistent:!1},n=>{n==="rename"&&this.watchNameLog(),this.stateChanged()});t.on("error",()=>{t.close(),this.nameLogWatcher===t&&(this.nameLogWatcher=null)}),this.nameLogWatcher=t}catch(t){D.log("Cannot watch the session name log",{file:e,error:String(t)})}}pollWal(){if(this.stopped)return;this.refreshWalWatchers(),this.archiveWatcher===null&&this.watchArchive(),this.nameLogWatcher===null&&this.watchNameLog();let e=ov(this.home);e!==this.walSnapshot&&(this.walSnapshot=e,this.stateChanged())}refreshWalWatchers(){if(this.stopped)return;let e=this.home,t=new Map;for(let n of XD(e)){let i=av(Zr.join(e,n));i!==null&&t.set(n,i)}for(let[n,i]of this.walWatchers)t.get(n)!==i.identity&&this.dropWalWatcher(n,i);for(let[n,i]of t)if(!this.walWatchers.has(n))try{let r=gn.watch(Zr.join(e,n),{persistent:!1},s=>{s==="rename"&&(process.platform!=="darwin"||av(Zr.join(e,n))!==u.identity)&&(this.dropWalWatcher(n,u),this.refreshWalWatchers()),this.stateChanged()}),u={watcher:r,identity:i};r.on("error",()=>this.dropWalWatcher(n,u)),this.walWatchers.set(n,u)}catch(r){D.log("Cannot watch the state DB WAL; the 30 s check remains",{name:n,error:String(r)})}}dropWalWatcher(e,t){t.watcher.close(),this.walWatchers.get(e)===t&&this.walWatchers.delete(e)}};function ov(e){return[...XD(e),Xo].map(t=>{try{let n=gn.statSync(Zr.join(e,t));return`${t}:${n.size}:${n.mtimeMs}`}catch{return`${t}:-`}}).join("|")}function av(e){try{let t=gn.statSync(e);return process.platform==="darwin"?`${t.dev}:${t.ino}:${t.birthtimeMs}`:`${t.dev}:${t.ino}`}catch{return null}}function XD(e){try{return gn.readdirSync(e).filter(t=>KD.test(t)).sort()}catch{return[]}}var Ac=128,Hq="too_many_subscriptions",Jq={quietMs:150,maxWaitMs:1e3,ownChangeDelayMs:20,minChangeIntervalMs:1e3,fallbackIntervalMs:3e4},Kq=1e3,Xq=20,Yq=100,bc=10,lv=8,Qq=256,eZ=1e4,tZ=1e3,nZ=class{constructor(e){this.deps=e,this.timings=e.timings??Jq,this.now=e.now??Date.now}deps;subscriptions=new Map;groups=new Map;timings;now;watcher=null;nameLog=null;marks=null;marksReady=null;watchingSince=0;stateChanges=0;resumes={unarchived:null,archived:null};watchGeneration=0;pendingThreads=new Set;scanRetries=new Set;epoch=0;readEpoch=0;appServerGeneration=0;deletedThreads=new Map;scanRequested=!1;firstStateChangeAt=null;scanDueAt=null;threadsDueAt=null;timer=null;timerDueAt=null;flushing=null;lastChangeAt=new Map;ignoredThreads=new Set;forking=new Map;disposed=!1;async subscribe(e){let t=Math.floor(this.now()/1e3);if(this.disposed)throw k.internalError(void 0,"The connection is closed");if(this.subscriptions.size>=Ac)throw k.invalidParams({reason:Hq,max:Ac},`At most ${Ac} session list subscriptions per connection`);let n=Lq.resolve(e),i=this.groups.get(n);if(i===void 0){let u={cwd:n,scope:new Set(this.deps.scopeCwds(n)),subscriptions:new Set,rows:new Map,ready:Promise.resolve(),scopeResolvedAt:this.now()};this.groups.set(n,u),i=u,this.startWatching(),u.ready=this.makeReady(u)}let r={id:jq(),group:i,sent:new Map,ready:!1,held:null,readyTimer:null,startedSecond:null,epoch:++this.epoch};return this.subscriptions.set(r.id,r),i.subscriptions.add(r),this.startWatching(),await Promise.all([i.ready,this.marksReady]),r.startedSecond=t,this.subscriptions.get(r.id)===r&&(r.readyTimer=setTimeout(()=>{r.readyTimer=null,r.ready=!0,r.held!==null&&this.requestThreads(0)},0),r.readyTimer.unref?.()),r.id}unsubscribe(e){let t=this.subscriptions.get(e);if(t===void 0)return;this.subscriptions.delete(e),t.readyTimer!==null&&clearTimeout(t.readyTimer);let n=t.group;n.subscriptions.delete(t),n.subscriptions.size===0&&this.groups.get(n.cwd)===n&&this.groups.delete(n.cwd),this.subscriptions.size===0&&this.stopWatching()}dispose(){this.disposed=!0;for(let e of this.subscriptions.values())e.readyTimer!==null&&clearTimeout(e.readyTimer);this.subscriptions.clear(),this.groups.clear(),this.stopWatching()}resources(){return{subscriptions:this.subscriptions.size,groups:this.groups.size,watching:this.watcher!==null,timer:this.timer!==null}}observe(e){if(this.subscriptions.size!==0)switch(e.method){case"thread/started":{let t=e.params.thread;if(t.ephemeral||!Wd(t)){this.ignore(t.id);return}this.threadChanged(t.id);return}case"thread/deleted":this.pendingThreads.delete(e.params.threadId),this.deletedThreads.set(e.params.threadId,!0),this.requestThreads(this.timings.ownChangeDelayMs);return;case"thread/status/changed":case"thread/name/updated":case"thread/archived":case"thread/unarchived":case"thread/closed":case"turn/started":case"turn/completed":this.ignoredThreads.has(e.params.threadId)||this.threadChanged(e.params.threadId);return;case"item/started":case"item/completed":(e.params.item.type==="enteredReviewMode"||e.params.item.type==="exitedReviewMode")&&!this.ignoredThreads.has(e.params.threadId)&&this.threadChanged(e.params.threadId);return;default:return}}refreshLoadedThreads(e){if(this.appServerGeneration++,this.subscriptions.size===0)return;let t=[...this.groups.values()].flatMap(n=>[...n.rows].filter(([,{row:i}])=>i._meta?.jetbrains?.air?.state!==void 0).map(([i])=>i));for(let n of new Set([...e,...t]))this.threadChanged(n);this.pendingThreads.size>0&&this.requestThreads(this.timings.ownChangeDelayMs)}threadsChanged(e){if(this.subscriptions.size!==0)for(let t of e)this.ignoredThreads.has(t)||this.threadChanged(t)}forkStarted(e){let t=this.forking.get(e);t!==void 0?t.count++:this.forking.set(e,{count:1,forks:new Set})}forkCreated(e,t){this.forking.get(e)?.forks.add(t)}forkAnswered(e){let t=this.forking.get(e);t!==void 0&&(--t.count>0||(this.forking.delete(e),[...this.subscriptions.values()].some(n=>n.held!==null)&&this.requestThreads(0)))}withoutForksInFlight(e){if(this.forking.size===0)return{now:e,later:null};let t=r=>{let u=vq(r);return u!==null&&this.forking.has(u)||[...this.forking.values()].some(s=>s.forks.has(r.sessionId))},n=e.sessions.filter(t);if(n.length===0)return{now:e,later:null};let i=e.sessions.filter(r=>!t(r));return{now:i.length===0&&e.removed.length===0?null:{...e,sessions:i},later:{subscriptionId:e.subscriptionId,sessions:n,removed:[]}}}threadChanged(e){this.scanRetries.delete(e),this.pendingThreads.add(e),this.requestThreads(this.timings.ownChangeDelayMs)}ignore(e){if(this.ignoredThreads.add(e),this.ignoredThreads.size>Qq){let t=this.ignoredThreads.values().next().value;t!==void 0&&this.ignoredThreads.delete(t)}}stateChanged(){this.stateChanges++,this.requestScan()}requestScan(){if(this.subscriptions.size===0)return;let e=this.now();this.scanRequested=!0,this.firstStateChangeAt??=e,this.scanDueAt=Math.min(e+this.timings.quietMs,this.firstStateChangeAt+this.timings.maxWaitMs),this.arm()}scanAt(e){this.subscriptions.size!==0&&(this.scanRequested=!0,this.scanDueAt=this.scanDueAt===null?e:Math.min(this.scanDueAt,e),this.arm())}requestThreads(e){if(this.subscriptions.size===0)return;let t=this.now()+e;this.threadsDueAt=this.threadsDueAt===null?t:Math.min(this.threadsDueAt,t),this.arm()}arm(){if(this.disposed||this.flushing!==null)return;let e=Math.min(this.scanDueAt??1/0,this.threadsDueAt??1/0);e!==1/0&&(this.timer!==null&&this.timerDueAt===e||(this.timer!==null&&clearTimeout(this.timer),this.timerDueAt=e,this.timer=setTimeout(()=>{this.timer=null,this.timerDueAt=null,this.flushing=this.flush().finally(()=>{this.flushing=null,this.arm()})},Math.max(0,e-this.now())),this.timer.unref?.()))}startWatching(){if(this.marksReady===null&&(this.watchingSince=Math.floor(this.now()/1e3),this.marksReady=this.withReader(async n=>{await this.scan(n,!0)})),this.watcher!==null)return;let e=this.deps.codexHome();if(e===null)return;this.nameLog=new Wq(e);let t=this.deps.watchCodexHome??((n,i,r)=>new Vq(n,i,r));this.watcher=t(e,{stateChanged:()=>this.stateChanged(),archiveMoved:n=>{this.scanRetries.delete(n),this.subscriptions.size!==0&&(this.pendingThreads.add(n),this.stateChanged())}},this.timings.fallbackIntervalMs)}stopWatching(){this.watcher?.stop(),this.watcher=null,this.nameLog=null,this.marks=null,this.resumes={unarchived:null,archived:null},this.marksReady=null,this.watchGeneration++,this.timer!==null&&clearTimeout(this.timer),this.timer=null,this.timerDueAt=null,this.scanRequested=!1,this.firstStateChangeAt=null,this.scanDueAt=null,this.threadsDueAt=null,this.pendingThreads.clear(),this.scanRetries.clear(),this.deletedThreads.clear(),this.lastChangeAt.clear(),this.ignoredThreads.clear()}async withReader(e){let t=this.deps.reader();if(t!==null)try{await e(t)}catch(n){D.log("Session list subscription read failed",{error:String(n)})}}async makeReady(e){await this.marksReady}async flush(){let e=this.now(),t=this.scanRequested&&this.scanDueAt!==null&&this.scanDueAt<=e;t&&(this.scanRequested=!1,this.firstStateChangeAt=null,this.scanDueAt=null),this.threadsDueAt=null;let n=new Set(this.pendingThreads);this.deps.reader()!==null?this.pendingThreads.clear():n.clear();let i=new Map(this.deletedThreads);this.deletedThreads.clear();for(let[g,C]of this.lastChangeAt)e-C>=this.timings.minChangeIntervalMs&&this.lastChangeAt.delete(g);let r=this.appServerGeneration;this.readEpoch=++this.epoch,t&&await this.marksReady;let u=new Map,s=new Set,o=new Set([...n].filter(g=>this.scanRetries.delete(g)));await this.withReader(async g=>{if(t){for(let y of this.nameLog?.readRenamedThreads()??[])n.add(y),o.delete(y),this.scanRetries.delete(y);try{for(let y of await this.scan(g))u.set(y.thread.id,y),s.add(y.thread.id)}catch(y){D.log("Session list scan failed",{error:String(y)}),this.scanAt(this.now()+Kq)}}let C=[...n].filter(y=>!u.has(y)&&!i.has(y));for(let y=0;y<C.length;y+=lv)await Promise.all(C.slice(y,y+lv).map(async b=>{let A=await this.readThread(g,b);A==="missing"?i.set(b,!1):A==="failed"?(o.has(b)&&!this.pendingThreads.has(b)&&this.scanRetries.add(b),this.pendingThreads.add(b)):A!==null&&u.set(b,A)}))});let a=g=>s.has(g)&&!n.has(g)||o.has(g);if(this.disposed||this.subscriptions.size===0)return;if(await Promise.all([...this.groups.values()].map(g=>g.ready)),r!==this.appServerGeneration){for(let g of u.keys())this.readAgainAsFound(g,a(g));u.clear()}let l=new Map,c=[...u.values()].flatMap(g=>{let C=this.groupsOf(g.thread.cwd);return C.length===0?[]:a(g.thread.id)&&C.every(y=>[...y.subscriptions].every(b=>!this.takesScanned(b,g)))?[]:[{entry:g,groups:C}]}),m=c.length===0?[]:await this.deps.rows(c.map(({entry:g})=>g));if(r!==this.appServerGeneration){for(let{entry:g}of c)this.readAgainAsFound(g.thread.id,a(g.thread.id));c.length=0}for(let[g,{entry:C,groups:y}]of c.entries())this.offer(C.thread.id,y.map(b=>({group:b,row:m[g]})),l,a(C.thread.id)?C:void 0);let p=!1;for(let g of i.keys()){let C=[...this.subscriptions.values()].filter(S=>S.sent.has(g)||S.group.rows.has(g)),y=[...this.groups.values()].map(S=>S.rows.get(g)?.row.cwd).find(S=>S!==void 0);y!==void 0&&!p&&(p=!0,this.placeCwd("",!0));let b=y===void 0?[]:[...this.groups.values()].filter(S=>S.scope.has(y)),A=y===void 0?C.length>0?C:[...this.subscriptions.values()]:[...new Set([...C,...[...this.subscriptions.values()].filter(S=>b.includes(S.group))])];for(let S of this.groups.values())S.rows.delete(g);for(let S of A)S.sent.delete(g),cv(l,S).removed.push(g)}for(let[g,C]of l)g.held=g.held===null?C:rZ(g.held,C);let v=[];for(let g of this.subscriptions.values()){if(this.disposed||!g.ready||g.held===null)continue;let{now:C,later:y}=this.withoutForksInFlight(g.held);g.held=y,C!==null&&(await this.send(C),v.push(C))}this.markSent(v)}markSent(e){let t=this.now();for(let n of e)for(let i of n.sessions)this.lastChangeAt.set(i.sessionId,t)}readAgainAsFound(e,t){t&&!this.pendingThreads.has(e)&&this.scanRetries.add(e),this.readAgain(e,this.now())}readAgain(e,t){this.pendingThreads.add(e),this.threadsDueAt=this.threadsDueAt===null?t:Math.min(this.threadsDueAt,t)}offer(e,t,n,i){let r=[],u=t.map(({group:l,row:c})=>({group:l,row:c,signature:gq(c)})),s=!1;for(let{group:l,row:c,signature:m}of u)for(let p of l.subscriptions){if(p.epoch>this.readEpoch){s=!0;continue}let v=p.sent.get(e);i!==void 0&&!this.takesScanned(p,i)||v!==m&&r.push({subscription:p,row:c,signature:m})}s&&this.readAgainAsFound(e,i!==void 0);let o=this.lastChangeAt.get(e),a=o!==void 0&&this.now()-o<this.timings.minChangeIntervalMs&&r.some(({subscription:l})=>l.ready);if(a)i!==void 0&&!this.pendingThreads.has(e)&&this.scanRetries.add(e),this.readAgain(e,o+this.timings.minChangeIntervalMs);else for(let{group:l,row:c,signature:m}of u)l.rows.set(e,{row:c,signature:m});for(let{subscription:l,row:c,signature:m}of r)a&&l.ready||(l.sent.set(e,m),cv(n,l).sessions.push(c))}takesScanned(e,t){return e.sent.has(t.thread.id)||e.startedSecond===null||t.thread.updatedAt>e.startedSecond}async send(e){try{await this.deps.notify(e)}catch(t){D.log("Failed to send session list changes",{subscriptionId:e.subscriptionId,error:String(t)})}}async scan(e,t=!1){let n=this.watchGeneration,i=this.stateChanges,r=this.marks,u=await Promise.allSettled([!1,!0].map(async c=>{let m=c?"archived":"unarchived",p=this.resumes[m],v=p?.cutoff??(r===null?this.watchingSince:r[m]),g=[],C=p?.newest??(r===null?0:v),y=p?.cursor??null,b=null;for(let A=0;A<bc;A++){let S=await e.threadList({cursor:y,limit:A===0&&p===null?Xq:Yq,sortKey:"updated_at",archived:c,sourceKinds:[],modelProviders:[],useStateDbOnly:!0}),z=!1;for(let M of S.data){if(M.updatedAt<v){r===null&&(C=Math.max(C,M.updatedAt)),z=!0;break}g.push({thread:M,archived:c}),C=Math.max(C,M.updatedAt)}if(y=S.nextCursor,t||z||y===null)break;A===bc-1&&(D.log("The session list scan goes on later from its page limit",{archived:c,pages:bc}),b=y)}return{key:m,mark:v,newest:C,stoppedAt:b,entries:g,resumed:p?.changesAtStart??null}})),s=u.find(c=>c.status==="rejected");if(s!==void 0)throw s.reason;let o=u.map(c=>c.value);if(n!==this.watchGeneration)return[];if(t)for(let c of o)c.newest=Math.min(c.newest,this.watchingSince);let a={unarchived:0,archived:0},l=!1;for(let c of o)c.stoppedAt!==null?(this.resumes[c.key]={cursor:c.stoppedAt,cutoff:c.mark,newest:c.newest,changesAtStart:c.resumed??i},a[c.key]=c.mark,l=!0):(c.resumed!==null&&this.stateChanges>c.resumed&&(l=!0),this.resumes[c.key]=null,a[c.key]=c.newest);return this.marks=a,l&&this.requestScan(),o.flatMap(c=>c.entries)}async readThread(e,t){let n;try{n=(await e.threadRead({threadId:t})).thread}catch(i){return Al(i)?"missing":(D.log("Session list subscription cannot read a thread",{threadId:t,error:String(i)}),"failed")}return n.ephemeral||!Wd(n)?(this.ignore(t),null):qD(n,this.deps.codexHome())}groupsOf(e){return this.placeCwd(e).groups}placeCwd(e,t=!1){let n=this.now(),i=!1;for(let r of this.groups.values()){let u=n-r.scopeResolvedAt;u>=eZ||!r.scope.has(e)&&(t||u>=tZ)?(r.scopeResolvedAt=n,r.scope=new Set(this.deps.scopeCwds(r.cwd))):r.scope.has(e)||(i=!0)}return{groups:[...this.groups.values()].filter(r=>r.scope.has(e)),deferred:i}}};function cv(e,t){let n=e.get(t);return n===void 0&&(n={subscriptionId:t.id,sessions:[],removed:[]},e.set(t,n)),n}function rZ(e,t){let n=new Map(e.sessions.map(r=>[r.sessionId,r]));for(let r of t.removed)n.delete(r);for(let r of t.sessions)n.set(r.sessionId,r);let i=new Set([...e.removed,...t.removed].filter(r=>!n.has(r)));return{subscriptionId:e.subscriptionId,sessions:[...n.values()],removed:[...i]}}var iZ=class{tails=new Map;run(e,t){let i=(this.tails.get(e)??Promise.resolve()).then(t),r=i.then(()=>{},()=>{});return this.tails.set(e,r),r.then(()=>{this.tails.get(e)===r&&this.tails.delete(e)}),i}},xs=Sn(Sr(),1);function uZ(e){return e!==null&&typeof e=="object"?e:{}}function sZ(e){let{code:t,data:n}=uZ(e);return bD(e)||pd(e)||t===xs.ErrorCodes.MessageWriteError||t===xs.ErrorCodes.MessageReadError||t===xs.ErrorCodes.ConnectionInactive||t===xs.ErrorCodes.ServerNotInitialized?!0:n!==null&&typeof n=="object"&&"reason"in n&&n.reason==="serverShuttingDown"}var dv=8;async function oZ(e,t,n){try{let{thread:i}=await e.threadRead({threadId:n,includeTurns:!1});return i.id!==n?null:qD(i,t)}catch(i){if(e.connectionLoss.lost||sZ(i))throw i;return null}}async function aZ(e,t,n){let i=[];for(let r=0;r<n.length;r+=dv){let s=n.slice(r,r+dv).map(a=>oZ(e,t,a)),o=await Promise.all(s);i.push(...o.filter(a=>a!==null))}return i}var lZ=class{constructor(e,t){this.host=e,this.activity=new mq(n=>e.session(n)!==void 0),this.titles=new zO(e,this.writes),this.forkOrigins=new Mq({onFound:n=>this.subscriptions.threadsChanged(n)}),this.subscriptions=new nZ({reader:()=>{let n=e.client().appServerClient;return n.connectionLoss.lost?null:n},codexHome:()=>e.client().getHomePath(),rows:async n=>await this.rows(n),scopeCwds:n=>[...new Set([...X4(n),...K4(n)])],notify:async n=>{await e.connection().notify(XL,n)},...t?{timings:t}:{}})}host;enabled=!1;activity;writes=new iZ;titles;subscriptions;forkOrigins;observedClients=new WeakSet;anyClientObserved=!1;rowsWithState=new Set;codexWorktrees=new bq;configure(e){this.enabled=yn(e,W4)}agentCapabilities(){return this.enabled?[W4,VL,HL,JL,KL,YL]:[]}observe(e){!this.enabled||this.observedClients.has(e)||(this.anyClientObserved&&(this.subscriptions.refreshLoadedThreads([...this.activity.resetLoaded(),...this.rowsWithState]),this.rowsWithState.clear()),this.anyClientObserved=!0,this.observedClients.add(e),e.appServerClient.onClientTransportEvent(t=>{if(t.eventType!=="notification"||this.host.client()!==e)return;let n=t;this.activity.observe(n),(n.method==="thread/deleted"||n.method==="thread/closed"||n.method==="thread/status/changed"&&n.params.status.type==="notLoaded")&&this.rowsWithState.delete(n.params.threadId),this.subscriptions.observe(n)}))}async list(e){let t=nq(e._meta),n=e.cwd?.trim()||null;return await this.readRows(n,t,e.cursor??null)}async batchGet({sessionIds:e}){if(this.require(Nd),e.length===0)return{sessions:[]};await this.host.ensureAppServer();let t=this.host.client(),n=await this.host.runWithProcessCheck(()=>aZ(t.appServerClient,t.getHomePath(),e));return{sessions:await this.rows(n,!0)}}async subscribeList(e){this.require(Ld);let t=e.cwd;if(typeof t!="string"||!qo(t))throw k.invalidParams({cwd:t??null},"cwd must be an absolute path");return await this.host.ensureAppServer(),{subscriptionId:await this.subscriptions.subscribe(t)}}unsubscribeList(e){this.require(qd);let t=e.subscriptionId;if(typeof t!="string")throw k.invalidParams({subscriptionId:t??null},"subscriptionId must be a string");return this.subscriptions.unsubscribe(t),{}}async forking(e,t){this.subscriptions.forkStarted(e);try{return await t()}finally{setTimeout(()=>this.subscriptions.forkAnswered(e),0)}}forkCreated(e,t){this.forkOrigins.remember(t,e),this.subscriptions.forkCreated(e,t)}subscriptionResources(){return this.subscriptions.resources()}async rename({sessionId:e,title:t}){return this.require(Md),await this.host.ensureAppServer(),await this.titles.rename(e,t),{}}async setArchived({sessionId:e},t){this.require(t?Ud:jd),D.log(t?"Archiving session...":"Unarchiving session...",{sessionId:e}),await this.host.ensureAppServer();let n=this.host.hasLocalSession(e);t&&this.host.beginSessionCloseFence(e);try{t&&n&&await this.host.closeSession(e),await this.writes.run(e,async()=>{let i;try{let r=this.host.client();i=await this.host.runWithProcessCheck(()=>FO(r.appServerClient,e,t,r.getHomePath()))}catch(r){throw Mo(e,r)}if(i==="missing")throw Cd(e)})}finally{t&&this.host.endSessionCloseFence(e)}return(t?n:this.host.session(e)!==void 0)&&await new Fe(this.host.connection(),e).update({sessionUpdate:"session_info_update",_meta:xt(void 0,$p,t)}),{}}async deleteThread(e,t){await this.writes.run(e,async()=>{let n;try{n=await this.host.runWithProcessCheck(()=>PO(this.host.client().appServerClient,e))}catch(i){throw Mo(e,i)}if(n==="missing"&&!t)throw Cd(e);this.activity.forget(e),this.titles.forget(e),this.rowsWithState.delete(e)})}dispose(){this.subscriptions.dispose(),this.forkOrigins.dispose()}require(e){if(!this.enabled)throw k.methodNotFound(e)}async readRows(e,t,n){let i=e!==null&&!qo(e)?e:null,r=e===null||i!==null?null:t.includeWorktrees?K4(e):X4(e),u=await this.host.runWithProcessCheck(()=>lq(s=>this.host.client().appServerClient.threadList(s),r,t,n,i===null?void 0:s=>pD(s.cwd,i),e===null||i!==null?e:GL.resolve(e)));return{sessions:await this.rows(u.threads,r===null),nextCursor:u.nextCursor}}async rows(e,t=!1){let n=i=>!(t&&Aq(i))&&this.codexWorktrees.isCodexWorktreeCwd(i);return e.map(i=>{let r=this.forkOrigins.originOf(i.thread),u=r===i.thread.forkedFromId?i.thread:{...i.thread,forkedFromId:r},s=this.activity.activityOf(u);return s?.state!==void 0?this.rowsWithState.add(u.id):this.rowsWithState.delete(u.id),this.withActiveAdditionalDirectories(hq(u,i.archived,s,n(u.cwd)))})}withActiveAdditionalDirectories(e){let t=this.host.session(e.sessionId);return!t||t.additionalDirectories.length===0?e:{...e,additionalDirectories:t.additionalDirectories}}},cZ=class{constructor(e,t,n,i){this.enabled=e,this.rootSessionId=t,this.appServer=n,this.session=i}enabled;rootSessionId;appServer;session;tasks=new Map;ended=new Map;syncs=new Map;appServerGeneration=0;appServerQueriesEnabled=!0;disposed=!1;async handleNotification(e,t,n){if(!this.isActive())return;let i=dZ(e);if(i!==null){if(e.method==="item/started"&&e.params.item.type==="commandExecution"){this.observeCommandStarted(e.params.item,i,t,n);return}if(e.method==="item/completed"&&e.params.item.type==="commandExecution"){await this.observeCommandCompleted(e.params.item,i);return}(e.method==="turn/completed"||e.method==="item/started"&&this.hasRunningTask(i))&&this.refresh(i,t)}}observeCommandStarted(e,t,n,i){!this.isActive()||e.processId===null||this.remember(t,n,{itemId:e.id,processId:e.processId,command:e.command},i)}async observeCommandCompleted(e,t){if(!this.isActive())return;let n=this.tasks.get(Ui(this.rootSessionId,t,e.id));n&&await this.finish(n,e.status==="completed"?"completed":"failed")}refresh(e=this.rootSessionId,t=this.rootSessionId){this.reconcile(e,t)}async reconcile(e=this.rootSessionId,t=this.rootSessionId){try{await this.sync(e,t)}catch(n){this.isActive()&&D.error(`Failed to list background terminals for ${e}`,n)}}setAppServer(e){this.appServer=e,this.appServerGeneration+=1,this.appServerQueriesEnabled=!0}prepareForAppServerReplacement(){this.appServerGeneration+=1,this.appServerQueriesEnabled=!1}async recover(e,t,n){if(!this.canQueryAppServer()||n.size===0)return;let i=await this.listAll(e);if(i!==null)for(let r of i.terminals){if(!this.queryIsCurrent(i.generation))return;if(!n.has(r.itemId)||this.ended.has(Ui(this.rootSessionId,e,r.itemId)))continue;let u=this.remember(e,t,r);u.publication==="unpublished"&&u.state==="running"&&await this.announce(u)}}async finishAll(e){if(!this.isActive())return;let t=[];for(let n of[...this.tasks.values()])try{await this.finish(n,e)}catch(i){t.push(i)}if(t.length>0)throw new AggregateError(t,`Failed to finish ${t.length} background terminal task(s)`)}async sync(e=this.rootSessionId,t=this.rootSessionId){if(!this.canQueryAppServer())return;let n=this.syncs.get(e);if(n)return n.requested=!0,n.sessionId=t,await n.promise;let i={requested:!1,sessionId:t,promise:Promise.resolve()};i.promise=this.syncUntilCurrent(e,i).finally(()=>{this.syncs.get(e)===i&&this.syncs.delete(e)}),this.syncs.set(e,i),await i.promise}async stop(e){if(!this.isActive())return!1;let t=this.tasks.get(e);if(!t||t.publication!=="published")return!1;if(t.state==="stopped"&&!t.terminalPublished)return await this.publishTerminalState(t),!0;if(t.state!=="running")return!1;t.state="stopping";try{return(await this.appServer.threadBackgroundTerminalsTerminate({threadId:t.threadId,processId:t.processId})).terminated?(await this.finish(t,"stopped"),!0):(t.state==="stopping"&&(t.state="running"),!1)}catch(n){throw t.state==="stopping"&&(t.state="running"),n}}clear(){this.disposed=!0,this.appServerGeneration+=1,this.appServerQueriesEnabled=!1,this.tasks.clear(),this.ended.clear(),this.syncs.clear()}hasRunningTask(e){for(let t of this.tasks.values())if(t.threadId===e&&t.state==="running")return!0;return!1}forget(e){this.tasks.get(e.asyncTaskId)===e&&(this.tasks.delete(e.asyncTaskId),this.ended.set(e.asyncTaskId,e.threadId))}async syncThread(e,t){let n=await this.listAll(e);if(n===null||!this.queryIsCurrent(n.generation))return;let i=new Set,r=new Set(n.terminals.map(u=>Ui(this.rootSessionId,e,u.itemId)));for(let[u,s]of[...this.ended])s===e&&!r.has(u)&&this.ended.delete(u);for(let u of n.terminals){if(!this.queryIsCurrent(n.generation))return;if(i.add(u.itemId),this.ended.has(Ui(this.rootSessionId,e,u.itemId)))continue;let s=this.remember(e,t,u);s.publication==="unpublished"&&s.state==="running"&&await this.announce(s)}for(let u of[...this.tasks.values()]){if(!this.queryIsCurrent(n.generation))return;u.threadId===e&&u.publication==="published"&&(u.state==="running"||u.state==="stopping")&&!i.has(u.itemId)&&await this.finish(u,"stopped")}}async syncUntilCurrent(e,t){let n=!1,i;do{t.requested=!1;try{await this.syncThread(e,t.sessionId),n=!1}catch(r){n=!0,i=r}}while(t.requested&&this.canQueryAppServer());if(n)throw i}async announce(e){if(e.publication==="published")return;if(e.announcement!==null){await e.announcement;return}e.publication="publishing";let t=this.publishAnnouncement(e);e.announcement=t;try{await t}finally{e.announcement===t&&(e.announcement=null)}hv(e.state)&&await this.publishTerminalState(e)}async publishAnnouncement(e){try{await this.publishSpawn(e),e.publication="published"}catch(t){throw e.publication="unpublished",t}}async publishSpawn(e){await this.session.update({sessionUpdate:"tool_call_update",toolCallId:e.itemId,_meta:{[Bt]:{[kt]:{[Us]:{[a2]:!0}}}}},e.sessionId),await this.session.update({sessionUpdate:"async_task_spawned",asyncTaskId:e.asyncTaskId,name:e.name,taskType:"shell",showInTranscript:!1,canStop:!0,toolCallId:e.itemId},e.sessionId)}remember(e,t,n,i){let r=Ui(this.rootSessionId,e,n.itemId),u=this.tasks.get(r);if(u)return u.processId=n.processId,i!==void 0&&(u.name=i),u;let s={threadId:e,sessionId:t,asyncTaskId:r,processId:n.processId,itemId:n.itemId,name:i??n.command,publication:"unpublished",announcement:null,terminalUpdate:null,terminalPublished:!1,state:"running"};return this.tasks.set(r,s),s}async finish(e,t){if(e.state==="running"||e.state==="stopping")e.state=t;else if(e.state!==t)return;e.announcement!==null&&await e.announcement,e.publication==="published"?await this.publishTerminalState(e):this.forget(e)}async publishTerminalState(e){if(!hv(e.state)||e.terminalPublished)return;if(e.terminalUpdate!==null){await e.terminalUpdate;return}let t=this.session.update({sessionUpdate:"async_task_state_update",asyncTaskId:e.asyncTaskId,state:e.state,toolCallId:e.itemId},e.sessionId);e.terminalUpdate=t;try{await t,e.terminalPublished=!0,this.forget(e)}finally{e.terminalUpdate===t&&(e.terminalUpdate=null)}}async listAll(e){let t=this.appServer,n=this.appServerGeneration,i=[],r=new Set,u=null;do{let s=await t.threadBackgroundTerminalsList({threadId:e,cursor:u});if(!this.queryIsCurrent(n))return null;if(i.push(...s.data),u=s.nextCursor,u!==null){if(r.has(u))throw new Error("Codex returned a repeated background terminal cursor");r.add(u)}}while(u!==null);return{generation:n,terminals:i}}isActive(){return this.enabled&&!this.disposed}canQueryAppServer(){return this.isActive()&&this.appServerQueriesEnabled}queryIsCurrent(e){return this.canQueryAppServer()&&e===this.appServerGeneration}};function hv(e){return e==="completed"||e==="failed"||e==="stopped"}function Ui(e,t,n){return t===e?n:`${t}:${n}`}function dZ(e){let t=e.params.threadId;return typeof t=="string"?t:null}function Sc(e){return e?.session?.compaction!=null}function Hd(e,t,n){return{sessionUpdate:"compaction_update",compactionId:e,status:t,...t==="failed"&&n!==void 0?{error:n}:{}}}var fv=class{items=new Map;latestByTurn=new Map;start(e,t,n){let i=JSON.stringify([e,n]);if(this.items.has(i))return null;let r=this.remember(e,t,n);return Hd(r.id,"in_progress")}complete(e,t,n){let i=this.latestByTurn.get(JSON.stringify([e,t]));!this.items.has(JSON.stringify([e,n]))&&i?.legacyOnly&&(this.items.delete(JSON.stringify([e,i.id])),this.items.set(JSON.stringify([e,n]),i),i.legacyOnly=!1);let r=this.items.get(JSON.stringify([e,n]))??this.remember(e,t,n);return this.finish(r,"completed")}completeLegacy(e,t){let n=this.latestByTurn.get(JSON.stringify([e,t]))??this.remember(e,t,`compaction:${t}`,!0);return this.finish(n,"completed")}finishTurn(e,t,n,i){let r=[];for(let u of this.items.values()){if(u.sessionId!==e||u.turnId!==t)continue;let s=this.finish(u,n,i);s&&r.push(s)}return r}finishOutstanding(e,t){let n=[];for(let i of this.items.values()){if(t!==void 0&&i.sessionId!==t)continue;let r=this.finish(i,e);r&&n.push({sessionId:i.sessionId,update:r})}return n}remember(e,t,n,i=!1){let r={sessionId:e,turnId:t,id:n,terminal:!1,legacyOnly:i};return this.items.set(JSON.stringify([e,n]),r),this.latestByTurn.set(JSON.stringify([e,t]),r),r}finish(e,t,n){return e.terminal?null:(e.terminal=!0,Hd(e.id,t,n))}},pv=[25,50,100,200,400],hZ=1e3;function Dc(){let e;return[new Promise(n=>{e=n}),e]}function mv(e,t){return e.currentTurnId===t?e.interruptTurnId??t:t}function fZ(e){switch(e){case"completed":case"failed":return"end_turn";case"interrupted":return"cancelled";case"inProgress":return"end_turn"}}var gv={handleCommandExecution:async()=>({decision:"cancel"}),handleFileChange:async()=>({decision:"cancel"}),handlePermissionsRequest:async()=>({permissions:{},scope:"turn",strictAutoReview:!1})},vv={handleElicitation:async()=>({action:"cancel",content:null,_meta:null}),handleUserInput:async()=>({answers:{}})};function Ic(e){return yn(e,Bo)}function pZ(e){return yn(e,Ms)}function mZ(e){return e instanceof k&&e.code===k.authRequired().code}var gZ=class{codexAcpClient;connection;mcpServerSignIn;reportingConnection;protocolVersion;v2Connection;defaultAuthRequest;getExitCode;getRecentStderr;managedChatgptProfile;sessionFailureEpoch;availableCommands;clientInfo;clientCapabilities;capabilities;booleanConfigOptionsSupported;currentAuthStatus;lastReadAccount=null;authStatusVersion=0;sessions;subagentAssociations=new Yz;subagentInteractionHandlers=new WeakMap;mcpSessionStartup;pendingTurnStarts;activePrompts;historyTurnIds=new WeakMap;pendingSteers;turnStartQueueTail;steeringQueues;v2PromptsInFlight=new Set;instructionUpdates=new Set;queuedV2PromptCancellers=new Map;closingSessions;sessionGenerations;sessionOpenGenerations;permissionLifecycleContexts;codexProcessState;recovery;initializeRequest=null;providerUpdate=null;providerRequests=0;appliedProviderRequest=0;sessionIndex=new lZ({connection:()=>this.connection,client:()=>this.codexAcpClient,ensureAppServer:async()=>{await this.ensureAppServer()},runWithProcessCheck:e=>this.runWithProcessCheck(e),session:e=>this.sessions.get(e),hasLocalSession:e=>this.hasLocalSession(e),closeSession:async e=>{await this.closeSession({sessionId:e})},beginSessionCloseFence:e=>this.beginSessionCloseFence(e),endSessionCloseFence:e=>this.endSessionCloseFence(e)});constructor(e,t,n,i,r,u,s=!1){this.sessions=new Map,this.pendingTurnStarts=new Map,this.activePrompts=new Map,this.pendingSteers=new Map,this.turnStartQueueTail=new Map,this.steeringQueues=new Map,this.closingSessions=new Map,this.sessionGenerations=new Map,this.sessionOpenGenerations=new Map,this.permissionLifecycleContexts=new WeakMap,e instanceof nn?(this.protocolVersion=2,this.v2Connection=e.client,this.reportingConnection=new U4(e.extensionOnlyV1View()),this.connection=this.reportingConnection.asClientConnection(),e.registerView(this.connection),e.setTurnRunningCheck(o=>this.isSessionBusy(o))):(this.protocolVersion=1,this.v2Connection=null,this.reportingConnection=new U4(e),this.connection=this.reportingConnection.asClientConnection()),this.codexAcpClient=t,this.mcpServerSignIn=BN(this.connection,()=>this.codexAcpClient,()=>this.clientCapabilities),this.mcpSessionStartup=new RN(this.connection,()=>this.codexAcpClient,o=>this.runWithProcessCheck(o),this.mcpServerSignIn,()=>this.capabilities,o=>this.sessions.has(o)&&!this.sessionIsClosing(o)),this.defaultAuthRequest=n??null,this.codexProcessState=u??null,this.captureStderr(),this.getExitCode=i??(()=>this.codexProcessState?.connection.process.exitCode??null),this.getRecentStderr=r??(()=>this.codexProcessState?.stderr??""),this.managedChatgptProfile=s,this.sessionFailureEpoch=wc(),this.clientInfo=null,this.clientCapabilities=null,this.capabilities=Zs.DEFAULT,this.booleanConfigOptionsSupported=!1,this.currentAuthStatus=null,this.availableCommands=this.createAvailableCommands(t),this.recovery=this.createRecovery()}createAvailableCommands(e){return new Tj(this.connection,e,t=>this.runWithProcessCheck(t),()=>this.refreshAuthState(null),this.mcpServerSignIn)}usesStandardSubagents(){return Z4(this.clientCapabilities,this.protocolVersion)==="standard"}supportsNativeSubagents(){return Z4(this.clientCapabilities,this.protocolVersion)!=="hidden"}createSubagentRouter(e,t=!1){let n=this.sessions.get(e)?.subagents;if(this.usesStandardSubagents()&&n instanceof Ue&&!n.isRetired())return n;let i=new Fe(this.connection,e),r=o=>this.reportingConnection.reports.releaseOpen(o),u=()=>{let o=this.sessions.get(e);return o?this.subagentModels(o):null},s=this.usesStandardSubagents()?new Ue(e,i,this.subagentAssociations,r,this.capabilities,t,this.sessions.get(e)?.subagentTransition,o=>this.codexAcpClient.appServerClient.runningTurnId(o),u,{read:(o,a)=>this.readSubagentConfiguration(o,a),enqueuePublication:o=>this.codexAcpClient.enqueueSessionTransition(e,o)}):new Qb(e,this.supportsNativeSubagents(),i,p_(this.clientCapabilities),r,u);return s instanceof Ue&&this.getSubagentInteractionHandlers(s,e),s}async readSubagentConfiguration(e,t){let{thread:n}=await this.codexAcpClient.appServerClient.threadRead({threadId:e});return!n||n.id!==e||n.parentThreadId!==t||n.status.type==="notLoaded"?null:{model:n.model,effort:n.reasoningEffort}}getSubagentInteractionHandlers(e,t){let n=this.subagentInteractionHandlers.get(e);if(n)return n;let i=new LL(this.connection,t,this.clientCapabilities,new Hr(this.capabilities));return e.setInteractionObserver((r,u)=>i.observe(r,u)),this.subagentInteractionHandlers.set(e,i),i}childInteractions(e){let t=this.subagentAssociations.get(e);if(!t)return;let n=this.sessions.get(t.rootSessionId)?.subagents;return n instanceof Ue&&!n.isRetired()?this.getSubagentInteractionHandlers(n,t.rootSessionId):{approvals:gv,elicitations:vv}}routeChildApprovals(e){return{handleCommandExecution:t=>(this.childInteractions(t.threadId)?.approvals??e).handleCommandExecution(t),handleFileChange:t=>(this.childInteractions(t.threadId)?.approvals??e).handleFileChange(t),handlePermissionsRequest:t=>(this.childInteractions(t.threadId)?.approvals??e).handlePermissionsRequest(t)}}routeChildElicitations(e){return{handleElicitation:t=>(this.childInteractions(t.threadId)?.elicitations??e).handleElicitation(t),handleUserInput:t=>(this.childInteractions(t.threadId)?.elicitations??e).handleUserInput(t)}}assertSessionMutationAllowed(e){if(this.isRestrictedChild(e))throw k.invalidRequest(void 0,"Subagent sessions do not permit client-initiated mutations")}isRestrictedChild(e){return this.subagentAssociations.isRestricted(e)||this.usesStandardSubagents()&&this.codexAcpClient.isSubagentThread(e)}captureSessionSetup(e){let t=this.sessions.get(e)?.subagents;t instanceof Ue&&t.suspendCancellation();let n=this.getSessionGeneration(e),i=()=>{if(this.assertInstructionsReady(e),this.sessionIsClosing(e)||this.getSessionGeneration(e)!==n)throw k.invalidRequest(void 0,"Session closed while setup was queued")};return i(),i}afterSessionSetupResponse(e){let t=this.sessions.get(e)?.subagents;return!(t instanceof Ue)||this.sessionIsClosing(e)?Promise.resolve():(this.codexAcpClient.redispatchSessionNotifications(e,t.releaseReplay(),()=>t.publishReplaySnapshots()),this.codexAcpClient.waitForSessionNotifications(e).catch(n=>{D.error("Failed to release child traffic after session setup",n)}))}async interruptStandardChildren(e){if(!(e.subagents instanceof Ue))return;let t=e.subagents,n=t.activeTurns();t.cancelInteractions(),await Promise.all(n.map(async i=>{try{let r=this.codexAcpClient.appServerClient.runningTurnId(i.threadId)??i.turnId;if(r===null)return;t.closeWorkRequests(i.threadId,r),await this.codexAcpClient.turnInterrupt({threadId:i.threadId,turnId:r})}catch(r){D.error(`Failed to interrupt child ${i.threadId}`,r)}}))}observeSubagentWorkEnd(e,t){let n=this.sessions.get(e)?.subagents;n instanceof Ue&&n.observeWorkEnd(t)}async initialize(e){D.log("Initialize request received"),this.clientInfo=e.clientInfo??null,this.clientCapabilities=e.clientCapabilities??null,this.initializeRequest=e,this.capabilities=Zs.from(e.clientCapabilities);let t=this.ensureAppServer();t&&await t,this.reportingConnection.reports.compareMeta=this.capabilities.airToolCallContract,this.booleanConfigOptionsSupported=ML(e.clientCapabilities),this.sessionIndex.configure(e.clientCapabilities),await this.runWithProcessCheck(()=>this.codexAcpClient.initialize(e)),this.sessionIndex.observe(this.codexAcpClient),this.publishFirstAuthStatusAfterResponse();let n={resume:{},list:{},close:{},delete:{},fork:{},additionalDirectories:{},subagents:{},systemPrompt:{}};return{protocolVersion:VI,agentInfo:{name:Et.name,title:"Codex",version:Et.version},agentCapabilities:{auth:{logout:{}},providers:{},loadSession:!0,promptCapabilities:{embeddedContext:!0,image:!0},sessionCapabilities:n,mcpCapabilities:{acp:!1,http:!0,sse:!1},_meta:{lody:eg,[Jm]:Km()}},authMethods:eD(e.clientCapabilities),_meta:this.initializeExtensionsMeta(1)}}async initializeV2(e){D.log("Initialize request received",{protocolVersion:e.protocolVersion});let t=aj(e.capabilities);this.clientInfo=e.info,this.clientCapabilities=t,this.initializeRequest={clientInfo:e.info},this.capabilities=Zs.fromV2(t);let n=this.ensureAppServer();return n&&await n,this.reportingConnection.reports.compareMeta=this.capabilities.airToolCallContract,this.booleanConfigOptionsSupported=!0,this.sessionIndex.configure(t),await this.runWithProcessCheck(()=>this.codexAcpClient.initialize({clientInfo:e.info})),this.sessionIndex.observe(this.codexAcpClient),this.publishFirstAuthStatusAfterResponse(),{protocolVersion:2,info:{name:Et.name,title:"Codex",version:Et.version},capabilities:{_meta:{lody:{promptSuggestions:eg.promptSuggestions}},auth:{_meta:{[Jm]:Km()}},providers:{},session:{prompt:{embeddedContext:{},image:{}},mcp:{stdio:{},http:{}},delete:{},additionalDirectories:{},fork:{},systemPrompt:{}}},authMethods:IN(t),_meta:this.initializeExtensionsMeta(2)}}initializeExtensionsMeta(e){let t=e===1?[Bo,tp,Ms,Qc,ed,Us,Qi,qb,Zb,f2,...this.sessionIndex.agentCapabilities()]:[Bo,Ms,Qc,ed,Us,Qi,...this.sessionIndex.agentCapabilities()];return{steering:{supported:!0},...this.capabilities.airClient?{[Bt]:{[kt]:{[du]:hu,[jb]:{version:Kr,controlMethod:mr,actions:[...CP]},[Ub]:t}}}:{}}}async listHooks(e){this.providerUpdate!==null&&await this.waitForProviderUpdate();let t=this.ensureAppServer();return t&&await t,await this.runWithProcessCheck(()=>Od(this.codexAcpClient.appServerClient,e))}async trustHooks(e,t){this.providerUpdate!==null&&await this.waitForProviderUpdate();let n=this.ensureAppServer();return n&&await n,{trusted:await this.runWithProcessCheck(()=>WL(this.codexAcpClient.appServerClient,e,t))}}async extMethod(e,t){let n={method:e,params:t};if(!Q2(n))return{};switch(n.method){case"authentication/status":return await this.readAuthenticationStatus();case"authentication/logout":return await this.logout({}),{};case To:return await this.unstable_setSessionModel(this.parseLegacySetSessionModelParams(n.params));case Vr:return await this.executeOrQueueSteeringRequest(this.parseSessionSteerParams(n.params));case Gr:{this.providerUpdate!==null&&await this.waitForProviderUpdate();let i=this.sessions.get(n.params.sessionId);return i?this.recovery!==null&&!this.recovery.sessionIsLive(i)?{stopped:!1}:{stopped:await this.runWithProcessCheck(()=>i.asyncTasks.stop(n.params.asyncTaskId))}:{stopped:!1}}case mr:{let i=this.sessions.get(n.params.sessionId);if(!i)throw k.invalidParams(void 0,`Unknown session: ${n.params.sessionId}`);this.providerUpdate!==null&&await this.waitForProviderUpdate();let r=this.ensureSessionReady(i);r&&await r;let u=this.getSessionGeneration(i.sessionId);if(n.params.action==="set"){let s=n.params.objective;await this.runWithProcessCheck(()=>this.codexAcpClient.setGoal(i.sessionId,s))}else if(n.params.action==="pause"){let s=await this.runWithProcessCheck(()=>this.codexAcpClient.setGoalStatus(i.sessionId,"paused"));this.sessionPublishIsCurrent(i,u)&&await this.publishGoalSnapshot(i,Zi(s),!1)}else if(n.params.action==="resume"){let s=null;await this.runWithProcessCheck(()=>this.codexAcpClient.resumeGoal(i.sessionId,void 0,o=>{s=o})),s!==null&&this.sessionPublishIsCurrent(i,u)&&await this.publishGoalSnapshot(i,Zi(s),!1)}else n.params.action==="clear"&&(await this.runWithProcessCheck(()=>this.codexAcpClient.clearGoal(i.sessionId)),this.sessionPublishIsCurrent(i,u)&&await this.publishGoalSnapshot(i,null,!1));return{}}}}async readAuthenticationStatus(){let e=this.ensureAppServer();e&&await e;try{return await this.runWithProcessCheck(()=>this.codexAcpClient.getAuthenticationStatus())}catch(t){if(yd(t)){D.log("Account read unavailable, so the authentication status uses the last known account",{error:String(t)});let n=this.lastReadAccount;return{type:"chat-gpt",email:n?.type==="chatgpt"?n.email??"":""}}if(Gs(t))return D.log("The account read found that the agent needs a login",{error:String(t)}),{type:"unauthenticated"};throw t}}async checkAuthorization(){let e=await this.readAccountOrUnavailable(()=>this.codexAcpClient.readAuthRequirement());if(e==="unavailable")return"unavailable";if(D.log("Auth requirement checked",{authRequired:e.required}),e.required){if(this.defaultAuthRequest)D.log("Authenticating with default auth request...",{authRequest:this.defaultAuthRequest}),await this.authenticate(this.defaultAuthRequest),D.log("Authentication completed");else throw D.log("Authentication required but no default auth request provided, return to IDE"),k.authRequired();return null}return e.account}async readRateLimits(){return yz(await this.runWithProcessCheck(()=>this.codexAcpClient.getRateLimits()))}async getOrCreateSession(e){try{return await this.tryCreateSession(e)}catch(t){let n=t instanceof Error?t:new Error(String(t));throw await this.handleError(n),t}}async getOrForkSession(e){try{return await this.tryOpenSession({kind:"fork",request:e})}catch(t){let n=t instanceof Error?t:new Error(String(t));throw await this.handleError(n),t}}handleManagedChatgptRefreshError(e){if(!this.managedChatgptProfile||!(e instanceof Error)||!e.message.includes("Your access token could not be refreshed"))return;let t="This Codex account could not refresh. Its saved credentials were kept. Restart the session to retry; if authentication still fails, add a new provider.";throw e.message.includes("refresh token was already used")?k.internalError({kind:"codex_refresh_contention",message:t},t):k.internalError(t)}async handleError(e){if(this.handleManagedChatgptRefreshError(e),e.message.includes("log out")||e.message.includes("cloud requirements")){if(this.managedChatgptProfile)return;throw await this.runWithProcessCheck(()=>this.codexAcpClient.logout()),await this.refreshAuthState(null),k.internalError(`${e.message}
|
|
140
|
+
|
|
141
|
+
You have been logged out. Please try again.`)}this.throwWorkspaceRoutingError(e)}throwWorkspaceRoutingError(e){if(!(e instanceof Error)||!e.message.includes("workspace routing discovery failed")&&!e.message.includes("workspace routing discovery timed out"))return;let t=`${e.message}
|
|
142
|
+
|
|
143
|
+
Check the network connection and any proxy or VPN settings, then try again.`;throw k.internalError({kind:"codex_workspace_routing",message:t},t)}async withSystemPromptUpdate(e,t){if(this.assertInstructionsReady(e.sessionId),!Id(e,this.sessions.get(e.sessionId)?.instructions))return t();let n=e.sessionId;if(this.isSessionBusy(n)||this.activePrompts.has(n)||this.pendingTurnStarts.has(n)||this.turnStartQueueTail.get(n)?.settled===!1)throw k.invalidParams(void 0,"Cannot change systemPrompt while session work is in progress; retry when idle");this.instructionUpdates.add(n);try{return await t()}finally{this.instructionUpdates.delete(n)}}restoreExistingSessionTracker(e){let t=this.sessions.get(e);this.instructionUpdates.has(e)&&t&&!this.sessionIsClosing(e)?this.startCodexTurnTracker(e,Promise.resolve(t)):this.codexAcpClient.discardSessionSubscription(e)}assertInstructionsReady(e){if(this.instructionUpdates.has(e))throw k.invalidRequest(void 0,"Session instructions are being updated; retry after session setup")}async beginSessionOpen(e){let t=this.getSessionGeneration(e),n=()=>{if(this.sessionIsClosing(e))throw k.invalidRequest(`Session ${e} is closing`);if(this.getSessionGeneration(e)!==t)throw k.invalidRequest("Session closed while setup was queued");let i=this.sessions.get(e)?.subagents;i instanceof Ue&&i.pauseForSetup(),this.sessionOpenGenerations.set(e,t)};return this.usesStandardSubagents()?await this.codexAcpClient.enqueueSessionTransition(e,n):n(),t}canReleaseFailedFork(e){return!this.sessionOpenGenerations.has(e)&&!this.sessions.has(e)}async releaseFailedFork(e){if(this.canReleaseFailedFork(e)){this.beginSessionCloseFence(e);try{(this.recovery===null||this.recovery.isReady())&&await this.codexAcpClient.closeSession(e)}catch(t){D.error(`Failed to close the thread of a failed fork ${e}`,t)}finally{this.endSessionCloseFence(e)}}}sessionOpenCanInstall(e,t){return!this.sessionIsClosing(e)&&this.getSessionGeneration(e)===t}async cleanupStaleSessionOpen(e,t){if(this.sessionOpenGenerations.get(e)===t){this.sessionIsClosing(e)||this.bumpSessionGeneration(e),this.beginSessionCloseFence(e);try{(this.recovery===null||this.recovery.isReady())&&await this.runWithProcessCheck(()=>this.codexAcpClient.closeSession(e))}catch(n){D.error(`Failed to close stale session open for ${e}`,n)}finally{this.endSessionCloseFence(e)}return!0}return!1}async closeStaleSessionOpen(e,t){throw await this.cleanupStaleSessionOpen(e,t),k.invalidRequest(`Session ${e} is closing`)}sessionIsClosing(e){return(this.closingSessions.get(e)??0)>0}beginSessionCloseFence(e){this.closingSessions.set(e,(this.closingSessions.get(e)??0)+1)}endSessionCloseFence(e){let t=this.closingSessions.get(e)??0;if(t<=1){this.closingSessions.delete(e);return}this.closingSessions.set(e,t-1)}getSessionGeneration(e){return this.sessionGenerations.get(e)??0}bumpSessionGeneration(e){let t=this.getSessionGeneration(e)+1;return this.sessionGenerations.set(e,t),t}async tryCreateSession(e){return await this.tryOpenSession("sessionId"in e?{kind:"resume",request:e}:{kind:"new",request:e})}async tryOpenSession(e){let{request:t}=e;ei(t.systemPrompt);let n="sessionId"in t?this.sessions.get(t.sessionId)?.instructions:void 0,i=e.kind==="resume"?{sessionId:e.request.sessionId,generation:await this.beginSessionOpen(e.request.sessionId)}:null,r=!1,u=async te=>{let ye=te??(e.kind==="resume"?e.request.sessionId:null);if(!ye)throw k.internalError("Codex subscribed without reporting a session id");r=!0,i||(i={sessionId:ye,generation:await this.beginSessionOpen(ye)})},s=await this.checkAuthorization(),o=t.mcpServers??[],a=()=>o.length>0?this.codexAcpClient.getMcpServerStartupVersion():null,l=a(),[c,m]=Dc();e.kind==="resume"&&this.startCodexTurnTracker(e.request.sessionId,c);let p,v=this.recovery?.generation??0;try{switch(e.kind){case"new":D.log("Create new session..."),p=await this.runWithProcessCheck(()=>(v=this.recovery?.generation??0,l=a(),this.codexAcpClient.newSession(e.request,u)));break;case"resume":D.log(`Resume existing session: ${e.request.sessionId}...`),await this.recovery?.settleResume(e.request.sessionId),p=await this.runWithProcessCheck(()=>(v=this.recovery?.generation??0,l=a(),this.codexAcpClient.resumeSession(e.request,u,n)));break;case"fork":D.log(`Fork existing session: ${e.request.sessionId}...`),p=await this.runWithProcessCheck(()=>(v=this.recovery?.generation??0,l=a(),this.codexAcpClient.forkSession(e.request,te=>this.releaseFailedFork(te),te=>this.sessionIndex.forkCreated(e.request.sessionId,te),n)));break}}catch(te){throw m(!r&&e.kind==="resume"&&this.instructionUpdates.has(e.request.sessionId)?this.sessions.get(e.request.sessionId)??null:null),r&&i?await this.cleanupStaleSessionOpen(i.sessionId,i.generation):e.kind==="resume"&&this.restoreExistingSessionTracker(e.request.sessionId),te}let{sessionId:g,currentModelId:C,models:y}=p;if(!i&&e.kind!=="fork")i={sessionId:g,generation:await this.beginSessionOpen(g)};else if(i&&i.sessionId!==g)throw r&&await this.cleanupStaleSessionOpen(i.sessionId,i.generation),k.internalError({expectedSessionId:i?.sessionId,actualSessionId:g},"Codex opened a different session than it reported");r=!0;let b=p.modelProvider??this.codexAcpClient.getModelProvider(),A;try{A=await this.getAuthStateForProvider(b,s)}catch(te){throw m(null),e.kind==="fork"?await this.releaseFailedFork(g):r&&i&&await this.cleanupStaleSessionOpen(g,i.generation),te}i??={sessionId:g,generation:await this.beginSessionOpen(g)},this.sessionOpenCanInstall(g,i.generation)||(r=!1,await this.closeStaleSessionOpen(g,i.generation));let S=this.resolveSessionMcpServers(o,e.kind!=="new"),z=this.findCurrentModel(y,C),M=Mi(z),T={sessionId:g,currentModelId:C,availableModels:y,supportedReasoningEfforts:z?.supportedReasoningEfforts??[],supportedInputModalities:z?.inputModalities??["text","image"],agentMode:pc.getInitialAgentMode(),collaborationMode:p.collaborationMode,currentTurnId:null,interruptTurnId:null,codexReportedRunningTurnId:null,lastTokenUsage:null,totalTokenUsage:null,promptTokenUsage:null,threadHasHistory:e.kind!=="new",...p.instructions?{instructions:p.instructions}:{},modelContextWindow:null,rateLimits:null,account:A.account,authConfigured:A.authConfigured,authProvider:b,cwd:t.cwd,additionalDirectories:p.additionalDirectories,mcpServers:o,fastModeEnabled:p.currentServiceTier==="fast",currentModelSupportsFast:M,sessionMcpServers:S,clientCapabilities:this.capabilities,goalRevision:0,sessionTitle:null,sessionTitleSource:e.kind==="resume"?"unknown":"unset",subagents:this.createSubagentRouter(g),asyncTasks:this.createAsyncTasks(g),compactions:new fv,toolCallReports:this.reportingConnection.reports,openToolCalls:new cd};e.kind==="new"&&(T.turnUsage=new Fo(!0)),this.installSessionState(T),nn.of(this.connection)?.restoreForegroundState(g,p.threadStatus?.type==="active"),this.recovery?.markLoaded(T,v),e.kind==="resume"?m(T):this.startCodexTurnTracker(g,Promise.resolve(T)),this.publishRateLimitsAsync(T),r=!1;let G=e.kind!=="fork";if(o.length>0&&l!==null){let te=this.mcpSessionStartup.begin(g,o,l,{publish:G,awaitTimeoutMs:ON(t._meta),skippedServers:p.skippedMcpServers});if(te!==null)try{await te}catch(ye){throw m(null),await this.closeSession({sessionId:g}).catch(Ne=>{D.error(`Failed to close session ${g} after a failed MCP startup wait`,Ne)}),ye}}await this.initializeAvailableCommandsV2(T,i.generation);let re=this.availableCommands.initialCommands(T);e.kind==="resume"&&(this.publishCurrentGoalAsync(T,i.generation),this.publishAsyncTasksAsync(T,i.generation));let Z=this.createModelState(y,C),oe=T.agentMode.toSessionModeState(T.clientCapabilities.airClient);return[g,Z,oe,re]}async getAuthStateForProvider(e,t=null){if(!this.authProviderUsesOpenAiAccount(e))return await this.publishAuthStatus(e,null),{account:null,authConfigured:!0};let n=t==="unavailable"?null:t??await this.readAccountIfAvailable();return n===null?(D.log("No account read, so the auth status stays as it was"),{account:this.lastReadAccount,authConfigured:!0}):(this.lastReadAccount=n.account,await this.publishAuthStatus(e,n.account),{account:n.account,authConfigured:n.account!==null||!n.requiresOpenaiAuth})}async readAccountIfAvailable(){let e=await this.readAccountOrUnavailable(()=>this.codexAcpClient.getAccount());return e==="unavailable"?null:e}async readAccountOrUnavailable(e){try{return await this.runWithProcessCheck(e)}catch(t){if(!yd(t))throw t;return D.log("Account read unavailable, the login state is unknown",{error:String(t)}),"unavailable"}}applyLateAccountRead(e,t,n){let i=()=>this.sessions.get(e.sessionId)===e,r=()=>i()?this.authStatusVersion!==n?(D.log("A late account read ended after a newer auth status, so it changes nothing",{sessionId:e.sessionId}),!1):!0:(D.log("A late account read ended after the load closed, so it changes nothing",{sessionId:e.sessionId}),!1);t.then(async u=>{if(u==="unavailable"||!r())return;let s=await this.getAuthStateForProvider(e.authProvider,u);i()&&(e.account=s.account,e.authConfigured=s.authConfigured)},async u=>{if(r()){if(mZ(u)||Gs(u)){D.log("A late account read found that the agent needs a login",{error:String(u)}),this.lastReadAccount=null,e.account=null,e.authConfigured=!1,await this.publishAuthStatus(e.authProvider,null);return}if(xO(u)){D.log("The account changed while a late account read ran, so the adapter reads it again"),await this.publishAuthStatusRead();return}D.error("A late account read failed, so the auth status stays as it was",u)}}).catch(u=>D.error("Failed to apply a late account read",u))}authProviderUsesOpenAiAccount(e){return e===null||e==="openai"}authProvidersMatch(e,t){return this.authProviderUsesOpenAiAccount(e)&&this.authProviderUsesOpenAiAccount(t)?!0:e===t}publishRateLimitsAsync(e){!e.authConfigured||!this.authProviderUsesOpenAiAccount(e.authProvider)||this.codexAcpClient.getRateLimits().then(async t=>{if(this.sessions.get(e.sessionId)!==e||!t?.rateLimits)return;let n=Object.values(t.rateLimitsByLimitId??{}).filter(u=>u!==void 0),i=n.length>0?n:[t.rateLimits],r=new tc(this.connection,e);for(let u of i)await r.handleRateLimitsSnapshot(u)}).catch(t=>{D.error(`Failed to read rate limits for session ${e.sessionId}`,t)})}createAsyncTasks(e){return new cZ(yn(this.clientCapabilities,Us),e,this.codexAcpClient.appServerClient,new Fe(this.connection,e))}installSessionState(e){this.sessions.get(e.sessionId)?.asyncTasks.clear(),this.sessions.set(e.sessionId,e)}startCodexTurnTracker(e,t){let n=null;this.codexAcpClient.subscribeToSessionEvents(e,async i=>{let r=await t;r&&(n||(n=new tc(this.connection,r,Ic(this.clientCapabilities),this.sessionFailureEpoch,r.subagents,u=>this.handleAccountUpdated(u),!1,Sc(this.clientCapabilities),Fm(this.clientCapabilities))),await this.trackCodexForegroundWork(r,i),this.handleSkillsChanged(r,i),await n.handleSessionScopedNotification(i),await this.trackCodexTurnCompletion(r,i,n))},this.routeChildApprovals(gv),this.routeChildElicitations(vv),this.supportsNativeSubagents(),()=>{},async i=>{let r=await t;return r?.subagents instanceof Ue?r.subagents.waitForMaterializedSession(i):null},async(i,r,u,s)=>(await t)?.subagents.withUserAction?.(i,r,u,s)??u(),i=>this.observeSubagentWorkEnd(e,i))}isCodexTurnRunning(e){return this.sessions.get(e)?.codexReportedRunningTurnId!=null}isSessionBusy(e){return this.isCodexTurnRunning(e)||this.v2PromptsInFlight.has(e)}async trackCodexForegroundWork(e,t){let n=nn.of(this.connection);t.method==="thread/status/changed"&&t.params.threadId===e.sessionId&&t.params.status.type==="active"&&t.params.status.activeFlags.length===0&&await this.reportCodexTurnState(e.sessionId,{state:"running"}),(t.method==="item/started"||t.method==="item/completed")&&t.params.threadId===e.sessionId&&t.params.turnId===e.codexReportedRunningTurnId&&t.params.item.type!=="userMessage"&&(t.method==="item/started"?await n?.startForegroundItem(e.sessionId,t.params.item.id):await n?.completeForegroundItem(e.sessionId,t.params.item.id)),(t.method==="item/agentMessage/delta"||t.method==="item/reasoning/textDelta"||t.method==="item/reasoning/summaryTextDelta")&&t.params.threadId===e.sessionId&&t.params.turnId===e.codexReportedRunningTurnId&&await n?.startForegroundItem(e.sessionId,t.params.itemId),!(t.method!=="turn/started"||t.params.threadId!==e.sessionId)&&(e.codexReportedRunningTurnId=t.params.turn.id,await this.reportCodexTurnState(e.sessionId,{state:"running"}))}async trackCodexTurnCompletion(e,t,n){if(t.method!=="turn/completed"||t.params.threadId!==e.sessionId)return;e.codexReportedRunningTurnId===t.params.turn.id&&(e.codexReportedRunningTurnId=null);let i=n.getTurnFailure(t.params.turn);this.protocolVersion===2&&i!==null&&!this.v2PromptsInFlight.has(e.sessionId)&&await this.finishOutstandingToolCalls(e),await this.reportCodexTurnState(e.sessionId,iu({stopReason:fZ(t.params.turn.status)},i))}async reportCodexTurnState(e,t){if(this.v2PromptsInFlight.has(e)&&t.state==="idle")return;let n=new Fe(this.connection,e);if(n.protocolVersion===2)try{await n.updateState(t)}catch(i){D.error(`Failed to send the '${t.state}' state for session ${e}`,i)}}async finishOutstandingToolCalls(e){let t=e.openToolCalls.finishOutstanding();if(t.length===0)return;let n=new Fe(this.connection,e.sessionId);for(let i of t)await n.update(i)}async emitLiveSteerUserMessage(e,t,n){let i=new Fe(this.connection,e);if(i.protocolVersion===2)try{for(let r of n)await i.update(ws(r,t))}catch(r){D.error(`Failed to send the steered user message for session ${e}`,r)}}getAuthProviderForAuthenticateRequest(e){return vp(e)&&e.methodId==="gateway"?"custom-gateway":null}async loadSession(e){return this.recovery===null?await this.loadSessionOnce(e):await this.recovery.trackOpen(e.sessionId,()=>this.loadSessionOnce(e))}async loadSessionOnce(e){this.providerUpdate!==null&&await this.waitForProviderUpdate();let t=this.ensureAppServer();t&&await t,D.log("Loading session...",{sessionId:e.sessionId});let{sessionId:n,modelState:i,modeState:r}=await this.loadSessionAndReplayHistory(e),u=this.availableCommands.initialCommands(this.getSessionState(n));return D.log("Session loaded",{sessionId:n,modelId:i.currentModelId,availableModelCount:i.availableModels.length}),{models:i,modes:r,availableCommands:u,...this.createSessionConfigOptionsResponse(this.getSessionState(n))}}async readSessionHistory(e){this.providerUpdate!==null&&await this.providerUpdate,D.log("Reading session history...",{sessionId:e.sessionId});let t=await this.runWithProcessCheck(()=>this.codexAcpClient.readSessionHistory(e.sessionId)),n={sessionId:e.sessionId,sessionTitle:null,sessionTitleSource:"unset"},i=new Fe(this.connection,e.sessionId);await this.publishThreadHistoryTitle(i,n,t,t.turns.flatMap(r=>r.items));for(let r of t.turns)for(let u of r.items)for(let s of await this.createHistoryUpdates(u,{clientCapabilities:this.capabilities},r.id))await i.update(s);return D.log("Session history read",{sessionId:e.sessionId}),{}}async loadSessionAndReplayHistory(e){return this.withSystemPromptUpdate(e,()=>this.loadSessionAndReplayHistoryOnce(e))}async loadSessionAndReplayHistoryOnce(e){let{sessionId:t,modelState:n,modeState:i,thread:r,history:u,availableCommands:s,sessionState:o,settleTrackerReady:a}=await this.getOrCreateSessionWithHistory(e).catch(l=>{throw this.handleManagedChatgptRefreshError(l),this.throwWorkspaceRoutingError(l),l});try{try{await this.streamThreadHistory(t,r,u)}finally{a(o)}}catch(l){throw l instanceof tn?k.invalidRequest(`Session ${t} is closing`):(await this.closeSession({sessionId:t}).catch(c=>{D.error(`Failed to close session ${t} after a failed history read`,c)}),this.recovery?.mapError(l)??l)}return await this.getSessionState(t).asyncTasks.reconcile(),this.publishAvailableCommandsAsync(t,s),{sessionId:t,modelState:n,modeState:i}}async resumeSession(e){return this.withSystemPromptUpdate(e,async()=>this.recovery===null?await this.resumeSessionOnce(e):await this.recovery.trackOpen(e.sessionId,()=>this.resumeSessionOnce(e)))}async resumeSessionOnce(e){this.providerUpdate!==null&&await this.waitForProviderUpdate();let t=this.ensureAppServer();t&&await t,D.log("Resuming session...",{sessionId:e.sessionId});let[n,i,r,u]=await this.getOrCreateSession(e);return this.publishAvailableCommandsAsync(n,u),D.log("Session resumed",{sessionId:n,modelId:i.currentModelId,availableModelCount:i.availableModels.length}),{models:i,modes:r,availableCommands:u,...this.createSessionConfigOptionsResponse(this.getSessionState(n))}}async resumeSessionV2(e){let{replayFrom:t,systemPrompt:n,...i}=e,r={...i,systemPrompt:gc(n)};if(t==null)return await this.resumeSession(r),await this.snapshotForegroundState(e.sessionId),this.createSessionSetupResponseV2(this.getSessionState(e.sessionId));if(t.type!=="start")throw k.invalidParams(void 0,`Unsupported replayFrom type: ${t.type}`);let{sessionId:u}=await this.loadSessionAndReplayHistory(r);return await this.snapshotForegroundState(u),this.createSessionSetupResponseV2(this.getSessionState(u))}async snapshotForegroundState(e){await this.codexAcpClient.waitForSessionNotifications(e),this.getSessionState(e),await nn.of(this.connection).snapshotForegroundState(e)}async forkSession(e){return ei(e.systemPrompt),this.assertInstructionsReady(e.sessionId),this.sessionIndex.forking(e.sessionId,()=>this.createFork(e))}async createFork(e){this.providerUpdate!==null&&await this.waitForProviderUpdate();let t=this.ensureAppServer();t&&await t,D.log("Forking session...",{sessionId:e.sessionId});let[n,,i,r]=await this.getOrForkSession(e);return this.publishAvailableCommandsAsync(n,r),D.log("Session forked",{sourceSessionId:e.sessionId,sessionId:n}),{sessionId:n,modes:i,...this.createSessionConfigOptionsResponse(this.getSessionState(n))}}async forkSessionV2(e){let{systemPrompt:t,...n}=e,i={...n,systemPrompt:gc(t)},{sessionId:r}=await this.forkSession(i);return{sessionId:r,...this.createSessionSetupResponseV2(this.getSessionState(r))}}async listSessions(e){let t=this.ensureAppServer();if(t&&await t,D.log("Listing sessions...",{cwd:e.cwd,cursor:e.cursor}),this.sessionIndex.enabled){let i=await this.sessionIndex.list(e);return{...i,sessions:i.sessions.filter(r=>!this.isRestrictedChild(r.sessionId))}}await this.checkAuthorization();let n=await this.runWithProcessCheck(()=>this.codexAcpClient.listSessions(e));return{...n,sessions:n.sessions.filter(i=>!this.isRestrictedChild(i.sessionId)).map(i=>{let r=this.sessions.get(i.sessionId);return!r||r.additionalDirectories.length===0?i:{...i,additionalDirectories:r.additionalDirectories}})}}async closeSession(e){D.log("Closing session...",{sessionId:e.sessionId});let t=this.bumpSessionGeneration(e.sessionId),n=this.sessions.get(e.sessionId);this.beginSessionCloseFence(e.sessionId);try{this.cancelQueuedV2Prompts(e.sessionId),n?(await this.interruptSessionTurn(n,"Close",!0),n.subagents instanceof Ue&&await n.subagents.finishOutstanding("disconnected"),n.asyncTasks.clear()):D.log("Close request received for unknown local session",{sessionId:e.sessionId});let i=this.activePrompts.get(e.sessionId);i&&(i.requestClose(),await i.completion),this.recovery===null||this.recovery.isReady()&&(!n||this.recovery.sessionIsLive(n))?await this.runWithProcessCheck(()=>this.codexAcpClient.closeSession(e.sessionId)):D.log("Session closed without an app-server call: its app-server is gone",{sessionId:e.sessionId}),await this.reportCodexTurnState(e.sessionId,{state:"idle",stopReason:"cancelled"}),D.log("Session closed",{sessionId:e.sessionId})}finally{this.getSessionGeneration(e.sessionId)===t&&(this.sessions.delete(e.sessionId),this.v2PromptsInFlight.has(e.sessionId)||nn.of(this.connection)?.forgetSession(e.sessionId),this.mcpSessionStartup.close(e.sessionId),this.codexAcpClient.appServerClient.mcpStartup.forgetThread(e.sessionId),this.pendingTurnStarts.delete(e.sessionId),this.activePrompts.delete(e.sessionId),this.pendingSteers.delete(e.sessionId),this.turnStartQueueTail.delete(e.sessionId),this.queuedV2PromptCancellers.delete(e.sessionId),this.steeringQueues.delete(e.sessionId),n&&this.availableCommands.cancelPendingSkillsPublish(n)),this.endSessionCloseFence(e.sessionId)}return{}}async deleteSession(e){let t=this.ensureAppServer();t&&await t,D.log("Deleting session...",{sessionId:e.sessionId});let n=e.sessionId,i=this.hasLocalSession(n);this.beginSessionCloseFence(n);try{i?await this.closeSession({sessionId:n}):this.bumpSessionGeneration(n),this.sessionIndex.enabled?await this.sessionIndex.deleteThread(n,i):await this.runWithProcessCheck(()=>this.codexAcpClient.deleteSession(n)),D.log("Session deleted",{sessionId:n})}finally{this.endSessionCloseFence(n)}return{}}hasLocalSession(e){return this.sessions.has(e)||this.mcpSessionStartup.isPending(e)||this.pendingTurnStarts.has(e)||this.activePrompts.has(e)||this.hasPendingSessionOpen(e)||this.sessionIsClosing(e)}hasPendingSessionOpen(e){return this.sessionOpenGenerations.get(e)===this.getSessionGeneration(e)}async newSession(e){this.providerUpdate!==null&&await this.waitForProviderUpdate();let t=this.ensureAppServer();t&&await t,D.log("Starting new session...");let[n,i,r,u]=await this.getOrCreateSession(e);return this.publishAvailableCommandsAsync(n,u),D.log("New session created",{sessionId:n,modelId:i.currentModelId,availableModelCount:i.availableModels.length}),{sessionId:n,models:i,modes:r,availableCommands:u,...this.createSessionConfigOptionsResponse(this.getSessionState(n))}}publishAvailableCommandsAsync(e,t){if(this.protocolVersion===2)return;let n=this.sessions.get(e);if(!n)return;let i=this.getSessionGeneration(e);setTimeout(()=>{let r=()=>this.sessionPublishIsCurrent(n,i);r()&&this.availableCommands.publish(n,r).catch(u=>{D.error(`Failed to publish available commands for session ${e}`,u)})},0)}async newSessionV2(e){let{systemPrompt:t,...n}=e,i={...n,systemPrompt:gc(t)},{sessionId:r}=await this.newSession(i);return{sessionId:r,...this.createSessionSetupResponseV2(this.getSessionState(r))}}async authenticate(e,t){D.log("Authenticate request received");let n=this.ensureAppServer();n&&await n;let i=this.createUrlElicitationRequester(t);if(!await this.runWithProcessCheck(()=>this.codexAcpClient.authenticate(e,i)))throw D.log("Authenticate request failed"),k.authRequired({methodId:e.methodId},"Sign-in did not complete");return await this.refreshAuthState(this.getAuthProviderForAuthenticateRequest(e)),D.log("Authenticate request completed"),{}}createUrlElicitationRequester(e){if(e==null||!Sl(this.clientCapabilities))return;let t=null;return{elicitUrl:n=>(t=n.elicitationId,this.connection.request(ae.client.elicitation.create,{mode:"url",requestId:e,...n})),completeElicitation:async()=>{t!==null&&await this.connection.notify(ae.client.elicitation.complete,{elicitationId:t})}}}async logout(e){D.log("Logout request received");let t=this.ensureAppServer();t&&await t,await this.runWithProcessCheck(()=>this.codexAcpClient.logout()),await this.refreshAuthState(null),D.log("Logout request completed")}async authenticateV2(e,t){return await this.authenticate(e,t)}async logoutV2(e){return await this.logout(e),{}}listProviders(e){return{providers:this.codexAcpClient.listProviders()}}async setProvider(e){let t=++this.providerRequests,n=await this.codexAcpClient.prepareProvider(e);return this.appliedProviderRequest>t?(D.log("providers/set dropped: a newer provider request was applied while the models were listed"),{}):(this.appliedProviderRequest=t,this.codexAcpClient.setProvider(n),await this.enqueueProviderUpdate(i=>i.setProvider(n)),{})}async disableProvider(e){return this.codexAcpClient.disableProvider(e),e.providerId!==pn?{}:(this.appliedProviderRequest=++this.providerRequests,await this.enqueueProviderUpdate(t=>t.disableProvider(e)),{})}async enqueueProviderUpdate(e){let n=(this.providerUpdate?.catch(()=>{})??Promise.resolve()).then(async()=>{if(this.sessions.size===0)return;let i=[...this.activePrompts.values()].map(a=>a.completion);i.length>0&&(D.log("Waiting for active prompts before provider restart",{count:i.length}),await Promise.all(i)),D.log("Restarting Codex app-server for provider update",{sessionCount:this.sessions.size});for(let a of this.sessions.values())a.asyncTasks.prepareForAppServerReplacement();await this.finishAllAsyncTasks("stopped","before the provider restart");let r=await this.restartCodexClient(),u=this.codexAcpClient;for(let a of this.sessions.values())a.subagents instanceof Ue&&await a.subagents.finishOutstanding("disconnected");if(e(r),this.initializeRequest===null)throw new Error("Cannot restart Codex app-server before ACP initialization");await r.initialize(this.initializeRequest),this.codexAcpClient=r,this.sessionIndex.observe(r),this.availableCommands=this.createAvailableCommands(r);let s=[];this.recovery?.completeReplacement(r);let o=this.recovery?.generation??0;for(let a of this.sessions.values()){if(await u.waitForSessionNotifications(a.sessionId),a.subagents instanceof Ue&&(a.subagents=this.createSubagentRouter(a.sessionId)),a.codexReportedRunningTurnId!==null&&(a.codexReportedRunningTurnId=null,await this.finishOutstandingToolCalls(a),await this.reportCodexTurnState(a.sessionId,{state:"idle",stopReason:"cancelled"})),a.asyncTasks.setAppServer(r.appServerClient),r.appServerClient.connectionLoss.lost)break;let[l,c]=Dc();this.startCodexTurnTracker(a.sessionId,l);try{let m={sessionId:a.sessionId,cwd:a.cwd,additionalDirectories:a.additionalDirectories,mcpServers:a.mcpServers??[]},p=null,v=async g=>(p=g===void 0?await r.resumeSession(m,void 0,a.instructions):await r.resumeSession(m,g,a.instructions),p);await(this.recovery?.resumeForReplacement(a,o,r,v)??v()),a.authProvider=r.getModelProvider(),a.asyncTasks.refresh(),c(a),D.log("Resumed session after provider restart",{sessionId:a.sessionId}),p&&await this.applyResumedModels(a,r,p)}catch(m){if(c(null),m instanceof TS||m instanceof FS||m instanceof PS){D.log("Session not resumed after provider restart",{sessionId:a.sessionId,reason:String(m)});continue}s.push(this.recovery?.mapError(m,r)??m),D.error(`Failed to resume session ${a.sessionId} after provider restart`,m)}}if(this.recovery!==null&&!this.recovery.isReady(o))throw this.recovery.errorForGeneration(o);if(s.length>0)throw new AggregateError(s,`Failed to resume ${s.length} session(s) after provider restart`)});this.providerUpdate=n,this.recovery?.settleReplacement(n);try{await n}catch(i){throw this.recovery?.mapError(i)??i}finally{this.providerUpdate===n&&(this.providerUpdate=null)}}captureStderr(){let e=this.codexProcessState;if(e===null||e.stderrProcess===e.connection.process)return;let t=e.connection.process;e.stderrProcess=t,t.stderr.addListener("data",n=>{e.connection.process===t&&(e.stderr=(e.stderr+n.toString()).slice(-2*1024))})}async restartCodexClient(){if(this.recovery===null)throw new Error("Codex process state is unavailable");return await this.recovery.beginReplacement()}async waitForProviderUpdate(){try{await this.providerUpdate}catch(e){let t=this.recovery?.mapError(e)??e;if(!(t instanceof k&&t.code===gr))throw e;D.log("A provider update failed because its app-server died; the request goes on",{error:String(e)})}}ensureAppServer(){return this.recovery?.ensureRunning()}ensureSessionReady(e){return this.recovery?.ensureSessionReady(e)}runOnAppServer(e,t,n){try{this.recovery?.throwIfLost(e)}catch(i){return Promise.reject(i)}return this.runWithProcessCheck(n,t)}createRecovery(){let e=this.codexProcessState;if(e===null)return null;let t=e.supervisor??new SD(e);return e.supervisor=t,new tj({supervisor:t,currentClient:()=>this.codexAcpClient,createClient:n=>(this.captureStderr(),this.codexAcpClient.withAppServer(new Ap(n.connection))),handshake:n=>this.initializeRequest!==null&&this.codexAcpClient.initialized?n.initialize(this.initializeRequest):null,install:n=>this.installCodexClient(n),crashed:()=>{for(let n of this.sessions.values())n.subagents instanceof Ue&&(n.subagentTransition=n.subagents.finishOutstanding("disconnected").catch(i=>D.error("Failed to report child observability loss",i)),n.subagents=this.createSubagentRouter(n.sessionId)),n.asyncTasks.finishAll("failed").catch(i=>{D.error("Failed to finish background terminal tasks after the Codex process exited",i)})},resumeSession:async(n,i,r)=>{let u=await i.resumeSession({sessionId:n.sessionId,cwd:n.cwd,additionalDirectories:n.additionalDirectories,mcpServers:n.mcpServers??[]},r,n.instructions);return await this.applyResumedModels(n,i,u),{collaborationMode:u.collaborationMode}},applyCollaborationMode:(n,i)=>i.setCollaborationMode(n.sessionId,n.collaborationMode,n.currentModelId),collaborationMode:n=>n.collaborationMode,resumed:n=>n.asyncTasks.refresh(),sessionLifetime:n=>this.getSessionGeneration(n.sessionId),isCurrent:(n,i)=>this.sessions.get(n.sessionId)===n&&this.getSessionGeneration(n.sessionId)===i&&!this.sessionIsClosing(n.sessionId),installedSession:n=>this.sessions.get(n)},QU())}installCodexClient(e){e.adoptRoutingFrom(this.codexAcpClient),this.codexAcpClient=e,this.sessionIndex.observe(e),this.availableCommands=this.createAvailableCommands(e);for(let t of this.sessions.values())t.asyncTasks.setAppServer(e.appServerClient)}async refreshSessionsAuthState(e){if(this.sessions.size===0)return!1;let t=[...this.sessions.values()].filter(i=>this.authProvidersMatch(i.authProvider,e));if(t.length===0)return!1;let n=await this.getAuthStateForProvider(e);for(let i of t)i.account=n.account,i.authConfigured=n.authConfigured,this.publishRateLimitsAsync(i);return!0}async refreshAuthState(e){if(!await this.refreshSessionsAuthState(e))try{await this.getAuthStateForProvider(e??this.codexAcpClient.getModelProvider())}catch(n){D.log("Failed to refresh auth status",{error:String(n)})}}publishFirstAuthStatusAfterResponse(){setImmediate(()=>{this.publishAuthStatusRead()})}async publishAuthStatusRead(){let e;try{e=await this.readAgentAuthIdentity()}catch(t){if(Gs(t)){D.log("The account read found that the agent needs a login",{error:String(t)}),this.lastReadAccount=null,await this.setAuthStatus(Gl(null));return}D.log("Cannot determine auth status",{error:String(t)});return}await this.setAuthStatus(e)}async readAgentAuthIdentity(){let e=this.codexAcpClient.getAuthGatewayProviderName();if(e!==null)return xo(e);let t=await this.runWithProcessCheck(()=>this.codexAcpClient.getAgentConfiguredModelProvider());if(!this.authProviderUsesOpenAiAccount(t))return Xm(t);let n=await this.runWithProcessCheck(()=>this.codexAcpClient.getAccount());return this.lastReadAccount=n.account,Gl(n.account)}async publishAuthStatus(e,t){let n=this.codexAcpClient.getAuthGatewayProviderName();if(n!==null){await this.setAuthStatus(xo(n));return}if(this.authProviderUsesOpenAiAccount(e)){await this.setAuthStatus(Gl(t));return}if(this.codexAcpClient.isClientConfiguredProvider(e)){await this.publishAuthStatusRead();return}await this.setAuthStatus(Xm(e))}handleAccountUpdated(e){this.applyAccountUpdated(e)}async applyAccountUpdated(e){this.lastReadAccount=V2(e,this.lastReadAccount);try{if(this.codexAcpClient.getAuthGatewayProviderName()!==null)return;if(this.currentAuthStatus===null){await this.publishAuthStatusRead();return}if(this.currentAuthStatus.kind==="gateway")return;await this.setAuthStatus(G2(e,this.currentAuthStatus))}catch(t){D.log("Failed to apply account update to auth status",{error:String(t)})}}async setAuthStatus(e){if(this.authStatusVersion+=1,!H2(this.currentAuthStatus,e)){this.currentAuthStatus=e;try{await this.connection.notify(N2,{authStatus:e})}catch(t){D.log("Failed to send auth status update",{error:String(t)})}}}async setSessionMode(e){this.assertInstructionsReady(e.sessionId),D.log("Set session mode requested",{sessionId:e.sessionId,modeId:e.modeId});let t=this.sessions.get(e.sessionId);if(!t)throw new Error(`Session ${e.sessionId} not found`);return this.applyModeChange(t,e.modeId),{}}async setSessionConfigOption(e){this.assertInstructionsReady(e.sessionId),D.log("Set session config option requested",{sessionId:e.sessionId,configId:e.configId});let t=this.sessions.get(e.sessionId);if(!t)throw new Error(`Session ${e.sessionId} not found`);return await this.applySessionConfigOption(t,e),{configOptions:this.createSessionConfigOptions(t)}}async setSessionConfigOptionV2(e){let t=await this.setSessionConfigOption(e2(e));return{configOptions:Yc(t.configOptions)}}async applySessionConfigOption(e,t){switch(t.configId){case Rd:this.applyFastModeChange(e,t);break;case fD:this.applyModeChange(e,this.stringConfigValue(t));break;case Eo:if(typeof t.value!="boolean")throw k.invalidParams();await this.applyCollaborationModeChange(e,t.value?Ci:Lo);break;case yl:this.applyModelChange(e,this.stringConfigValue(t));break;case rp:this.applyReasoningEffortChange(e,this.stringConfigValue(t));break;default:throw k.invalidParams()}}applyFastModeChange(e,t){let n=t.value;if(typeof n=="boolean"){e.fastModeEnabled=n;return}if(n!==Ho&&n!==zd)throw k.invalidParams();e.fastModeEnabled=n===Ho}stringConfigValue(e){if(typeof e.value!="string")throw k.invalidParams();return e.value}applyModeChange(e,t){let n=pc.find(t);if(!n)throw k.invalidParams();e.agentMode=n}async applyCollaborationModeChange(e,t){let n=GM(t);if(n===null)throw k.invalidParams();if(this.recovery!==null&&!this.recovery.sessionIsLive(e)){e.collaborationMode=n;return}await this.runWithProcessCheck(()=>this.codexAcpClient.setCollaborationMode(e.sessionId,n,e.currentModelId)),e.collaborationMode=n}applyModelChange(e,t){let n=e.availableModels.find(u=>u.id===t);if(!n){let u=tt.fromString(e.currentModelId).model;if(t===u)return;throw k.invalidParams()}let i=tt.fromString(e.currentModelId).effort,r=eu(n.supportedReasoningEfforts,i)??n.defaultReasoningEffort;this.applyModelAndEffort(e,n,r)}applyReasoningEffortChange(e,t){let n=eu(e.supportedReasoningEfforts,t);if(!n)throw k.invalidParams();let{model:i}=tt.fromString(e.currentModelId);e.currentModelId=tt.create(i,n).toString()}async applyResumedModels(e,t,n){let i=JSON.stringify(this.createSessionConfigOptions(e)),{model:r,effort:u}=tt.fromString(e.currentModelId);e.availableModels=n.models,e.currentModelId=t.createModelId(n.models,r,u).toString();let s=this.findCurrentModel(n.models,e.currentModelId);e.supportedReasoningEfforts=s?.supportedReasoningEfforts??[],e.supportedInputModalities=s?.inputModalities??["text","image"],e.currentModelSupportsFast=Mi(s),JSON.stringify(this.createSessionConfigOptions(e))!==i&&await new Fe(this.connection,e.sessionId).update({sessionUpdate:"config_option_update",configOptions:this.createSessionConfigOptions(e)})}applyModelAndEffort(e,t,n){e.currentModelId=tt.fromComponents(t,n).toString(),e.supportedReasoningEfforts=t.supportedReasoningEfforts,e.supportedInputModalities=t.inputModalities,e.currentModelSupportsFast=Mi(t)}async unstable_setSessionModel(e){this.assertInstructionsReady(e.sessionId),D.log("Set session model requested",{sessionId:e.sessionId,modelId:e.modelId});let t=this.sessions.get(e.sessionId);if(!t)throw new Error(`Session ${e.sessionId} not found`);let{model:n,effort:i}=tt.fromString(e.modelId),r=this.ensureAppServer();r&&await r;let u=await this.runWithProcessCheck(()=>this.codexAcpClient.fetchAvailableModels()),s=u.find(a=>a.id===n);if(!s)throw new Error(`Unknown model ${e.modelId}`);let o;if(i){let a=eu(s.supportedReasoningEfforts,i);if(!a)throw new Error(`Unsupported reasoning effort ${i} for model ${n}`);o=a}else o=s.defaultReasoningEffort;return t.availableModels=u,this.applyModelAndEffort(t,s,o),{}}parseLegacySetSessionModelParams(e){let t=e.sessionId,n=e.modelId;if(typeof t!="string"||typeof n!="string")throw k.invalidParams();return{sessionId:t,modelId:n}}async executeOrQueueSteeringRequest(e){this.assertInstructionsReady(e.sessionId);let t=this.getSteeringQueue(e.sessionId);try{return await t.enqueue(e)}catch(n){throw n instanceof k||D.error(`Steering request for session ${e.sessionId} failed`,n),n}finally{t.isIdle&&this.steeringQueues.get(e.sessionId)===t&&this.steeringQueues.delete(e.sessionId)}}getSteeringQueue(e){let t=this.steeringQueues.get(e);return t||(t=new Pj(n=>this.performSteeringRequest(n)),this.steeringQueues.set(e,t)),t}async performSteeringRequest(e){D.log("Steering session requested",{sessionId:e.sessionId,prompt:e.prompt});let t=this.getSessionState(e.sessionId);this.assertSteerInputSupported(e,t);let n=await this.getSteerableTurnId(t);if(n&&await this.injectSteerIntoActiveTurn(e,n))return D.log("Steering session injected",{sessionId:e.sessionId,turnId:n}),{outcome:"injected"};throw k.invalidRequest("No active Codex turn to steer")}assertSteerInputSupported(e,t){if(e.prompt.some(i=>i.type==="image")&&!t.supportedInputModalities.includes("image"))throw k.invalidRequest("The current model does not support image input")}async injectSteerIntoActiveTurn(e,t){let n=this.activePrompts.get(e.sessionId),i=n?.currentTurn;if((e.prompt[0]?.type==="text"?e.prompt[0].text:"").startsWith("/"))throw k.invalidRequest("Slash commands cannot steer an active Codex turn");if(!n||!i||i.turnId!==t||n.signal.aborted)return!1;let u=this.pendingSteers.get(e.sessionId)??new Map;if(u.has(e.steerId))throw k.invalidRequest(`Duplicate Codex steer id: ${e.steerId}`);let s=()=>{},o=new Promise(c=>{s=c}),a={prompt:e.prompt,activePrompt:n,threadId:i.threadId,turnId:t,requestPending:!0,acknowledgement:null,applied:o,resolveApplied:s};u.set(e.steerId,a),this.pendingSteers.set(e.sessionId,u);let l=!1;try{let c=await this.runWithProcessCheck(()=>this.codexAcpClient.steerTurn({threadId:i.threadId,turnId:t,prompt:e.prompt,steerId:e.steerId}));if(c.turnId!==t)throw k.internalError({expectedTurnId:t,actualTurnId:c.turnId},`Codex steered unexpected turn ${c.turnId}; expected ${t}`);return l=!0,!0}catch(c){let m=this.isNoActiveTurnToSteerError(c);if(await this.reconcileSteer(e,a,!m))return await this.acknowledgeSteer(e.sessionId,e.steerId,a),!0;if(m)return!1;throw c}finally{a.requestPending=!1,(!l||this.activePrompts.get(e.sessionId)!==n)&&this.removePendingSteer(e.sessionId,e.steerId,a)}}async reconcileSteer(e,t,n){let i=!1,r;try{let u=(async()=>{if(await this.codexAcpClient.waitForSessionNotifications(e.sessionId),t.acknowledgement!==null)return!0;if(i||!n)return!1;let s=await this.codexAcpClient.readSessionHistory(t.threadId);return s.id===t.threadId&&s.turns.some(o=>o.id===t.turnId&&o.items.some(a=>a.type==="userMessage"&&a.clientId===e.steerId))})().catch(s=>(D.error("Could not reconcile Codex steer history",s),!1));return await Promise.race([u,t.applied.then(()=>!0),new Promise(s=>{r=setTimeout(()=>s(!1),5e3),r.unref?.()})])||t.acknowledgement!==null}finally{i=!0,clearTimeout(r)}}isNoActiveTurnToSteerError(e){let t=e instanceof Error?[e.message]:[];if(typeof e=="object"&&e!==null&&"data"in e){let n=e.data;if(typeof n=="string")t.push(n);else if(typeof n=="object"&&n!==null&&"details"in n){let i=n.details;typeof i=="string"&&t.push(i)}}return t.some(n=>n.toLowerCase().includes("no active turn to steer"))}async getSteerableTurnId(e){if(this.sessionIsClosing(e.sessionId))return null;if(e.currentTurnId)return mv(e,e.currentTurnId);let t=this.pendingTurnStarts.get(e.sessionId);return t?await t.promise:null}parseSessionSteerParams(e){let t=e.sessionId,n=e.prompt,i=e.steerId;if(typeof t!="string"||!Array.isArray(n)||typeof i!="string"||i.length===0)throw k.invalidParams();return{sessionId:t,prompt:n,steerId:i}}createSessionConfigOptions(e){let t=tt.fromString(e.currentModelId),n=yn(this.clientCapabilities,Qi),i=this.findCurrentModel(e.availableModels,e.currentModelId),r=n?e.availableModels.find(s=>s.isDefault)?.id:void 0,u=[e.agentMode.toConfigOption(e.clientCapabilities.airClient),WM(e.collaborationMode)];return e.availableModels.length>0&&u.push($2(e.availableModels,t.model,r)),e.supportedReasoningEfforts.length>0&&u.push(Kb(e.supportedReasoningEfforts,t.effort,n?i?.defaultReasoningEffort:void 0)),e.currentModelSupportsFast&&u.push(UL(e.fastModeEnabled,this.booleanConfigOptionsSupported)),u}createSessionConfigOptionsResponse(e){return this.isSessionConfigEnabled()?{configOptions:this.createSessionConfigOptions(e),...this.createModelCapabilitiesMeta(e)}:{}}createModelCapabilitiesMeta(e){let t=e.availableModels;return t.length===0?{}:{_meta:{lody:{modelCapabilities:{version:1,models:Object.fromEntries(t.map(n=>[n.id,{effortValues:n.supportedReasoningEfforts.map(i=>i.reasoningEffort),fastMode:Mi(n)}]))}}}}}createSessionSetupResponseV2(e){let{configOptions:t}=this.createSessionConfigOptionsResponse(e),n=this.availableCommands.initialCommands(e);return{...t?{configOptions:Yc(t)}:{},...n.length>0?{availableCommands:Nb(n)}:{}}}isSessionConfigEnabled(){return!jL(this.clientInfo)}async initializeAvailableCommandsV2(e,t){if(await this.availableCommands.initialize(e,()=>this.sessionPublishIsCurrent(e,t)),!this.sessionPublishIsCurrent(e,t))throw k.invalidRequest(void 0,`Session ${e.sessionId} was closed or replaced during setup`)}publishCurrentGoalAsync(e,t){this.publishCurrentGoalBestEffort(e,t,!0)}publishAsyncTasksAsync(e,t){this.sessionPublishIsCurrent(e,t)&&e.asyncTasks.refresh()}async publishCurrentGoalBestEffort(e,t,n){try{await this.publishCurrentGoal(e,t,n)}catch(i){D.error(`Failed to publish current goal for session ${e.sessionId}`,i)}}async publishCurrentGoal(e,t,n){let i=++e.goalRevision,r=await this.runWithProcessCheck(()=>this.codexAcpClient.getGoal(e.sessionId)),u=r===null?null:Zi(r);!this.sessionPublishIsCurrent(e,t)||e.goalRevision!==i||await this.publishGoalSnapshot(e,u,n,!1)}handleSkillsChanged(e,t){if(t.method!=="skills/changed")return;let n=this.getSessionGeneration(e.sessionId);this.availableCommands.publishOnSkillsChanged(e,()=>this.sessionPublishIsCurrent(e,n))}sessionPublishIsCurrent(e,t){return this.sessions.get(e.sessionId)===e&&this.getSessionGeneration(e.sessionId)===t&&!this.sessionIsClosing(e.sessionId)}async publishGoalSnapshot(e,t,n,i=!0){if(i&&(e.goalRevision+=1),!n&&hS(e.currentGoal,t))return;e.currentGoal=t,await new Fe(this.connection,e.sessionId).update({sessionUpdate:"session_info_update",_meta:{lody:{goal:t}}})}subagentModels(e){if(!this.isSessionConfigEnabled())return null;let t=null;try{t=tt.fromString(e.currentModelId).model}catch{}return{currentModel:t,availableModels:e.availableModels}}findCurrentModel(e,t){let n=tt.fromString(t);return e.find(i=>i.id===n.model)}createModelState(e,t){return{availableModels:e.flatMap(i=>i.supportedReasoningEfforts.map(r=>({modelId:tt.fromComponents(i,r.reasoningEffort).toString(),name:`${nd(i.displayName)} (${r.reasoningEffort})`,description:`${i.description} ${r.description}`}))),currentModelId:t}}async getOrCreateSessionWithHistory(e){ei(e.systemPrompt);let t=this.sessions.get(e.sessionId)?.instructions,n=await this.beginSessionOpen(e.sessionId),i=performance.now(),r=()=>hZ-(performance.now()-i),u=this.authStatusVersion,s=this.defaultAuthRequest?Promise.resolve(await this.checkAuthorization()):this.checkAuthorization();s.catch(()=>{});let o=e.mcpServers??[],a=()=>o.length>0?this.codexAcpClient.getMcpServerStartupVersion():null,l=a();D.log(`Load existing session: ${e.sessionId}...`);let c=!1,[m,p]=Dc();this.startCodexTurnTracker(e.sessionId,m);let v,g,C=this.recovery?.generation??0;try{try{let Ne=this.recovery?.settleResume(e.sessionId);Ne&&await Ne,v=await this.runWithProcessCheck(()=>(C=this.recovery?.generation??0,l=a(),this.codexAcpClient.loadSession(e,()=>{c=!0},t)))}catch(Ne){throw await Zc(s,r()),Ne}g=await Zc(s,r())}catch(Ne){throw p(!c&&this.instructionUpdates.has(e.sessionId)?this.sessions.get(e.sessionId)??null:null),c?await this.cleanupStaleSessionOpen(e.sessionId,n):this.restoreExistingSessionTracker(e.sessionId),Ne}let{sessionId:y,currentModelId:b,models:A,thread:S}=v,z=v.modelProvider??this.codexAcpClient.getModelProvider(),M;try{M=await this.getAuthStateForProvider(z,g==="pending"?"unavailable":g)}catch(Ne){throw p(null),c&&await this.cleanupStaleSessionOpen(e.sessionId,n),Ne}this.sessionOpenCanInstall(y,n)||(p(null),c=!1,await this.closeStaleSessionOpen(y,n));let T=this.resolveSessionMcpServers(o,!0),G=this.findCurrentModel(A,b),re=Mi(G),Z={sessionId:y,currentModelId:b,availableModels:A,supportedReasoningEfforts:G?.supportedReasoningEfforts??[],supportedInputModalities:G?.inputModalities??["text","image"],agentMode:pc.getInitialAgentMode(),collaborationMode:v.collaborationMode,currentTurnId:null,interruptTurnId:null,codexReportedRunningTurnId:null,lastTokenUsage:null,totalTokenUsage:null,promptTokenUsage:null,threadHasHistory:!0,...v.instructions?{instructions:v.instructions}:{},modelContextWindow:null,rateLimits:null,account:M.account,authConfigured:M.authConfigured,authProvider:z,cwd:e.cwd,additionalDirectories:v.additionalDirectories,mcpServers:o,fastModeEnabled:v.currentServiceTier==="fast",currentModelSupportsFast:re,sessionMcpServers:T,clientCapabilities:this.capabilities,goalRevision:0,sessionTitle:null,sessionTitleSource:"unset",subagents:this.createSubagentRouter(y,!0),asyncTasks:this.createAsyncTasks(y),compactions:new fv,toolCallReports:this.reportingConnection.reports,openToolCalls:new cd};this.installSessionState(Z),this.publishRateLimitsAsync(Z),nn.of(this.connection)?.restoreForegroundState(y,S.status.type==="active"),this.recovery?.markLoaded(Z,C),g==="pending"&&this.applyLateAccountRead(Z,s,u),c=!1,o.length>0&&l!==null&&this.mcpSessionStartup.begin(y,o,l,{publish:!0,skippedServers:v.skippedMcpServers}),await this.initializeAvailableCommandsV2(Z,n);let oe=this.availableCommands.initialCommands(Z);await this.publishCurrentGoalBestEffort(Z,n,!0);let te=this.createModelState(A,b),ye=Z.agentMode.toSessionModeState(Z.clientCapabilities.airClient);return{sessionId:y,modelState:te,modeState:ye,thread:S,availableCommands:oe,history:v.history,sessionState:Z,settleTrackerReady:p}}async streamThreadHistory(e,t,n){let i=new Fe(this.connection,e),r=this.getSessionState(e),u=this.getSessionGeneration(e),s=()=>this.getSessionGeneration(e)===u,o=n[Symbol.asyncIterator](),a=await o.next(),l=a.done?[]:a.value;await this.publishThreadHistoryTitle(i,r,t,l.map(C=>C.item));let c=this.rememberHistoryTurns(AZ(l,o)),m=yv(this.protocolVersion===2?CZ(c):yZ(c),s);if(this.usesStandardSubagents()){await this.streamStandardHistory(e,EZ(m),r,s);return}if(this.supportsNativeSubagents()){await this.streamNativeThreadHistory(e,m,r,new Set([e]),new Set,s);return}let p=t.historyMode!=="paginated"?await Oj(t,uz(this.clientCapabilities)):null,v=[],g=new Set;for await(let C of m)for(let y of C){if(!s())throw new tn;for(let b of await this.createHistoryUpdates(y,r))this.protocolVersion===2&&await this.sendReplayMessageStart(i,b,g),p?v.push(b):await i.update(b)}if(p)for(let C of SZ(p,v))await i.update(C)}async sendReplayMessageStart(e,t,n){let i=_Z(t.sessionUpdate),r=i?t.messageId:null;if(!i||!r)return;let u=`${i}:${r}`;n.has(u)||(n.add(u),await e.startReplayMessage(i,r))}async streamNativeThreadHistory(e,t,n,i,r,u){let s=new Fe(this.connection,e),o=new Map,a=(c,m)=>Yb(s,c,this.subagentModels(n),m),l=new Set;for await(let c of t)for(let m of c){if(!u())throw new tn;if(m.type==="subAgentActivity"){let p=m.kind;if(p==="started"||p==="interacted"){let v=o.get(m.agentThreadId);if(v&&!v.terminal||p==="interacted"&&!v)continue;let g=(v?.generation??0)+1,C=g===1?m.agentThreadId:`${m.agentThreadId}:generation:${g}`,y=null;if(!i.has(m.agentThreadId)&&!r.has(m.agentThreadId))try{y=await this.codexAcpClient.readSessionTurnItems(m.agentThreadId,g-1)}catch(S){r.add(m.agentThreadId),D.error(`Failed to read subagent history ${m.agentThreadId}`,S)}if(p==="interacted"&&!y)continue;let b=pi(m.agentPath,`Agent ${m.agentThreadId.slice(-8)}`),A=m.model||v?.model;if(await s.update({sessionUpdate:"subagent_spawned",subagentSessionId:C,name:b,task:`Delegated task for ${b}`,capabilities:{}}),o.set(m.agentThreadId,{generation:g,sessionId:C,terminal:!1,...A?{model:A}:{}}),await a(C,A),y){let S=new Set;try{await this.streamNativeThreadHistory(C,bZ(yv(y,u),S),n,new Set([...i,m.agentThreadId]),r,u)}catch(z){if(z instanceof tn)throw z;r.add(m.agentThreadId),D.error(`Failed to read subagent history ${m.agentThreadId}`,z)}try{await n.asyncTasks.recover(m.agentThreadId,C,S)}catch(z){D.error(`Failed to restore background terminals for ${m.agentThreadId}`,z)}}}else if(p==="completed"||p==="interrupted"){let v=o.get(m.agentThreadId);if(!v){let g=pi(m.agentPath,`Agent ${m.agentThreadId.slice(-8)}`),C=m.model||void 0;await s.update({sessionUpdate:"subagent_spawned",subagentSessionId:m.agentThreadId,name:g,task:`Delegated task for ${g}`,capabilities:{}}),o.set(m.agentThreadId,{generation:1,sessionId:m.agentThreadId,terminal:!1,...C?{model:C}:{}}),await a(m.agentThreadId,C);continue}if(v.terminal)continue;await s.update({sessionUpdate:"subagent_state_update",subagentSessionId:v.sessionId,state:p==="completed"?"completed":"cancelled"}),v.terminal=!0}continue}if(!(m.type==="collabAgentToolCall"&&m.tool==="spawnAgent"))for(let p of await this.createHistoryUpdates(m,n))this.protocolVersion===2&&await this.sendReplayMessageStart(s,p,l),await s.update(p)}for(let c of o.values())c.terminal||await s.update({sessionUpdate:"subagent_state_update",subagentSessionId:c.sessionId,state:"disconnected"})}async streamStandardHistory(e,t,n,i,r=e,u=new Set([r]),s=new Set,o=new Set){let a=n.subagents;if(!(a instanceof Ue))return;let l=new Fe(this.connection,e),c=new Set,m=async(g,C)=>{if(!(C===null||s.has(g))){if(u.has(g)){o.add(g);return}s.add(g);try{let y=await this.codexAcpClient.readSubagentHistory(g);if(!i())throw new tn;let b=a.parentThreadId(g);if(b!==void 0)try{let A=await this.codexAcpClient.restoreSubagentSubscription(n.sessionId,b,y.thread);A&&await a.restoreRuntime(A,this.codexAcpClient.appServerClient.runningTurnId(g))}catch(A){D.error(`Failed to restore subagent ${g}`,A)}await this.streamStandardHistory(C,y.items,n,i,g,new Set([...u,g]),s,o)}catch(y){if(y instanceof tn)throw y;o.add(g),D.error(`Failed to replay subagent ${g}`,y)}}},p=async g=>{let C=await a.announceHistory(g.agentThreadId,g.agentPath);if(C===null)return!1;let y=RS(this.subagentModels(n),{model:g.model,effort:g.reasoningEffort});if(y.length>0)try{await l.update({sessionUpdate:"config_option_update",configOptions:y},C)}catch(b){D.error(`Failed to replay child configuration ${g.agentThreadId}`,b)}return await m(g.agentThreadId,C),!0},v=[];for await(let g of t)for(let C of g){if(!i())throw new tn;if("turn"in C){C.turn===null?o.add(r):r!==n.sessionId&&await a.replayTurnOutcome(r,C.turn);continue}let{item:y,completed:b,turnId:A}=C;if(y.type==="subAgentActivity"){if(fi(y.agentPath))continue;if(u.has(y.agentThreadId)){o.add(y.agentThreadId);continue}await p(y)||v.push(y);continue}if(y.type==="collabAgentToolCall"&&y.tool==="spawnAgent"){if(y.senderThreadId===r)for(let S of y.receiverThreadIds){if(!S.trim()||u.has(S)){o.add(S);continue}await m(S,await a.announce(S,e,void 0,y.prompt??void 0))}continue}if(r!==n.sessionId){if(y.type==="userMessage"||!b&&!wZ(y)){o.add(r);continue}if(b||o.add(r),!await a.reconcileHistoryItem(r,y,b,A)){o.add(r);continue}if(!i())throw new tn}for(let S of await this.createHistoryUpdates(y,n))this.protocolVersion===2&&await this.sendReplayMessageStart(l,S,c),await l.update(S)}for(;v.length>0;){let g=[];for(let C of v)await p(C)||g.push(C);if(g.length===v.length){for(let C of g)o.add(C.agentThreadId);break}v=g}if(!i())throw new tn;if(r===n.sessionId&&o.size>0){let g={sessionUpdate:"agent_thought_chunk",messageId:`${e}:subagent-history-gap`,content:{type:"text",text:"Some recorded child history is unavailable or incomplete."}};this.protocolVersion===2&&await this.sendReplayMessageStart(l,g,c),await l.update(g)}}async publishThreadHistoryTitle(e,t,n,i){let r=vn(n.name);if(r){t.sessionTitle=r,t.sessionTitleSource="explicit",await e.update({sessionUpdate:"session_info_update",title:r,_meta:{lody:{titleSource:"explicit"}}});return}let u=this.findFirstUserMessageTitle(i)??vn(n.preview);await this.publishFallbackSessionTitle(t,u)}findFirstUserMessageTitle(e){for(let t of e){if(t.type!=="userMessage")continue;let n=vn(t.content.filter(i=>i.type==="text").map(i=>i.text).join(" "));if(n)return n}return null}async publishFallbackSessionTitle(e,t){if(e.sessionTitleSource!=="unset"||!t)return;e.sessionTitle=t,e.sessionTitleSource="fallback",await new Fe(this.connection,e.sessionId).update({sessionUpdate:"session_info_update",title:t,_meta:{lody:{titleSource:"fallback"}}})}async publishAgentFileChangeReport(e,t,n,i,r,u){let s;try{s=t===null?Ng(n.requestId,i):oO(n.requestId,r,u)}catch(o){D.error(o instanceof En?"Agent file-change report unavailable":"Agent file-change report failed unexpectedly",o),s=Ng(n.requestId,o instanceof En?o.reason:"providerError")}try{await new Fe(this.connection,e.sessionId).update({sessionUpdate:"session_info_update",_meta:{[Bt]:{[kt]:{[du]:hu,[Ms]:s}}}})}catch(o){D.error("Failed to publish agent file-change report",o)}}createPromptFallbackTitle(e){return vn(e.filter(t=>t.type==="text").map(t=>t.text).join(" "))}async*rememberHistoryTurns(e){for await(let t of e){for(let n of t)this.historyTurnIds.set(n.item,n.turnId);yield t}}async createHistoryUpdates(e,t,n=this.historyTurnIds.get(e)){let i=new Hr(t.clientCapabilities);switch(e.type){case"userMessage":return this.createUserMessageUpdates(e);case"hookPrompt":case"functionCallOutput":case"sleep":return[];case"subAgentActivity":return[i.render(mu.activity(e,"completed","start"))];case"agentMessage":{let r=Po(e.phase,t.clientCapabilities.airClient);return[{sessionUpdate:"agent_message_chunk",messageId:e.id,content:{type:"text",text:e.text},_meta:n?{...r,...cS(e.phase,n)}:r??{}}]}case"reasoning":return this.createReasoningUpdates(e);case"fileChange":return[i.render(zo.started(e,i.capabilities.diffPatchFormat))];case"commandExecution":return ap.history(e).map(r=>i.render(r));case"mcpToolCall":return[i.render(qs.started(e))];case"dynamicToolCall":return[i.render(od.started(e))];case"collabAgentToolCall":return[i.render(pu.started(e))];case"webSearch":return[i.render(fd.history(e))];case"imageView":return[i.render(hd.viewed(e))];case"imageGeneration":return[i.render(Ls.whole(e))];case"enteredReviewMode":return[this.createReviewModeUpdate(e,!0)];case"exitedReviewMode":return[this.createReviewModeUpdate(e,!1)];case"contextCompaction":return[Sc(this.clientCapabilities)?Hd(e.id,"completed"):i.render(sd.history(e))];case"plan":return e.text.length>0?[this.createPlanHistoryUpdate(e)]:[]}}createUserMessageUpdates(e){let t=[],n=this.protocolVersion===2?e.clientId??e.id:e.id,i=e.content.map(u=>this.userInputToContentBlocks(u)),r=new Set(i.flatMap((u,s)=>e.content[s]?.type==="text"?u.flatMap(o=>o.type==="resource_link"?[o.uri]:[]):[]));for(let[u,s]of e.content.entries()){let o=s.type==="localImage"||s.type==="localAudio"||s.type==="mention"?s.path:(s.type==="image"||s.type==="audio")&&"url"in s?s.url:null;if(o!==null&&r.has(Ed(o)??""))continue;let a=i[u];for(let l of a)t.push(ws(l,n))}return t}createReasoningUpdates(e){let t=e.id;return op(e.summary,e.content).map(n=>id(n,t))}createReviewModeUpdate(e,t){return{sessionUpdate:"agent_message_chunk",...this.protocolVersion===2?{messageId:e.id}:{},content:{type:"text",text:`${t?"Entered":"Exited"} review mode: ${e.review}`}}}createPlanHistoryUpdate(e){return this.capabilities.planUpdates?{sessionUpdate:"plan_update",plan:{type:"markdown",planId:e.id,content:e.text}}:Un(e.text,e.id,Po("final_answer",this.capabilities.airClient))}userInputToContentBlocks(e){switch(e.type){case"text":return WO(e.text)??(e.text.length>0?[{type:"text",text:e.text}]:[]);case"image":return[{type:"text",text:"url"in e?this.formatUriAsLink("image",e.url):`image:${e.fileId}`}];case"localImage":case"localAudio":case"mention":{let t=Ed(e.path),n=e.path.split(/[\\/]/).pop()||e.type,i=e.type==="mention"&&e.name.trim().length>0?e.name:n;return t!==null?[{type:"resource_link",name:i,uri:t}]:[{type:"text",text:this.formatUriAsLink(i,e.path)}]}case"skill":return[{type:"text",text:`skill:${e.name} (${e.path})`}];case"audio":return[{type:"text",text:this.formatUriAsLink("audio",e.url)}]}}formatUriAsLink(e,t){if(e&&e.length>0)return`[@${e}](${t})`;if(t.startsWith("file://")){let n=t.replace("file://","");return`[@${n.split("/").pop()??n}](${t})`}return t}getSessionState(e){let t=this.sessions.get(e);if(!t)throw new Error(`Session ${e} not found`);return t}permissionLifecycleContext(e){let t=this.permissionLifecycleContexts.get(e);if(t)return t;let n=new XS(e);return this.permissionLifecycleContexts.set(e,n),n}resolveSessionMcpServers(e,t){let n=rD(e);return n.length>0?n:t?(D.log("Skipping MCP server recovery for load/resume without explicit mcpServers"),[]):[]}trackActivePrompt(e){let t=()=>{},n=new Promise(g=>{t=g}),i=()=>{},r=new Promise(g=>{i=g}),u=()=>{},s=new Promise(g=>{u=g}),o=new AbortController,a=()=>{},l=new Promise(g=>{a=g}),c=new AbortController,m=!1,p=!1,v={completion:n,closeSignal:r,cancelSignal:s,signal:o.signal,interactionSignal:c.signal,cancelRequested:!1,abortInteractions:()=>c.abort(),currentTurn:null,hasCompletedTurn:!1,nativeCommandInFlight:!1,requestCancel:()=>{v.abortInteractions(),!o.signal.aborted&&(o.abort(),u(null))},requestClose:()=>{p||(p=!0,v.requestCancel(),i(null))},complete:()=>{m||(m=!0,this.activePrompts.get(e)===v&&this.activePrompts.delete(e),this.clearPendingSteers(e,v),t())},clientCancelled:!1,clientCancelSignal:l,requestClientCancel:()=>{v.clientCancelled=!0,a(null)}};return this.activePrompts.set(e,v),v}setActivePromptTurn(e,t){e.hasCompletedTurn=!1,e.currentTurn=t}clearPendingSteers(e,t){let n=this.pendingSteers.get(e);if(n){for(let[i,r]of n)r.activePrompt===t&&!r.requestPending&&n.delete(i);n.size===0&&this.pendingSteers.delete(e)}}async handleSteerAppliedNotification(e,t,n){if(t.method!=="item/completed"||t.params.item.type!=="userMessage")return;let i=t.params.item.clientId;if(!i)return;let r=this.pendingSteers.get(e);if(!r)return;let u=r.get(i);!u||u.activePrompt!==n||u.threadId!==t.params.threadId||u.turnId!==t.params.turnId||await this.acknowledgeSteer(e,i,u)}removePendingSteer(e,t,n){let i=this.pendingSteers.get(e);i?.get(t)===n&&(i.delete(t),i.size===0&&this.pendingSteers.delete(e))}async acknowledgeSteer(e,t,n){n.acknowledgement===null&&(n.acknowledgement=Promise.resolve().then(async()=>{await this.connection.notify(X2,{sessionId:e,steerId:t}),await this.emitLiveSteerUserMessage(e,t,n.prompt)}),this.removePendingSteer(e,t,n),n.resolveApplied()),await n.acknowledgement}cancelBeforeTurnStarted(e){return e.cancelSignal.then(()=>e.currentTurn===null&&!e.nativeCommandInFlight?null:new Promise(()=>{}))}observePromptRequestCancellation(e,t,n){if(!e)return()=>{};let i=()=>{if(this.activePrompts.get(t.sessionId)!==n)return;D.log("Prompt request cancelled",{sessionId:t.sessionId}),n.requestCancel();let r=n.currentTurn;r&&this.requestTurnInterrupt(t,r.threadId,r.turnId,"Cancel")};return e.aborted?(i(),()=>{}):(e.addEventListener("abort",i,{once:!0}),()=>e.removeEventListener("abort",i))}createPendingTurnStart(){let e=()=>{};return{promise:new Promise(n=>{e=n}),resolve:e}}acquireTurnStartReservation(e){let t=this.turnStartQueueTail.get(e),n=t!==void 0&&!t.settled,i=n?t.promise:Promise.resolve(),r={promise:Promise.resolve(),settled:!1},u=()=>{};return r.promise=new Promise(s=>{u=()=>{r.settled=!0,s()}}),this.turnStartQueueTail.set(e,r),{wait:i,needsWait:n,release:u}}registerQueuedV2PromptCanceller(e,t){let n=this.queuedV2PromptCancellers.get(e);return n||(n=new Set,this.queuedV2PromptCancellers.set(e,n)),n.add(t),()=>n.delete(t)}cancelQueuedV2Prompts(e){let t=this.queuedV2PromptCancellers.get(e);if(t){for(let n of t)n();t.clear()}}async interruptPromptTurn(e,t,n){this.codexAcpClient.markTurnStale({threadId:t.threadId,turnId:t.turnId});try{await this.interruptStandardChildren(e),await this.requestTurnInterrupt(e,t.threadId,t.turnId,n)}finally{this.codexAcpClient.resolveTurnInterrupted({threadId:t.threadId,turnId:t.turnId})}}async requestTurnInterrupt(e,t,n,i){if(!this.turnAppServerIsLive(t))return;let r=mv(e,n);for(let u=0;;u++)try{await this.runWithProcessCheck(()=>this.codexAcpClient.turnInterrupt({threadId:t,turnId:r})),D.log(`${i} - turnInterrupt succeeded`,{sessionId:t,currentTurnId:r});return}catch(s){let o=this.activePrompts.has(t),a=AO(s),l=a!==null&&a.expected===r&&a.found!=="";if(!((i==="Cancel"||this.activePrompts.get(e.sessionId)?.nativeCommandInFlight===!0)&&o&&(_O(s)||l)&&u<pv.length)){D.error(`${i} - turnInterrupt failed`,s);return}await new Promise(m=>setTimeout(m,pv[u])),r=l?a.found:e.interruptTurnId??n,D.log(`${i} - turn not interruptible yet, retrying`,{sessionId:t,currentTurnId:r,attempt:u})}}turnAppServerIsLive(e){if(this.recovery===null)return!0;let t=this.sessions.get(e);return t===void 0?this.recovery.isReady():this.recovery.sessionIsLive(t)}interruptLateStartedTurn(e,t,n){if(n.nativeCommandInFlight){this.codexAcpClient.markTurnStale(t),this.requestTurnInterrupt(e,t.threadId,t.turnId,"Cancel");return}this.interruptPromptTurn(e,t,"Close")}promptShouldStop(e,t){return t.signal.aborted||this.activePrompts.get(e)!==t||this.sessionIsClosing(e)}async interruptSessionTurn(e,t,n){await this.interruptStandardChildren(e);let i=await this.getInterruptibleTurn(e,t);if(i){D.log(`${t} session requested`,{sessionId:e.sessionId,threadId:i.threadId,currentTurnId:i.turnId}),n&&this.codexAcpClient.markTurnStale(i);try{await this.requestTurnInterrupt(e,i.threadId,i.turnId,t),D.log(`${t} - turnInterrupt succeeded`,{sessionId:e.sessionId,threadId:i.threadId,currentTurnId:i.turnId})}catch(r){D.error(`${t} - turnInterrupt failed`,r)}finally{n&&this.codexAcpClient.resolveTurnInterrupted(i)}}}async getInterruptibleTurn(e,t){let n=this.activePrompts.get(e.sessionId)?.currentTurn;if(n)return n;if(e.currentTurnId)return{threadId:e.sessionId,turnId:e.currentTurnId};let i=this.pendingTurnStarts.get(e.sessionId);if(!i)return D.log(`${t} request rejected: no current turn`,{sessionId:e.sessionId}),null;if(t==="Close")return i.resolve(null),null;let r=await i.promise;return r?this.activePrompts.get(e.sessionId)?.currentTurn??{threadId:e.sessionId,turnId:r}:(D.log(`${t} request rejected: no current turn`,{sessionId:e.sessionId}),null)}async promptV2(e,t){this.assertInstructionsReady(e.sessionId);let n=e.sessionId,i=Kz(e),r=this.getSessionState(n);if(this.sessionIsClosing(n))throw k.invalidRequest(`Session ${n} is closing`);let u=this.acquireTurnStartReservation(n);if(u.needsWait){let v=!1,g=()=>{v=!0},C=new Promise(A=>{g=()=>{v=!0,A()}}),y=this.registerQueuedV2PromptCanceller(n,g),b=()=>g();if(t&&(t.aborted?b():t.addEventListener("abort",b,{once:!0})),await Promise.race([u.wait,C]),y(),t?.removeEventListener("abort",b),v)throw u.wait.then(()=>u.release()),k.requestCancelled(void 0,`Session ${n} was cancelled before the prompt was inserted`)}let s=this.availableCommands.classifyPrompt(i.prompt),o=wc(),a=new Fe(this.connection,n),l=null;this.v2PromptsInFlight.add(n);let c=async v=>{try{await a.updateState(v)}catch(g){D.error(`Failed to send the '${v.state}' state for session ${n}`,g)}},m=async()=>{try{await nn.of(this.connection)?.startForegroundWork(n)}catch(v){D.error(`Failed to report foreground work for session ${n}`,v)}},p=async v=>{if(l!==null&&v.stopReason!=="cancelled")try{await this.finishOutstandingToolCalls(r)}catch(g){D.error(`Failed to close tools for failed work in session ${n}`,g)}await c(iu(v,l))};return await new Promise((v,g)=>{let C=null,y=!1,b=!1,A=null,S=!1,z=()=>{y||S||(S=!0,!b&&A!==null&&this.requestTurnInterrupt(r,A.threadId,A.turnId,"Cancel"),g(k.requestCancelled(void 0,"The prompt request was cancelled before it was inserted")))};t&&(t.aborted?z():t.addEventListener("abort",z,{once:!0}));let M=async()=>{y=!0;try{for(let G of i.prompt)await a.update(ws(G,o))}catch(G){D.error(`Failed to send the user message for session ${n}`,G)}v({messageId:o}),!b&&(C??=m(),await C)};(async()=>(s.kind==="localCommand"&&await M(),await this.prompt(i,void 0,void 0,{clientUserMessageId:o,onInserted:M,onSyntheticInserted:async(G,re)=>{try{for(let Z of re)await a.update(ws(Z,G))}catch(Z){D.error(`Failed to send the synthetic user message for session ${n}`,Z)}},onTurnAdopted:()=>{b=!0},onTurnStarted:G=>{A=G,C=m()},onFailure:G=>{l??=G}},u)))().then(async G=>{if(this.v2PromptsInFlight.delete(n),!y){let re="The prompt ended before Codex recorded the user message";g(G.stopReason==="cancelled"?k.requestCancelled(void 0,re):l!==null?new k(l.code,l.message):k.internalError(void 0,re)),(b||A!==null)&&(C!==null&&await C,await p(G));return}C!==null&&await C,await p(G)},async G=>{if(l??=Fg(G),!y){this.v2PromptsInFlight.delete(n),g(new k(l.code,l.message));let re=this.getExitCode()!==null||this.recovery!==null&&!this.recovery.isReady();(b||A!==null||re)&&(C!==null&&await C,await p(this.failedPromptResponse(n)));return}if(D.error(`Prompt for session ${n} failed after it was inserted`,G),C!==null&&await C,!UO(G))try{await a.update({sessionUpdate:"session_info_update",_meta:{codex:{error:{message:ru(Xz(G,s.kind==="localCommand"?s.name:void 0)),willRetry:!1}}}})}catch(re){D.error(`Failed to send the prompt failure for session ${n}`,re)}this.v2PromptsInFlight.delete(n),await p(this.failedPromptResponse(n))}).finally(()=>{t?.removeEventListener("abort",z),u.release(),this.sessions.has(n)||nn.of(this.connection)?.forgetSession(n)})})}async prompt(e,t,n,i,r){if(this.assertInstructionsReady(e.sessionId),r===void 0&&(this.activePrompts.has(e.sessionId)||this.turnStartQueueTail.get(e.sessionId)?.settled===!1))throw k.invalidRequest("A Codex prompt is already active; use the advertised steer extension");let u=r===void 0,s=r??this.acquireTurnStartReservation(e.sessionId);s.needsWait&&await s.wait;try{return await this.promptAfterReservation(e,t,n,i)}finally{u&&s.release()}}async promptAfterReservation(e,t,n,i){if(this.activePrompts.has(e.sessionId)||(this.providerUpdate!==null&&await this.waitForProviderUpdate(),this.activePrompts.has(e.sessionId)))throw k.invalidRequest("A Codex prompt is already active; use the advertised steer extension");D.log("Prompt received",{sessionId:e.sessionId,prompt:e.prompt});let r=this.getSessionState(e.sessionId),u=pZ(this.clientCapabilities)?sO(e._meta):null,s=yP(e._meta),o=u===null?null:uO(r.cwd,r.additionalDirectories),a=null,l="providerError",c=!1,m=r.sessionFailure;r.currentTurnId=null,r.interruptTurnId=null,r.promptTokenUsage=null;let p=this.trackActivePrompt(e.sessionId),v=new Fj(e.sessionId,r.currentGoal?.status==="active"),g=()=>v.cancel();p.signal.addEventListener("abort",g);let C=()=>{},y=null,b=()=>(y===null&&(y=this.createPendingTurnStart(),this.pendingTurnStarts.set(e.sessionId,y)),y),A=this.observePromptRequestCancellation(t,r,p),S=null,z=N=>{let F=S?.getTurnFailure(N);F&&i?.onFailure?.(F)},M=!0,T=this.codexAcpClient,G=this.availableCommands,re=this.recovery?.generation??0,Z=new AbortController,oe=()=>{},te=null,ye=this.recovery===null?this.connection:oj(this.connection,Z.signal),Ne=this.recovery===null?p.signal:AbortSignal.any([p.interactionSignal,Z.signal]),At=i,j=new Map,x=(N,F)=>{i!==void 0&&j.set(N,()=>i.onSyntheticInserted(N,F))},$=async N=>{await N.completeSuccessfulTurn(r.currentTurnId);let F=r.sessionFailure;m!==void 0&&F!==void 0&&F.id===m.id&&F.revision===m.revision&&await N.clearSessionFailure()},P=()=>(c=!0,a=null,l="cancelled",this.cancelledPromptResponse(r));try{let N=this.recovery?.ensureSessionReady(r);if(N){let V=N.then(()=>!0);if(V.catch(()=>{}),!await Promise.race([V,p.closeSignal.then(()=>!1),p.cancelSignal.then(()=>!1),p.clientCancelSignal.then(()=>!1)]))return P()}if(p.clientCancelled)return P();this.recovery!==null&&(T=this.codexAcpClient,G=this.availableCommands,re=this.recovery.generation,oe=this.recovery.onGenerationLost(re,()=>Z.abort())),C=T.onConnectionClosed(()=>{v.fail(new Error("Codex connection closed during goal continuation"))}),r.turnUsage??=new Fo(!1,this.codexAcpClient.appServerClient.getThreadTokenUsage(e.sessionId)?.tokenUsage.total),r.turnUsage.prepare(tt.fromString(r.currentModelId).model);let F=new tc(this.connection,r,Ic(this.clientCapabilities),this.sessionFailureEpoch,r.subagents,V=>this.handleAccountUpdated(V),u!==null,Sc(this.clientCapabilities),Fm(this.clientCapabilities));S=F;let Ye=this.permissionLifecycleContext(r).beginPrompt(),In=new Hr(this.capabilities),Tr=new KS(ye,Ye,p.interactionSignal,In),$n=new YS(ye,Ye,this.clientCapabilities,p.interactionSignal,In);te=$n;let Bn=async V=>{let xe=V.params.threadId;r.subagents instanceof Ue&&typeof xe=="string"&&xe!==r.sessionId||(Ye.handleNotification(V),await $n.handleNotification(V))},kn=async()=>{if(At===void 0)return;let{onInserted:V}=At;At=void 0,await V()};if(await T.subscribeToSessionEvents(e.sessionId,async V=>{if(this.activePrompts.get(e.sessionId)===p){if(v.observe(V),V.method==="turn/started"&&V.params.threadId===e.sessionId){let Ie={threadId:e.sessionId,turnId:V.params.turn.id};if(this.setActivePromptTurn(p,Ie),this.promptShouldStop(e.sessionId,p)){this.interruptLateStartedTurn(r,Ie,p);return}m=r.sessionFailure,M=!0}V.method==="turn/completed"&&V.params.threadId===e.sessionId&&p.currentTurn?.threadId===V.params.threadId&&p.currentTurn.turnId===V.params.turn.id&&(p.currentTurn=null,p.hasCompletedTurn=!0)}if(await this.handleSteerAppliedNotification(e.sessionId,V,p),await this.trackCodexForegroundWork(r,V),this.handleSkillsChanged(r,V),At!==void 0&&Tg(V,e.sessionId,At.clientUserMessageId))await kn();else for(let[Ie,zt]of j)if(Tg(V,e.sessionId,Ie)){j.delete(Ie),await zt();break}if(await Bn(V),!M){await F.handleSessionScopedNotification(V),await this.trackCodexTurnCompletion(r,V,F);return}let xe=V.method==="turn/completed"&&V.params.threadId===r.sessionId&&p.currentTurn?.threadId===V.params.threadId&&p.currentTurn.turnId===V.params.turn.id;await F.handleNotification(V),xe&&(M=!1),await this.trackCodexTurnCompletion(r,V,F)},this.routeChildApprovals(Tr),this.routeChildElicitations($n),this.supportsNativeSubagents(),Bn,V=>F.waitForNativeSubagentSession(V),(V,xe,Ie,zt)=>r.subagents.withUserAction?.(V,xe,Ie,zt)??Ie(),V=>this.observeSubagentWorkEnd(e.sessionId,V)),p.signal.aborted)return P();let cn={signal:p.signal,onTurnStartPending:()=>{this.beginPromptTokenUsage(r),b()},onTurnStarted:(V,xe)=>{let Ie={threadId:xe,turnId:V};if(xe===e.sessionId&&v.startTurn(V),this.setActivePromptTurn(p,Ie),i?.onTurnStarted?.(Ie),this.promptShouldStop(e.sessionId,p)){this.interruptLateStartedTurn(r,Ie,p);return}r.currentTurnId=V,y?.resolve(V),n?.()},onNativeCommandStarted:()=>{p.nativeCommandInFlight=!0},onNativeCommandFinished:()=>{p.nativeCommandInFlight=!1},...i===void 0?{}:{onCommandAccepted:()=>{kn()}},setConfigOption:async(V,xe)=>{await this.applySessionConfigOption(r,{sessionId:r.sessionId,configId:V,...typeof xe=="boolean"?{type:"boolean",value:xe}:{value:xe}}),await new Fe(this.connection,r.sessionId).update({sessionUpdate:"config_option_update",configOptions:this.createSessionConfigOptions(r)})}},xn=s===null?this.availableCommands.tryHandleCommand(e.prompt,r,cn):this.availableCommands.runGoalPromptControl(r,s,cn);xn.catch(V=>{this.activePrompts.get(e.sessionId)!==p&&D.error(`Command for cancelled prompt ${e.sessionId} failed after prompt returned`,V)});let Me=await Promise.race([xn,p.closeSignal,this.cancelBeforeTurnStarted(p)]);if(Me===null)return P();if(Me.handled){if(Me.turnCompleted&&Me.waitForGoalContinuation!==!1){await this.codexAcpClient.waitForSessionNotifications(e.sessionId);let Ie=Me.turnCompleted,zt=await this.runWithProcessCheck(()=>Promise.race([v.waitForCompletion(Ie),p.closeSignal]));if(zt===null)return P();Me={...Me,turnCompleted:zt}}if(M=!1,D.log("Prompt handled by a command"),await T.waitForSessionNotifications(e.sessionId),await S.flushPendingErrors(),await S.flushPendingErrorsAsSessionScoped(),Me.turnCompleted){if(await S.handleFailedTurn(Me.turnCompleted.turn),i&&p.clientCancelled&&Me.turnCompleted.turn.status==="failed")return P();z(Me.turnCompleted.turn)}if(Me.turnCompleted?.turn.status==="interrupted")return P();let V=S.getFailure();if(V)throw V;let xe=this.terminalFailurePromptResponse(r,S,Me.turnCompleted?.turn.id??r.currentTurnId);return xe||(Me.turnCompleted?.turn.status==="completed"?a=Me.turnCompleted.turn.id:Me.turnCompleted===void 0&&(l="notReported"),await $(S),{stopReason:"end_turn",usage:this.buildPromptUsage(r),_meta:this.buildQuotaMeta(r)})}if(this.sessionIsClosing(e.sessionId))return P();let Qn=Me.prompt??e.prompt,Qt=tt.fromString(r.currentModelId),Bi=r.supportedReasoningEfforts.length>0&&r.supportedReasoningEfforts.every(V=>V.reasoningEffort==="none"),Zt=r.account?.type==="apiKey"||Bi;if(Zt&&D.log("Disable reasoning.summary",{sessionId:e.sessionId,reason:r.account?.type==="apiKey"?"API key":"model lacks reasoning"}),!r.supportedInputModalities.includes("image")&&e.prompt.some(V=>V.type==="image"))throw k.invalidRequest("The current model does not support image input");let Wt=r.agentMode,er=NL(r.fastModeEnabled,r.currentModelSupportsFast);this.beginPromptTokenUsage(r),b(),v.prepareTurn(),r.turnUsage.prepare(Qt.model);let Tn=r.codexReportedRunningTurnId,be=this.runOnAppServer(re,T,()=>T.sendPrompt({...e,prompt:Qn},Wt,Qt,er,Zt,r.cwd,r.additionalDirectories,V=>{let xe={threadId:e.sessionId,turnId:V};if(!v.startSubmittedTurn(V)){y?.resolve(V),n?.();return}if(this.setActivePromptTurn(p,xe),i?.onTurnStarted?.(xe),this.promptShouldStop(e.sessionId,p)){this.interruptLateStartedTurn(r,xe,p);return}r.currentTurnId=V,y?.resolve(V),Tn!==null&&V===Tn&&i?.onTurnAdopted?.(),n?.()},()=>this.promptShouldStop(e.sessionId,p),i?.clientUserMessageId));be.catch(V=>{this.activePrompts.get(e.sessionId)!==p&&D.error(`Prompt for cancelled session ${e.sessionId} failed after prompt returned`,V)});let ve=await Promise.race([be,p.closeSignal,this.cancelBeforeTurnStarted(p)]);if(ve===null)return P();await this.codexAcpClient.waitForSessionNotifications(e.sessionId);let Je=ve;if(ve=await this.runWithProcessCheck(()=>Promise.race([v.waitForCompletion(Je),p.closeSignal])),ve===null)return P();if(await this.codexAcpClient.waitForSessionNotifications(e.sessionId),ve.turn.status==="completed"){if(await S.waitForNativeSubagents(Ne),p.signal.aborted)return P();this.throwIfSubagentWaitLost(Z.signal,r,re),await T.waitForSessionNotifications(e.sessionId)}else await S.finishOutstandingNativeSubagents(ve.turn.status==="interrupted"?"cancelled":"failed");if(await S.flushPendingErrors(),await S.handleFailedTurn(ve.turn),i&&p.clientCancelled&&ve.turn.status==="failed")return P();if(z(ve.turn),M=!1,ve.turn.status==="interrupted")return await S.flushPendingPlanUpdates(),P();let Gt=S.getFailure();if(Gt)throw Gt;let Fr=this.terminalFailurePromptResponse(r,S,ve.turn.id);if(Fr)return Fr;await S.flushPendingPlanUpdates();let ki=S.takeCompletedPlan();if(ki!==null&&r.collaborationMode===Ci&&!this.promptShouldStop(e.sessionId,p)){let V=await this.requestPlanImplementationPermission(r,ki,p.interactionSignal,ye);if(this.promptShouldStop(e.sessionId,p)||p.cancelRequested)return P();if(V&&!this.promptShouldStop(e.sessionId,p)){await this.applyCollaborationModeChange(r,Lo),await new Fe(this.connection,r.sessionId).update({sessionUpdate:"config_option_update",configOptions:this.createSessionConfigOptions(r)});let Ie={sessionId:e.sessionId,prompt:[{type:"text",text:"Implement the approved plan."}]};p.currentTurn=null,r.currentTurnId=null,v.prepareTurn(),r.turnUsage.prepare(Qt.model),r.interruptTurnId=null;let zt=i!==void 0?wc():void 0;zt!==void 0&&x(zt,Ie.prompt);let xi=this.runOnAppServer(re,T,()=>T.sendPrompt(Ie,Wt,Qt,er,Zt,r.cwd,r.additionalDirectories,tr=>{let ds={threadId:e.sessionId,turnId:tr};if(v.startSubmittedTurn(tr)){if(this.setActivePromptTurn(p,ds),this.promptShouldStop(e.sessionId,p)){this.interruptLateStartedTurn(r,ds,p);return}r.currentTurnId=tr,m=r.sessionFailure,M=!0}},()=>this.promptShouldStop(e.sessionId,p),zt));if(xi.catch(tr=>{this.activePrompts.get(e.sessionId)!==p&&D.error(`Implementation turn for cancelled prompt ${e.sessionId} failed after prompt returned`,tr)}),ve=await Promise.race([xi,p.closeSignal,this.cancelBeforeTurnStarted(p)]),ve===null)return P();await this.codexAcpClient.waitForSessionNotifications(e.sessionId);let cs=ve;if(ve=await this.runWithProcessCheck(()=>Promise.race([v.waitForCompletion(cs),p.closeSignal])),ve===null)return P();if(await this.codexAcpClient.waitForSessionNotifications(e.sessionId),ve.turn.status==="completed"){if(await S.waitForNativeSubagents(Ne),p.signal.aborted)return P();this.throwIfSubagentWaitLost(Z.signal,r,re),await T.waitForSessionNotifications(e.sessionId)}else await S.finishOutstandingNativeSubagents(ve.turn.status==="interrupted"?"cancelled":"failed");if(await S.flushPendingErrors(),await S.handleFailedTurn(ve.turn),i&&p.clientCancelled&&ve.turn.status==="failed")return P();if(z(ve.turn),M=!1,ve.turn.status==="interrupted")return await S.flushPendingPlanUpdates(),P();let dn=S.getFailure();if(dn)throw dn;let Ti=this.terminalFailurePromptResponse(r,S,ve.turn.id);if(Ti)return Ti}}ve.turn.status==="completed"&&(a=ve.turn.id),await $(S);let ls=this.getSessionGeneration(r.sessionId);return this.availableCommands.publish(r,()=>this.sessionPublishIsCurrent(r,ls),!0),At===void 0&&await this.publishFallbackSessionTitle(r,this.createPromptFallbackTitle(e.prompt)),{stopReason:"end_turn",usage:this.buildPromptUsage(r),_meta:this.buildQuotaMeta(r)}}catch(N){let F=this.recovery?.mapError(N,T)??N;D.error(`Prompt for session ${e.sessionId} failed`,F);let H=this.recovery!==null&&F instanceof k&&F.code===gr;if(p.signal.aborted||this.sessionIsClosing(e.sessionId)||i&&p.clientCancelled)return H&&await this.finishPromptAfterAppServerLoss(r,S,T,te,"cancelled"),P();a=null,l="providerError";let Ye=F instanceof k&&F.code===gr;if(H){if(p.clientCancelled)return await this.finishPromptAfterAppServerLoss(r,S,T,te,"cancelled"),P();if(await this.finishPromptAfterAppServerLoss(r,S,T,te,"failed"),p.clientCancelled||p.signal.aborted)return P()}i?.onFailure?.(Fg(F));let In=!(F instanceof k);if(S!==null&&Ic(this.clientCapabilities)&&(Ye||In)){S.recordSyntheticTerminalFailure(Ye?"transport_lost":"internal_error",r.currentTurnId);let Tr=this.terminalFailurePromptResponse(r,S,r.currentTurnId,!0);if(Tr!==null)return Tr}throw F}finally{if((c||p.signal.aborted)&&r.currentGoal?.status==="active")try{let F=await this.runWithProcessCheck(()=>this.codexAcpClient.setGoalStatus(e.sessionId,"paused"));await this.publishGoalSnapshot(r,Zi(F),!1)}catch(F){D.error("Failed to pause goal after prompt cancellation",F)}M=!1;try{await T.waitForSessionNotifications(e.sessionId),await S?.finishOutstandingNativeSubagents(c||p.signal.aborted||this.sessionIsClosing(e.sessionId)?"cancelled":"failed")}catch(F){D.error("Failed to publish terminal compaction or subagent state during prompt cleanup",F)}u!==null&&o!==null&&(c||p.signal.aborted||this.sessionIsClosing(e.sessionId)?(a=null,l="cancelled"):a!==null&&S?.isTurnDiffOversized(a)&&(a=null,l="invalidOutput"),await this.publishAgentFileChangeReport(r,a,u,l,a===null||S===null?"":S.getTurnDiff(a),o)),D.log("Prompt completed",{sessionId:e.sessionId}),await S?.dispose(),C(),v.fail(new Error("ACP prompt closed")),p.signal.removeEventListener("abort",g),A(),oe(),r.currentTurnId=null,r.interruptTurnId=null;let N=this.pendingTurnStarts.get(e.sessionId);N!==void 0&&(this.pendingTurnStarts.delete(e.sessionId),N.resolve(null)),p.complete()}}async requestPlanImplementationPermission(e,t,n,i=this.connection){let r=new Hr(e.clientCapabilities);try{let u=await i.request(ae.client.session.requestPermission,yc.permissionRequest(e.sessionId,t,r),{cancellationSignal:n}),s=yc.approved(u);return await this.connection.notify(ae.client.session.update,{sessionId:e.sessionId,update:r.render(yc.decided(t,s))}),s}catch(u){if(u instanceof yi)throw u;return D.error("Error requesting plan implementation permission",u),!1}}throwIfSubagentWaitLost(e,t,n){if(!(this.recovery===null||!e.aborted||!t.subagents.hasOutstanding()))throw this.recovery.errorForGeneration(n)}async finishPromptAfterAppServerLoss(e,t,n,i,r){try{await i?.completeAllUrlElicitations();let u=new Set([e.sessionId,...e.subagents.childSessionIds()]);await this.failUnfinishedToolCalls(u),await t?.finishOutstandingNativeSubagents(r),await n.waitForSessionNotifications(e.sessionId);for(let s of e.subagents.childSessionIds())u.add(s);await this.failUnfinishedToolCalls(u),await t?.finishOutstandingNativeSubagents(r)}catch(u){D.error("Failed to finish the tool calls of a prompt whose app-server died",u)}}async failUnfinishedToolCalls(e){for(let t of e)for(let n of this.reportingConnection.reports.unfinished(t))await this.connection.notify(ae.client.session.update,{sessionId:t,update:{sessionUpdate:"tool_call_update",toolCallId:n,status:"failed"}})}cancelledPromptResponse(e){return{stopReason:"cancelled",usage:this.buildPromptUsage(e),_meta:this.buildQuotaMeta(e)}}failedPromptResponse(e){let t=this.sessions.get(e);return t===void 0?{stopReason:"end_turn"}:{stopReason:"end_turn",usage:this.buildPromptUsage(t),_meta:this.buildQuotaMeta(t)}}terminalFailurePromptResponse(e,t,n,i=!1){let r=t.getTerminalSessionFailureMeta(n,i);return r===null?null:{stopReason:"end_turn",usage:this.buildPromptUsage(e),_meta:{...this.buildQuotaMeta(e),...r}}}buildQuotaMeta(e){let t=e.promptTokenUsage?.usage()??null,n=e.currentModelId.replace(/\[.*?]$/,""),i=t!=null?[{model:n,token_count:t}]:[];return{quota:{token_count:t,model_usage:i}}}beginPromptTokenUsage(e){e.lastTokenUsage=null;let t=e.totalTokenUsage??(e.threadHasHistory?null:tz);e.promptTokenUsage=new rz(t)}buildPromptUsage(e){let t=e.promptTokenUsage?.usage()??null;return t===null?null:ez(t)}async runWithProcessCheck(e,t=this.codexAcpClient){try{return await e()}catch(n){if(this.recovery!==null)throw this.recovery.mapError(n,t);let i=this.getExitCode(),r=gr;if(i==3221225781)throw new k(r,"VC++ redistributable should be installed");if(i!==null){await this.finishAllAsyncTasks("failed","after the Codex process exited");let u=this.getRecentStderr().trim(),s=u?`:
|
|
144
|
+
${u}`:"";throw new k(r,`Codex process has exited with code ${i}${s}`)}throw n}}async finishAllAsyncTasks(e,t){for(let n of this.sessions.values())try{await n.asyncTasks.finishAll(e)}catch(i){D.error(`Failed to finish background terminal tasks ${t}`,i)}}async cancel(e){let t=this.subagentAssociations.get(e.sessionId);if(t&&this.usesStandardSubagents()){let r=this.sessions.get(t.rootSessionId)?.subagents;r instanceof Ue&&await r.cancelChild(e.sessionId,(u,s)=>this.codexAcpClient.turnInterrupt({threadId:u,turnId:s}));return}if(this.isRestrictedChild(e.sessionId))return;this.activePrompts.get(e.sessionId)?.requestClientCancel();let n=this.sessions.get(e.sessionId);if(!n){D.log("Cancel request rejected: session not found",{sessionId:e.sessionId});return}let i=this.activePrompts.get(e.sessionId);if(!(i?.nativeCommandInFlight&&(i.requestCancel(),i.currentTurn===null))){if(i?.hasCompletedTurn&&i.currentTurn===null){i.requestCancel();return}i?.currentTurn&&i.requestCancel(),i&&(i.cancelRequested=!0,i.abortInteractions()),this.cancelQueuedV2Prompts(e.sessionId),await this.interruptSessionTurn(n,"Cancel",!1)}}},vZ=100;async function*CZ(e){let t=null,n=null;for await(let i of e){let r=[];for(let u of i){let s=u.item,o=u.turnId!==t;if(t=u.turnId,n!==null&&o){let a=s.type==="enteredReviewMode"&&Cv(n.turnId)&&Cv(u.turnId)&&n.turnId>u.turnId;r.push(...a?n.items.slice(1):n.items),n=null}if(o&&s.type==="userMessage"&&s.clientId===null){n={turnId:u.turnId,items:[s]};continue}if(n===null){r.push(s);continue}n.items.push(s),(s.type==="agentMessage"||s.type==="userMessage"||n.items.length>=vZ)&&(r.push(...n.items),n=null)}r.length>0&&(yield r)}n!==null&&(yield n.items)}async function*yZ(e){for await(let t of e)yield t.map(n=>n.item)}async function*EZ(e){for await(let t of e)yield t.map(n=>({item:n,completed:!("status"in n)||n.status!=="inProgress"}))}function wZ(e){switch(e.type){case"commandExecution":case"fileChange":case"mcpToolCall":case"dynamicToolCall":return!0;default:return!1}}function Cv(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}function _Z(e){switch(e){case"user_message_chunk":return"user_message";case"agent_message_chunk":return"agent_message";case"agent_thought_chunk":return"agent_thought";default:return null}}var tn=class extends Error{constructor(){super("The session closed during the history load")}};async function*yv(e,t){for await(let n of e){if(!t())throw new tn;yield n}}async function*AZ(e,t){e.length>0&&(yield e);for(let n=await t.next();!n.done;n=await t.next())yield n.value}async function*bZ(e,t){for await(let n of e){for(let i of n)i.type==="commandExecution"&&t.add(i.id);yield n}}function SZ(e,t){let n=[],i=new Set,r=0,u=o=>{let a=no(o);a&&i.has(a)||(a&&i.add(a),n.push(o))},s=o=>{let a=no(o),l=Ev(o);if(!a&&!l)return;let c=e.findIndex((m,p)=>p>=r&&(a!==null&&no(m)===a||l!==null&&Ev(m)===l));if(c!==-1){for(;r<c;)u(e[r]),r+=1;r+=1}};for(let o of t)s(o),u(o);for(;r<e.length;)u(e[r]),r+=1;return n}function no(e){switch(e.sessionUpdate){case"user_message_chunk":case"agent_message_chunk":case"agent_thought_chunk":return`${e.sessionUpdate}:${e.messageId??""}:${JSON.stringify(e.content)}`;case"tool_call":return`tool_call:${e.toolCallId}:start`;case"tool_call_update":return`tool_call:${e.toolCallId}:update`;default:return null}}function Ev(e){switch(e.sessionUpdate){case"user_message_chunk":case"agent_message_chunk":case"agent_thought_chunk":return`${e.sessionUpdate}:${JSON.stringify(e.content)}`;default:return no(e)}}function DZ(e){let t={};for(let n=0;n<e.length;n++){let i=e[n];if(i==="--help"||i==="-h")return IZ(),null;i==="--client-name"&&n+1<e.length?t.clientName=e[++n]:i.startsWith("--client-name=")&&(t.clientName=i.slice(14)),i==="--client-title"&&n+1<e.length?t.clientTitle=e[++n]:i.startsWith("--client-title=")&&(t.clientTitle=i.slice(15)),i==="--client-version"&&n+1<e.length?t.clientVersion=e[++n]:i.startsWith("--client-version=")&&(t.clientVersion=i.slice(17))}return t}function IZ(){console.log(`
|
|
145
|
+
acp-extension-codex login - Initialize and login to Codex with client context
|
|
146
|
+
|
|
147
|
+
Usage:
|
|
148
|
+
acp-extension-codex login [options]
|
|
149
|
+
|
|
150
|
+
Options:
|
|
151
|
+
--client-name <name> Client application name (default: "acp-extension-codex")
|
|
152
|
+
--client-title <title> Client application title (default: "Codex ACP")
|
|
153
|
+
--client-version <version> Client application version (default: "${Et.version}")
|
|
154
|
+
--help, -h Show this help message
|
|
155
|
+
|
|
156
|
+
Example:
|
|
157
|
+
acp-extension-codex login --client-name="AIA Plugin" --client-title="AI Assistant" --client-version="1.0.0"
|
|
158
|
+
`)}async function $Z(e){let t=process.env.CODEX_PATH??"codex";D.log("Starting Codex connection...");let n=Lf(t),i=new Ap(n.connection);try{let r={name:e.clientName??"acp-extension-codex",title:e.clientTitle??"Codex ACP",version:e.clientVersion??Et.version};D.log("Initializing with client",{name:r.name,version:r.version}),await i.initialize({clientInfo:r,capabilities:null});let u=await i.accountRead({refreshToken:!1});if(u.account&&(D.log("Already logged in",{accountType:u.account.type}),u.account.type==="chatgpt"))return!0;D.log("Starting ChatGPT login...");let s=BZ(i),o=await i.accountLogin({type:"chatgpt"});if(o.type==="chatgpt")D.log("Opening browser for authentication...",{authUrl:o.authUrl}),await hD(o.authUrl);else return D.error("Unexpected login response type",new Error(`Expected 'chatgpt', got '${o.type}'`)),!1;return D.log("Waiting for login completion..."),(await s).success?(D.log("Login successful!"),!0):(D.error("Login failed",new Error("Login was not successful")),!1)}finally{n.connection.dispose(),n.process.kill()}}function BZ(e){return new Promise(t=>{e.connection.onNotification("account/login/completed",n=>{t(n)})})}async function kZ(e){let t=DZ(e);return t===null?!0:$Z(t)}function TZ(e,t){let n=FZ(e,t);return new Promise((i,r)=>{n.on("error",r),n.on("exit",(u,s)=>{if(s){process.kill(process.pid,s);return}i(u??1)})})}function FZ(e,t){let n={env:process.env,stdio:"inherit",windowsHide:!0};if(e)return wv(e,t,{...n,shell:process.platform==="win32"});let i=xZ(import.meta.url).resolve("@openai/codex/bin/codex.js");return wv(process.execPath,[i,...t],n)}function PZ(e){if(e?.hooks===void 0)return{sessionConfig:e,appServerStartupArgs:["app-server"]};let{hooks:t,...n}=e;return{sessionConfig:n,appServerStartupArgs:["app-server","-c",`hooks=${Jd(t)}`]}}function Jd(e){return Array.isArray(e)?`[${e.map(Jd).join(", ")}]`:e!==null&&typeof e=="object"?`{ ${Object.entries(e).map(([t,n])=>`${JSON.stringify(t)} = ${Jd(n)}`).join(", ")} }`:JSON.stringify(e)}var RZ=class{callbacks=new Map;disposed=!1;afterWrite(e,t){this.disposed||this.callbacks.set(e,t)}observe(e){return{readable:e.readable,writable:new WritableStream({write:async t=>{let n=e.writable.getWriter();try{await n.write(t)}finally{n.releaseLock()}for(let i of Array.isArray(t)?t:[t]){if("method"in i||i.id===null)continue;let r=this.callbacks.get(i.id);this.callbacks.delete(i.id),r?.()}},close:async()=>{let t=e.writable.getWriter();try{await t.close()}finally{this.dispose(),t.releaseLock()}},abort:async t=>{let n=e.writable.getWriter();try{await n.abort(t)}finally{this.dispose(),n.releaseLock()}}})}}dispose(){this.disposed=!0,this.callbacks.clear()}},_v=Q.preprocess(e=>e??{},Q.object({}).passthrough()),zZ=Q.object({sessionId:Q.string(),modelId:Q.string()}).passthrough(),Av=Q.object({sessionId:Q.string(),prompt:Q.array(Q.any())}).passthrough(),bv=Q.object({sessionId:Q.string().min(1)}).passthrough(),Sv=Q.object({sessionId:Q.string().optional(),accountId:Q.string().optional(),modelId:Q.string().optional()}).passthrough(),Dv=Q.discriminatedUnion("action",[Q.object({sessionId:Q.string(),action:Q.literal("set"),objective:Q.string().trim().min(1)}).passthrough(),Q.object({sessionId:Q.string(),action:Q.enum(["pause","resume","clear"])}).passthrough()]),Iv=Q.object({sessionId:Q.string().trim().min(1),asyncTaskId:Q.string().trim().min(1)}).passthrough(),OZ=Q.object({cwd:Q.string().trim().min(1)}),NZ=Q.object({cwd:Q.string().trim().min(1),hooks:Q.array(Q.object({key:Q.string().min(1),currentHash:Q.string().min(1)})).min(1)});function MZ(e){return{connect(t,n){let i=new RZ,r=UZ(e,i).connect(i.observe(t),n);return r.closed.then(()=>i.dispose()),r}}}function UZ(e,t){let n=null,i=l=>{if(!n)throw k.internalError("ACP agent is not connected");return typeof l?.sessionId=="string"&&n.assertSessionMutationAllowed(l.sessionId),n},r=new Map,u=(l,c,m,p)=>{let v=i({sessionId:l});if(!v.usesStandardSubagents())return m();let g=v.captureSessionSetup(l),C=r.get(l)??{tail:Promise.resolve(),publication:Promise.resolve(),epoch:0,pending:0};r.set(l,C),C.pending++;let y=++C.epoch,b=()=>{--C.pending===0&&r.get(l)===C&&r.delete(l)},A,S,z=new Promise((M,T)=>{A=M,S=T});return C.tail=C.tail.catch(()=>{}).then(async()=>{let M=!1,T=!1;try{for(;;){let re=C.publication;if(await re,re===C.publication)break}if(p.aborted)throw new k(-32800,"Session setup was cancelled");g(),t.afterWrite(c,()=>{y===C.epoch&&T&&(C.publication=v.afterSessionSetupResponse(l)),C.publication.then(b,b)}),M=!0;let G=await m();if(p.aborted)throw new k(-32800,"Session setup was cancelled");T=!0,A(G)}catch(G){S(G),M||b()}}),z},s=(l,c)=>{n=l,c.addEventListener("abort",()=>{r.clear(),l.sessionIndex.dispose(),n===l&&(n=null)})},o=eP({name:Et.name}).onConnect(l=>s(e(l.client),l.signal)).onRequest(ae.agent.initialize,l=>i().initialize(l.params)).onRequest(ae.agent.session.new,l=>i().newSession(l.params)).onRequest(ae.agent.session.load,l=>u(l.params.sessionId,l.requestId,()=>i(l.params).loadSession(l.params),l.signal)).onRequest(ae.agent.session.fork,l=>i(l.params).forkSession(l.params)).onRequest(ae.agent.session.list,l=>i().listSessions(l.params)).onRequest(ae.agent.session.delete,l=>i(l.params).deleteSession(l.params)).onRequest(ae.agent.session.resume,l=>u(l.params.sessionId,l.requestId,()=>i(l.params).resumeSession(l.params),l.signal)).onRequest(ae.agent.session.close,l=>i(l.params).closeSession(l.params)).onRequest(ae.agent.session.setMode,l=>i(l.params).setSessionMode(l.params)).onRequest(ae.agent.session.setConfigOption,l=>i(l.params).setSessionConfigOption(l.params)).onRequest(ae.agent.authenticate,l=>i().authenticate(l.params,l.requestId)).onRequest(ae.agent.logout,l=>i().logout(l.params)).onRequest(ae.agent.providers.list,l=>i().listProviders(l.params)).onRequest(ae.agent.providers.set,l=>i().setProvider(l.params)).onRequest(ae.agent.providers.disable,l=>i().disableProvider(l.params)).onRequest(ae.agent.session.prompt,l=>i(l.params).prompt(l.params,l.signal)).onNotification(ae.agent.session.cancel,l=>i().cancel(l.params)).onRequest("authentication/status",_v,l=>i().extMethod("authentication/status",l.params)).onRequest("authentication/logout",_v,l=>i().extMethod("authentication/logout",l.params)).onRequest(To,zZ,l=>i(l.params).extMethod(To,l.params)).onRequest(Ym,bv,l=>i().readSessionHistory(l.params)).onRequest(Qm,Sv,()=>i().readRateLimits()).onRequest(Vr,Av,l=>i(l.params).extMethod(Vr,l.params)).onRequest(Gr,Iv,l=>i(l.params).extMethod(Gr,l.params)).onRequest(qL,OZ,l=>i().listHooks(l.params.cwd)).onRequest(ZL,NZ,l=>i().trustHooks(l.params.cwd,l.params.hooks)).onRequest(mr,Dv,l=>i(l.params).extMethod(mr,l.params)).onRequest(Md,V4,l=>i(l.params).sessionIndex.rename(l.params)).onRequest(Nd,G4,l=>i().sessionIndex.batchGet(l.params)).onRequest(Ud,Bs,l=>i(l.params).sessionIndex.setArchived(l.params,!0)).onRequest(jd,Bs,l=>i(l.params).sessionIndex.setArchived(l.params,!1)).onRequest(Ld,ks,l=>i().sessionIndex.subscribeList(l.params)).onRequest(qd,ks,l=>i().sessionIndex.unsubscribeList(l.params)),a=H8({name:Et.name}).onConnect(l=>s(e(new nn(l.client)),l.signal)).onRequest(Ve.agent.initialize,l=>i().initializeV2(l.params)).onRequest(Ve.agent.session.new,l=>i().newSessionV2(l.params)).onRequest(Ve.agent.session.list,l=>i().listSessions(l.params)).onRequest(Ve.agent.session.delete,l=>i(l.params).deleteSession(l.params)).onRequest(Ve.agent.session.resume,l=>u(l.params.sessionId,l.requestId,()=>i(l.params).resumeSessionV2(l.params),l.signal)).onRequest(Ve.agent.session.fork,l=>i(l.params).forkSessionV2(l.params)).onRequest(Ve.agent.session.close,l=>i(l.params).closeSession(l.params)).onRequest(Ve.agent.session.setConfigOption,l=>i(l.params).setSessionConfigOptionV2(l.params)).onRequest(Ve.agent.auth.login,l=>i().authenticateV2(l.params,l.requestId)).onRequest(Ve.agent.auth.logout,l=>i().logoutV2(l.params)).onRequest(Ve.agent.session.prompt,l=>i(l.params).promptV2(l.params,l.signal)).onNotification(Ve.agent.session.cancel,l=>i().cancel(l.params)).onRequest(Ve.agent.providers.list,l=>i().listProviders(l.params)).onRequest(Ve.agent.providers.set,l=>i().setProvider(l.params)).onRequest(Ve.agent.providers.disable,l=>i().disableProvider(l.params)).onRequest(Ym,bv,l=>i().readSessionHistory(l.params)).onRequest(Qm,Sv,()=>i().readRateLimits()).onRequest(Vr,Av,l=>i(l.params).extMethod(Vr,l.params)).onRequest(mr,Dv,l=>i(l.params).extMethod(mr,l.params)).onRequest(Gr,Iv,l=>i(l.params).extMethod(Gr,l.params)).onRequest(Md,V4,l=>i(l.params).sessionIndex.rename(l.params)).onRequest(Ud,Bs,l=>i(l.params).sessionIndex.setArchived(l.params,!0)).onRequest(jd,Bs,l=>i(l.params).sessionIndex.setArchived(l.params,!1)).onRequest(Nd,G4,l=>i().sessionIndex.batchGet(l.params)).onRequest(Ld,ks,l=>i().sessionIndex.subscribeList(l.params)).onRequest(qd,ks,l=>i().sessionIndex.unsubscribeList(l.params));return v8().withV1(o).withV2(a)}process.argv.includes("--version")&&(console.log(`${Et.name} ${Et.version}`),process.exit(0));if(process.argv[2]==="login"){let e=process.argv.slice(3);kZ(e).then(t=>process.exit(t?0:1)).catch(t=>{console.error("Login error:",t.message),process.exit(1)})}else if(process.argv[2]==="cli"){let e=process.argv.slice(3);TZ(process.env.CODEX_PATH,e).then(t=>process.exit(t)).catch(t=>{console.error("Codex CLI error:",t.message),process.exit(1)})}else jZ();function jZ(){let e=process.env.CODEX_PATH,t=process.env.CODEX_CONFIG,n=process.env.DEFAULT_AUTH_REQUEST,i=process.env.MODEL_PROVIDER,r=t?JSON.parse(t):void 0,u=PZ(r),s=n?JSON.parse(n):void 0,o=s&&vp(s)?s:void 0;D.log("Startup",{name:Et.name,version:Et.version,codexPath:e,modelProvider:i??null,codexConfig:r??null,authRequest:n??null,defaultAuthRequest:o??null});let a={connection:Lf(e,void 0,u.appServerStartupArgs,{disposeOnExit:!1}),codexPath:e,config:u.sessionConfig,appServerStartupArgs:u.appServerStartupArgs,modelProvider:i,stderr:""},l=new SD(a);a.supervisor=l,process.stdin.on("close",()=>{l.shutdown()});let c=oP(process.stdin,process.stdout);function m(p){let v=new Ap(a.connection.connection),g=new pU(v,u.sessionConfig,i);return new gZ(p,g,o,void 0,void 0,a,!!process.env.LODY_CODEX_PROFILE_CONFIG&&r?.forced_login_method==="chatgpt")}MZ(m).connect(c)}
|