UNPKG

code-server

Version:

Run VS Code on a remote server.

76 lines • 179 kB
import{a as Yt,c as Xt,i as Qt,j as lt,k as oe}from"./chunk-UKJEVVXS.js";import"./chunk-OOJM4CTU.js";var en;function I(e,t,n){function i(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let d=o.prototype,u=Object.keys(d);for(let l=0;l<u.length;l++){let h=u[l];h in a||(a[h]=d[h].bind(a))}}let r=n?.Parent??Object;class s extends r{}Object.defineProperty(s,"name",{value:e});function o(a){var c;let d=n?.Parent?new s:this;i(d,a),(c=d._zod).deferred??(c.deferred=[]);for(let u of d._zod.deferred)u();return d}return Object.defineProperty(o,"init",{value:i}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Ce=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(en=globalThis).__zod_globalConfig??(en.__zod_globalConfig={});var fr=globalThis.__zod_globalConfig;function me(e){return fr}function si(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}function mr(e,t){return typeof t=="bigint"?t.toString():t}function _r(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function oi(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var tn=Symbol("evaluating");function se(e,t,n){let i;Object.defineProperty(e,t,{get(){if(i!==tn)return i===void 0&&(i=tn,i=n()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}var ai="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function St(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function gr(e){if(St(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(St(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}var vr=new Set(["string","number","symbol"]);function It(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yr(e,t,n){let i=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(i._zod.parent=e),i}function J(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 br(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var wr={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]};function Re(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 zr(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 ze(e,t){return t.map(n=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Ve(e){return typeof e=="string"?e:e?.message}function _e(e,t,n){let i=e.message?e.message:Ve(e.inst?._zod.def?.error?.(e))??Ve(t?.error?.(e))??Ve(n.customError?.(e))??Ve(n.localeError?.(e))??"Invalid input",{inst:r,continue:s,input:o,...a}=e;return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=o),a}var ci=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,mr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Sr=I("$ZodError",ci),st=I("$ZodError",ci,{Parent:Error}),Ir=e=>(t,n,i,r)=>{let s=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new Ce;if(o.issues.length){let a=new(r?.Err??e)(o.issues.map(c=>_e(c,s,me())));throw ai(a,r?.callee),a}return o.value},kr=Ir(st),xr=e=>async(t,n,i,r)=>{let s=i?{...i,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){let a=new(r?.Err??e)(o.issues.map(c=>_e(c,s,me())));throw ai(a,r?.callee),a}return o.value},$r=xr(st),Or=e=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new Ce;return s.issues.length?{success:!1,error:new(e??Sr)(s.issues.map(o=>_e(o,r,me())))}:{success:!0,data:s.value}},Q=Or(st),Er=e=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(o=>_e(o,r,me())))}:{success:!0,data:s.value}},di=Er(st),Pr=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Tr=/^-?\d+$/,ui=/^-?\d+(?:\.\d+)?$/,Nr=/^(?:true|false)$/i,li=I("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Rr={number:"number",bigint:"bigint",object:"date"},hi=I("$ZodCheckGreaterThan",(e,t)=>{li.init(e,t);let n=Rr[typeof t.value];e._zod.onattach.push(i=>{let r=i._zod.bag,s=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin: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})}}),jr=I("$ZodCheckNumberFormat",(e,t)=>{li.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=wr[t.format];e._zod.onattach.push(o=>{let a=o._zod.bag;a.format=t.format,a.minimum=r,a.maximum=s,n&&(a.pattern=Tr)}),e._zod.check=o=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?o.issues.push({input:a,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}):o.issues.push({input:a,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}}a<r&&o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),a>s&&o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Ar={major:4,minor:4,patch:3},K=I("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ar;let i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(let r of i)for(let s of r._zod.onattach)s(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let r=(o,a,c)=>{let d=Re(o),u;for(let l of a){if(l._zod.def.when){if(zr(o)||!l._zod.def.when(o))continue}else if(d)continue;let h=o.issues.length,f=l._zod.check(o);if(f instanceof Promise&&c?.async===!1)throw new Ce;if(u||f instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await f,o.issues.length!==h&&(d||(d=Re(o,h)))});else{if(o.issues.length===h)continue;d||(d=Re(o,h))}}return u?u.then(()=>o):o},s=(o,a,c)=>{if(Re(o))return o.aborted=!0,o;let d=r(a,i,c);if(d instanceof Promise){if(c.async===!1)throw new Ce;return d.then(u=>e._zod.parse(u,c))}return e._zod.parse(d,c)};e._zod.run=(o,a)=>{if(a.skipChecks)return e._zod.parse(o,a);if(a.direction==="backward"){let d=e._zod.parse({value:o.value,issues:[]},{...a,skipChecks:!0});return d instanceof Promise?d.then(u=>s(u,o,a)):s(d,o,a)}let c=e._zod.parse(o,a);if(c instanceof Promise){if(a.async===!1)throw new Ce;return c.then(d=>r(d,i,a))}return r(c,i,a)}}se(e,"~standard",()=>({validate:r=>{try{let s=Q(e,r);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return di(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Cr=I("$ZodString",(e,t)=>{K.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Pr(e._zod.bag),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}}),pi=I("$ZodNumber",(e,t)=>{K.init(e,t),e._zod.pattern=e._zod.bag.pattern??ui,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 s=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),Mr=I("$ZodNumberFormat",(e,t)=>{jr.init(e,t),pi.init(e,t)}),Zr=I("$ZodBoolean",(e,t)=>{K.init(e,t),e._zod.pattern=Nr,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}}),Fr=I("$ZodUnknown",(e,t)=>{K.init(e,t),e._zod.parse=n=>n}),Lr=I("$ZodVoid",(e,t)=>{K.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}});function nn(e,t,n){e.issues.length&&t.issues.push(...ze(n,e.issues)),t.value[n]=e.value}var Hr=I("$ZodArray",(e,t)=>{K.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);let s=[];for(let o=0;o<r.length;o++){let a=r[o],c=t.element._zod.run({value:a,issues:[]},i);c instanceof Promise?s.push(c.then(d=>nn(d,n,o))):nn(c,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function Qe(e,t,n,i,r,s){let o=n in i;if(e.issues.length){if(r&&s&&!o)return;t.issues.push(...ze(n,e.issues))}if(!o&&!r){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Dr(e){let t=Object.keys(e.shape);for(let i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);let n=br(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Vr(e,t,n,i,r,s){let o=[],a=r.keySet,c=r.catchall._zod,d=c.def.type,u=c.optin==="optional",l=c.optout==="optional";for(let h in t){if(h==="__proto__"||a.has(h))continue;if(d==="never"){o.push(h);continue}let f=c.run({value:t[h],issues:[]},i);f instanceof Promise?e.push(f.then(g=>Qe(g,n,h,t,u,l))):Qe(f,n,h,t,u,l)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}var Jr=I("$ZodObject",(e,t)=>{if(K.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let o=t.shape;Object.defineProperty(t,"shape",{get:()=>{let a={...o};return Object.defineProperty(t,"shape",{value:a}),a}})}let n=_r(()=>Dr(t));se(e._zod,"propValues",()=>{let o=t.shape,a={};for(let c in o){let d=o[c]._zod;if(d.values){a[c]??(a[c]=new Set);for(let u of d.values)a[c].add(u)}}return a});let i=St,r=t.catchall,s;e._zod.parse=(o,a)=>{s??(s=n.value);let c=o.value;if(!i(c))return o.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),o;o.value={};let d=[],u=s.shape;for(let l of s.keys){let h=u[l],f=h._zod.optin==="optional",g=h._zod.optout==="optional",_=h._zod.run({value:c[l],issues:[]},a);_ instanceof Promise?d.push(_.then(N=>Qe(N,o,l,c,f,g))):Qe(_,o,l,c,f,g)}return r?Vr(d,c,o,a,n.value,e):d.length?Promise.all(d).then(()=>o):o}});function rn(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter(s=>!Re(s));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(s=>s.issues.map(o=>_e(o,i,me())))}),t)}var qr=I("$ZodUnion",(e,t)=>{K.init(e,t),se(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),se(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),se(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),se(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){let i=t.options.map(r=>r._zod.pattern);return new RegExp(`^(${i.map(r=>oi(r.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 s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}return s?Promise.all(o).then(a=>rn(a,i,e,r)):rn(o,i,e,r)}}),Ur=I("$ZodRecord",(e,t)=>{K.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;if(!gr(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;let s=[],o=t.keyType._zod.values;if(o){n.value={};let a=new Set;for(let d of o)if(typeof d=="string"||typeof d=="number"||typeof d=="symbol"){a.add(typeof d=="number"?d.toString():d);let u=t.keyType._zod.run({value:d,issues:[]},i);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(u.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(f=>_e(f,i,me())),input:d,path:[d],inst:e});continue}let l=u.value,h=t.valueType._zod.run({value:r[d],issues:[]},i);h instanceof Promise?s.push(h.then(f=>{f.issues.length&&n.issues.push(...ze(d,f.issues)),n.value[l]=f.value})):(h.issues.length&&n.issues.push(...ze(d,h.issues)),n.value[l]=h.value)}let c;for(let d in r)a.has(d)||(c=c??[],c.push(d));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:c})}else{n.value={};for(let a of Reflect.ownKeys(r)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(r,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},i);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&ui.test(a)&&c.issues.length){let u=t.keyType._zod.run({value:Number(a),issues:[]},i);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");u.issues.length===0&&(c=u)}if(c.issues.length){t.mode==="loose"?n.value[a]=r[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(u=>_e(u,i,me())),input:a,path:[a],inst:e});continue}let d=t.valueType._zod.run({value:r[a],issues:[]},i);d instanceof Promise?s.push(d.then(u=>{u.issues.length&&n.issues.push(...ze(a,u.issues)),n.value[c.value]=u.value})):(d.issues.length&&n.issues.push(...ze(a,d.issues)),n.value[c.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}}),Wr=I("$ZodEnum",(e,t)=>{K.init(e,t);let n=si(t.entries),i=new Set(n);e._zod.values=i,e._zod.pattern=new RegExp(`^(${n.filter(r=>vr.has(typeof r)).map(r=>typeof r=="string"?It(r):r.toString()).join("|")})$`),e._zod.parse=(r,s)=>{let o=r.value;return i.has(o)||r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),Gr=I("$ZodLiteral",(e,t)=>{if(K.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(i=>typeof i=="string"?It(i):i?It(i.toString()):String(i)).join("|")})$`),e._zod.parse=(i,r)=>{let s=i.value;return n.has(s)||i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});function sn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Br=I("$ZodOptional",(e,t)=>{K.init(e,t),e._zod.optin="optional",e._zod.optout="optional",se(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),se(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${oi(n.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(t.innerType._zod.optin==="optional"){let r=n.value,s=t.innerType._zod.run(n,i);return s instanceof Promise?s.then(o=>sn(o,r)):sn(s,r)}return n.value===void 0?n:t.innerType._zod.run(n,i)}}),on,Kr=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 Yr(){return new Kr}(on=globalThis).__zod_globalRegistry??(on.__zod_globalRegistry=Yr());var Xr=globalThis.__zod_globalRegistry;function Qr(e,t){return new e({type:"string",...J(t)})}function es(e,t){return new e({type:"number",checks:[],...J(t)})}function ts(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...J(t)})}function ns(e,t){return new e({type:"boolean",...J(t)})}function is(e){return new e({type:"unknown"})}function rs(e,t){return new e({type:"void",...J(t)})}function ss(e,t){return new hi({check:"greater_than",...J(t),value:e,inclusive:!1})}function os(e,t){return new hi({check:"greater_than",...J(t),value:e,inclusive:!0})}function as(e){return ss(0,e)}function $e(e){return os(0,e)}function kt(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??Xr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function O(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,d);else{let l=o.schema,h=t.processors[r.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);h(e,t,l,d)}let u=e._zod.parent;u&&(o.ref||(o.ref=u),O(u,t,d),t.seen.get(u).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&L(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function xt(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=o=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let u=e.external.registry.get(o[0])?.id,l=e.external.uri??(f=>f);if(u)return{ref:l(u)};let h=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=h,{defId:h,ref:`${l("__shared")}#/${a}/${h}`}}if(o[1]===n)return{ref:"#"};let c=`#/${a}/`,d=o[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:c+d}},s=o=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:d}=r(o);a.def={...a.schema},d&&(a.defId=d);let u=a.schema;for(let l in u)delete u[l];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>

Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let c=e.external.registry.get(o[0])?.id;if(t!==o[0]&&c){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1&&e.reused==="ref"){s(o);continue}}}function $t(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=a=>{let c=e.seen.get(a);if(c.ref===null)return;let d=c.def??c.schema,u={...d},l=c.ref;if(c.ref=null,l){i(l);let f=e.seen.get(l),g=f.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(g)):Object.assign(d,g),Object.assign(d,u),a._zod.parent===l)for(let _ in d)_==="$ref"||_==="allOf"||_ in u||delete d[_];if(g.$ref&&f.def)for(let _ in d)_==="$ref"||_==="allOf"||_ in f.def&&JSON.stringify(d[_])===JSON.stringify(f.def[_])&&delete d[_]}let h=a._zod.parent;if(h&&h!==l){i(h);let f=e.seen.get(h);if(f?.schema.$ref&&(d.$ref=f.schema.$ref,f.def))for(let g in d)g==="$ref"||g==="allOf"||g in f.def&&JSON.stringify(d[g])===JSON.stringify(f.def[g])&&delete d[g]}e.override({zodSchema:a,jsonSchema:d,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())i(a[0]);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 a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}Object.assign(r,n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&r.id===s&&delete r.id;let o=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,o[c.defId]=c.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?r.$defs=o:r.definitions=o);try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:an(t,"input",e.processors),output:an(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function L(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 L(i.element,n);if(i.type==="set")return L(i.valueType,n);if(i.type==="lazy")return L(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")return L(i.innerType,n);if(i.type==="intersection")return L(i.left,n)||L(i.right,n);if(i.type==="record"||i.type==="map")return L(i.keyType,n)||L(i.valueType,n);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:L(i.in,n)||L(i.out,n);if(i.type==="object"){for(let r in i.shape)if(L(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(L(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(L(r,n))return!0;return!!(i.rest&&L(i.rest,n))}return!1}var an=(e,t,n={})=>i=>{let{libraryOptions:r,target:s}=i??{},o=kt({...r??{},target:s,io:t,processors:n});return O(e,o),xt(o,e),$t(o,e)},cs={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ds=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:d}=e._zod.bag;if(typeof s=="number"&&(r.minLength=s),typeof o=="number"&&(r.maxLength=o),a&&(r.format=cs[a]??a,r.format===""&&delete r.format,a==="time"&&delete r.format),d&&(r.contentEncoding=d),c&&c.size>0){let u=[...c];u.length===1?r.pattern=u[0].source:u.length>1&&(r.allOf=[...u.map(l=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:l.source}))])}},us=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:d,exclusiveMinimum:u}=e._zod.bag;typeof a=="string"&&a.includes("int")?r.type="integer":r.type="number";let l=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),h=typeof d=="number"&&d<=(o??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";l?f?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u:typeof s=="number"&&(r.minimum=s),h?f?(r.maximum=d,r.exclusiveMaximum=!0):r.exclusiveMaximum=d:typeof o=="number"&&(r.maximum=o),typeof c=="number"&&(r.multipleOf=c)},ls=(e,t,n,i)=>{n.type="boolean"},hs=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},ps=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},fs=(e,t,n,i)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},ms=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},_s=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},gs=(e,t,n,i)=>{n.not={}},vs=(e,t,n,i)=>{},ys=(e,t,n,i)=>{},bs=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},ws=(e,t,n,i)=>{let r=e._zod.def,s=si(r.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},zs=(e,t,n,i)=>{let r=e._zod.def,s=[];for(let o of r.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){let o=s[0];n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[o]:n.const=o}else s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),s.every(o=>typeof o=="boolean")&&(n.type="boolean"),s.every(o=>o===null)&&(n.type="null"),n.enum=s},Ss=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},Is=(e,t,n,i)=>{let r=n,s=e._zod.pattern;if(!s)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=s.source},ks=(e,t,n,i)=>{let r=n,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:a,mime:c}=e._zod.bag;o!==void 0&&(s.minLength=o),a!==void 0&&(s.maxLength=a),c?c.length===1?(s.contentMediaType=c[0],Object.assign(r,s)):(Object.assign(r,s),r.anyOf=c.map(d=>({contentMediaType:d}))):Object.assign(r,s)},xs=(e,t,n,i)=>{n.type="boolean"},$s=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Os=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Es=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ps=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Ts=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Ns=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;typeof o=="number"&&(r.minItems=o),typeof a=="number"&&(r.maxItems=a),r.type="array",r.items=O(s.element,t,{...i,path:[...i.path,"items"]})},Rs=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object",r.properties={};let o=s.shape;for(let d in o)r.properties[d]=O(o[d],t,{...i,path:[...i.path,"properties",d]});let a=new Set(Object.keys(o)),c=new Set([...a].filter(d=>{let u=s.shape[d]._zod;return t.io==="input"?u.optin===void 0:u.optout===void 0}));c.size>0&&(r.required=Array.from(c)),s.catchall?._zod.def.type==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=O(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},js=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>O(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=o:n.anyOf=o},As=(e,t,n,i)=>{let r=e._zod.def,s=O(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=O(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=d=>"allOf"in d&&Object.keys(d).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c},Cs=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((h,f)=>O(h,t,{...i,path:[...i.path,o,f]})),d=s.rest?O(s.rest,t,{...i,path:[...i.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;t.target==="draft-2020-12"?(r.prefixItems=c,d&&(r.items=d)):t.target==="openapi-3.0"?(r.items={anyOf:c},d&&r.items.anyOf.push(d),r.minItems=c.length,d||(r.maxItems=c.length)):(r.items=c,d&&(r.additionalItems=d));let{minimum:u,maximum:l}=e._zod.bag;typeof u=="number"&&(r.minItems=u),typeof l=="number"&&(r.maxItems=l)},Ms=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=o._zod.bag?.patterns;if(s.mode==="loose"&&a&&a.size>0){let d=O(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let u of a)r.patternProperties[u.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=O(s.keyType,t,{...i,path:[...i.path,"propertyNames"]})),r.additionalProperties=O(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]});let c=o._zod.values;if(c){let d=[...c].filter(u=>typeof u=="string"||typeof u=="number");d.length>0&&(r.required=d)}},Zs=(e,t,n,i)=>{let r=e._zod.def,s=O(r.innerType,t,i),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=r.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},Fs=(e,t,n,i)=>{let r=e._zod.def;O(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Ls=(e,t,n,i)=>{let r=e._zod.def;O(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},Hs=(e,t,n,i)=>{let r=e._zod.def;O(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},Ds=(e,t,n,i)=>{let r=e._zod.def;O(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},Vs=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;O(o,t,i);let a=t.seen.get(e);a.ref=o},Js=(e,t,n,i)=>{let r=e._zod.def;O(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0},qs=(e,t,n,i)=>{let r=e._zod.def;O(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Us=(e,t,n,i)=>{let r=e._zod.def;O(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Ws=(e,t,n,i)=>{let r=e._zod.innerType;O(r,t,i);let s=t.seen.get(e);s.ref=r},cn={string:ds,number:us,boolean:ls,bigint:hs,symbol:ps,null:fs,undefined:ms,void:_s,never:gs,any:vs,unknown:ys,date:bs,enum:ws,literal:zs,nan:Ss,template_literal:Is,file:ks,success:xs,custom:$s,function:Os,transform:Es,map:Ps,set:Ts,array:Ns,object:Rs,union:js,intersection:As,tuple:Cs,record:Ms,nullable:Zs,nonoptional:Fs,default:Ls,prefault:Hs,catch:Ds,pipe:Vs,readonly:Js,promise:qs,optional:Us,lazy:Ws};function Gs(e,t){if("_idmap"in e){let i=e,r=kt({...t,processors:cn}),s={};for(let c of i._idmap.entries()){let[d,u]=c;O(u,r)}let o={},a={registry:i,uri:t?.uri,defs:s};r.external=a;for(let c of i._idmap.entries()){let[d,u]=c;xt(r,u),o[d]=$t(r,u)}if(Object.keys(s).length>0){let c=r.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[c]:s}}return{schemas:o}}let n=kt({...t,processors:cn});return O(e,n),xt(n,e),$t(n,e)}var Y=I("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");K.init(e,t),e.def=t,e.type=t.type,e.parse=(n,i)=>kr(e,n,i,{callee:e.parse}),e.safeParse=(n,i)=>Q(e,n,i),e.parseAsync=async(n,i)=>$r(e,n,i,{callee:e.parseAsync}),e.safeParseAsync=async(n,i)=>di(e,n,i),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]},{parent:!0}),e.with=e.check,e.clone=(n,i)=>yr(e,n,i),e.brand=()=>e,e.register=((n,i)=>(n.add(e,i),e)),e.apply=n=>n(e)}),Bs=I("ZodMiniString",(e,t)=>{Cr.init(e,t),Y.init(e,t)});function m(e){return Qr(Bs,e)}var fi=I("ZodMiniNumber",(e,t)=>{pi.init(e,t),Y.init(e,t)});function q(e){return es(fi,e)}var Ks=I("ZodMiniNumberFormat",(e,t)=>{Mr.init(e,t),fi.init(e,t)});function ge(e){return ts(Ks,e)}var Ys=I("ZodMiniBoolean",(e,t)=>{Zr.init(e,t),Y.init(e,t)});function He(e){return ns(Ys,e)}var Xs=I("ZodMiniUnknown",(e,t)=>{Fr.init(e,t),Y.init(e,t)});function fe(){return is(Xs)}var Qs=I("ZodMiniVoid",(e,t)=>{Lr.init(e,t),Y.init(e,t)});function dn(e){return rs(Qs,e)}var eo=I("ZodMiniArray",(e,t)=>{Hr.init(e,t),Y.init(e,t)});function G(e,t){return new eo({type:"array",element:e,...J(t)})}var to=I("ZodMiniObject",(e,t)=>{Jr.init(e,t),Y.init(e,t),se(e,"shape",()=>t.shape)});function y(e,t){let n={type:"object",shape:e??{},...J(t)};return new to(n)}var no=I("ZodMiniUnion",(e,t)=>{qr.init(e,t),Y.init(e,t)});function Ee(e,t){return new no({type:"union",options:e,...J(t)})}var un=I("ZodMiniRecord",(e,t)=>{Ur.init(e,t),Y.init(e,t)});function mi(e,t,n){return!t||!t._zod?new un({type:"record",keyType:m(),valueType:e,...J(t)}):new un({type:"record",keyType:e,valueType:t,...J(n)})}var io=I("ZodMiniEnum",(e,t)=>{Wr.init(e,t),Y.init(e,t),e.options=Object.values(t.entries)});function ce(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new io({type:"enum",entries:n,...J(t)})}var ro=I("ZodMiniLiteral",(e,t)=>{Gr.init(e,t),Y.init(e,t)});function _i(e,t){return new ro({type:"literal",values:Array.isArray(e)?e:[e],...J(t)})}var so=I("ZodMiniOptional",(e,t)=>{Br.init(e,t),Y.init(e,t)});function v(e){return new so({type:"optional",innerType:e})}var oo=new Set(["type","format","properties","required","additionalProperties","items","prefixItems","const","enum","anyOf","oneOf","discriminator","$ref","title","description"]);function te(e){if(e===!0||e===!1)return e;if(e===null||typeof e!="object")throw new Error(`normalizeJsonSchema: expected object, got ${typeof e}`);if(Array.isArray(e))throw new Error("normalizeJsonSchema: expected object, got array");let t=e;if("not"in t&&co(t.not))return!1;let n={};for(let[i,r]of Object.entries(t)){if(!oo.has(i))continue;let s=ao(i,r);s!==void 0&&(n[i]=s)}if(n.type==="object"&&!("additionalProperties"in n)&&(n.additionalProperties=!1),Array.isArray(n.oneOf)&&!("discriminator"in n)){let i=uo(n.oneOf);i!==void 0&&(n.discriminator=i)}return"discriminator"in n&&!Array.isArray(n.oneOf)&&delete n.discriminator,Object.keys(n).length===0?!0:n}function ao(e,t){switch(e){case"properties":{if(!Ot(t))return{};let n={};for(let[i,r]of Object.entries(t))n[i]=te(r);return n}case"items":case"additionalProperties":return t===!1?!1:te(t);case"prefixItems":case"anyOf":case"oneOf":return Array.isArray(t)?t.map(n=>te(n)):[];case"discriminator":{if(!Ot(t))return;let n=t.propertyName;return typeof n!="string"||n.length===0?void 0:{propertyName:n}}case"enum":return Array.isArray(t)?t.slice():[];case"required":return Array.isArray(t)?t.slice().sort():[];default:return t}}function co(e){return Ot(e)&&Object.keys(e).length===0}function Ot(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function uo(e){if(e.length<2)return;let t=[];for(let i of e){if(i===!0||i===!1||i.type!=="object")return;let r=i.properties;if(!r)return;t.push(r)}let n=ln(t[0]);for(let i=1;i<t.length;i++)if(n=n.filter(r=>ln(t[i]).includes(r)),n.length===0)return;for(let i of n){let r=new Set,s=!0;for(let o of t){let a=o[i],c=JSON.stringify(a.const);if(r.has(c)){s=!1;break}r.add(c)}if(s)return{propertyName:i}}}function ln(e){let t=[];for(let[n,i]of Object.entries(e))i===!0||i===!1||"const"in i&&t.push(n);return t}var gi=class vi{paramsSchema;resultSchema;errorSchema;docs;clientStreamSchema;serverStreamSchema;kind="request";constructor(t,n,i,r={},s,o){this.paramsSchema=t,this.resultSchema=n,this.errorSchema=i,this.docs=r,this.clientStreamSchema=s,this.serverStreamSchema=o}withStream(t){return new vi(this.paramsSchema,this.resultSchema,this.errorSchema,this.docs,t.client,t.server)}},yi=class{paramsSchema;docs;kind="notification";constructor(e,t={}){this.paramsSchema=e,this.docs=t}};function $(e,t,n,i){let r={};return new gi(e,t??dn(),dn(),r)}function B(e,t={}){return new yi(e,t)}function lo(e,t){let n=e._zod?.def?.type;return n==="void"||n==="undefined"?!0:ho(Gs(e),t)}function ho(e,t){if(!et(e))return te(e);let n=et(e.$defs)?e.$defs:{},i=Et(e);if(Object.keys(n).length===0&&i.size===0)return te(e);if(t===void 0)throw new Error("zodToSvcJsonSchema: local references require a component destination");let r=`method=${ht(t.methodName)}&schema=${ht(t.schemaPosition)}`,s=new Map;for(let d of Object.keys(n))s.set(d,`${r}&def=${ht(d)}`);let o=i.has("#")?`${r}&root`:void 0,a=d=>Pt(d,s,o);for(let[d,u]of Object.entries(n)){let l=s.get(d);if(l===void 0)throw new Error(`zodToSvcJsonSchema: missing component for "${d}"`);hn(t.components,l,te(a(u)))}let c=a(e);return o!==void 0?(hn(t.components,o,te(c)),{$ref:Tt(o)}):te(c)}function Et(e,t=new Set){if(Array.isArray(e)){for(let n of e)Et(n,t);return t}if(!et(e))return t;typeof e.$ref=="string"&&e.$ref.startsWith("#")&&t.add(e.$ref);for(let n of Object.values(e))Et(n,t);return t}function Pt(e,t,n){if(Array.isArray(e))return e.map(r=>Pt(r,t,n));if(!et(e))return e;let i={};for(let[r,s]of Object.entries(e))r!=="$defs"&&(r==="$ref"&&typeof s=="string"?i[r]=po(s,t,n):i[r]=Pt(s,t,n));return i}function po(e,t,n){if(e==="#"){if(n===void 0)throw new Error("zodToSvcJsonSchema: root reference has no component destination");return Tt(n)}if(e.startsWith("#/$defs/")){let i=e.slice(8),r=[...t.keys()].find(o=>bi(o)===i),s=r===void 0?void 0:t.get(r);if(s===void 0)throw new Error(`zodToSvcJsonSchema: dangling local reference "${e}"`);return Tt(s)}if(e.startsWith("#")&&!e.startsWith("#/components/schemas/"))throw new Error(`zodToSvcJsonSchema: unsupported local reference "${e}"`);return e}function hn(e,t,n){if(Object.hasOwn(e,t))throw new Error(`zodToSvcJsonSchema: duplicate component name "${t}"`);e[t]=n}function Tt(e){return`#/components/schemas/${bi(e)}`}function bi(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ht(e){return encodeURIComponent(e).replace(/~/g,"%7E")}function et(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function fo(e){let t=Be(e);if(t===void 0)throw new Error("jcsCanonicalize: value is not JSON-representable");return t}new TextEncoder;function Be(e,t=new Set){if(typeof e=="number"&&Number.isNaN(e))throw new Error("NaN is not allowed");if(typeof e=="number"&&!Number.isFinite(e))throw new Error("Infinity is not allowed");if(e===null||typeof e!="object")return JSON.stringify(e);let n=e;if(typeof n.toJSON=="function"){if(t.has(n))throw new Error("Circular reference detected");t.add(n);let r=Be(n.toJSON(),t);return t.delete(n),r}if(t.has(n))throw new Error("Circular reference detected");t.add(n);let i;if(Array.isArray(n))i=`[${n.map(r=>Be(r===void 0||typeof r=="symbol"?null:r,t)).join(",")}]`;else{let r=[];for(let s of Object.keys(n).sort()){let o=n[s];o===void 0||typeof o=="symbol"||r.push(`${JSON.stringify(s)}:${Be(o,t)}`)}i=`{${r.join(",")}}`}return t.delete(n),i}var mo=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function ee(e,t){return e>>>t|e<<32-t}function _o(e){let t=e.length,n=t*8,i=t+9+63&-64,r=new Uint8Array(i);r.set(e),r[t]=128;let s=new DataView(r.buffer);s.setUint32(i-8,Math.floor(n/4294967296),!1),s.setUint32(i-4,n>>>0,!1);let o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);for(let u=0;u<i;u+=64){for(let w=0;w<16;w++)a[w]=s.getUint32(u+w*4,!1);for(let w=16;w<64;w++){let z=a[w-15],P=a[w-2],M=ee(z,7)^ee(z,18)^z>>>3,he=ee(P,17)^ee(P,19)^P>>>10;a[w]=a[w-16]+M+a[w-7]+he>>>0}let l=o[0],h=o[1],f=o[2],g=o[3],_=o[4],N=o[5],k=o[6],E=o[7];for(let w=0;w<64;w++){let z=ee(_,6)^ee(_,11)^ee(_,25),P=_&N^~_&k,M=E+z+P+mo[w]+a[w]>>>0,he=(ee(l,2)^ee(l,13)^ee(l,22))+(l&h^l&f^h&f)>>>0;E=k,k=N,N=_,_=g+M>>>0,g=f,f=h,h=l,l=M+he>>>0}o[0]=o[0]+l>>>0,o[1]=o[1]+h>>>0,o[2]=o[2]+f>>>0,o[3]=o[3]+g>>>0,o[4]=o[4]+_>>>0,o[5]=o[5]+N>>>0,o[6]=o[6]+k>>>0,o[7]=o[7]+E>>>0}let c=new Uint8Array(32),d=new DataView(c.buffer);for(let u=0;u<8;u++)d.setUint32(u*4,o[u],!1);return c}var go=["params","result","clientStream","serverStream"];function vo(e){let t=fo(Nt(yo(e),!0)),n=_o(new TextEncoder().encode(t));return Array.from(n.subarray(0,8),i=>i.toString(16).padStart(2,"0")).join("")}function yo(e){let t=Object.fromEntries(Object.entries(e.methods).map(([r,s])=>{let o={...s};for(let a of go){let c=o[a];c!==void 0&&(o[a]=te(c))}return[r,o]})),n=e.components?.schemas,i=n===void 0?e.components:{...e.components,schemas:Object.fromEntries(Object.entries(n).map(([r,s])=>[r,te(s)]))};return{...e,methods:t,...i===void 0?{}:{components:i}}}function bo(e,t){return e==="comment"||e.startsWith("x-")||t&&e==="hash"}function Nt(e,t=!1){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(i=>Nt(i));let n={};for(let i of Object.keys(e)){if(bo(i,t))continue;let r=e[i];r!==void 0&&(n[i]=Nt(r))}return n}var pt=new WeakMap,wo=class{info;members;constructor(e,t,n={}){if(this.info=e,this.members=t,pt.set(this,{frozenSchema:n.frozenSchema,schemaCache:void 0,hashCache:void 0}),e.hash!==void 0&&this.schemaHash!==e.hash)throw new Error(`Interface hash mismatch for "${e.id}": expected "${e.hash}", got "${this.schemaHash}". The interface's wire contract changed \u2014 update the pinned hash to "${this.schemaHash}" after reviewing the change.`)}get schemaHash(){let e=pt.get(this);return e.hashCache===void 0&&(e.hashCache=vo(e.frozenSchema??pn(this.info,this.members,""))),e.hashCache}toSchema(){let e=pt.get(this);return e.schemaCache===void 0&&(e.schemaCache=e.frozenSchema!==void 0?{...e.frozenSchema,hash:this.schemaHash}:pn(this.info,this.members,this.schemaHash)),e.schemaCache}};function pn(e,t,n){let i={},r={};for(let[o,a]of Object.entries(t))i[o]=zo(o,a,r);let s={id:e.id,hash:n,methods:i};return Object.keys(r).length>0&&(s.components={schemas:r}),e.description!==void 0&&(s.description=e.description),e.comment!==void 0&&(s.comment=e.comment),s}function zo(e,t,n){let i=t.docs;if(t.kind==="request"){let s={params:Te(e,"params",t.paramsSchema,n),result:Te(e,"result",t.resultSchema,n)};return t.clientStreamSchema!==void 0&&(s.clientStream=Te(e,"clientStream",t.clientStreamSchema,n)),t.serverStreamSchema!==void 0&&(s.serverStream=Te(e,"serverStream",t.serverStreamSchema,n)),i.description!==void 0&&(s.description=i.description),i.comment!==void 0&&(s.comment=i.comment),i.annotations!==void 0&&(s.annotations=i.annotations),s}let r={params:Te(e,"params",t.paramsSchema,n)};return i.description!==void 0&&(r.description=i.description),i.comment!==void 0&&(r.comment=i.comment),i.annotations!==void 0&&(r.annotations=i.annotations),r}function Te(e,t,n,i){return lo(n,{methodName:e,schemaPosition:t,components:i})}function F(e,t){return new wo(e,t)}var fn=F({id:"hubrpc.defaults",description:"Reflection: preset default service / interface on this connection."},{get:$(y({}),y({serviceId:v(m()),interfaceId:v(m()),interfaceHash:v(m())}))}),So=G(y({principal:m(),transitive:v(He())})),Rt=Ee([y({exact:m()}),y({prefix:m()})]),Io=y({serviceId:m(),interfaceId:m(),interfaceHash:m(),serviceDescription:v(m()),rootPrincipalSets:v(G(So)),reachableServiceIds:v(G(Rt))}),mn=F({id:"hubrpc.directory",description:"Reflection: list services exposed by this endpoint. Can also list other directory services that can be explored."},{list:$(y({interfaceId:v(m()),interfaceIdPrefix:v(m()),serviceId:v(m()),serviceIdScopes:v(G(Rt)),cursor:v(m()),limit:v(q().check(ge(),as())),timeoutMs:v(q().check(ge(),$e()))}),y({items:G(Io),nextCursor:v(m()),truncated:v(He())})),watch:$(y({interfaceId:v(m()),interfaceIdPrefix:v(m()),serviceId:v(m()),serviceIdScopes:v(G(Rt))}),y({})).withStream({server:y({})})}),_n=F({id:"hubrpc.schemas",description:"Reflection: fetch interface schemas by id (+ optional hash). Must serve the interfaces advertised in this endpoint's directory."},{get:$(y({interfaceId:m(),hash:v(m())}),y({schema:fe()}))}),ko=y({portId:m(),label:v(m())}),xo=y({type:v(m()),label:v(m()),processId:v(q()),processType:v(m()),nodeStatusServiceId:v(m()),metadata:v(mi(m(),Ee([m(),q(),He()])))}),wi=y({source:ce(["self","attacher"]),descriptor:xo}),$o=y({nodeId:m(),kind:v(ce(["endpoint","hub"])),label:v(m()),descriptors:v(G(wi)),ports:G(ko)}),gn=y({nodeId:m(),portId:m()}),vn=y({address:v(m()),port:v(q().check(ge(),$e()))}),Oo=y({type:m(),local:v(vn),remote:v(vn),path:v(m()),metadata:v(mi(m(),Ee([m(),q(),He()])))}),Eo=y({from:gn,to:gn,label:v(m()),peerState:v(ce(["identified","pending","unsupported","error"])),transport:v(Oo)}),Po=y({serviceId:m(),nodeId:m(),portId:m(),match:ce(["exact","prefix"])}),To=y({observerServiceId:m(),entryNodeId:m(),nodes:G($o),links:G(Eo),routes:G(Po)}),zi=F({id:"hubrpc.topology",description:"Inspect the transport graph visible from a service. A watch emits invalidation ticks; consumers re-fetch getGraph after each tick."},{getGraph:$(y({}),To),watchGraph:$(y({}),y({})).withStream({server:y({})})}),yn=y({edgeId:m(),portId:m(),requestId:v(Ee([q(),m()]))}),No=y({type:_i("transit"),ts:q(),nodeId:m(),in:v(yn),out:v(yn),disposition:ce(["forwarded","consumed","dropped","unroutable"]),kind:ce(["request","notification","response","stream"]),method:v(m()),params:v(fe()),result:v(fe()),error:v(y({code:q(),message:m(),data:v(fe())}))}),Ro=y({type:_i("overflow"),dropped:q().check(ge(),$e())}),bn=Ee([No,Ro]),wn=y({delivered:q().check(ge(),$e()),dropped:q().check(ge(),$e())}),jo=y({methodPrefix:v(m())}),Ao=y({methodPrefix:v(m()),maxPayloadBytes:q().check(ge(),$e())}),Si=F({id:"hubrpc.traffic",description:"Stream raw message transits for the entire node hosting the addressed service. Payload-free and explicitly payload-bearing variants keep disclosure opt-in."},{watch:$(jo,wn).withStream({server:bn}),watchWithPayloads:$(Ao,wn).withStream({server:bn})}),Co=y({nodeId:m(),portId:m(),descriptors:v(G(wi))}),jt=F({id:"hubrpc.node",description:"Topology bootstrap: identify the node and port at this end of the direct connection."},{getNodeId:$(y({}),Co)}),we={toCaller:"toCaller",toCallee:"toCallee"},ae={cancel:"cancel",ping:"ping",pong:"pong"},Mo=F({id:"$stream",description:"Reserved sub-protocol for in-flight stream messages correlated to a request by `requestId`."},{send:B(y({requestId:Ee([q(),m()]),dir:ce(["toCaller","toCallee"]),control:v(y({type:ce(["cancel","ping","pong"]),reason:v(m()),nonce:v(m())})),payload:v(fe())}),{description:"Emit a stream message tied to the request `requestId`."})}),Se=`${Mo.info.id}::send`,D={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,permissionRequired:-32401,peerDisconnected:-32402,requestTimeout:-32403,cancelled:-32800};function je(e){return typeof e.method=="string"&&e.id!==void 0}function Ii(e){return typeof e.method=="string"&&e.id===void 0}function Ke(e){return typeof e.method!="string"}var re="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function Zo(e){let t="",n=0;for(;n+3<=e.length;n+=3){let r=e[n]<<16|e[n+1]<<8|e[n+2];t+=re[r>>18&63]+re[r>>12&63]+re[r>>6&63]+re[r&63]}let i=e.length-n;if(i===1){let r=e[n]<<16;t+=re[r>>18&63]+re[r>>12&63]}else if(i===2){let r=e[n]<<16|e[n+1]<<8;t+=re[r>>18&63]+re[r>>12&63]+re[r>>6&63]}return t}var Fo="$hubrpcSignature",Lo="$hubrpcUnsigned",Ho="$hubrpc";function Do(e){let t=e.split("::");if(t.length===3&&t[0].length===0&&t[1].length>0&&t[2].length>0)return{kind:"interface",interfaceId:t[1],member:t[2]};if(!t.some(n=>n.length===0)){if(t.length===1)return{kind:"bare",member:t[0]};if(t.length===2)return{kind:"interface",interfaceId:t[0],member:t[1]};if(t.length===3)return{kind:"full",serviceId:t[0],interfaceId:t[1],member:t[2]}}}function zn(e){if(e===void 0)return;if(e===null||typeof e!="object"||Array.isArray(e))return e;let t=e,n=[Ho,Fo,Lo];if(!n.some(r=>r in t))return t;let i={};for(let r of Object.keys(t))n.includes(r)||(i[r]=t[r]);return i}var ki=Symbol.for("@vscode/hubrpc.localMessageContext");function Vo(e,t){return Object.defineProperties(e,{context:{configurable:!0,enumerable:!1,value:t},[ki]:{configurable:!0,enumerable:!1,value:!0}}),e}function Jo(e){let t=e;return e[ki]===!0?t.context:void 0}var qo=class xi{sender;_setHandler;_setWireObserver;constructor(t,n,i){this.sender=t,this._setHandler=n,this._setWireObserver=i}setRequestHandler(t){this._setHandler(t)}setWireMessageObserver(t,n){this._setWireObserver?.(t,n)}withSender(t){return new xi(t(this.sender),this._setHandler,this._setWireObserver)}},$i=Symbol("hubrpc.inspectionCall");function ft(e){return Object.defineProperty(e,$i,{value:!0}),e}function mt(e){return e?.[$i]===!0}var ne=class extends Error{code;data;constructor(e,t,n){super(e),this.code=t,this.data=n,this.name="RpcError"}};function Uo(e,t){return"exact"in t?e===t.exact:t.prefix===""||e===t.prefix||e.startsWith(`${t.prefix}/`)}function Oi(e,t){return t===void 0||t.some(n=>Uo(e,n))}var Wo=10*6e4,Ei=class Pi{_transport;static create(t){return this.createWithClose(t).channel}static createWithClose(t){let n=new Pi(t);return{channel:new qo(n,i=>n.setRequestHandler(i),(i,r)=>n.setWireMessageObserver(i,r)),close:()=>n.close()}}_nextId=1;_pending=new Map;_streamListeners=new Map;_streamControl=new Map;_incomingAborts=new Map;_handler;_wireObserver;_isInspectionMethod;_outboundInspectionRequests=new Set;_inboundInspectionRequests=new Set;_closeError;setRequestHandler(t){this._handler=t}setWireMessageObserver(t,n){this._wireObserver=t,this._isInspectionMethod=t===void 0?void 0:n,t===void 0&&(this._outboundInspectionRequests.clear(),this._inboundInspectionRequests.clear())}constructor(t){this._transport=t,this._transport.setListener(n=>this._onMessage(n))}async sendRequest(t,n,i){this._throwIfClosed();let r=this._nextId++,s={jsonrpc:"2.0",id:r,method:t};n!==void 0&&(s.params=n);let o=new Promise((a,c)=>{this._pending.set(String(r),{resolve:a,reject:c})});this._observeOutbound(s,i);try{await this._transport.send(s)}catch(a){throw this._pending.delete(String(r)),this._observeSendFailure(r,a),a}return o}async sendNotification(t,n,i){this._throwIfClosed();let r={jsonrpc:"2.0",method:t};n!==void 0&&(r.params=n),this._observeOutbound(r,i),await this._transport.send(r)}sendRequestWithStream(t,n,i){this._throwIfClosed();let r=this._nextId++,s=String(r),o,a,c=new Promise((f,g)=>{o=f,a=g});this._pending.set(s,{resolve:o,reject:a}),i?.onStreamMessage&&this._streamListeners.set(s,i.onStreamMessage);let d=this._makePinger(r,we.toCallee);this._streamControl.set(s,d.onControl);let u=setInterval(()=>{this._sendStream(r,we.toCallee,{control:{type:ae.ping}})},Wo);u.unref?.();let l=()=>{clearInterval(u),d.dispose(),this._streamControl.delete(s)},h=(f="streaming request disposed")=>{this._pending.delete(s)&&(this._streamListeners.delete(s),l(),a(new ne(f,D.cancelled)))};return c.then(l,l),(async()=>{let f={jsonrpc:"2.0",id:r,method:t};n!==void 0&&(f.params=n),this._observeOutbound(f,i),await this._transport.send(f)})().catch(f=>{this._pending.delete(s),this._streamListeners.delete(s),this._observeSendFailure(r,f),l(),a(f instanceof Error?f:new Error(String(f)))}),{result:c,send:f=>this._sendStream(r,we.toCallee,{payload:f}),cancel:f=>this._sendStream(r,we.toCallee,{control:f!==void 0?{type:ae.cancel,reason:f}:{type:ae.cancel}}),dispose:h,ping:d.ping}}_makePinger(t,n){let i=new Map,r=1;return{ping:()=>{let s=`${t}:${r++}`,o=new Promise((a,c)=>i.set(s,{resolve:a,reject:c}));return this._sendStream(t,n,{control:{type:ae.ping,nonce:s}}),o},onControl:s=>{if(s.type===ae.ping)this._sendStream(t,n,{control:{type:ae.pong,nonce:s.nonce}});else if(s.type===ae.pong&&s.nonce!==void 0){let o=i.get(s.nonce);o&&(i.delete(s.nonce),o.resolve())}},dispose:()=>{let s=new ne("Request settled before pong",D.cancelled);for(let o of i.values())o.reject(s);i.clear()}}}async _sendStream(t,n,i){this._throwIfClosed();let r={jsonrpc:"2.0",method:Se,params:{requestId:t,dir:n,...i}};this._observeOutbound(r),await this._transport.send(r)}close(){if(this._closeError)return;let t=new ne("Connection closed",D.peerDisconnected);this._closeError=t;for(let n of this._incomingAborts.values())n.abort(t);this._incomingAborts.clear(),this._transport.dispose();for(let n of this._pending.values())n.reject(t);this._pending.clear(),this._streamListeners.clear(),this._streamControl.clear()}_throwIfClosed(){if(this._closeError)throw this._closeError}_onMessage(t){let n=t.context;if(this._observeInbound(t),Ke(t)){if(t.id===null)return;let i=String(t.id),r=this._pending.get(i);if(!r)return;if(this._pending.delete(i),this._streamListeners.delete(i),"error"in t){let s=t.error,o=new ne(s.message,s.code,s.data);r.reject(o)}else r.resolve(t.result);return}if(je(t)){this._handleRequest(t,n).catch(()=>{});return}if(Ii(t)){if(t.method===Se){this._handleStreamNotification(t);return}this._handleNotification(t,n);return}}_handleStreamNotification(t){let n=t.params;if(!n)return;let i=n.requestId;if(i===void 0)return;let r=String(i);if(n.control){this._streamControl.get(r)?.(n.control);return}let s=this._streamListeners.get(r);s&&s(n.payload)}async _handleRequest(t,n){let i=String(t.id),r=this._makePinger(t.id,we.toCaller),s={send:c=>this._sendStream(t.id,we.toCaller,{payload:c}),onMessage:c=>{c?this._streamListeners.set(i,c):this._streamListeners.delete(i)},ping:r.ping,markInspectionLifecycle:()=>{this._wireObserver!==void 0&&this._inboundInspectionRequests.add(i)}},o=new AbortController;this._incomingAborts.set(i,o),this._streamControl.set(i,c=>{c.type===ae.cancel?o.abort(new ne(c.reason??"cancelled",D.cancelled)):r.onControl(c)});let a;try{if(!this._handler)a={error:{code:D.methodNotFound,message:`No handler registered on this endpoint (method: ${t.method}).`}};else try{a=await this._handler.handleRequest({method:t.method,params:t.params,context:n,stream:s,signal:o.signal})}catch(c){a={error:{code:D.internalError,message:c instanceof Error?c.message:String(c)}}}}finally{this._streamListeners.delete(i),this._streamControl.delete(i),this._incomingAborts.delete(i),r.dispose()}if("result"in a){let c={jsonrpc:"2.0",id:t.id,result:a.result};this._observeOutbound(c),await this._transport.send(c)}else{let c={jsonrpc:"2.0",id:t.id,error:a.error};this._observeOutbound(c),await this._transport.send(c)}}_handleNotification(t,n){if(this._handler)try{this._handler.handleNotification({method:t.method,params:t.params,context:n,stream:Go,signal:Bo})}catch{}}_observeInbound(t){let n=this._wireObserver;if(n===void 0)return;let i=!1;if(je(t))i=this._isInspectionMethod?.(t.method)===!0,i&&this._inboundInspectionRequests.add(String(t.id));else if(Ke(t)){if(t.id!==null){let r=String(t.id);i=this._outboundInspectionRequests.delete(r)}}else t.method===Se?i=this._isInspectionStream(t):i=this._isInspectionMethod?.(t.method)===!0;i||n("inbound",t)}_observeOutbound(t,n){je(t)&&mt(n)&&Vo(t,{...Jo(t),inspection:!0});let i=this._wireObserver;if(i===void 0)return;let r=!1;if(je(t))r=mt(n),r&&this._outboundInspectionRequests.add(String(t.id));else if(Ke(t)){if(t.id!==null){let s=String(t.id);r=this._inboundInspectionRequests.delete(s)}}else t.method===Se?r=this._isInspectionStream(t):r=mt(n);r||i("outbound",t)}_observeSendFailure(t,n){if(this._wireObserver===void 0){this._outboundInspectionRequests.delete(String(t));return}this._observeInbound({jsonrpc:"2.0",id:t,error:{code:D.peerDisconnected,message:n instanceof Error?n.message:String(n)}})}_isInspectionStream(t){let n=t.params;if(n?.requestId===void 0)return!1;let i=String(n.requestId);return this._outboundInspectionRequests.has(i)||this._inboundInspectionRequests.has(i)}},Go={send:()=>Promise.resolve(),onMessage:()=>{},ping:()=>Promise.resolve(),markInspectionLifecycle:()=>{}},Bo=new AbortController().signal,Ko=256,Yo=class{_options;_send;_onDispose;_queueLimit;_queue=[];_active=!0;_pumping=!1;_overflowPending=0;_delivered=0;_dropped=0;_resolveClosed;closed;constructor(e,t,n,i=Ko){this._options=e,this._send=t,this._onDispose=n,this._queueLimit=i;let r;this.closed=new Promise(s=>r=s),this._resolveClosed=r}enqueue(e){if(!this._active||this._options.methodPrefix!==void 0&&!e.method?.startsWith(this._options.methodPrefix))return;let t=this._options.maxPayloadBytes===void 0?Xo(e):Qo(e,this._options.maxPayloadBytes);this._queue.length>=this._queueLimit&&(this._queue.shift(),this._dropped++,this._overflowPending++),this._queue.push(t),this._pumping||(this._pumping=!0,queueMicrotask(()=>{this._pump()}))}dispose(){this._active&&(this._active=!1,this._dropped+=this._queue.length,this._queue.length=0,this._overflowPending=0,this._onDispose(),this._pumping||this._complete())}async _pump(){try{for(;this._active;){if(this._overflowPending>0){let t=this._overflowPending;this._overflowPending=0,await this._send({type:"overflow",dropped:t});continue}let e=this._queue.shift();if(e===void 0)break;await this._send(e),this._delivered++}}catch{this.dispose()}finally{this._pumping=!1,this._active?(this._queue.length>0||this._overflowPending>0)&&(this._pumping=!0,queueMicrotask(()=>{this._pump()})):this._complete()}}_complete(){this._resolveClosed({delivered:this._delivered,dropped:this._dropped})}};function Xo(e){let{params:t,result:n,error:i,...r}=e;return i===void 0?r:{...r,error:{code:i.code,message:i.message}}}function Qo(e,t){return{...e,params:_t(e.params,t),result:_t(e.result,t),error:e.error===void 0?void 0:{...e.error,data:_t(e.error.data,t)}}}function _t(e,t){if(e===void 0)return;if(t===Number.POSITIVE_INFINITY)return e;let n=JSON.stringify(e);if(n===void 0)return;let i=new TextEncoder().encode(n);if(i.byteLength<=t)return e;let r=new TextEncoder,s=new TextDecoder().decode(i.slice(0,t));for(;r.encode(s).byteLength>t;)s=s.slice(0,-1);return s}var ea=class{_nodeId;_portId;_setActive;_subscribers=new Set;_observers=new Set;_outboundRequests=new Map;_inboundRequests=new Map;observe=(e,t)=>{this._onMessage(e,t)};constructor(e,t,n){this._nodeId=e,this._portId=t,this._setActive=n}get observerCount(){return this._subscribers.size+this._observers.size}subscribe(e,t){let n=new Yo(e,t,()=>{this._subscribers.delete(n),this._deactivateIfUnused()});return this._activateIfUnused(),this._subscribers.add(n),n}observeTransits(e){this._activateIfUnused(),this._observers.add(e);let t=!1;return{dispose:()=>{t||(t=!0,this._observers.delete(e),this._deactivateIfUnused())}}}dispose(){for(let e of[...this._subscribers])e.dispose();this._subscribers.clear(),this._observers.clear(),this._outboundRequests.clear(),this._inboundRequests.clear(),this._setActive(!1)}_onMessage(e,t){if(this._subscribers.size===0&&this._observers.size===0)return;let n=Date.now(),i,r=this._endpoint("id"in t?t.id??void 0:void 0),s={type:"transit",ts:n,nodeId:this._nodeId,...e==="inbound"?{in:r}:{out:r},disposition:e==="inbound"?"consumed":"forwarded"};if(je(t)){let o={method:t.method};this._requestMap(e).set(String(t.id),o),i={...s,kind:"request",method:t.method,params:t.params}}else if(Ke(t)){let o=e==="inbound"?this._outboundRequests:this._inboundRequests,a=String(t.id),c=o.get(a);o.delete(a),i={...s,kind:"response",method:c?.method,result:"result"in t?t.result:void 0,error:"error"in t?t.error:void 0}}else if(Ii(t)&&t.method===Se){let o=t.params,a=this._endpoint(o?.requestId);i={...s,...e==="inbound"?{in:a}:{out:a},kind:"stream",method:Se,params:t.params}}else i={...s,kind:"notification",method:t.method,params:t.params};for(let o of[...this._observers])try{o(i)}catch{}for(let o of this._subscribers)o.enqueue(i)}_requestMap(e){return e==="outbound"?this._outboundRequests:this._inboundRequests}_endpoint(e){return{edgeId:this._portId,portId:this._portId,...e!==void 0?{requestId:e}:{}}}_activateIfUnused(){this._subscribers.size===0&&this._observers.size===0&&this._setActive(!0)}_deactivateIfUnused(){this._subscribers.size!==0||this._observers.size!==0||(this._outboundRequests.clear(),this._inboundRequests.clear(),this._setActive(!1))}},ta=class Ti{static fromTransport(t,n={}){return new Ti(Ei.create(t),n)}channel;_registry=new Map;_serviceDescriptions=new Map;_serviceRootPrincipalSets=new Map;_directoryWatchers=new Set;_directoryListeners=new Set;_inspection;_trafficInspector;_serviceInspectionRegistrations=new Map;_wireChannel;_validateOutboundParams;_preset;constructor(t,n={}){this._validateOutboundParams=n.validateOutboundParams!==!1,"sender"in t?(this._wireChannel=t,this.channel=t.sender,t.setRequestHandler({handleRequest:i=>this._handleRequest(i),handleNotification:i=>this._handleNotification(i)})):(this._wireChannel=void 0,this.channel=t)}get(t,n={}){return this._buildClient(t,n)}service(t){return new ia(this,t)}register(t,n,i={}){return this._register(t,n,i,!1)}_register(t,n,i,r){let s=i.serviceId,o=`${s??""}::${t.info.id}`;if(this._registry.has(o))throw new Error(`Interface "${t.info.id}" already registered${s?` under service "${s}"`:""}.`);let a=!1;if(i.serviceDescription!==void 0){if(s===void 0)throw new Error("register: `serviceDescription` requires `serviceId`.");let u=this._serviceDescriptions.get(s);if(u!==void 0&&u!==i.serviceDescription)throw new Error(`register: conflicting descriptions for service "${s}".`);this._serviceDescriptions.set(s,i.serviceDescription),a=u===void 0}if(i.rootPrincipalSets!==void 0){if(s===void 0)throw new Error("register: `rootPrincipalSets` requires `serviceId`.");let u=this._serviceRootPrincipalSets.get(s);if(u!==void 0&&!na(u,i.rootPrincipalSets))throw new Error(`register: conflicting rootPrincipalSets for service "${s}".`);this._serviceRootPrincipalSets.set(s,i.rootPrincipalSets),a||=u===void 0}let c={iface:t,handlers:n,serviceId:s,internalInspection:r};if(this._registry.set(o,c),this._notifyDirectoryWatchers(c,a),!r&&s!==void 0&&this._inspection!==void 0&&!this._serviceInspectionRegistrations.has(s))try{this._installServiceInspection(s)}catch(u){throw this._registry.delete(o),this._notifyDirectoryWatchers(c),u}let d=!1;return{dispose:()=>{d||(d=!0,this._registry.get(o)===c&&(this._registry.delete(o),this._notifyDirectoryWatchers(c),s===void 0&&this._preset?.interfaceId===t.info.id&&(this._preset=void 0),s!==void 0&&!this._hasBusinessServiceRegistration(s)&&(this._removeServiceInspection(s),this._serviceDescriptions.delete(s),this._serviceRootPrincipalSets.delete(s))))}}}setPreset(t){let n=`::${t.info.id}`;if(!this._registry.has(n))throw new Error(`setPreset: interface "${t.info.id}" is not registered under the root service.`);this._preset={serviceId:void 0,interfaceId:t.info.id,hash:t.schemaHash}}listRegisteredInterfaces(){return Array.from(this._registry.values()).map(t=>{let n=t.serviceId??"",i={serviceId:n,interfaceId:t.iface.info.id,interfaceHash:t.iface.schemaHash},r=n===""?void 0:this._serviceDescriptions.get(n);r!==void 0&&(i.serviceDescription=r);let s=n===""?void 0:this._serviceRootPrincipalSets.get(n);return s!==void 0&&(i.rootPrincipalSets=s),i})}onDidChangeDirectory(t){return this._directoryListeners.add(t),()=>this._directoryListeners.delete(t)}findRegisteredInterface(t,n){for(let i of this._registry.values())if(i.iface.info.id===t&&!(n!==void 0&&i.iface.schemaHash!==n))return i.iface}enableReflection(t={}){let n=`${t.serviceId??""}::${fn.info.id}`;if(this._registry.has(n))return{dispose(){}};let i=`${t.serviceId??""}::`;for(let a of[mn,_n])if(this._registry.has(`${i}${a.info.id}`))throw new Error(`enableReflection: partial reflection registration for service "${t.serviceId??""}".`);let r=t.serviceId!==void 0?{serviceId:t.serviceId}:{},s=[];if(s.push(this.register(fn,{get:()=>this._preset?{serviceId:this._preset.serviceId,interfaceId:this._preset.interfaceId,interfaceHash:this._preset.hash}:{}},r)),s.push(this.register(mn,{list:({interfaceId:a,interfaceIdPrefix:c,serviceId:d,serviceIdScopes:u,cursor:l,limit:h})=>{let f=this.listRegisteredInterfaces().filter(k=>t.serviceId===void 0||k.serviceId===t.serviceId).filter(k=>a===void 0||k.interfaceId===a).filter(k=>c===void 0||k.interfaceId.startsWith(c)).filter(k=>d===void 0||k.serviceId===d).filter(k=>Oi(k.serviceId,u)),g=l===void 0?0:Number.parseInt(l,10)||0,_=h===void 0?f.length:Math.min(f.length,g+h),N=f.slice(g,_).map(k=>({serviceId:k.serviceId,interfaceId:k.interfaceId,interfaceHash:k.interfaceHash,serviceDescription:k.serviceDescription,rootPrincipalSets:k.rootPrincipalSets?.map(E=>E.map(w=>({...w})))}));return _<f.length?{items:N,nextCursor:String(_)}:{items:N}},watch:(a,c,d)=>new Promise(u=>{let l={interfaceId:a.interfaceId,interfaceIdPrefix:a.interfaceIdPrefix,serviceId:a.serviceId,serviceIdScopes:a.serviceIdScopes,send:()=>d.send({})};this._directoryWatchers.add(l);let h=()=>{this._directoryWatchers.delete(l),u({})};if(d.signal.aborted){h();return}d.signal.addEventListener("abort",h,{once:!0})})},r)),s.push(this.register(_n,{get:({interfaceId:a,hash:c})=>{let d=this.findRegisteredInterface(a,c);if(!d)throw new ne("Interface not found",D.methodNotFound,{reason:"unknown-interface",interfaceId:a,hash:c});return{schema:d.toSchema()}}},r)),t.serviceId!==void 0)try{this.enableReflection()}catch(a){for(let c of s.reverse())c.dispose();throw a}let o=!1;return{dispose:()=>{if(!o){o=!0;for(let a of s.reverse())a.dispose()}}}}_notifyDirectoryWatchers(t,n=!1){for(let i of this._directoryListeners)try{i()}catch{}for(let i of this._directoryWatchers){if(i.pending)continue;let r=In(i,t),s=n&&t.serviceId!==void 0&&[...this._registry.values()].some(o=>o.serviceId===t.serviceId&&In(i,o));!r&&!s||(i.pending=!0,queueMicrotask(()=>{i.pending=!1,this._directoryWatchers.has(i)&&i.send()}))}}enableInspection(t){if(this._inspection!==void 0)return this._inspection;let n={nodeId:Sn("node"),portId:Sn("port"),...t!==void 0?{descriptors:[...t]}:{}},i=this._register(jt,{getNodeId:()=>n},{},!0),r=new ea(n.nodeId,n.portId,a=>this._wireChannel?.setWireMessageObserver(a?r.observe:void 0,a?c=>this._isInspectionMethod(c):void 0));this._trafficInspector=r;let s=!1,o={...n,observeTraffic:a=>r.observeTransits(a),dispose:()=>{if(!s){s=!0;for(let a of[...this._serviceInspectionRegistrations.keys()])this._removeServiceInspection(a);r.dispose(),this._trafficInspector===r&&(this._trafficInspector=void 0),i.dispose(),this._inspection===o&&(this._inspection=void 0)}}};this._inspection=o;try{let a=new Set(Array.from(this._registry.values()).filter(c=>c.serviceId!==void 0&&!c.internalInspection).map(c=>c.serviceId));for(let c of a)this._installServiceInspection(c)}catch(a){throw o.dispose(),a}return o}get trafficObserverCount(){return this._trafficInspector?.observerCount??0}close(){this.channel.close()}_buildClient(t,n){let{serviceId:i,...r}=n,s=r,o=t.schemaHash,a=gt(t),c={};for(let[d,u]of Object.entries(t.members)){let l=i?`${i}::${t.info.id}::${d}`:`${t.info.id}::${d}`;if(u.kind==="request")if(u.clientStreamSchema!==void 0||u.serverStreamSchema!==void 0){let h=u.serverStreamSchema;c[d]=(f,g)=>{let _=g?.onMessage,N=_!==void 0?z=>{if(h!==void 0){let P=Q(h,z);if(!P.success)return;_(P.data);return}_(z)}:void 0,k=N!==void 0?{ctx:s,interfaceHash:o,onStreamMessage:N}:{ctx:s,interfaceHash:o};a&&ft(k),this._validateOutboundParamsFor(u,l,f);let E=this.channel.sendRequestWithStream(l,f,k),w=E.result.then(z=>{let P=Q(u.resultSchema,z===null?void 0:z);if(!P.success)throw new ne(`Invalid result for ${l}`,D.internalError,{issues:P.error.issues});return z});return Object.assign(w,{send:async z=>E.send(z),cancel:async z=>E.cancel(z),dispose:z=>E.dispose?.(z),ping:()=>E.ping()})}}else{let h=u.resultSchema;c[d]=async f=>{let g={ctx:s,interfaceHash:o};a&&ft(g),this._validateOutboundParamsFor(u,l,f);let _=await this.channel.sendRequest(l,f,g),N=Q(h,_===null?void 0:_);if(!N.success)throw new ne(`Invalid result for ${l}`,D.internalError,{issues:N.error.issues});return _}}else c[d]=async h=>{let f={ctx:s,interfaceHash:o};a&&ft(f),this._validateOutboundParamsFor(u,l,h),this.channel.sendNotification(l,h,f)}}return c}_validateOutboundParamsFor(t,n,i){if(!this._validateOutboundParams)return;let r=Q(t.paramsSchema,i);if(!r.success)throw new ne(`Invalid params for ${n}`,D.invalidParams,{issues:r.error.issues})}async _handleRequest(t){let n=this._parseRouted(t.method);if(!n.ok)return Je(n.reason,t.method);let{entry:i,memberName:r}=n,s=i.iface.members[r];if(!s)return Je("unknown-method",t.method);let o=i.handlers[r];if(!o)return Je("unknown-method",t.method);let a=zn(t.params),c=Q(s.paramsSchema,a);if(!c.success)return{error:{code:D.invalidParams,message:"Invalid params",data:{issues:c.error.issues}}};if(!(s instanceof gi))return Je("unknown-method",t.method);let d=this._buildStreamApi(t.stream,t.signal,s);try{let u=o(c.data,t.context,d);gt(i.iface)&&t.stream.markInspectionLifecycle();let l=await u,h=Q(s.resultSchema,l);return h.success?{result:l===void 0?null:l}:{error:{code:D.internalError,message:`Invalid result for ${t.method}`,data:{issues:h.error.issues}}}}catch(u){return u instanceof ne?{error:{code:u.code,message:u.message,data:u.data}}:{error:{code:D.internalError,message:u instanceof Error?u.message:String(u)}}}}_buildStreamApi(t,n,i){return{send:r=>{if(i.serverStreamSchema){let s=Q(i.serverStreamSchema,r);if(!s.success)throw new Error(`Server stream payload failed schema validation: ${s.error.message}`)}return t.send(r)},onMessage:r=>{t.onMessage(s=>{if(i.clientStreamSchema){let o=Q(i.clientStreamSchema,s);if(!o.success)return;r(o.data);return}})},ping:()=>t.ping(),signal:n}}_handleNotification(t){let n=this._parseRouted(t.method);if(!n.ok)return;let{entry:i,memberName:r}=n,s=i.iface.members[r];if(!(s instanceof yi))return;let o=i.handlers[r];if(!o)return;let a=zn(t.params),c=Q(s.paramsSchema,a);c.success&&o(c.data,t.context)}_parseRouted(t){let n=Do(t);if(!n)return{ok:!1,reason:"bad-method-grammar"};if(n.kind==="bare"){if(!this._preset)return{ok:!1,reason:"no-preset"};let o=this._registry.get(`::${this._preset.interfaceId}`);return o?{ok:!0,entry:o,memberName:n.member}:{ok:!1,reason:"no-preset"}}let i=n.kind==="full"?n.serviceId:void 0,r=`${i??""}::${n.interfaceId}`,s=this._registry.get(r);return s?{ok:!0,entry:s,memberName:n.member}:{ok:!1,reason:i?"unknown-service":"unknown-interface"}}_installServiceInspection(t){if(this._serviceInspectionRegistrations.has(t))return;let n=this._inspection,i=this._trafficInspector;if(n===void 0||i===void 0)return;let r=[],s={serviceId:t};try{r.push(this._register(jt,{getNodeId:()=>({nodeId:n.nodeId,portId:n.portId})},s,!0)),r.push(this._register(zi,{getGraph:()=>this._endpointGraph(t,n),watchGraph:async(o,a,c)=>(await ra(c.signal),{})},s,!0)),r.push(this._register(Si,{watch:({methodPrefix:o},a,c)=>this._watchTraffic(i,{methodPrefix:o},c),watchWithPayloads:({methodPrefix:o,maxPayloadBytes:a},c,d)=>this._watchTraffic(i,{methodPrefix:o,maxPayloadBytes:a},d)},s,!0))}catch(o){for(let a of r.reverse())a.dispose();throw o}this._serviceInspectionRegistrations.set(t,r)}_removeServiceInspection(t){let n=this._serviceInspectionRegistrations.get(t);if(n!==void 0){this._serviceInspectionRegistrations.delete(t);for(let i of n.reverse())i.dispose()}}_hasBusinessServiceRegistration(t){return Array.from(this._registry.values()).some(n=>n.serviceId===t&&!n.internalInspection)}_isInspectionMethod(t){let n=this._parseRouted(t);return n.ok&&gt(n.entry.iface)}_endpointGraph(t,n){return{observerServiceId:t,entryNodeId:n.nodeId,nodes:[{nodeId:n.nodeId,kind:"endpoint",...n.descriptors!==void 0?{descriptors:n.descriptors}:{},ports:[{portId:n.portId}]}],links:[],routes:[{serviceId:t,nodeId:n.nodeId,portId:n.portId,match:"exact"}]}}async _watchTraffic(t,n,i){let r=t.subscribe(n,o=>i.send(o)),s=()=>r.dispose();i.signal.aborted?s():i.signal.addEventListener("abort",s,{once:!0});try{return await r.closed}finally{i.signal.removeEventListener("abort",s),r.dispose()}}};function Sn(e){let t=new Uint8Array(16);return globalThis.crypto.getRandomValues(t),`${e}:${Zo(t)}`}function na(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],r=t[n];if(i.length!==r.length)return!1;for(let s=0;s<i.length;s++)if(i[s].principal!==r[s].principal||i[s].transitive===!0!=(r[s].transitive===!0))return!1}return!0}function In(e,t){let n=t.serviceId??"";return(e.interfaceId===void 0||e.interfaceId===t.iface.info.id)&&(e.interfaceIdPrefix===void 0||t.iface.info.id.startsWith(e.interfaceIdPrefix))&&(e.serviceId===void 0||e.serviceId===n)&&Oi(n,e.serviceIdScopes)}var ia=class{_connection;_serviceId;constructor(e,t){this._connection=e,this._serviceId=t}get(e,t={}){return this._connection.get(e,{...t,serviceId:this._serviceId})}register(e,t,n={}){return this._connection.register(e,t,{...n,serviceId:this._serviceId})}};function Je(e,t){return{error:{code:D.methodNotFound,message:`Method not found: ${t}`,data:{reason:e,method:t}}}}function gt(e){return e===jt||e===zi||e===Si}function ra(e){return e.aborted?Promise.resolve():new Promise(t=>{e.addEventListener("abort",()=>t(),{once:!0})})}sa(globalThis,{});function sa(e,t){return new Proxy(e,{get(n,i,r){return i in t?t[i]:e[i]},set(n,i,r){return i in t&&delete t[i],e[i]=r,!0},deleteProperty(n,i){let r=!1;return i in t&&(delete t[i],r=!0),i in e&&(delete e[i],r=!0),r},ownKeys(n){let i=Reflect.ownKeys(e),r=Reflect.ownKeys(t),s=new Set(r);return[...i.filter(o=>!s.has(o)),...r]},defineProperty(n,i,r){return i in t&&delete t[i],Reflect.defineProperty(e,i,r),!0},getOwnPropertyDescriptor(n,i){return i in t?Reflect.getOwnPropertyDescriptor(t,i):Reflect.getOwnPropertyDescriptor(e,i)},has(n,i){return i in t||i in e}})}var pe=m();F({id:"identity",description:"Per-participant key oracle: exposes signing and HPKE-based wrap/unwrap for the identity the executor has attached to this participant's root overlay. Private keys never leave the executor."},{getPrincipal:$(y({}),y({principal:m()})),getWrapPublicKey:$(y({}),y({wrapPublicKey:pe})),sign:$(y({bytes:pe}),y({signature:pe})),wrap:$(y({domain:m(),bytes:pe}),y({blob:pe})),unwrap:$(y({domain:m(),blob:pe}),y({bytes:pe}))});F({id:"identity.storage",description:"Per-identity persistent key/value store. Scope is the executor's managed-identity slot; lifecycle is tied to the identity itself. Backed by an at-rest-encrypted file in the executor."},{get:$(y({key:m()}),y({value:v(fe())})),set:$(y({key:m(),value:fe()}),y({})),delete:$(y({key:m()}),y({existed:He()})),list:$(y({prefix:v(m())}),y({keys:G(m())}))});var oa=class{_our;_their;_filterSource;_listener;_buffer=[];_closed=!1;_handler=e=>{if(this._filterSource&&e.source!==this._their)return;let t=e.data;aa(t)&&(this._listener?this._listener(t):this._buffer.push(t))};constructor(e,t,n=!0){if(this._our=e,this._their=t,this._filterSource=n,e===t)throw new Error("WindowMessageTransport: cannot connect to self");e.addEventListener("message",this._handler)}send(e){this._closed||this._their.postMessage(e,"*")}setListener(e){if(this._listener=e,e)for(;this._buffer.length>0&&this._listener;)e(this._buffer.shift())}dispose(){this._closed||(this._closed=!0,this._our.removeEventListener("message",this._handler))}};function aa(e){return typeof e=="object"&&e!==null&&e.jsonrpc==="2.0"}var kn;function p(e,t,n){function i(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let d=o.prototype,u=Object.keys(d);for(let l=0;l<u.length;l++){let h=u[l];h in a||(a[h]=d[h].bind(a))}}let r=n?.Parent??Object;class s extends r{}Object.defineProperty(s,"name",{value:e});function o(a){var c;let d=n?.Parent?new s:this;i(d,a),(c=d._zod).deferred??(c.deferred=[]);for(let u of d._zod.deferred)u();return d}return Object.defineProperty(o,"init",{value:i}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var ke=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ni=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(kn=globalThis).__zod_globalConfig??(kn.__zod_globalConfig={});var Dt=globalThis.__zod_globalConfig;function ve(e){return Dt}function Ri(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}function At(e,t){return typeof t=="bigint"?t.toString():t}function ot(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Vt(e){return e==null}function Jt(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function ca(e,t){let n=e/t,i=Math.round(n),r=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-i)<r?0:n-i}var xn=Symbol("evaluating");function x(e,t,n){let i;Object.defineProperty(e,t,{get(){if(i!==xn)return i===void 0&&(i=xn,i=n()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function be(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ue(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function $n(e){return JSON.stringify(e)}function da(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var ji="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ze(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var ua=ot(()=>{if(Dt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function Fe(e){if(Ze(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(Ze(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Ai(e){return Fe(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var la=new Set(["string","number","symbol"]);function Oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function le(e,t,n){let i=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(i._zod.parent=e),i}function b(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 ha(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var pa={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]};function fa(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");return le(e,ue(e._zod.def,{get shape(){let r={};for(let s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(r[s]=n.shape[s])}return be(this,"shape",r),r},checks:[]}))}function ma(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");return le(e,ue(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete r[s]}return be(this,"shape",r),r},checks:[]}))}function _a(e,t){if(!Fe(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let i=e._zod.def.shape;for(let r in t)if(Object.getOwnPropertyDescriptor(i,r)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return le(e,ue(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return be(this,"shape",i),i}}))}function ga(e,t){if(!Fe(t))throw new Error("Invalid input to safeExtend: expected a plain object");return le(e,ue(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return be(this,"shape",n),n}}))}function va(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return le(e,ue(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return be(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ya(e,t,n){let i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return le(t,ue(t._zod.def,{get shape(){let r=t._zod.def.shape,s={...r};if(n)for(let o in n){if(!(o in r))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(s[o]=e?new e({type:"optional",innerType:r[o]}):r[o])}else for(let o in r)s[o]=e?new e({type:"optional",innerType:r[o]}):r[o];return be(this,"shape",s),s},checks:[]}))}function ba(e,t,n){return le(t,ue(t._zod.def,{get shape(){let i=t._zod.def.shape,r={...i};if(n)for(let s in n){if(!(s in r))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(r[s]=new e({type:"nonoptional",innerType:i[s]}))}else for(let s in i)r[s]=new e({type:"nonoptional",innerType:i[s]});return be(this,"shape",r),r}}))}function Ie(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 wa(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 Ci(e,t){return t.map(n=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function qe(e){return typeof e=="string"?e:e?.message}function ye(e,t,n){let i=e.message?e.message:qe(e.inst?._zod.def?.error?.(e))??qe(t?.error?.(e))??qe(n.customError?.(e))??qe(n.localeError?.(e))??"Invalid input",{inst:r,continue:s,input:o,...a}=e;return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=o),a}function qt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Le(...e){let[t,n,i]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:i}:{...t}}var Mi=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,At,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Zi=p("$ZodError",Mi),Fi=p("$ZodError",Mi,{Parent:Error});function za(e,t=n=>n.message){let n={},i=[];for(let r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):i.push(t(r));return{formErrors:i,fieldErrors:n}}function Sa(e,t=n=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(a=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,d=0;for(;d<a.length;){let u=a[d];d!==a.length-1?c[u]=c[u]||{_errors:[]}:(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))),c=c[u],d++}}}};return i(e),n}var Ut=e=>(t,n,i,r)=>{let s=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new ke;if(o.issues.length){let a=new(r?.Err??e)(o.issues.map(c=>ye(c,s,ve())));throw ji(a,r?.callee),a}return o.value},Wt=e=>async(t,n,i,r)=>{let s=i?{...i,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){let a=new(r?.Err??e)(o.issues.map(c=>ye(c,s,ve())));throw ji(a,r?.callee),a}return o.value},at=e=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new ke;return s.issues.length?{success:!1,error:new(e??Zi)(s.issues.map(o=>ye(o,r,ve())))}:{success:!0,data:s.value}},Ia=at(Fi),ct=e=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(o=>ye(o,r,ve())))}:{success:!0,data:s.value}},ka=ct(Fi),xa=e=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Ut(e)(t,n,r)},$a=e=>(t,n,i)=>Ut(e)(t,n,i),Oa=e=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Wt(e)(t,n,r)},Ea=e=>async(t,n,i)=>Wt(e)(t,n,i),Pa=e=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return at(e)(t,n,r)},Ta=e=>(t,n,i)=>at(e)(t,n,i),Na=e=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return ct(e)(t,n,r)},Ra=e=>async(t,n,i)=>ct(e)(t,n,i),ja=/^[cC][0-9a-z]{6,}$/,Aa=/^[0-9a-z]+$/,Ca=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ma=/^[0-9a-vA-V]{20}$/,Za=/^[A-Za-z0-9]{27}$/,Fa=/^[a-zA-Z0-9_-]{21}$/,La=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ha=/^([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})$/,On=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)$/,Da=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Va="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Ja(){return new RegExp(Va,"u")}var qa=/^(?:(?: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])$/,Ua=/^(([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}|:))$/,Wa=/^((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])$/,Ga=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ba=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Li=/^[A-Za-z0-9_-]*$/,Ka=/^https?$/,Ya=/^\+[1-9]\d{6,14}$/,Hi="(?:(?:\\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])))",Xa=new RegExp(`^${Hi}$`);function Di(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}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Qa(e){return new RegExp(`^${Di(e)}$`)}function ec(e){let t=Di({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let i=`${t}(?:${n.join("|")})`;return new RegExp(`^${Hi}T(?:${i})$`)}var tc=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},nc=/^-?\d+$/,ic=/^-?\d+(?:\.\d+)?$/,rc=/^(?:true|false)$/i,sc=/^[^A-Z]*$/,oc=/^[^a-z]*$/,U=p("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Vi={number:"number",bigint:"bigint",object:"date"},Ji=p("$ZodCheckLessThan",(e,t)=>{U.init(e,t);let n=Vi[typeof t.value];e._zod.onattach.push(i=>{let r=i._zod.bag,s=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin: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})}}),qi=p("$ZodCheckGreaterThan",(e,t)=>{U.init(e,t);let n=Vi[typeof t.value];e._zod.onattach.push(i=>{let r=i._zod.bag,s=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin: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})}}),ac=p("$ZodCheckMultipleOf",(e,t)=>{U.init(e,t),e._zod.onattach.push(n=>{var i;(i=n._zod.bag).multipleOf??(i.multipleOf=t.value)}),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"?n.value%t.value===BigInt(0):ca(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})}}),cc=p("$ZodCheckNumberFormat",(e,t)=>{U.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=pa[t.format];e._zod.onattach.push(o=>{let a=o._zod.bag;a.format=t.format,a.minimum=r,a.maximum=s,n&&(a.pattern=nc)}),e._zod.check=o=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?o.issues.push({input:a,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}):o.issues.push({input:a,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}}a<r&&o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),a>s&&o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),dc=p("$ZodCheckMaxLength",(e,t)=>{var n;U.init(e,t),(n=e._zod.def).when??(n.when=i=>{let r=i.value;return!Vt(r)&&r.length!==void 0}),e._zod.onattach.push(i=>{let r=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{let r=i.value;if(r.length<=t.maximum)return;let s=qt(r);i.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),uc=p("$ZodCheckMinLength",(e,t)=>{var n;U.init(e,t),(n=e._zod.def).when??(n.when=i=>{let r=i.value;return!Vt(r)&&r.length!==void 0}),e._zod.onattach.push(i=>{let r=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{let r=i.value;if(r.length>=t.minimum)return;let s=qt(r);i.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),lc=p("$ZodCheckLengthEquals",(e,t)=>{var n;U.init(e,t),(n=e._zod.def).when??(n.when=i=>{let r=i.value;return!Vt(r)&&r.length!==void 0}),e._zod.onattach.push(i=>{let r=i._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=i=>{let r=i.value,s=r.length;if(s===t.length)return;let o=qt(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})}}),dt=p("$ZodCheckStringFormat",(e,t)=>{var n,i;U.init(e,t),e._zod.onattach.push(r=>{let s=r._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),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=p("$ZodCheckRegex",(e,t)=>{dt.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})}}),pc=p("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=sc),dt.init(e,t)}),fc=p("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=oc),dt.init(e,t)}),mc=p("$ZodCheckIncludes",(e,t)=>{U.init(e,t);let n=Oe(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=i,e._zod.onattach.push(r=>{let s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(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})}}),_c=p("$ZodCheckStartsWith",(e,t)=>{U.init(e,t);let n=new RegExp(`^${Oe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(i=>{let r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(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})}}),gc=p("$ZodCheckEndsWith",(e,t)=>{U.init(e,t);let n=new RegExp(`.*${Oe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(i=>{let r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(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})}}),vc=p("$ZodCheckOverwrite",(e,t)=>{U.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}}),yc=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split(`
`).filter(r=>r),n=Math.min(...t.map(r=>r.length-r.trimStart().length)),i=t.map(r=>r.slice(n)).map(r=>" ".repeat(this.indent*2)+r);for(let r of i)this.content.push(r)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[""]).map(i=>`  ${i}`)];return new e(...t,n.join(`
`))}},bc={major:4,minor:4,patch:3},j=p("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=bc;let i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(let r of i)for(let s of r._zod.onattach)s(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let r=(o,a,c)=>{let d=Ie(o),u;for(let l of a){if(l._zod.def.when){if(wa(o)||!l._zod.def.when(o))continue}else if(d)continue;let h=o.issues.length,f=l._zod.check(o);if(f instanceof Promise&&c?.async===!1)throw new ke;if(u||f instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await f,o.issues.length!==h&&(d||(d=Ie(o,h)))});else{if(o.issues.length===h)continue;d||(d=Ie(o,h))}}return u?u.then(()=>o):o},s=(o,a,c)=>{if(Ie(o))return o.aborted=!0,o;let d=r(a,i,c);if(d instanceof Promise){if(c.async===!1)throw new ke;return d.then(u=>e._zod.parse(u,c))}return e._zod.parse(d,c)};e._zod.run=(o,a)=>{if(a.skipChecks)return e._zod.parse(o,a);if(a.direction==="backward"){let d=e._zod.parse({value:o.value,issues:[]},{...a,skipChecks:!0});return d instanceof Promise?d.then(u=>s(u,o,a)):s(d,o,a)}let c=e._zod.parse(o,a);if(c instanceof Promise){if(a.async===!1)throw new ke;return c.then(d=>r(d,i,a))}return r(c,i,a)}}x(e,"~standard",()=>({validate:r=>{try{let s=Ia(e,r);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return ka(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Gt=p("$ZodString",(e,t)=>{j.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??tc(e._zod.bag),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}}),T=p("$ZodStringFormat",(e,t)=>{dt.init(e,t),Gt.init(e,t)}),wc=p("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ha),T.init(e,t)}),zc=p("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=On(n))}else t.pattern??(t.pattern=On());T.init(e,t)}),Sc=p("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Da),T.init(e,t)}),Ic=p("$ZodURL",(e,t)=>{T.init(e,t),e._zod.check=n=>{try{let i=n.value.trim();if(!t.normalize&&t.protocol?.source===Ka.source&&!/^https?:\/\//i.test(i)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}let r=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.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&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=i;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),kc=p("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Ja()),T.init(e,t)}),xc=p("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Fa),T.init(e,t)}),$c=p("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ja),T.init(e,t)}),Oc=p("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Aa),T.init(e,t)}),Ec=p("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ca),T.init(e,t)}),Pc=p("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ma),T.init(e,t)}),Tc=p("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Za),T.init(e,t)}),Nc=p("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ec(t)),T.init(e,t)}),Rc=p("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Xa),T.init(e,t)}),jc=p("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Qa(t)),T.init(e,t)}),Ac=p("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=La),T.init(e,t)}),Cc=p("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=qa),T.init(e,t),e._zod.bag.format="ipv4"}),Mc=p("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ua),T.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Zc=p("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Wa),T.init(e,t)}),Fc=p("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ga),T.init(e,t),e._zod.check=n=>{let i=n.value.split("/");try{if(i.length!==2)throw new Error;let[r,s]=i;if(!s)throw new Error;let o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Ui(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Lc=p("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ba),T.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ui(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Hc(e){if(!Li.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/");return Ui(t.padEnd(Math.ceil(t.length/4)*4,"="))}var Dc=p("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Li),T.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Hc(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Vc=p("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ya),T.init(e,t)});function Jc(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 qc=p("$ZodJWT",(e,t)=>{T.init(e,t),e._zod.check=n=>{Jc(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Wi=p("$ZodNumber",(e,t)=>{j.init(e,t),e._zod.pattern=e._zod.bag.pattern??ic,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 s=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),Uc=p("$ZodNumberFormat",(e,t)=>{cc.init(e,t),Wi.init(e,t)}),Wc=p("$ZodBoolean",(e,t)=>{j.init(e,t),e._zod.pattern=rc,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}}),Gc=p("$ZodUnknown",(e,t)=>{j.init(e,t),e._zod.parse=n=>n}),Bc=p("$ZodNever",(e,t)=>{j.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function En(e,t,n){e.issues.length&&t.issues.push(...Ci(n,e.issues)),t.value[n]=e.value}var Kc=p("$ZodArray",(e,t)=>{j.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);let s=[];for(let o=0;o<r.length;o++){let a=r[o],c=t.element._zod.run({value:a,issues:[]},i);c instanceof Promise?s.push(c.then(d=>En(d,n,o))):En(c,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function tt(e,t,n,i,r,s){let o=n in i;if(e.issues.length){if(r&&s&&!o)return;t.issues.push(...Ci(n,e.issues))}if(!o&&!r){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Gi(e){let t=Object.keys(e.shape);for(let i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);let n=ha(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Bi(e,t,n,i,r,s){let o=[],a=r.keySet,c=r.catchall._zod,d=c.def.type,u=c.optin==="optional",l=c.optout==="optional";for(let h in t){if(h==="__proto__"||a.has(h))continue;if(d==="never"){o.push(h);continue}let f=c.run({value:t[h],issues:[]},i);f instanceof Promise?e.push(f.then(g=>tt(g,n,h,t,u,l))):tt(f,n,h,t,u,l)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}var Yc=p("$ZodObject",(e,t)=>{if(j.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let o=t.shape;Object.defineProperty(t,"shape",{get:()=>{let a={...o};return Object.defineProperty(t,"shape",{value:a}),a}})}let n=ot(()=>Gi(t));x(e._zod,"propValues",()=>{let o=t.shape,a={};for(let c in o){let d=o[c]._zod;if(d.values){a[c]??(a[c]=new Set);for(let u of d.values)a[c].add(u)}}return a});let i=Ze,r=t.catchall,s;e._zod.parse=(o,a)=>{s??(s=n.value);let c=o.value;if(!i(c))return o.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),o;o.value={};let d=[],u=s.shape;for(let l of s.keys){let h=u[l],f=h._zod.optin==="optional",g=h._zod.optout==="optional",_=h._zod.run({value:c[l],issues:[]},a);_ instanceof Promise?d.push(_.then(N=>tt(N,o,l,c,f,g))):tt(_,o,l,c,f,g)}return r?Bi(d,c,o,a,n.value,e):d.length?Promise.all(d).then(()=>o):o}}),Xc=p("$ZodObjectJIT",(e,t)=>{Yc.init(e,t);let n=e._zod.parse,i=ot(()=>Gi(t)),r=l=>{let h=new yc(["shape","payload","ctx"]),f=i.value,g=E=>{let w=$n(E);return`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`};h.write("const input = payload.value;");let _=Object.create(null),N=0;for(let E of f.keys)_[E]=`key_${N++}`;h.write("const newResult = {};");for(let E of f.keys){let w=_[E],z=$n(E),P=l[E],M=P?._zod?.optin==="optional",he=P?._zod?.optout==="optional";h.write(`const ${w} = ${g(E)};`),M&&he?h.write(`
        if (${w}.issues.length) {
          if (${z} in input) {
            payload.issues = payload.issues.concat(${w}.issues.map(iss => ({
              ...iss,
              path: iss.path ? [${z}, ...iss.path] : [${z}]
            })));
          }
        }
        
        if (${w}.value === undefined) {
          if (${z} in input) {
            newResult[${z}] = undefined;
          }
        } else {
          newResult[${z}] = ${w}.value;
        }
        
      `):M?h.write(`
        if (${w}.issues.length) {
          payload.issues = payload.issues.concat(${w}.issues.map(iss => ({
            ...iss,
            path: iss.path ? [${z}, ...iss.path] : [${z}]
          })));
        }
        
        if (${w}.value === undefined) {
          if (${z} in input) {
            newResult[${z}] = undefined;
          }
        } else {
          newResult[${z}] = ${w}.value;
        }
        
      `):h.write(`
        const ${w}_present = ${z} in input;
        if (${w}.issues.length) {
          payload.issues = payload.issues.concat(${w}.issues.map(iss => ({
            ...iss,
            path: iss.path ? [${z}, ...iss.path] : [${z}]
          })));
        }
        if (!${w}_present && !${w}.issues.length) {
          payload.issues.push({
            code: "invalid_type",
            expected: "nonoptional",
            input: undefined,
            path: [${z}]
          });
        }

        if (${w}_present) {
          if (${w}.value === undefined) {
            newResult[${z}] = undefined;
          } else {
            newResult[${z}] = ${w}.value;
          }
        }

      `)}h.write("payload.value = newResult;"),h.write("return payload;");let k=h.compile();return(E,w)=>k(l,E,w)},s,o=Ze,a=!Dt.jitless,c=a&&ua.value,d=t.catchall,u;e._zod.parse=(l,h)=>{u??(u=i.value);let f=l.value;return o(f)?a&&c&&h?.async===!1&&h.jitless!==!0?(s||(s=r(t.shape)),l=s(l,h),d?Bi([],f,l,h,u,e):l):n(l,h):(l.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),l)}});function Pn(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter(s=>!Ie(s));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(s=>s.issues.map(o=>ye(o,i,ve())))}),t)}var Ki=p("$ZodUnion",(e,t)=>{j.init(e,t),x(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),x(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),x(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),x(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){let i=t.options.map(r=>r._zod.pattern);return new RegExp(`^(${i.map(r=>Jt(r.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 s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}return s?Promise.all(o).then(a=>Pn(a,i,e,r)):Pn(o,i,e,r)}}),Qc=p("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ki.init(e,t);let n=e._zod.parse;x(e._zod,"propValues",()=>{let r={};for(let s of t.options){let o=s._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[a,c]of Object.entries(o)){r[a]||(r[a]=new Set);for(let d of c)r[a].add(d)}}return r});let i=ot(()=>{let r=t.options,s=new Map;for(let o of r){let a=o._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,o)}}return s});e._zod.parse=(r,s)=>{let o=r.value;if(!Ze(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let a=i.value.get(o?.[t.discriminator]);return a?a._zod.run(r,s):t.unionFallback||s.direction==="backward"?n(r,s):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()),input:o,path:[t.discriminator],inst:e}),r)}}),ed=p("$ZodIntersection",(e,t)=>{j.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),o=t.right._zod.run({value:r,issues:[]},i);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([a,c])=>Tn(n,a,c)):Tn(n,s,o)}});function Ct(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(Fe(e)&&Fe(t)){let n=Object.keys(t),i=Object.keys(e).filter(s=>n.indexOf(s)!==-1),r={...e,...t};for(let s of i){let o=Ct(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.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],s=t[i],o=Ct(r,s);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Tn(e,t,n){let i=new Map,r;for(let a of t.issues)if(a.code==="unrecognized_keys"){r??(r=a);for(let c of a.keys)i.has(c)||i.set(c,{}),i.get(c).l=!0}else e.issues.push(a);for(let a of n.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)i.has(c)||i.set(c,{}),i.get(c).r=!0;else e.issues.push(a);let s=[...i].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&r&&e.issues.push({...r,keys:s}),Ie(e))return e;let o=Ct(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var td=p("$ZodEnum",(e,t)=>{j.init(e,t);let n=Ri(t.entries),i=new Set(n);e._zod.values=i,e._zod.pattern=new RegExp(`^(${n.filter(r=>la.has(typeof r)).map(r=>typeof r=="string"?Oe(r):r.toString()).join("|")})$`),e._zod.parse=(r,s)=>{let o=r.value;return i.has(o)||r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),nd=p("$ZodLiteral",(e,t)=>{if(j.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(i=>typeof i=="string"?Oe(i):i?Oe(i.toString()):String(i)).join("|")})$`),e._zod.parse=(i,r)=>{let s=i.value;return n.has(s)||i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}}),id=p("$ZodTransform",(e,t)=>{j.init(e,t),e._zod.optin="optional",e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Ni(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.fallback=!0,n));if(r instanceof Promise)throw new ke;return n.value=r,n.fallback=!0,n}});function Nn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Yi=p("$ZodOptional",(e,t)=>{j.init(e,t),e._zod.optin="optional",e._zod.optout="optional",x(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),x(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Jt(n.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(t.innerType._zod.optin==="optional"){let r=n.value,s=t.innerType._zod.run(n,i);return s instanceof Promise?s.then(o=>Nn(o,r)):Nn(s,r)}return n.value===void 0?n:t.innerType._zod.run(n,i)}}),rd=p("$ZodExactOptional",(e,t)=>{Yi.init(e,t),x(e._zod,"values",()=>t.innerType._zod.values),x(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),sd=p("$ZodNullable",(e,t)=>{j.init(e,t),x(e._zod,"optin",()=>t.innerType._zod.optin),x(e._zod,"optout",()=>t.innerType._zod.optout),x(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Jt(n.source)}|null)$`):void 0}),x(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>n.value===null?n:t.innerType._zod.run(n,i)}),od=p("$ZodDefault",(e,t)=>{j.init(e,t),e._zod.optin="optional",x(e._zod,"values",()=>t.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(s=>Rn(s,t)):Rn(r,t)}});function Rn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var ad=p("$ZodPrefault",(e,t)=>{j.init(e,t),e._zod.optin="optional",x(e._zod,"values",()=>t.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))}),cd=p("$ZodNonOptional",(e,t)=>{j.init(e,t),x(e._zod,"values",()=>{let n=t.innerType._zod.values;return n?new Set([...n].filter(i=>i!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(s=>jn(s,e)):jn(r,e)}});function jn(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 dd=p("$ZodCatch",(e,t)=>{j.init(e,t),e._zod.optin="optional",x(e._zod,"optout",()=>t.innerType._zod.optout),x(e._zod,"values",()=>t.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(n,i);return r instanceof Promise?r.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(o=>ye(o,i,ve()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(s=>ye(s,i,ve()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),ud=p("$ZodPipe",(e,t)=>{j.init(e,t),x(e._zod,"values",()=>t.in._zod.values),x(e._zod,"optin",()=>t.in._zod.optin),x(e._zod,"optout",()=>t.out._zod.optout),x(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);return s instanceof Promise?s.then(o=>Ue(o,t.in,i)):Ue(s,t.in,i)}let r=t.in._zod.run(n,i);return r instanceof Promise?r.then(s=>Ue(s,t.out,i)):Ue(r,t.out,i)}});function Ue(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var ld=p("$ZodReadonly",(e,t)=>{j.init(e,t),x(e._zod,"propValues",()=>t.innerType._zod.propValues),x(e._zod,"values",()=>t.innerType._zod.values),x(e._zod,"optin",()=>t.innerType?._zod?.optin),x(e._zod,"optout",()=>t.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(An):An(r)}});function An(e){return e.value=Object.freeze(e.value),e}var hd=p("$ZodCustom",(e,t)=>{U.init(e,t),j.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(s=>Cn(s,n,i,e));Cn(r,n,i,e)}});function Cn(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(Le(r))}}var Mn,pd=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 fd(){return new pd}(Mn=globalThis).__zod_globalRegistry??(Mn.__zod_globalRegistry=fd());var Ae=globalThis.__zod_globalRegistry;function md(e,t){return new e({type:"string",...b(t)})}function _d(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...b(t)})}function Zn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...b(t)})}function gd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...b(t)})}function vd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...b(t)})}function yd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...b(t)})}function bd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...b(t)})}function wd(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...b(t)})}function zd(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...b(t)})}function Sd(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...b(t)})}function Id(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...b(t)})}function kd(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...b(t)})}function xd(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...b(t)})}function $d(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...b(t)})}function Od(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...b(t)})}function Ed(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...b(t)})}function Pd(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...b(t)})}function Td(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...b(t)})}function Nd(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...b(t)})}function Rd(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...b(t)})}function jd(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...b(t)})}function Ad(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...b(t)})}function Cd(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...b(t)})}function Md(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...b(t)})}function Zd(e,t){return new e({type:"string",format:"date",check:"string_format",...b(t)})}function Fd(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...b(t)})}function Ld(e,t){return new e({type:"string",format:"duration",check:"string_format",...b(t)})}function Hd(e,t){return new e({type:"number",checks:[],...b(t)})}function Dd(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...b(t)})}function Vd(e,t){return new e({type:"boolean",...b(t)})}function Jd(e){return new e({type:"unknown"})}function qd(e,t){return new e({type:"never",...b(t)})}function Fn(e,t){return new Ji({check:"less_than",...b(t),value:e,inclusive:!1})}function vt(e,t){return new Ji({check:"less_than",...b(t),value:e,inclusive:!0})}function Ln(e,t){return new qi({check:"greater_than",...b(t),value:e,inclusive:!1})}function yt(e,t){return new qi({check:"greater_than",...b(t),value:e,inclusive:!0})}function Hn(e,t){return new ac({check:"multiple_of",...b(t),value:e})}function Xi(e,t){return new dc({check:"max_length",...b(t),maximum:e})}function nt(e,t){return new uc({check:"min_length",...b(t),minimum:e})}function Qi(e,t){return new lc({check:"length_equals",...b(t),length:e})}function Ud(e,t){return new hc({check:"string_format",format:"regex",...b(t),pattern:e})}function Wd(e){return new pc({check:"string_format",format:"lowercase",...b(e)})}function Gd(e){return new fc({check:"string_format",format:"uppercase",...b(e)})}function Bd(e,t){return new mc({check:"string_format",format:"includes",...b(t),includes:e})}function Kd(e,t){return new _c({check:"string_format",format:"starts_with",...b(t),prefix:e})}function Yd(e,t){return new gc({check:"string_format",format:"ends_with",...b(t),suffix:e})}function Pe(e){return new vc({check:"overwrite",tx:e})}function Xd(e){return Pe(t=>t.normalize(e))}function Qd(){return Pe(e=>e.trim())}function eu(){return Pe(e=>e.toLowerCase())}function tu(){return Pe(e=>e.toUpperCase())}function nu(){return Pe(e=>da(e))}function iu(e,t,n){return new e({type:"array",element:t,...b(n)})}function ru(e,t,n){return new e({type:"custom",check:"custom",fn:t,...b(n)})}function su(e,t){let n=ou(i=>(i.addIssue=r=>{if(typeof r=="string")i.issues.push(Le(r,i.value,n._zod.def));else{let s=r;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=i.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(Le(s))}},e(i.value,i)),t);return n}function ou(e,t){let n=new U({check:"custom",...b(t)});return n._zod.check=e,n}function er(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??Ae,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Z(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,d);else{let l=o.schema,h=t.processors[r.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);h(e,t,l,d)}let u=e._zod.parent;u&&(o.ref||(o.ref=u),Z(u,t,d),t.seen.get(u).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&H(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function tr(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=o=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let u=e.external.registry.get(o[0])?.id,l=e.external.uri??(f=>f);if(u)return{ref:l(u)};let h=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=h,{defId:h,ref:`${l("__shared")}#/${a}/${h}`}}if(o[1]===n)return{ref:"#"};let c=`#/${a}/`,d=o[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:c+d}},s=o=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:d}=r(o);a.def={...a.schema},d&&(a.defId=d);let u=a.schema;for(let l in u)delete u[l];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>

Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let c=e.external.registry.get(o[0])?.id;if(t!==o[0]&&c){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1&&e.reused==="ref"){s(o);continue}}}function nr(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=a=>{let c=e.seen.get(a);if(c.ref===null)return;let d=c.def??c.schema,u={...d},l=c.ref;if(c.ref=null,l){i(l);let f=e.seen.get(l),g=f.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(g)):Object.assign(d,g),Object.assign(d,u),a._zod.parent===l)for(let _ in d)_==="$ref"||_==="allOf"||_ in u||delete d[_];if(g.$ref&&f.def)for(let _ in d)_==="$ref"||_==="allOf"||_ in f.def&&JSON.stringify(d[_])===JSON.stringify(f.def[_])&&delete d[_]}let h=a._zod.parent;if(h&&h!==l){i(h);let f=e.seen.get(h);if(f?.schema.$ref&&(d.$ref=f.schema.$ref,f.def))for(let g in d)g==="$ref"||g==="allOf"||g in f.def&&JSON.stringify(d[g])===JSON.stringify(f.def[g])&&delete d[g]}e.override({zodSchema:a,jsonSchema:d,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())i(a[0]);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 a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}Object.assign(r,n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&r.id===s&&delete r.id;let o=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,o[c.defId]=c.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?r.$defs=o:r.definitions=o);try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:it(t,"input",e.processors),output:it(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function H(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return H(i.element,n);if(i.type==="set")return H(i.valueType,n);if(i.type==="lazy")return H(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")return H(i.innerType,n);if(i.type==="intersection")return H(i.left,n)||H(i.right,n);if(i.type==="record"||i.type==="map")return H(i.keyType,n)||H(i.valueType,n);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:H(i.in,n)||H(i.out,n);if(i.type==="object"){for(let r in i.shape)if(H(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(H(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(H(r,n))return!0;return!!(i.rest&&H(i.rest,n))}return!1}var au=(e,t={})=>n=>{let i=er({...n,processors:t});return Z(e,i),tr(i,e),nr(i,e)},it=(e,t,n={})=>i=>{let{libraryOptions:r,target:s}=i??{},o=er({...r??{},target:s,io:t,processors:n});return Z(e,o),tr(o,e),nr(o,e)},cu={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},du=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:d}=e._zod.bag;if(typeof s=="number"&&(r.minLength=s),typeof o=="number"&&(r.maxLength=o),a&&(r.format=cu[a]??a,r.format===""&&delete r.format,a==="time"&&delete r.format),d&&(r.contentEncoding=d),c&&c.size>0){let u=[...c];u.length===1?r.pattern=u[0].source:u.length>1&&(r.allOf=[...u.map(l=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:l.source}))])}},uu=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:d,exclusiveMinimum:u}=e._zod.bag;typeof a=="string"&&a.includes("int")?r.type="integer":r.type="number";let l=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),h=typeof d=="number"&&d<=(o??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";l?f?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u:typeof s=="number"&&(r.minimum=s),h?f?(r.maximum=d,r.exclusiveMaximum=!0):r.exclusiveMaximum=d:typeof o=="number"&&(r.maximum=o),typeof c=="number"&&(r.multipleOf=c)},lu=(e,t,n,i)=>{n.type="boolean"},hu=(e,t,n,i)=>{n.not={}},pu=(e,t,n,i)=>{let r=e._zod.def,s=Ri(r.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},fu=(e,t,n,i)=>{let r=e._zod.def,s=[];for(let o of r.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){let o=s[0];n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[o]:n.const=o}else s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),s.every(o=>typeof o=="boolean")&&(n.type="boolean"),s.every(o=>o===null)&&(n.type="null"),n.enum=s},mu=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},_u=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},gu=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;typeof o=="number"&&(r.minItems=o),typeof a=="number"&&(r.maxItems=a),r.type="array",r.items=Z(s.element,t,{...i,path:[...i.path,"items"]})},vu=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object",r.properties={};let o=s.shape;for(let d in o)r.properties[d]=Z(o[d],t,{...i,path:[...i.path,"properties",d]});let a=new Set(Object.keys(o)),c=new Set([...a].filter(d=>{let u=s.shape[d]._zod;return t.io==="input"?u.optin===void 0:u.optout===void 0}));c.size>0&&(r.required=Array.from(c)),s.catchall?._zod.def.type==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=Z(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},yu=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>Z(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=o:n.anyOf=o},bu=(e,t,n,i)=>{let r=e._zod.def,s=Z(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=Z(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1;n.allOf=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]]},wu=(e,t,n,i)=>{let r=e._zod.def,s=Z(r.innerType,t,i),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=r.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},zu=(e,t,n,i)=>{let r=e._zod.def;Z(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Su=(e,t,n,i)=>{let r=e._zod.def;Z(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},Iu=(e,t,n,i)=>{let r=e._zod.def;Z(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},ku=(e,t,n,i)=>{let r=e._zod.def;Z(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},xu=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;Z(o,t,i);let a=t.seen.get(e);a.ref=o},$u=(e,t,n,i)=>{let r=e._zod.def;Z(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0},ir=(e,t,n,i)=>{let r=e._zod.def;Z(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Ou=p("ZodISODateTime",(e,t)=>{Nc.init(e,t),R.init(e,t)});function Eu(e){return Md(Ou,e)}var Pu=p("ZodISODate",(e,t)=>{Rc.init(e,t),R.init(e,t)});function Tu(e){return Zd(Pu,e)}var Nu=p("ZodISOTime",(e,t)=>{jc.init(e,t),R.init(e,t)});function Ru(e){return Fd(Nu,e)}var ju=p("ZodISODuration",(e,t)=>{Ac.init(e,t),R.init(e,t)});function Au(e){return Ld(ju,e)}var Cu=(e,t)=>{Zi.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Sa(e,n)},flatten:{value:n=>za(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,At,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,At,2)}},isEmpty:{get(){return e.issues.length===0}}})},X=p("ZodError",Cu,{Parent:Error}),Mu=Ut(X),Zu=Wt(X),Fu=at(X),Lu=ct(X),Hu=xa(X),Du=$a(X),Vu=Oa(X),Ju=Ea(X),qu=Pa(X),Uu=Ta(X),Wu=Na(X),Gu=Ra(X),Dn=new WeakMap;function De(e,t,n){let i=Object.getPrototypeOf(e),r=Dn.get(i);if(r||(r=new Set,Dn.set(i,r)),!r.has(t)){r.add(t);for(let s in n){let o=n[s];Object.defineProperty(i,s,{configurable:!0,enumerable:!1,get(){let a=o.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var A=p("ZodType",(e,t)=>(j.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:it(e,"input"),output:it(e,"output")}}),e.toJSONSchema=au(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,i)=>Mu(e,n,i,{callee:e.parse}),e.safeParse=(n,i)=>Fu(e,n,i),e.parseAsync=async(n,i)=>Zu(e,n,i,{callee:e.parseAsync}),e.safeParseAsync=async(n,i)=>Lu(e,n,i),e.spa=e.safeParseAsync,e.encode=(n,i)=>Hu(e,n,i),e.decode=(n,i)=>Du(e,n,i),e.encodeAsync=async(n,i)=>Vu(e,n,i),e.decodeAsync=async(n,i)=>Ju(e,n,i),e.safeEncode=(n,i)=>qu(e,n,i),e.safeDecode=(n,i)=>Uu(e,n,i),e.safeEncodeAsync=async(n,i)=>Wu(e,n,i),e.safeDecodeAsync=async(n,i)=>Gu(e,n,i),De(e,"ZodType",{check(...n){let i=this.def;return this.clone(ue(i,{checks:[...i.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,i){return le(this,n,i)},brand(){return this},register(n,i){return n.add(this,i),this},refine(n,i){return this.check(Dl(n,i))},superRefine(n,i){return this.check(Vl(n,i))},overwrite(n){return this.check(Pe(n))},optional(){return qn(this)},exactOptional(){return El(this)},nullable(){return Un(this)},nullish(){return qn(Un(this))},nonoptional(n){return Al(this,n)},array(){return xe(this)},or(n){return bl([this,n])},and(n){return Il(this,n)},transform(n){return Wn(this,$l(n))},default(n){return Nl(this,n)},prefault(n){return jl(this,n)},catch(n){return Ml(this,n)},pipe(n){return Wn(this,n)},readonly(){return Ll(this)},describe(n){let i=this.clone();return Ae.add(i,{description:n}),i},meta(...n){if(n.length===0)return Ae.get(this);let i=this.clone();return Ae.add(i,n[0]),i},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return Ae.get(e)?.description},configurable:!0}),e)),rr=p("_ZodString",(e,t)=>{Gt.init(e,t),A.init(e,t),e._zod.processJSONSchema=(i,r,s)=>du(e,i,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,De(e,"_ZodString",{regex(...i){return this.check(Ud(...i))},includes(...i){return this.check(Bd(...i))},startsWith(...i){return this.check(Kd(...i))},endsWith(...i){return this.check(Yd(...i))},min(...i){return this.check(nt(...i))},max(...i){return this.check(Xi(...i))},length(...i){return this.check(Qi(...i))},nonempty(...i){return this.check(nt(1,...i))},lowercase(i){return this.check(Wd(i))},uppercase(i){return this.check(Gd(i))},trim(){return this.check(Qd())},normalize(...i){return this.check(Xd(...i))},toLowerCase(){return this.check(eu())},toUpperCase(){return this.check(tu())},slugify(){return this.check(nu())}})}),Bu=p("ZodString",(e,t)=>{Gt.init(e,t),rr.init(e,t),e.email=n=>e.check(_d(Ku,n)),e.url=n=>e.check(wd(Yu,n)),e.jwt=n=>e.check(Cd(hl,n)),e.emoji=n=>e.check(zd(Xu,n)),e.guid=n=>e.check(Zn(Vn,n)),e.uuid=n=>e.check(gd(We,n)),e.uuidv4=n=>e.check(vd(We,n)),e.uuidv6=n=>e.check(yd(We,n)),e.uuidv7=n=>e.check(bd(We,n)),e.nanoid=n=>e.check(Sd(Qu,n)),e.guid=n=>e.check(Zn(Vn,n)),e.cuid=n=>e.check(Id(el,n)),e.cuid2=n=>e.check(kd(tl,n)),e.ulid=n=>e.check(xd(nl,n)),e.base64=n=>e.check(Rd(dl,n)),e.base64url=n=>e.check(jd(ul,n)),e.xid=n=>e.check($d(il,n)),e.ksuid=n=>e.check(Od(rl,n)),e.ipv4=n=>e.check(Ed(sl,n)),e.ipv6=n=>e.check(Pd(ol,n)),e.cidrv4=n=>e.check(Td(al,n)),e.cidrv6=n=>e.check(Nd(cl,n)),e.e164=n=>e.check(Ad(ll,n)),e.datetime=n=>e.check(Eu(n)),e.date=n=>e.check(Tu(n)),e.time=n=>e.check(Ru(n)),e.duration=n=>e.check(Au(n))});function V(e){return md(Bu,e)}var R=p("ZodStringFormat",(e,t)=>{T.init(e,t),rr.init(e,t)}),Ku=p("ZodEmail",(e,t)=>{Sc.init(e,t),R.init(e,t)}),Vn=p("ZodGUID",(e,t)=>{wc.init(e,t),R.init(e,t)}),We=p("ZodUUID",(e,t)=>{zc.init(e,t),R.init(e,t)}),Yu=p("ZodURL",(e,t)=>{Ic.init(e,t),R.init(e,t)}),Xu=p("ZodEmoji",(e,t)=>{kc.init(e,t),R.init(e,t)}),Qu=p("ZodNanoID",(e,t)=>{xc.init(e,t),R.init(e,t)}),el=p("ZodCUID",(e,t)=>{$c.init(e,t),R.init(e,t)}),tl=p("ZodCUID2",(e,t)=>{Oc.init(e,t),R.init(e,t)}),nl=p("ZodULID",(e,t)=>{Ec.init(e,t),R.init(e,t)}),il=p("ZodXID",(e,t)=>{Pc.init(e,t),R.init(e,t)}),rl=p("ZodKSUID",(e,t)=>{Tc.init(e,t),R.init(e,t)}),sl=p("ZodIPv4",(e,t)=>{Cc.init(e,t),R.init(e,t)}),ol=p("ZodIPv6",(e,t)=>{Mc.init(e,t),R.init(e,t)}),al=p("ZodCIDRv4",(e,t)=>{Zc.init(e,t),R.init(e,t)}),cl=p("ZodCIDRv6",(e,t)=>{Fc.init(e,t),R.init(e,t)}),dl=p("ZodBase64",(e,t)=>{Lc.init(e,t),R.init(e,t)}),ul=p("ZodBase64URL",(e,t)=>{Dc.init(e,t),R.init(e,t)}),ll=p("ZodE164",(e,t)=>{Vc.init(e,t),R.init(e,t)}),hl=p("ZodJWT",(e,t)=>{qc.init(e,t),R.init(e,t)}),sr=p("ZodNumber",(e,t)=>{Wi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(i,r,s)=>uu(e,i,r),De(e,"ZodNumber",{gt(i,r){return this.check(Ln(i,r))},gte(i,r){return this.check(yt(i,r))},min(i,r){return this.check(yt(i,r))},lt(i,r){return this.check(Fn(i,r))},lte(i,r){return this.check(vt(i,r))},max(i,r){return this.check(vt(i,r))},int(i){return this.check(Jn(i))},safe(i){return this.check(Jn(i))},positive(i){return this.check(Ln(0,i))},nonnegative(i){return this.check(yt(0,i))},negative(i){return this.check(Fn(0,i))},nonpositive(i){return this.check(vt(0,i))},multipleOf(i,r){return this.check(Hn(i,r))},step(i,r){return this.check(Hn(i,r))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function ie(e){return Hd(sr,e)}var pl=p("ZodNumberFormat",(e,t)=>{Uc.init(e,t),sr.init(e,t)});function Jn(e){return Dd(pl,e)}var fl=p("ZodBoolean",(e,t)=>{Wc.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>lu(e,n,i)});function C(e){return Vd(fl,e)}var ml=p("ZodUnknown",(e,t)=>{Gc.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>{}});function Mt(){return Jd(ml)}var _l=p("ZodNever",(e,t)=>{Bc.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>hu(e,n,i)});function gl(e){return qd(_l,e)}var vl=p("ZodArray",(e,t)=>{Kc.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>gu(e,n,i,r),e.element=t.element,De(e,"ZodArray",{min(n,i){return this.check(nt(n,i))},nonempty(n){return this.check(nt(1,n))},max(n,i){return this.check(Xi(n,i))},length(n,i){return this.check(Qi(n,i))},unwrap(){return this.element}})});function xe(e,t){return iu(vl,e,t)}var yl=p("ZodObject",(e,t)=>{Xc.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vu(e,n,i,r),x(e,"shape",()=>t.shape),De(e,"ZodObject",{keyof(){return ut(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:Mt()})},loose(){return this.clone({...this._zod.def,catchall:Mt()})},strict(){return this.clone({...this._zod.def,catchall:gl()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return _a(this,n)},safeExtend(n){return ga(this,n)},merge(n){return va(this,n)},pick(n){return fa(this,n)},omit(n){return ma(this,n)},partial(...n){return ya(ar,this,n[0])},required(...n){return ba(cr,this,n[0])}})});function S(e,t){let n={type:"object",shape:e??{},...b(t)};return new yl(n)}var or=p("ZodUnion",(e,t)=>{Ki.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yu(e,n,i,r),e.options=t.options});function bl(e,t){return new or({type:"union",options:e,...b(t)})}var wl=p("ZodDiscriminatedUnion",(e,t)=>{or.init(e,t),Qc.init(e,t)});function zl(e,t,n){return new wl({type:"union",options:t,discriminator:e,...b(n)})}var Sl=p("ZodIntersection",(e,t)=>{ed.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>bu(e,n,i,r)});function Il(e,t){return new Sl({type:"intersection",left:e,right:t})}var Zt=p("ZodEnum",(e,t)=>{td.init(e,t),A.init(e,t),e._zod.processJSONSchema=(i,r,s)=>pu(e,i,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let o of i)if(n.has(o))s[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Zt({...t,checks:[],...b(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let o of i)if(n.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new Zt({...t,checks:[],...b(r),entries:s})}});function ut(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new Zt({type:"enum",entries:n,...b(t)})}var kl=p("ZodLiteral",(e,t)=>{nd.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>fu(e,n,i),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 rt(e,t){return new kl({type:"literal",values:Array.isArray(e)?e:[e],...b(t)})}var xl=p("ZodTransform",(e,t)=>{id.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_u(e,n),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Ni(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Le(s,n.value,t));else{let o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=e),n.issues.push(Le(o))}};let r=t.transform(n.value,n);return r instanceof Promise?r.then(s=>(n.value=s,n.fallback=!0,n)):(n.value=r,n.fallback=!0,n)}});function $l(e){return new xl({type:"transform",transform:e})}var ar=p("ZodOptional",(e,t)=>{Yi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ir(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function qn(e){return new ar({type:"optional",innerType:e})}var Ol=p("ZodExactOptional",(e,t)=>{rd.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ir(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function El(e){return new Ol({type:"optional",innerType:e})}var Pl=p("ZodNullable",(e,t)=>{sd.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>wu(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Un(e){return new Pl({type:"nullable",innerType:e})}var Tl=p("ZodDefault",(e,t)=>{od.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Su(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Nl(e,t){return new Tl({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Ai(t)}})}var Rl=p("ZodPrefault",(e,t)=>{ad.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Iu(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function jl(e,t){return new Rl({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Ai(t)}})}var cr=p("ZodNonOptional",(e,t)=>{cd.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>zu(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Al(e,t){return new cr({type:"nonoptional",innerType:e,...b(t)})}var Cl=p("ZodCatch",(e,t)=>{dd.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ku(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ml(e,t){return new Cl({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var Zl=p("ZodPipe",(e,t)=>{ud.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xu(e,n,i,r),e.in=t.in,e.out=t.out});function Wn(e,t){return new Zl({type:"pipe",in:e,out:t})}var Fl=p("ZodReadonly",(e,t)=>{ld.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>$u(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Ll(e){return new Fl({type:"readonly",innerType:e})}var Hl=p("ZodCustom",(e,t)=>{hd.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,i,r)=>mu(e,n)});function Dl(e,t={}){return ru(Hl,e,t)}function Vl(e,t){return su(e,t)}var de=Mt(),Jl=S({supportsContentEdits:C().optional(),supportsOptions:C().optional(),supportsPresentation:C().optional()}),ql=S({supportsContentEdits:C().optional(),supportsOptions:C().optional(),supportsForceUpdate:C().optional(),supportsHostTransport:C().optional(),supportsPresentation:C().optional()}),Ul=S({offset:ie().int().nonnegative(),length:ie().int().nonnegative(),newText:V()}),dr=zl("kind",[S({kind:rt("replace"),path:xe(V()),newValue:de}),S({kind:rt("stringEdits"),path:xe(V()),stringEdits:xe(Ul)})]),Wl=S({content:de.optional(),options:de.optional(),readOnly:C().optional(),serverRevision:ie().int().nonnegative().optional(),acknowledgedClientRevision:ie().int().nonnegative().optional(),force:C().optional()}),Gl=ut(["inline","full-width","full-view"]),Gn=ie().positive().max(1e4),Bl=S({resizable:C().optional(),fullWidth:C().optional(),fullView:C().optional(),minHeight:Gn.optional(),maxAutomaticHeight:Gn.optional()}),Kl=F({id:"web-editor-host",description:"Methods the host exposes to the editor (web-editor/0.12)."},{initialized:$(S({protocolVersion:rt("web-editor/0.12"),contentType:ut(["text","json"]),capabilities:Jl.optional()}),S({protocolVersion:rt("web-editor-host/0.12"),capabilities:ql.optional()})),applyContentEdit:B(S({edits:xe(dr),clientRevision:ie().int().nonnegative(),basedOnServerRevision:ie().int().nonnegative()})),reportSize:B(S({height:ie().nonnegative()}))}),Yl=F({id:"web-editor",description:"Methods the editor exposes to the host (web-editor/0.12)."},{update:B(Wl),applyContentEdits:B(S({edits:xe(dr),serverRevision:ie().int().nonnegative(),acknowledgedClientRevision:ie().int().nonnegative()})),getContentSchema:$(S({}),S({schema:de}))}),Xl=F({id:"web-editor-host-transport",description:"Optional messages the web editor sends to its host."},{message:B(S({message:de}))}),Ql=F({id:"web-editor-client-transport",description:"Optional messages the web editor host sends to the editor."},{message:B(S({message:de}))}),eh=F({id:"web-editor-presentation",description:"How the embedding host currently presents the editor."},{changed:B(S({mode:Gl}))}),th=F({id:"web-editor-presentation-host",description:"Presentation preferences and actions of an embedded editor."},{setPreferences:B(Bl),exitFullView:B(S({}))}),Ge=S({registered:C(),isDefault:C()}),Bt=S({handleId:V(),appId:V(),serviceId:V(),serviceIdPrefix:V()}),nh=Bt.extend({parentAppId:V()});F({id:"vscode-app-host",description:"Methods an app `.vscode-app.html` exposes to the host (vscode-app-host/0.1)."},{getContext:$(S({}),S({dataDocument:S({contentType:ut(["text","json"])}).nullable(),embedding:nh.nullable()})),loadApp:$(S({path:V()}),Bt).withStream({server:S({})}),unloadApp:$(S({handleId:V()}),S({})),embeddedReady:B(S({})),setModalVisibility:$(S({visible:C(),presentation:S({title:V().optional()}).optional()}),S({})),getEditorRegistration:$(S({extension:V()}),S({global:Ge,workspace:Ge,hasWorkspace:C()})),configureEditorAssociation:$(S({extension:V(),dismissable:C().optional()}),S({global:Ge,workspace:Ge,hasWorkspace:C(),changed:C()})),getViewState:$(S({}),S({value:de.optional()})),setViewState:$(S({value:de}),S({}))});F({id:"vscode-app-embedding-events",description:"Lifecycle notifications for child apps loaded by a VS Code app."},{changed:B(Bt),removed:B(S({handleId:V()}))});function Bn(e,t){let n=e;for(let i of t)if(i.kind==="replace")n=Kn(n,i.path,i.newValue);else{let r=rh(n,i.path);if(typeof r!="string")throw new Error(`applyContentEdits: stringEdits at path [${i.path.join(", ")}] requires a string, got ${typeof r}`);n=Kn(n,i.path,ih(r,i.stringEdits))}return n}function ih(e,t){let n=e;for(let i of t)n=n.slice(0,i.offset)+i.newText+n.slice(i.offset+i.length);return n}function rh(e,t){let n=e;for(let i of t){if(n==null)return;n=n[i]}return n}function Kn(e,t,n){if(t.length===0)return n;let i=e===null||typeof e!="object"?{}:e,r=i;for(let s=0;s<t.length-1;s++){let o=t[s],a=r[o];(a===null||typeof a!="object")&&(r[o]={}),r=r[o]}return r[t[t.length-1]]=n,i}function bt(e,t){return t==="text"?e:e===""?null:JSON.parse(e)}function Yn(e,t,n={}){if(t==="text"){if(typeof e!="string")throw new Error(`decodeFromEditor: expected string for text content, got ${typeof e}`);return e}let i=n.indentation;if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let r=e["$web-editor.format-json"];typeof r=="number"||r==="	"?i=r:r!==void 0&&(i=4)}return JSON.stringify(e,void 0,i)}var Ne=class{_listeners=new Set;event=e=>(this._listeners.add(e),{dispose:()=>this._listeners.delete(e)});fire(e){for(let t of this._listeners)try{t(e)}catch(n){console.error("Emitter listener threw:",n)}}dispose(){this._listeners.clear()}},sh=class{_connection;_editor;_clientTransport;_presentation;_contentType;_jsonFormat;_onError;_capabilities;_hostTransportSubscription;_text;_readOnly;_presentationMode;_serverRevision=0;_acknowledgedClientRevision=0;_editorInitialized=!1;_editorCapabilities;_pendingHostTransportMessages=[];_onDidChangeText=new Ne;onDidChangeText=this._onDidChangeText.event;_onDidInitialize=new Ne;onDidInitialize=this._onDidInitialize.event;_onDidReportSize=new Ne;onDidReportSize=this._onDidReportSize.event;_onDidSetPresentationPreferences=new Ne;onDidSetPresentationPreferences=this._onDidSetPresentationPreferences.event;_onDidRequestExitFullView=new Ne;onDidRequestExitFullView=this._onDidRequestExitFullView.event;constructor(e){this._connection=e.connection,this._contentType=e.contentType??"text",this._text=e.initialText??"",this._readOnly=e.readOnly??!1,this._jsonFormat=e.jsonFormat??{},this._onError=e.onError??((t,n)=>console.error("WebEditorHost:",t,n)),this._capabilities={...e.capabilities??{supportsForceUpdate:!0},supportsHostTransport:e.hostTransport?!0:void 0,supportsPresentation:e.supportsPresentation?!0:void 0},this._editor=this._connection.get(Yl),this._clientTransport=this._connection.get(Ql),this._presentation=this._connection.get(eh),this._connection.register(Kl,{initialized:t=>{t.contentType!==this._contentType&&this._onError(`Editor contentType "${t.contentType}" does not match host "${this._contentType}"`),this._editorCapabilities=t.capabilities,this._editorInitialized=!0,this._serverRevision=0,this._acknowledgedClientRevision=0,this._pushFullUpdate();for(let n of this._pendingHostTransportMessages.splice(0))this._clientTransport.message({message:n});return this._pushPresentationMode(),this._onDidInitialize.fire({capabilities:t.capabilities}),{protocolVersion:"web-editor-host/0.12",capabilities:this._capabilities}},applyContentEdit:t=>{if(this._readOnly){this._onError("Editor sent applyContentEdit while readOnly"),this._acknowledgeAndRestore(t.clientRevision);return}if(t.basedOnServerRevision!==this._serverRevision){this._onError(`Editor edit is based on stale server revision ${t.basedOnServerRevision}; current revision is ${this._serverRevision}`),this._acknowledgeAndRestore(t.clientRevision);return}let n;try{n=Bn(bt(this._text,this._contentType),t.edits)}catch(r){this._onError("Failed to apply content edits from editor",r),this._acknowledgeAndRestore(t.clientRevision);return}let i;try{i=Yn(n,this._contentType,this._jsonFormat)}catch(r){this._onError("Failed to decode editor content",r),this._acknowledgeAndRestore(t.clientRevision);return}this._acknowledgedClientRevision=Math.max(this._acknowledgedClientRevision,t.clientRevision),i!==this._text&&(this._text=i,this._onDidChangeText.fire({text:i})),this._pushAcknowledgement()},reportSize:t=>{this._onDidReportSize.fire({height:t.height})}}),e.supportsPresentation&&this._connection.register(th,{setPreferences:t=>this._onDidSetPresentationPreferences.fire(t),exitFullView:()=>this._onDidRequestExitFullView.fire()}),e.hostTransport&&(this._connection.register(Xl,{message:({message:t})=>e.hostTransport.sendMessage(t)}),this._hostTransportSubscription=e.hostTransport.onMessage(t=>{this._editorInitialized?this._clientTransport.message({message:t}):this._pendingHostTransportMessages.push(t)}))}getText(){return this._text}setText(e,t={}){e===this._text&&!t.force||(this._text=e,this._pushFullUpdate(t.force))}reuse(e,t){this._readOnly=t,this._text=e,this._pushFullUpdate(!0)}getReadOnly(){return this._readOnly}setPresentationMode(e){this._presentationMode!==e&&(this._presentationMode=e,this._pushPresentationMode())}setReadOnly(e){this._readOnly!==e&&(this._readOnly=e,this._editorInitialized&&this._editor.update({readOnly:e,acknowledgedClientRevision:this._acknowledgedClientRevision}))}applyEdits(e){if(e.length===0||!this._editorInitialized)return;let t;try{t=Bn(bt(this._text,this._contentType),e),this._text=Yn(t,this._contentType,this._jsonFormat)}catch(n){this._onError("Failed to apply outgoing edits to local text",n);return}this._serverRevision++,this._editor.applyContentEdits({edits:e,serverRevision:this._serverRevision,acknowledgedClientRevision:this._acknowledgedClientRevision})}dispose(){this._hostTransportSubscription?.dispose(),this._onDidChangeText.dispose(),this._onDidInitialize.dispose(),this._onDidReportSize.dispose(),this._onDidSetPresentationPreferences.dispose(),this._onDidRequestExitFullView.dispose(),this._pendingHostTransportMessages.length=0,this._connection.close()}_pushFullUpdate(e){if(!this._editorInitialized)return;this._serverRevision++;let t;try{t=bt(this._text,this._contentType)}catch(n){this._onError("Failed to encode text for editor",n);return}this._editor.update({content:t,readOnly:this._readOnly,serverRevision:this._serverRevision,acknowledgedClientRevision:this._acknowledgedClientRevision,force:e})}_pushAcknowledgement(){this._editorInitialized&&this._editor.update({serverRevision:this._serverRevision,acknowledgedClientRevision:this._acknowledgedClientRevision})}_pushPresentationMode(){!this._editorInitialized||!this._capabilities.supportsPresentation||!this._editorCapabilities?.supportsPresentation||this._presentationMode===void 0||this._presentation.changed({mode:this._presentationMode})}_acknowledgeAndRestore(e){this._acknowledgedClientRevision=Math.max(this._acknowledgedClientRevision,e),this._pushFullUpdate(!0)}};function oh(e,t){let n=e.filter(s=>"language"in s.selector&&s.selector.language===t);if(n.length>0)return n.length===1?{kind:"match",provider:n[0]}:{kind:"ambiguous",providers:n};let i=-1,r=[];for(let s of e){if(!("languagePrefix"in s.selector)||!t.startsWith(s.selector.languagePrefix))continue;let o=s.selector.languagePrefix.length;o>i?(i=o,r=[s]):o===i&&r.push(s)}if(r.length!==0)return r.length===1?{kind:"match",provider:r[0]}:{kind:"ambiguous",providers:r}}var ah=`
	:root { color-scheme: light dark; }
	html, body { margin: 0; padding: 0; background: transparent; }
	body {
		font-family: var(--vscode-font-family, system-ui, sans-serif);
		font-size: var(--vscode-font-size, 13px);
		color: var(--vscode-foreground, #1e1e1e);
		box-sizing: border-box;
	}
`,Me="vscode-markdown-editor::control",Kt=1e4,ch=28,W=10,Xn=4,wt=6,Qn=W+4,Ye=16,zt=20;function dh(e,t,n,i){let r=ah.replace(/<\/style/gi,"<\\/style"),s=(n??"").replace(/<\/style/gi,"<\\/style"),o=i?` nonce="${ei(i)}"`:"",a=(t?`<base href="${ei(t)}">`:"")+`<style data-vscode-markdown-editor-base>${r}</style><style data-vscode-markdown-editor-theme>${s}</style><script${o}>(function(){var t=document.currentScript.previousElementSibling;var sendSize=function(){parent.postMessage({type:${JSON.stringify(Me)},height:Math.max(document.documentElement.scrollHeight,document.body?document.body.scrollHeight:0)},"*");};addEventListener("message",function(e){if(e.source!==parent)return;var d=e.data;if(d&&d.type===${JSON.stringify(Me)}&&typeof d.themeCss==="string")t.textContent=d.themeCss;});addEventListener("load",sendSize);new ResizeObserver(sendSize).observe(document.documentElement);addEventListener("keydown",function(e){if(e.key==="Escape"&&!e.defaultPrevented)parent.postMessage({type:${JSON.stringify(Me)},action:"exit-full-view"},"*");});})();<\/script>`,c=i?e.replace(/<script\b(?![^>]*\bnonce\s*=)/gi,`<script${o}`):e,d=c.match(/<head[^>]*>/i);if(d?.index!==void 0){let l=d.index+d[0].length;return c.slice(0,l)+a+c.slice(l)}let u=c.match(/<html[^>]*>/i);if(u?.index!==void 0){let l=u.index+u[0].length;return c.slice(0,l)+`<head>${a}</head>`+c.slice(l)}return`<!doctype html><html><head>${a}</head><body>${c}</body></html>`}function ei(e){return e.replaceAll("&","&amp;").replaceAll('"',"&quot;")}var ti=class{constructor(t){this._options=t,this._providers=t.providers,this._frameLayer=document.createElement("div"),this._frameLayer.style.position="absolute",this._frameLayer.style.inset="0",this._frameLayer.style.height="0",this._frameLayer.style.pointerEvents="none",this._frameLayer.style.zIndex="1",t.frameRoot&&this._setFrameRoot(t.frameRoot),this._observer=typeof IntersectionObserver>"u"?void 0:new IntersectionObserver(n=>{for(let i of n)Array.from(this._logicalEditors).find(r=>r.element===i.target)?.setVisible(i.isIntersecting)},{root:t.root??null}),this._themeSubscription=t.onDidChangeTheme?.(()=>{for(let n of this._pools.values())n.updateTheme()})}_frameLayer;_frameRoot;_restoreFrameRootPosition;_layoutObserver;_layoutFrame=0;_observer;_themeSubscription;_logicalEditors=new Set;_pools=new Map;_descriptorCache=new Map;_rejectedProviders=new Set;_providers;_generation=0;_descriptorCacheHits=0;_disposed=!1;updateProviders(t){this._providers=t,this._generation++,this._descriptorCache.clear(),this._rejectedProviders.clear(),this._descriptorCacheHits=0,this._disposePools();for(let n of this._logicalEditors)n.invalidate();this._options.onDidChange?.()}get diagnostics(){let t=0,n=0;for(let i of this._pools.values())t+=i.leasedFrames,n+=i.idleFrames;return{logicalEditors:this._logicalEditors.size,leasedFrames:t,idleFrames:n,descriptorCacheEntries:this._descriptorCache.size,descriptorCacheHits:this._descriptorCacheHits}}create(t,n,i){let r=oh(this._providers,t);if(!r)return;if(r.kind==="ambiguous"){this._options.onAmbiguous?.(t,r.providers);return}let s=ri(r.provider.id,n);if(this._rejectedProviders.has(s))return;let o=new Ft(this,r.provider,n,i,this._options.defaultHeight??120,this._generation);return this._logicalEditors.add(o),this._observer?.observe(o.element),this._layoutObserver&&o.observeLayout(this._layoutObserver),this._observer||o.setVisible(!0),o}dispose(){if(!this._disposed){this._disposed=!0,this._observer?.disconnect(),this._themeSubscription?.dispose(),this._layoutObserver?.disconnect(),cancelAnimationFrame(this._layoutFrame),window.removeEventListener("resize",this._scheduleLayout),window.removeEventListener("scroll",this._scheduleLayout,!0);for(let t of Array.from(this._logicalEditors))t.dispose();this._disposePools(),this._frameLayer.remove(),this._frameRoot&&this._restoreFrameRootPosition!==void 0&&(this._frameRoot.style.position=this._restoreFrameRootPosition)}}remove(t){this._observer?.unobserve(t.element),this._layoutObserver?.unobserve(t.element),this._logicalEditors.delete(t),t.frame?.unbind()}enterFullView(t){for(let n of this._logicalEditors)n!==t&&n.exitFullView();this._frameLayer.style.zIndex="11"}exitFullView(){this._frameLayer.style.zIndex="1"}async resolve(t,n){let i=ri(t.provider.id,t.infoString),r=this._descriptorCache.get(i),s;try{r?this._descriptorCacheHits++:(r=t.provider.resolve(t.infoString),this._descriptorCache.set(i,r)),s=await r}catch{r&&this._descriptorCache.get(i)===r&&this._descriptorCache.delete(i),this._rejectEditor(t,n,i);return}if(this._disposed||t.disposed||n!==this._generation||!s){this._rejectEditor(t,n,i);return}let o=hh(t.provider.id,s),a=this._pools.get(o);if(!a){let c=this._ensureFrameRoot(t);a=new Lt(t.provider,s,this._frameLayer,c,this._options.scriptNonce,this._options.themeCss,this._options.iframeBootstrapUrl),this._pools.set(o,a)}t.resolve(a)}_rejectEditor(t,n,i){t.resolve(void 0),!this._disposed&&!t.disposed&&n===this._generation&&(this._rejectedProviders.add(i),this._options.onDidChange?.())}_ensureFrameRoot(t){return this._frameRoot??this._setFrameRoot(t.element.closest(".md-editor")??(this._options.root instanceof HTMLElement?this._options.root:document.body))}_setFrameRoot(t){if(this._frameRoot=t,t!==document.body&&getComputedStyle(t).position==="static"&&(this._restoreFrameRootPosition=t.style.position,t.style.position="relative"),t.appendChild(this._frameLayer),typeof ResizeObserver<"u"){this._layoutObserver=new ResizeObserver(()=>this._scheduleLayout()),this._layoutObserver.observe(t);for(let n=t.parentElement;n;n=n.parentElement)this._layoutObserver.observe(n);for(let n of this._logicalEditors)n.observeLayout(this._layoutObserver)}return window.addEventListener("resize",this._scheduleLayout),window.addEventListener("scroll",this._scheduleLayout,!0),t}_scheduleLayout=()=>{this._layoutFrame||(this._layoutFrame=requestAnimationFrame(()=>{this._layoutFrame=0,this.layout()}))};layout(){for(let t of this._pools.values())t.layout()}_disposePools(){for(let t of this._pools.values())t.dispose();this._pools.clear()}},Ft=class{constructor(t,n,i,r,s,o){this._factory=t,this.provider=n,this.infoString=i,this._content=r,this._height=s,this.element=document.createElement("div"),this.element.style.width="100%",this.element.style.minHeight=`${s}px`,this._frameHost=document.createElement("div"),this._frameHost.style.width="100%",this.element.appendChild(this._frameHost),this.estimateHeight=()=>parseFloat(this.element.style.minHeight)||s,this._factory.resolve(this,o)}element;onEdit;estimateHeight;frame;disposed=!1;visible=!1;infoString;_frameHost;_content;_readOnly=!1;_pool;_resolved=!1;_height;_guestPresentation={};_userHeight;_contentHeight;_widthFraction=0;_fullView=!1;resizing=!1;_actions;get presentation(){return{...this._guestPresentation,...this._pool?.descriptor.presentation}}get mode(){return this._fullView?"full-view":this._widthFraction===1?"full-width":"inline"}get widthFraction(){return this._widthFraction}get toolbarHeight(){return this._actions||this.presentation.fullView?ch:0}get pinned(){return this._fullView||this.resizing||this.hasFocus()}setContent(t){t!==this._content&&(this._content=t,this.frame?.bind(this))}setReadOnly(t){this._readOnly!==t&&(this._readOnly=t,this.frame?.bind(this))}setActions(t){this._actions!==t&&(this._actions=t,this.mountActions(),this.frame?.layout(this))}mountActions(t){if(!this._actions)return;let n=t??this.element;this._actions.parentElement!==n&&n.prepend(this._actions)}setVisible(t){this.visible=t,this._resolved&&(t?this._pool?.acquire(this):this.pinned||this._pool?.release(this))}resolve(t){this.disposed||(this._resolved=!0,this._pool=t,t?t.descriptor.initialHeight!==void 0&&this.applyHeight(t.descriptor.initialHeight):this._renderFallback(),this.visible&&t?.acquire(this))}invalidate(){this.frame?.unbind(),this._pool=void 0,this._resolved=!1,this._renderFallback()}bindFrame(t){this.frame=t,t.layout(this)}unbindFrame(t){this.frame&&(this.element.style.minHeight=`${t}px`,this.frame=void 0)}applyGuestText(t){if(t===this._content)return;let n=Xt.replace(Yt.ofLength(this._content.length),t);this._content=t,this.onEdit?.(n)}applyHeight(t){let n=this._userHeight??this._clampAutomaticHeight(t);this._height=n,this.element.style.minHeight=`${n}px`,this._frameHost.style.height=`${n}px`,this.frame&&this.frame.layout(this)}get inlineHeight(){return this._height}get automaticHeight(){return this._clampAutomaticHeight(this._contentHeight??this._pool?.descriptor.initialHeight??120)}get contentHeight(){return this._contentHeight}setContentHeight(t,n){n==="document"&&(this._userHeight!==void 0||this._fullView)||(this._contentHeight=Xe(t),this._userHeight===void 0&&this.applyHeight(this._contentHeight))}resize(t){let n=Xe(Math.max(this.presentation.minHeight??1,t));if(Math.abs(n-this.automaticHeight)<=Ye){this.resetHeight();return}this._userHeight=n,this.applyHeight(n)}resetHeight(){this._userHeight=void 0,this.applyHeight(this.automaticHeight)}_clampAutomaticHeight(t){let{minHeight:n,maxAutomaticHeight:i}=this.presentation;return Math.max(n??1,Math.min(i??Kt,Xe(t)))}setGuestPresentation(t){let n=this.inlineHeight;this._guestPresentation=t,this.presentation.fullWidth||(this._widthFraction=0),this.presentation.fullView||this.exitFullView(),this.applyHeight(n),this.frame?.notifyPresentation()}setWidthFraction(t,n){if(!this.presentation.fullWidth)return;let i=Math.max(0,Math.min(1,t)),r=i*n<=Ye?0:(1-i)*n<=Ye?1:i;if(r===this._widthFraction)return;let s=this.mode;this._widthFraction=r,this.frame?.layout(this),this.mode!==s&&this.frame?.notifyPresentation()}toggleFullView(){if(this._fullView){this.exitFullView();return}this.presentation.fullView&&(this._factory.enterFullView(this),this.frame?.rememberScroll(),this._fullView=!0,this.frame?.layout(this),this.frame?.notifyPresentation())}exitFullView(){this._fullView&&(this._fullView=!1,this._factory.exitFullView(),this.frame?.restoreScroll(),this.frame?.layout(this),this.frame?.notifyPresentation(),this.frame?.focusFullViewButton())}observeLayout(t){t.observe(this.element)}hasFocus(){return this.frame?.hasFocus()??!1}get content(){return this._content}get readOnly(){return this._readOnly}get frameHost(){return this._frameHost}dispose(){this.disposed||(this.exitFullView(),this.disposed=!0,this._factory.remove(this),this.element.remove())}_renderFallback(){this._frameHost.style.height="";let t=document.createElement("pre"),n=document.createElement("code");n.textContent=this._content,t.appendChild(n),this._frameHost.replaceChildren(t)}},Lt=class{constructor(t,n,i,r,s,o,a){this._provider=t,this._frameLayer=i,this._frameRoot=r,this._scriptNonce=s,this._themeCss=o,this._iframeBootstrapUrl=a,this.descriptor=n}descriptor;_frames=new Set;get leasedFrames(){return Array.from(this._frames).filter(t=>t.editor!==void 0).length}get idleFrames(){return this._frames.size-this.leasedFrames}acquire(t){if(t.frame){t.frame.bind(t);return}(Array.from(this._frames).find(n=>n.editor===void 0)??this._createFrame()).bind(t)}release(t){let n=t.frame;!n||n.editor!==t||t.pinned||n.unbind()}park(t){t.style.top="-100000px",t.style.left="auto",t.style.right="100%"}dispose(){for(let t of this._frames)t.dispose();this._frames.clear()}layout(){for(let t of this._frames)t.editor&&t.layout(t.editor)}updateTheme(){for(let t of this._frames)t.updateTheme()}_createFrame(){let t=this.descriptor.hostTransport?this._provider.createHostTransport?.(this.descriptor.runtimeKey):void 0,n=new Ht(this,this.descriptor,t,this._frameLayer,this._frameRoot,this._scriptNonce,this._themeCss,this._iframeBootstrapUrl);return this._frames.add(n),n}},Ht=class{constructor(t,n,i,r,s,o,a,c){this._descriptor=n,this._hostTransport=i,this._frameRoot=s,this._scriptNonce=o,this._themeCss=a,this._iframeBootstrapUrl=c,this.pool=t,this._surface=document.createElement("div"),this._surface.className="md-iframe-surface";let d=document.createElement("iframe");d.setAttribute("sandbox",ur(n.sandbox)),d.setAttribute("allow",n.sandbox?.clipboardWrite?"clipboard-write":""),d.style.width="100%",d.style.border="none",d.style.display="block",d.style.position="absolute",d.style.pointerEvents="auto",d.style.background="var(--md-iframe-background, #fff)",d.style.height=`${n.initialHeight??120}px`,t.park(d),d.addEventListener("blur",()=>{let u=this.editor;u&&!u.visible&&this.pool.release(u)}),this.iframe=d,d.className="md-iframe-frame",this._toolbar=document.createElement("div"),this._toolbar.className="md-iframe-toolbar",this._toolbar.setAttribute("data-md-editor-chrome",""),this._toolbar.setAttribute("role","toolbar"),this._toolbar.setAttribute("aria-label","Embedded editor presentation"),this._fullViewButton=this._addButton("Full view","screen-full",()=>this.editor?.toggleFullView()),this._toolbar.addEventListener("keydown",u=>{u.key==="Escape"&&this.editor?.mode==="full-view"&&(u.preventDefault(),u.stopPropagation(),this.editor.exitFullView())},!0),this._heightGrip=this._createGrip("height","Resize embedded editor height"),this._widthGrip=this._createGrip("width","Resize embedded editor width"),this._onWindowMessage=u=>{if(u.source!==d.contentWindow)return;let l=u.data;if(l?.type===Me){if(l.action==="exit-full-view"){this.editor?.exitFullView();return}typeof l.height!="number"||!Number.isFinite(l.height)||this._guestReportsSize||this.editor?.setContentHeight(l.height,"document")}},window.addEventListener("message",this._onWindowMessage),this._surface.append(d,this._toolbar,this._heightGrip,this._widthGrip),r.appendChild(this._surface),this._surface.hidden=!0,this._toolbar.hidden=!0,this._heightGrip.hidden=!0,this._widthGrip.hidden=!0,queueMicrotask(()=>this._setup())}iframe;editor;pool;_host;_transport;_pendingEditor;_guestReportsSize=!1;_disposed=!1;_onWindowMessage;_surface;_toolbar;_fullViewButton;_heightGrip;_widthGrip;_drag;_widthTravel=0;_guestPresentation={};_scrollPositions=[];bind(t){if(this.editor===t){this._host?.setText(t.content),this._host?.setReadOnly(t.readOnly),t.applyHeight(ii(t.contentHeight,t.inlineHeight));return}this.editor&&this.editor!==t&&this.unbind(),this._pendingEditor=t,this._host&&this._host.reuse(t.content,t.readOnly),this.editor=t,this._pendingEditor=void 0,t.setGuestPresentation(this._guestPresentation),t.bindFrame(this),t.applyHeight(ii(t.contentHeight,t.inlineHeight)),this.notifyPresentation()}unbind(){let t=this.editor;if(!t)return;t.exitFullView(),this._endResize();let n=t.estimateHeight();this.editor=void 0,t.mountActions(),t.unbindFrame(n),this.pool.park(this.iframe),this._surface.hidden=!0,this._toolbar.hidden=!0,this._heightGrip.hidden=!0,this._widthGrip.hidden=!0}layout(t){if(this.editor!==t)return;let n=t.frameHost.getBoundingClientRect(),i=lt(this._frameRoot),r=this._frameRoot===document.body,s=t.mode==="full-view",o=ni(this._frameRoot),a=W/Math.max(Number.EPSILON,oe(this._frameRoot,1,0).x),c=lh(o,n,a),d=s?o:uh(n,c,t.widthFraction);this._widthTravel=Math.max(0,c.left+c.width-n.right);let u=oe(this._frameRoot,d.left-(r?0:i.left),(s?d.top:n.top)-(r?0:i.top)),l=oe(this._frameRoot,d.width,d.height),h=u.y+(r?window.scrollY:this._frameRoot.scrollTop),f=u.x+(r?window.scrollX:this._frameRoot.scrollLeft),g=l.x,_=s?Math.max(1,l.y):t.inlineHeight;this._surface.hidden=!1,this._surface.style.top=`${h}px`,this._surface.style.left=`${f}px`,this._surface.style.width=`${g}px`,this._surface.style.height=`${_}px`,this._surface.style.zIndex=s?"10":"",this._surface.classList.toggle("md-iframe-surface-full-view",s);let N=this._horizontalRoom(d,s),k={left:Math.min(W,N.left),right:Math.min(W,N.right)};this._surface.style.setProperty("--md-iframe-outline-inset",`${-W}px ${-k.right}px ${-W}px ${-k.left}px`);let E=s?"10":"";this.iframe.style.zIndex=E,this._toolbar.style.zIndex=s?"11":"1",this.iframe.style.top="0",this.iframe.style.left="0",this.iframe.style.right="",this.iframe.style.width=`${g}px`,this.iframe.style.height=`${_}px`,this._toolbar.hidden=t.toolbarHeight===0,this._toolbar.classList.toggle("md-iframe-toolbar-full-view",s),t.mountActions(this._toolbar.hidden?void 0:this._toolbar);let w=-(W+Xn+t.toolbarHeight),z=!s&&h+w>=0;this._toolbar.classList.toggle("md-iframe-toolbar-outside",z),this._toolbar.style.setProperty("--md-iframe-toolbar-bridge",`${W+Xn}px`),this._toolbar.style.top=`${z?w:wt}px`,this._toolbar.style.left=`${z?g+k.right:g-wt}px`,this._toolbar.style.maxWidth=`${Math.max(0,g-2*wt)}px`,this._toolbar.style.height=`${t.toolbarHeight}px`,this._fullViewButton.hidden=!t.presentation.fullView,this._setButtonAppearance(this._fullViewButton,s?"Exit full view":"Full view",s?"screen-normal":"screen-full"),this._fullViewButton.setAttribute("aria-pressed",String(s));let P=this._heightGrip;P.hidden=!t.presentation.resizable||s,P.style.top=`${_}px`,P.style.left="0",P.style.width=`${g}px`,P.style.height=`${Qn}px`,P.style.setProperty("--md-iframe-grip-line",`${W}px`),P.setAttribute("aria-valuenow",String(Math.round(_))),P.setAttribute("aria-valuemin",String(t.presentation.minHeight??1)),P.setAttribute("aria-valuemax",String(Kt));let M=this._widthGrip;M.hidden=!t.presentation.fullWidth||s||this._widthTravel<=Ye;let he=g+k.right,lr=Math.min(Qn-W,N.right-k.right);M.style.top="0",M.style.left=`${he-W}px`,M.style.width=`${W+lr}px`,M.style.height=`${_}px`,M.style.setProperty("--md-iframe-grip-line",`${W}px`);let hr=oe(this._frameRoot,n.width,0).x,pr=oe(this._frameRoot,c.width,0).x;M.setAttribute("aria-valuenow",String(Math.round(g))),M.setAttribute("aria-valuemin",String(Math.round(hr))),M.setAttribute("aria-valuemax",String(Math.round(pr)))}_horizontalRoom(t,n){if(n)return{left:0,right:0};let i=ni(this._frameRoot),r=s=>Math.max(0,oe(this._frameRoot,s,0).x);return{left:r(t.left-i.left),right:r(i.left+i.width-(t.left+t.width))}}rememberScroll(){this._scrollPositions=[];for(let t=this._frameRoot;t;t=t.parentElement)this._scrollPositions.push({element:t,top:t.scrollTop,left:t.scrollLeft})}restoreScroll(){for(let{element:t,top:n,left:i}of this._scrollPositions)t.scrollTop=n,t.scrollLeft=i;this._scrollPositions=[]}notifyPresentation(){this.editor&&this._host?.setPresentationMode(this.editor.mode)}focusFullViewButton(){this._fullViewButton.focus({preventScroll:!0})}hasFocus(){let t=this.iframe.getRootNode(),n=t instanceof ShadowRoot?t.activeElement:document.activeElement;return n===this.iframe||this._toolbar.contains(n)||n===this._heightGrip||n===this._widthGrip}_addButton(t,n,i){let r=document.createElement("button");r.type="button";let s=document.createElement("span");return s.setAttribute("aria-hidden","true"),r.appendChild(s),this._setButtonAppearance(r,t,n),r.addEventListener("click",o=>{o.stopPropagation(),i()}),this._toolbar.appendChild(r),r}_setButtonAppearance(t,n,i){t.title=n,t.setAttribute("aria-label",n),t.firstElementChild.className=`codicon codicon-${i}`}_createGrip(t,n){let i=document.createElement("div");return i.className=`md-iframe-grip md-iframe-grip-${t}`,i.setAttribute("data-md-editor-chrome",""),i.tabIndex=0,i.setAttribute("role","separator"),i.setAttribute("aria-label",n),i.setAttribute("aria-orientation",t==="height"?"horizontal":"vertical"),i.addEventListener("pointerdown",r=>{let s=this.editor;r.button!==0||!s||this._drag||(r.preventDefault(),r.stopPropagation(),i.focus({preventScroll:!0,focusVisible:!1}),i.setPointerCapture(r.pointerId),this._drag=t==="height"?{axis:t,grip:i,pointerId:r.pointerId,start:r.clientY,height:s.inlineHeight}:{axis:t,grip:i,pointerId:r.pointerId,start:r.clientX,fraction:s.widthFraction,travel:this._widthTravel},s.resizing=!0,this.iframe.style.pointerEvents="none")}),i.addEventListener("pointermove",r=>{let s=this._drag;s?.pointerId!==r.pointerId||!this.editor||(s.axis==="height"?this.editor.resize(s.height+oe(this._frameRoot,0,r.clientY-s.start).y):s.travel>0&&this.editor.setWidthFraction(s.fraction+(r.clientX-s.start)/s.travel,s.travel))}),i.addEventListener("pointerup",()=>this._endResize()),i.addEventListener("pointercancel",()=>this._endResize()),i.addEventListener("lostpointercapture",()=>this._endResize()),i.addEventListener("dblclick",r=>{r.preventDefault(),r.stopPropagation(),t==="height"?this.editor?.resetHeight():this.editor?.setWidthFraction(0,this._widthTravel)}),i.addEventListener("keydown",r=>{let s=this.editor;if(s){if(t==="height"){let o=r.key==="ArrowDown"?zt:r.key==="ArrowUp"?-zt:0;if(!o)return;s.resize(s.inlineHeight+o)}else{let o=this._widthTravel,a=o>0?zt/o:0,c=r.key==="Home"?0:r.key==="End"?1:r.key==="ArrowRight"?s.widthFraction+a:r.key==="ArrowLeft"?s.widthFraction-a:void 0;if(c===void 0)return;s.setWidthFraction(c,o)}r.preventDefault(),r.stopPropagation()}}),i}_endResize(){let t=this._drag;this._drag=void 0,this.editor&&(this.editor.resizing=!1),this.iframe.style.pointerEvents="auto",t?.grip.hasPointerCapture(t.pointerId)&&t.grip.releasePointerCapture(t.pointerId)}dispose(){this._disposed||(this._disposed=!0,this.unbind(),window.removeEventListener("message",this._onWindowMessage),this._host?.dispose(),this._transport?.dispose(),this._hostTransport?.dispose(),this.iframe.remove(),this._toolbar.remove(),this._heightGrip.remove(),this._widthGrip.remove(),this._surface.remove())}_setup(){if(this._disposed)return;let t=this.iframe.contentWindow;if(!t){requestAnimationFrame(()=>this._setup());return}this._transport=new oa(window,t);let n=new ta(Ei.create(this._transport)),i=this._pendingEditor??this.editor;this._host=new sh({connection:n,contentType:this._descriptor.contentType??"text",initialText:i?.content??"",readOnly:i?.readOnly??!1,hostTransport:this._hostTransport,supportsPresentation:!0}),this._host.onDidChangeText(({text:s})=>this.editor?.applyGuestText(s)),this._host.onDidReportSize(({height:s})=>{this._guestReportsSize=!0,this.editor?.setContentHeight(s,"protocol")}),this._host.onDidSetPresentationPreferences(s=>{this._guestPresentation=s,this.editor?.setGuestPresentation(s)}),this._host.onDidRequestExitFullView(()=>this.editor?.exitFullView()),i&&this._host.setPresentationMode(i.mode),this.iframe.addEventListener("load",()=>this.updateTheme(),{once:!0});let r=dh(this._descriptor.html,this._descriptor.resourceBaseUrl,this._getThemeCss(),this._scriptNonce);this._iframeBootstrapUrl?(this.iframe.addEventListener("load",()=>{let s=this.iframe.contentDocument;s&&(s.open(),s.write(r),s.close())},{once:!0}),this.iframe.src=this._iframeBootstrapUrl):this.iframe.srcdoc=r}_getThemeCss(){return typeof this._themeCss=="function"?this._themeCss():this._themeCss}updateTheme(){let t=this._getThemeCss();t!==void 0&&this.iframe.contentWindow?.postMessage({type:Me,themeCss:t},"*")}};function uh(e,t,n){let i=e.left+(t.left-e.left)*n,r=e.right+(t.left+t.width-e.right)*n;return{left:i,top:e.top,width:r-i,height:e.height}}function lh(e,t,n){let i=Math.min(t.left,e.left+n),r=Math.max(t.right,e.left+e.width-n);return{left:i,top:e.top,width:r-i,height:e.height}}function ur(e){let t=["allow-scripts","allow-same-origin"];return e?.forms&&t.push("allow-forms"),e?.downloads&&t.push("allow-downloads"),e?.pointerLock&&t.push("allow-pointer-lock"),t.join(" ")}function Xe(e){return Math.max(1,Math.min(Kt,Math.ceil(e)))}function ni(e){let t=lt(e),n=Qt(e),i=Math.max(t.left,n.left),r=Math.min(t.right,n.right),s=Math.max(t.top,n.top),o=Math.min(t.bottom,n.bottom);return{left:i,top:s,width:Math.max(1,r-i),height:Math.max(1,o-s)}}function ii(e,t){return Xe(e??t)}function ri(e,t){return`${e}\0${t}`}function hh(e,t){return[e,t.runtimeKey,t.html,t.resourceBaseUrl??"",t.hostTransport===!0?"host-transport":"",t.contentType??"text",ur(t.sandbox),t.sandbox?.clipboardWrite===!0?"clipboard-write":"",JSON.stringify(t.presentation??{})].join("\0")}export{ti as VirtualizedIframeEmbeddedEditorFactory,oh as selectCodeBlockEditorProvider};