(e,n,r)
| 488 | ]))`;continue}}if(n.s&&r[c]==="."){o+=i?`${r[c]}\r |
| 489 | `:`[${r[c]}\r |
| 490 | ]`;continue}o+=r[c],r[c]==="\\"?s=!0:i&&r[c]==="]"?i=!1:!i&&r[c]==="["&&(i=!0)}try{new RegExp(o)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return o}var Pg,gn,kz,nl=x(()=>{jr();gn={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Pg===void 0&&(Pg=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Pg),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};kz=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789")});function rl(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===N.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((r,o)=>({...r,[o]:Y(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",o]})??je(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let n={type:"object",additionalProperties:Y(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return n;if(t.keyType?._def.typeName===N.ZodString&&t.keyType._def.checks?.length){let{type:r,...o}=tl(t.keyType._def,e);return{...n,propertyNames:o}}else{if(t.keyType?._def.typeName===N.ZodEnum)return{...n,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===N.ZodBranded&&t.keyType._def.type._def.typeName===N.ZodString&&t.keyType._def.type._def.checks?.length){let{type:r,...o}=Qu(t.keyType._def,e);return{...n,propertyNames:o}}}return n}var ol=x(()=>{Gi();Je();nl();el();an()});function ZE(t,e){if(e.mapStrategy==="record")return rl(t,e);let n=Y(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||je(e),r=Y(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||je(e);return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}var Cg=x(()=>{Je();ol();an()});function BE(t){let e=t.values,r=Object.keys(t.values).filter(s=>typeof e[e[s]]!="number").map(s=>e[s]),o=Array.from(new Set(r.map(s=>typeof s)));return{type:o.length===1?o[0]==="string"?"string":"number":["string","number"],enum:r}}var Og=x(()=>{});function qE(t){return t.target==="openAi"?void 0:{not:je({...t,currentPath:[...t.currentPath,"not"]})}}var Ig=x(()=>{an()});function VE(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var Ag=x(()=>{});function KE(t,e){if(e.target==="openApi3")return WE(t,e);let n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in Sa&&(!r._def.checks||!r._def.checks.length))){let r=n.reduce((o,s)=>{let i=Sa[s._def.typeName];return i&&!o.includes(i)?[...o,i]:o},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){let r=n.reduce((o,s)=>{let i=typeof s._def.value;switch(i){case"string":case"number":case"boolean":return[...o,i];case"bigint":return[...o,"integer"];case"object":if(s._def.value===null)return[...o,"null"];default:return o}},[]);if(r.length===n.length){let o=r.filter((s,i,a)=>a.indexOf(s)===i);return{type:o.length>1?o:o[0],enum:n.reduce((s,i)=>s.includes(i._def.value)?s:[...s,i._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,o)=>[...r,...o._def.values.filter(s=>!r.includes(s))],[])};return WE(t,e)}var Sa,WE,sl=x(()=>{Je();Sa={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};WE=(t,e)=>{let n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((r,o)=>Y(r._def,{...e,currentPath:[...e.currentPath,"anyOf",`${o}`]})).filter(r=>!!r&&(!e.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0}});function GE(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:Sa[t.innerType._def.typeName],nullable:!0}:{type:[Sa[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let r=Y(t.innerType._def,{...e,currentPath:[...e.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}let n=Y(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}var Ng=x(()=>{Je();sl()});function JE(t,e){let n={type:"number"};if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"int":n.type="integer",gg(n,"type",r.message,e);break;case"min":e.target==="jsonSchema7"?r.inclusive?de(n,"minimum",r.value,r.message,e):de(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),de(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?de(n,"maximum",r.value,r.message,e):de(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),de(n,"maximum",r.value,r.message,e));break;case"multipleOf":de(n,"multipleOf",r.value,r.message,e);break}return n}var Mg=x(()=>{jr()});function XE(t,e){let n=e.target==="openAi",r={type:"object",properties:{}},o=[],s=t.shape();for(let a in s){let c=s[a];if(c===void 0||c._def===void 0)continue;let u=Tz(c);u&&n&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=Y(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});l!==void 0&&(r.properties[a]=l,u||o.push(a))}o.length&&(r.required=o);let i=Ez(t,e);return i!==void 0&&(r.additionalProperties=i),r}function Ez(t,e){if(t.catchall._def.typeName!=="ZodNever")return Y(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function Tz(t){try{return t.isOptional()}catch{return!0}}var Dg=x(()=>{Je()});var YE,jg=x(()=>{Je();an();YE=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return Y(t.innerType._def,e);let n=Y(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return n?{anyOf:[{not:je(e)},n]}:je(e)}});var QE,Lg=x(()=>{Je();QE=(t,e)=>{if(e.pipeStrategy==="input")return Y(t.in._def,e);if(e.pipeStrategy==="output")return Y(t.out._def,e);let n=Y(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),r=Y(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(o=>o!==void 0)}}});function e0(t,e){return Y(t.type._def,e)}var zg=x(()=>{Je()});function t0(t,e){let r={type:"array",uniqueItems:!0,items:Y(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&de(r,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&de(r,"maxItems",t.maxSize.value,t.maxSize.message,e),r}var Hg=x(()=>{jr();Je()});function n0(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>Y(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Y(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>Y(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}var Ug=x(()=>{Je()});function r0(t){return{not:je(t)}}var Fg=x(()=>{an()});function o0(t){return je(t)}var Zg=x(()=>{an()});var s0,Bg=x(()=>{Je();s0=(t,e)=>Y(t.innerType._def,e)});var i0,qg=x(()=>{Gi();an();yg();_g();bg();el();xg();vg();kg();wg();Eg();Tg();$g();Cg();Og();Ig();Ag();Ng();Mg();Dg();jg();Lg();zg();ol();Hg();nl();Ug();Fg();sl();Zg();Bg();i0=(t,e,n)=>{switch(e){case N.ZodString:return tl(t,n);case N.ZodNumber:return JE(t,n);case N.ZodObject:return XE(t,n);case N.ZodBigInt:return NE(t,n);case N.ZodBoolean:return ME();case N.ZodDate:return Sg(t,n);case N.ZodUndefined:return r0(n);case N.ZodNull:return VE(n);case N.ZodArray:return AE(t,n);case N.ZodUnion:case N.ZodDiscriminatedUnion:return KE(t,n);case N.ZodIntersection:return HE(t,n);case N.ZodTuple:return n0(t,n);case N.ZodRecord:return rl(t,n);case N.ZodLiteral:return UE(t,n);case N.ZodEnum:return zE(t);case N.ZodNativeEnum:return BE(t);case N.ZodNullable:return GE(t,n);case N.ZodOptional:return YE(t,n);case N.ZodMap:return ZE(t,n);case N.ZodSet:return t0(t,n);case N.ZodLazy:return()=>t.getter()._def;case N.ZodPromise:return e0(t,n);case N.ZodNaN:case N.ZodNever:return qE(n);case N.ZodEffects:return LE(t,n);case N.ZodAny:return je(n);case N.ZodUnknown:return o0(n);case N.ZodDefault:return jE(t,n);case N.ZodBranded:return Qu(t,n);case N.ZodReadonly:return s0(t,n);case N.ZodCatch:return DE(t,n);case N.ZodPipeline:return QE(t,n);case N.ZodFunction:case N.ZodVoid:case N.ZodSymbol:return;default:return(r=>{})(e)}}});function Y(t,e,n=!1){let r=e.seen.get(t);if(e.override){let a=e.override?.(t,e,r,n);if(a!==CE)return a}if(r&&!n){let a=$z(r,e);if(a!==void 0)return a}let o={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,o);let s=i0(t,t.typeName,e),i=typeof s=="function"?Y(s(),e):s;if(i&&Pz(t,e,i),e.postProcess){let a=e.postProcess(i,t,e);return o.jsonSchema=i,a}return o.jsonSchema=i,i}var $z,Pz,Je=x(()=>{Ju();qg();Yu();an();$z=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Xu(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((n,r)=>e.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),je(e)):e.$refStrategy==="seen"?je(e):void 0}},Pz=(t,e,n)=>(t.description&&(n.description=t.description,e.markdownDescription&&(n.markdownDescription=t.description)),n)});var a0=x(()=>{});var Vg,Wg=x(()=>{Je();hg();an();Vg=(t,e)=>{let n=IE(e),r=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:Y(l._def,{...n,currentPath:[...n.basePath,n.definitionPath,u]},!0)??je(n)}),{}):void 0,o=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=Y(t._def,o===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,o]},!1)??je(n),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(s.title=i),n.flags.hasReferencedOpenAiAnyType&&(r||(r={}),r[n.openAiAnyTypeName]||(r[n.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:n.$refStrategy==="relative"?"1":[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join("/")}}));let a=o===void 0?r?{...s,[n.definitionPath]:r}:s:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,o].join("/"),[n.definitionPath]:{...r,[o]:s}};return n.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(n.target==="jsonSchema2019-09"||n.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),n.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a}});var c0=x(()=>{Ju();hg();jr();Yu();Je();a0();an();yg();_g();bg();el();xg();vg();kg();wg();Eg();Tg();$g();Cg();Og();Ig();Ag();Ng();Mg();Dg();jg();Lg();zg();Bg();ol();Hg();nl();Ug();Fg();sl();Zg();qg();Wg();Wg()});function Rz(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function Kg(t,e){return rn(t)?Mh(t,{target:Rz(e?.target),io:e?.pipeStrategy??"input"}):Vg(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function Gg(t){let n=Nr(t)?.method;if(!n)throw new Error("Schema is missing a method literal");let r=Cu(n);if(typeof r!="string")throw new Error("Schema method literal must be a string");return r}function Jg(t,e){let n=Ar(t,e);if(!n.success)throw n.error;return n.data}var Xg=x(()=>{Lh();ca();c0()});function u0(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function l0(t,e){let n={...t};for(let r in e){let o=r,s=e[o];if(s===void 0)continue;let i=n[o];u0(i)&&u0(s)?n[o]={...i,...s}:n[o]=s}return n}var Cz,il,d0=x(()=>{ca();Lo();PE();Xg();Cz=6e4,il=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(ju,n=>{this._oncancel(n)}),this.setNotificationHandler(zu,n=>{this._onprogress(n)}),this.setRequestHandler(Lu,n=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Hu,async(n,r)=>{let o=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!o)throw new B(K.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Fu,async(n,r)=>{let o=async()=>{let s=n.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,r.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,p=new B(d.error.code,d.error.message,d.error.data);l(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:r.requestId})}}let i=await this._taskStore.getTask(s,r.sessionId);if(!i)throw new B(K.InvalidParams,`Task not found: ${s}`);if(!Dr(i.status))return await this._waitForTaskUpdate(s,r.signal),await o();if(Dr(i.status)){let a=await this._taskStore.getTaskResult(s,r.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[Mr]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Zu,async(n,r)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(n.params?.cursor,r.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new B(K.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(qu,async(n,r)=>{try{let o=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!o)throw new B(K.InvalidParams,`Task not found: ${n.params.taskId}`);if(Dr(o.status))throw new B(K.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",r.sessionId),this._clearTaskQueue(n.params.taskId);let s=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!s)throw new B(K.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof B?o:new B(K.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,n,r,o,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,n),startTime:Date.now(),timeout:n,maxTotalTimeout:r,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(e){let n=this._timeoutInfo.get(e);if(!n)return!1;let r=Date.now()-n.startTime;if(n.maxTotalTimeout&&r>=n.maxTotalTimeout)throw this._timeoutInfo.delete(e),B.fromError(K.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:r});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),!0}_cleanupTimeout(e){let n=this._timeoutInfo.get(e);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let n=this.transport?.onclose;this._transport.onclose=()=>{n?.(),this._onclose()};let r=this.transport?.onerror;this._transport.onerror=s=>{r?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),pa(s)||yE(s)?this._onresponse(s):tg(s)?this._onrequest(s,i):gE(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let r of this._timeoutInfo.values())clearTimeout(r.timeoutId);this._timeoutInfo.clear();for(let r of this._requestHandlerAbortControllers.values())r.abort();this._requestHandlerAbortControllers.clear();let n=B.fromError(K.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let r of e.values())r(n)}_onerror(e){this.onerror?.(e)}_onnotification(e){let n=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(e)).catch(r=>this._onerror(new Error(`Uncaught error in notification handler: ${r}`)))}_onrequest(e,n){let r=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,s=e.params?._meta?.[Mr]?.taskId;if(r===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:K.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=mE(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new B(K.ConnectionClosed,"Request was cancelled");let f={...p,relatedRequestId:e.id};s&&!f.relatedTask&&(f.relatedTask={taskId:s});let m=f.relatedTask?.taskId??s;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(l,d,f)},authInfo:n?.authInfo,requestId:e.id,requestInfo:n?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:n?.closeSSEStream,closeStandaloneSSEStream:n?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>r(e,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:K.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:n,...r}=e.params,o=Number(n),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(r)}_onresponse(e){let n=Number(e.id),r=this._requestResolvers.get(n);if(r){if(this._requestResolvers.delete(n),pa(e))r(e);else{let i=new B(e.error.code,e.error.message,e.error.data);r(i)}return}let o=this._responseHandlers.get(n);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let s=!1;if(pa(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,n))}}if(s||this._progressHandlers.delete(n),pa(e))o(e);else{let i=B.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,n,r){let{task:o}=r??{};if(!o){try{yield{type:"result",result:await this.request(e,n,r)}}catch(i){yield{type:"error",error:i instanceof B?i:new B(K.InternalError,String(i))}}return}let s;try{let i=await this.request(e,js,r);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new B(K.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},r);if(yield{type:"taskStatus",task:a},Dr(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},n,r)}:a.status==="failed"?yield{type:"error",error:new B(K.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new B(K.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},n,r)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),r?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof B?i:new B(K.InternalError,String(i))}}}request(e,n,r){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=r??{};return new Promise((u,l)=>{let d=_=>{l(_)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(_){d(_);return}r?.signal?.throwIfAborted();let p=this._requestMessageId++,f={...e,jsonrpc:"2.0",id:p};r?.onprogress&&(this._progressHandlers.set(p,r.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(f.params={...f.params,task:a}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[Mr]:c}});let m=_=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(_)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(S=>this._onerror(new Error(`Failed to send cancellation: ${S}`)));let b=_ instanceof B?_:new B(K.RequestTimeout,String(_));l(b)};this._responseHandlers.set(p,_=>{if(!r?.signal?.aborted){if(_ instanceof Error)return l(_);try{let b=Ar(n,_.result);b.success?u(b.data):l(b.error)}catch(b){l(b)}}}),r?.signal?.addEventListener("abort",()=>{m(r?.signal?.reason)});let h=r?.timeout??Cz,g=()=>m(B.fromError(K.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(p,h,r?.maxTotalTimeout,g,r?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let _=b=>{let S=this._responseHandlers.get(p);S?S(b):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,_),this._enqueueTaskMessage(y,{type:"request",message:f,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(p),l(b)})}else this._transport.send(f,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(_=>{this._cleanupTimeout(p),l(_)})})}async getTask(e,n){return this.request({method:"tasks/get",params:e},Uu,n)}async getTaskResult(e,n,r){return this.request({method:"tasks/result",params:e},n,r)}async listTasks(e,n){return this.request({method:"tasks/list",params:e},Bu,n)}async cancelTask(e,n){return this.request({method:"tasks/cancel",params:e},xE,n)}async notification(e,n){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let r=n?.relatedTask?.taskId;if(r){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[Mr]:n.relatedTask}}};await this._enqueueTaskMessage(r,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!n?.relatedRequestId&&!n?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};n?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Mr]:n.relatedTask}}}),this._transport?.send(a,n).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};n?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Mr]:n.relatedTask}}}),await this._transport.send(i,n)}setRequestHandler(e,n){let r=Gg(e);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(o,s)=>{let i=Jg(e,o);return Promise.resolve(n(i,s))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,n){let r=Gg(e);this._notificationHandlers.set(r,o=>{let s=Jg(e,o);return Promise.resolve(n(s))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let n=this._taskProgressTokens.get(e);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,n,r){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,n,r,o)}async _clearTaskQueue(e,n){if(this._taskMessageQueue){let r=await this._taskMessageQueue.dequeueAll(e,n);for(let o of r)if(o.type==="request"&&tg(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new B(K.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,n){let r=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(r=o.pollInterval)}catch{}return new Promise((o,s)=>{if(n.aborted){s(new B(K.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,r);n.addEventListener("abort",()=>{clearTimeout(i),s(new B(K.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,n){let r=this._taskStore;if(!r)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await r.createTask(o,e.id,{method:e.method,params:e.params},n)},getTask:async o=>{let s=await r.getTask(o,n);if(!s)throw new B(K.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await r.storeTaskResult(o,s,i,n);let a=await r.getTask(o,n);if(a){let c=ya.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Dr(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>r.getTaskResult(o,n),updateTaskStatus:async(o,s,i)=>{let a=await r.getTask(o,n);if(!a)throw new B(K.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Dr(a.status))throw new B(K.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await r.updateTaskStatus(o,s,i,n);let c=await r.getTask(o,n);if(c){let u=ya.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Dr(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>r.listTasks(o,n)}}}});var wa=L(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.regexpCode=he.getEsmExportName=he.getProperty=he.safeStringify=he.stringify=he.strConcat=he.addCodeArg=he.str=he._=he.nil=he._Code=he.Name=he.IDENTIFIER=he._CodeOrName=void 0;var va=class{};he._CodeOrName=va;he.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var zo=class extends va{constructor(e){if(super(),!he.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};he.Name=zo;var cn=class extends va{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((n,r)=>`${n}${r}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((n,r)=>(r instanceof zo&&(n[r.str]=(n[r.str]||0)+1),n),{})}};he._Code=cn;he.nil=new cn("");function p0(t,...e){let n=[t[0]],r=0;for(;r<e.length;)Qg(n,e[r]),n.push(t[++r]);return new cn(n)}he._=p0;var Yg=new cn("+");function m0(t,...e){let n=[ka(t[0])],r=0;for(;r<e.length;)n.push(Yg),Qg(n,e[r]),n.push(Yg,ka(t[++r]));return Oz(n),new cn(n)}he.str=m0;function Qg(t,e){e instanceof cn?t.push(...e._items):e instanceof zo?t.push(e):t.push(Nz(e))}he.addCodeArg=Qg;function Oz(t){let e=1;for(;e<t.length-1;){if(t[e]===Yg){let n=Iz(t[e-1],t[e+1]);if(n!==void 0){t.splice(e-1,3,n);continue}t[e++]="+"}e++}}function Iz(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof zo||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof zo))return`"${t}${e.slice(1)}`}function Az(t,e){return e.emptyStr()?t:t.emptyStr()?e:m0`${t}${e}`}he.strConcat=Az;function Nz(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:ka(Array.isArray(t)?t.join(","):t)}function Mz(t){return new cn(ka(t))}he.stringify=Mz;function ka(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}he.safeStringify=ka;function Dz(t){return typeof t=="string"&&he.IDENTIFIER.test(t)?new cn(`.${t}`):p0`[${t}]`}he.getProperty=Dz;function jz(t){if(typeof t=="string"&&he.IDENTIFIER.test(t))return new cn(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}he.getEsmExportName=jz;function Lz(t){return new cn(t.toString())}he.regexpCode=Lz});var ny=L(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.ValueScope=Mt.ValueScopeName=Mt.Scope=Mt.varKinds=Mt.UsedValueState=void 0;var Nt=wa(),ey=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},al;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(al||(Mt.UsedValueState=al={}));Mt.varKinds={const:new Nt.Name("const"),let:new Nt.Name("let"),var:new Nt.Name("var")};var cl=class{constructor({prefixes:e,parent:n}={}){this._names={},this._prefixes=e,this._parent=n}toName(e){return e instanceof Nt.Name?e:this.name(e)}name(e){return new Nt.Name(this._newName(e))}_newName(e){let n=this._names[e]||this._nameGroup(e);return`${e}${n.index++}`}_nameGroup(e){var n,r;if(!((r=(n=this._parent)===null||n===void 0?void 0:n._prefixes)===null||r===void 0)&&r.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Mt.Scope=cl;var ul=class extends Nt.Name{constructor(e,n){super(n),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,Nt._)`.${new Nt.Name(n)}[${r}]`}};Mt.ValueScopeName=ul;var zz=(0,Nt._)`\n`,ty=class extends cl{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?zz:Nt.nil}}get(){return this._scope}name(e){return new ul(e,this._newName(e))}value(e,n){var r;if(n.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:s}=o,i=(r=n.key)!==null&&r!==void 0?r:n.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=n.ref,o.setValue(n,{property:s,itemIndex:u}),o}getValue(e,n){let r=this._values[e];if(r)return r.get(n)}scopeRefs(e,n=this._values){return this._reduceValues(n,r=>{if(r.scopePath===void 0)throw new Error(`CodeGen: name "${r}" has no value`);return(0,Nt._)`${e}${r.scopePath}`})}scopeCode(e=this._values,n,r){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},n,r)}_reduceValues(e,n,r={},o){let s=Nt.nil;for(let i in e){let a=e[i];if(!a)continue;let c=r[i]=r[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,al.Started);let l=n(u);if(l){let d=this.opts.es5?Mt.varKinds.var:Mt.varKinds.const;s=(0,Nt._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Nt._)`${s}${l}${this.opts._n}`;else throw new ey(u);c.set(u,al.Completed)})}return s}};Mt.ValueScope=ty});var oe=L(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});se.or=se.and=se.not=se.CodeGen=se.operators=se.varKinds=se.ValueScopeName=se.ValueScope=se.Scope=se.Name=se.regexpCode=se.stringify=se.getProperty=se.nil=se.strConcat=se.str=se._=void 0;var pe=wa(),_n=ny(),Lr=wa();Object.defineProperty(se,"_",{enumerable:!0,get:function(){return Lr._}});Object.defineProperty(se,"str",{enumerable:!0,get:function(){return Lr.str}});Object.defineProperty(se,"strConcat",{enumerable:!0,get:function(){return Lr.strConcat}});Object.defineProperty(se,"nil",{enumerable:!0,get:function(){return Lr.nil}});Object.defineProperty(se,"getProperty",{enumerable:!0,get:function(){return Lr.getProperty}});Object.defineProperty(se,"stringify",{enumerable:!0,get:function(){return Lr.stringify}});Object.defineProperty(se,"regexpCode",{enumerable:!0,get:function(){return Lr.regexpCode}});Object.defineProperty(se,"Name",{enumerable:!0,get:function(){return Lr.Name}});var ml=ny();Object.defineProperty(se,"Scope",{enumerable:!0,get:function(){return ml.Scope}});Object.defineProperty(se,"ValueScope",{enumerable:!0,get:function(){return ml.ValueScope}});Object.defineProperty(se,"ValueScopeName",{enumerable:!0,get:function(){return ml.ValueScopeName}});Object.defineProperty(se,"varKinds",{enumerable:!0,get:function(){return ml.varKinds}});se.operators={GT:new pe._Code(">"),GTE:new pe._Code(">="),LT:new pe._Code("<"),LTE:new pe._Code("<="),EQ:new pe._Code("==="),NEQ:new pe._Code("!=="),NOT:new pe._Code("!"),OR:new pe._Code("||"),AND:new pe._Code("&&"),ADD:new pe._Code("+")};var rr=class{optimizeNodes(){return this}optimizeNames(e,n){return this}},ry=class extends rr{constructor(e,n,r){super(),this.varKind=e,this.name=n,this.rhs=r}render({es5:e,_n:n}){let r=e?_n.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${r} ${this.name}${o};`+n}optimizeNames(e,n){if(e[this.name.str])return this.rhs&&(this.rhs=qs(this.rhs,e,n)),this}get names(){return this.rhs instanceof pe._CodeOrName?this.rhs.names:{}}},ll=class extends rr{constructor(e,n,r){super(),this.lhs=e,this.rhs=n,this.sideEffects=r}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof pe.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=qs(this.rhs,e,n),this}get names(){let e=this.lhs instanceof pe.Name?{}:{...this.lhs.names};return pl(e,this.rhs)}},oy=class extends ll{constructor(e,n,r,o){super(e,r,o),this.op=n}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},sy=class extends rr{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},iy=class extends rr{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},ay=class extends rr{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},cy=class extends rr{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,n){return this.code=qs(this.code,e,n),this}get names(){return this.code instanceof pe._CodeOrName?this.code.names:{}}},Ea=class extends rr{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((n,r)=>n+r.render(e),"")}optimizeNodes(){let{nodes:e}=this,n=e.length;for(;n--;){let r=e[n].optimizeNodes();Array.isArray(r)?e.splice(n,1,...r):r?e[n]=r:e.splice(n,1)}return e.length>0?this:void 0}optimizeNames(e,n){let{nodes:r}=this,o=r.length;for(;o--;){let s=r[o];s.optimizeNames(e,n)||(Hz(e,s.names),r.splice(o,1))}return r.length>0?this:void 0}get names(){return this.nodes.reduce((e,n)=>Fo(e,n.names),{})}},or=class extends Ea{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},uy=class extends Ea{},Bs=class extends or{};Bs.kind="else";var Ho=class t extends or{constructor(e,n){super(n),this.condition=e}render(e){let n=`if(${this.condition})`+super.render(e);return this.else&&(n+="else "+this.else.render(e)),n}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let n=this.else;if(n){let r=n.optimizeNodes();n=this.else=Array.isArray(r)?new Bs(r):r}if(n)return e===!1?n instanceof t?n:n.nodes:this.nodes.length?this:new t(f0(e),n instanceof t?[n]:n.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,n){var r;if(this.else=(r=this.else)===null||r===void 0?void 0:r.optimizeNames(e,n),!!(super.optimizeNames(e,n)||this.else))return this.condition=qs(this.condition,e,n),this}get names(){let e=super.names;return pl(e,this.condition),this.else&&Fo(e,this.else.names),e}};Ho.kind="if";var Uo=class extends or{};Uo.kind="for";var ly=class extends Uo{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,n){if(super.optimizeNames(e,n))return this.iteration=qs(this.iteration,e,n),this}get names(){return Fo(super.names,this.iteration.names)}},dy=class extends Uo{constructor(e,n,r,o){super(),this.varKind=e,this.name=n,this.from=r,this.to=o}render(e){let n=e.es5?_n.varKinds.var:this.varKind,{name:r,from:o,to:s}=this;return`for(${n} ${r}=${o}; ${r}<${s}; ${r}++)`+super.render(e)}get names(){let e=pl(super.names,this.from);return pl(e,this.to)}},dl=class extends Uo{constructor(e,n,r,o){super(),this.loop=e,this.varKind=n,this.name=r,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,n){if(super.optimizeNames(e,n))return this.iterable=qs(this.iterable,e,n),this}get names(){return Fo(super.names,this.iterable.names)}},Ta=class extends or{constructor(e,n,r){super(),this.name=e,this.args=n,this.async=r}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Ta.kind="func";var $a=class extends Ea{render(e){return"return "+super.render(e)}};$a.kind="return";var py=class extends or{render(e){let n="try"+super.render(e);return this.catch&&(n+=this.catch.render(e)),this.finally&&(n+=this.finally.render(e)),n}optimizeNodes(){var e,n;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(n=this.finally)===null||n===void 0||n.optimizeNodes(),this}optimizeNames(e,n){var r,o;return super.optimizeNames(e,n),(r=this.catch)===null||r===void 0||r.optimizeNames(e,n),(o=this.finally)===null||o===void 0||o.optimizeNames(e,n),this}get names(){let e=super.names;return this.catch&&Fo(e,this.catch.names),this.finally&&Fo(e,this.finally.names),e}},Pa=class extends or{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Pa.kind="catch";var Ra=class extends or{render(e){return"finally"+super.render(e)}};Ra.kind="finally";var my=class{constructor(e,n={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...n,_n:n.lines?` |
| 491 | `:""},this._extScope=e,this._scope=new _n.Scope({parent:e}),this._nodes=[new uy]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,n){let r=this._extScope.value(e,n);return(this._values[r.prefix]||(this._values[r.prefix]=new Set)).add(r),r}getScopeValue(e,n){return this._extScope.getValue(e,n)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,n,r,o){let s=this._scope.toName(n);return r!==void 0&&o&&(this._constants[s.str]=r),this._leafNode(new ry(e,s,r)),s}const(e,n,r){return this._def(_n.varKinds.const,e,n,r)}let(e,n,r){return this._def(_n.varKinds.let,e,n,r)}var(e,n,r){return this._def(_n.varKinds.var,e,n,r)}assign(e,n,r){return this._leafNode(new ll(e,n,r))}add(e,n){return this._leafNode(new oy(e,se.operators.ADD,n))}code(e){return typeof e=="function"?e():e!==pe.nil&&this._leafNode(new cy(e)),this}object(...e){let n=["{"];for(let[r,o]of e)n.length>1&&n.push(","),n.push(r),(r!==o||this.opts.es5)&&(n.push(":"),(0,pe.addCodeArg)(n,o));return n.push("}"),new pe._Code(n)}if(e,n,r){if(this._blockNode(new Ho(e)),n&&r)this.code(n).else().code(r).endIf();else if(n)this.code(n).endIf();else if(r)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new Ho(e))}else(){return this._elseNode(new Bs)}endIf(){return this._endBlockNode(Ho,Bs)}_for(e,n){return this._blockNode(e),n&&this.code(n).endFor(),this}for(e,n){return this._for(new ly(e),n)}forRange(e,n,r,o,s=this.opts.es5?_n.varKinds.var:_n.varKinds.let){let i=this._scope.toName(e);return this._for(new dy(s,i,n,r),()=>o(i))}forOf(e,n,r,o=_n.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=n instanceof pe.Name?n:this.var("_arr",n);return this.forRange("_i",0,(0,pe._)`${i}.length`,a=>{this.var(s,(0,pe._)`${i}[${a}]`),r(s)})}return this._for(new dl("of",o,s,n),()=>r(s))}forIn(e,n,r,o=this.opts.es5?_n.varKinds.var:_n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,pe._)`Object.keys(${n})`,r);let s=this._scope.toName(e);return this._for(new dl("in",o,s,n),()=>r(s))}endFor(){return this._endBlockNode(Uo)}label(e){return this._leafNode(new sy(e))}break(e){return this._leafNode(new iy(e))}return(e){let n=new $a;if(this._blockNode(n),this.code(e),n.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode($a)}try(e,n,r){if(!n&&!r)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new py;if(this._blockNode(o),this.code(e),n){let s=this.name("e");this._currNode=o.catch=new Pa(s),n(s)}return r&&(this._currNode=o.finally=new Ra,this.code(r)),this._endBlockNode(Pa,Ra)}throw(e){return this._leafNode(new ay(e))}block(e,n){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(n),this}endBlock(e){let n=this._blockStarts.pop();if(n===void 0)throw new Error("CodeGen: not in self-balancing block");let r=this._nodes.length-n;if(r<0||e!==void 0&&r!==e)throw new Error(`CodeGen: wrong number of nodes: ${r} vs ${e} expected`);return this._nodes.length=n,this}func(e,n=pe.nil,r,o){return this._blockNode(new Ta(e,n,r)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Ta)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,n){let r=this._currNode;if(r instanceof e||n&&r instanceof n)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${n?`${e.kind}/${n.kind}`:e.kind}"`)}_elseNode(e){let n=this._currNode;if(!(n instanceof Ho))throw new Error('CodeGen: "else" without "if"');return this._currNode=n.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let n=this._nodes;n[n.length-1]=e}};se.CodeGen=my;function Fo(t,e){for(let n in e)t[n]=(t[n]||0)+(e[n]||0);return t}function pl(t,e){return e instanceof pe._CodeOrName?Fo(t,e.names):t}function qs(t,e,n){if(t instanceof pe.Name)return r(t);if(!o(t))return t;return new pe._Code(t._items.reduce((s,i)=>(i instanceof pe.Name&&(i=r(i)),i instanceof pe._Code?s.push(...i._items):s.push(i),s),[]));function r(s){let i=n[s.str];return i===void 0||e[s.str]!==1?s:(delete e[s.str],i)}function o(s){return s instanceof pe._Code&&s._items.some(i=>i instanceof pe.Name&&e[i.str]===1&&n[i.str]!==void 0)}}function Hz(t,e){for(let n in e)t[n]=(t[n]||0)-(e[n]||0)}function f0(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,pe._)`!${fy(t)}`}se.not=f0;var Uz=h0(se.operators.AND);function Fz(...t){return t.reduce(Uz)}se.and=Fz;var Zz=h0(se.operators.OR);function Bz(...t){return t.reduce(Zz)}se.or=Bz;function h0(t){return(e,n)=>e===pe.nil?n:n===pe.nil?e:(0,pe._)`${fy(e)} ${t} ${fy(n)}`}function fy(t){return t instanceof pe.Name?t:(0,pe._)`(${t})`}});var me=L(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});ae.checkStrictMode=ae.getErrorPath=ae.Type=ae.useFunc=ae.setEvaluated=ae.evaluatedPropsToName=ae.mergeEvaluated=ae.eachItem=ae.unescapeJsonPointer=ae.escapeJsonPointer=ae.escapeFragment=ae.unescapeFragment=ae.schemaRefOrVal=ae.schemaHasRulesButRef=ae.schemaHasRules=ae.checkUnknownRules=ae.alwaysValidSchema=ae.toHash=void 0;var Te=oe(),qz=wa();function Vz(t){let e={};for(let n of t)e[n]=!0;return e}ae.toHash=Vz;function Wz(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(_0(t,e),!b0(e,t.self.RULES.all))}ae.alwaysValidSchema=Wz;function _0(t,e=t.schema){let{opts:n,self:r}=t;if(!n.strictSchema||typeof e=="boolean")return;let o=r.RULES.keywords;for(let s in e)o[s]||v0(t,`unknown keyword: "${s}"`)}ae.checkUnknownRules=_0;function b0(t,e){if(typeof t=="boolean")return!t;for(let n in t)if(e[n])return!0;return!1}ae.schemaHasRules=b0;function Kz(t,e){if(typeof t=="boolean")return!t;for(let n in t)if(n!=="$ref"&&e.all[n])return!0;return!1}ae.schemaHasRulesButRef=Kz;function Gz({topSchemaRef:t,schemaPath:e},n,r,o){if(!o){if(typeof n=="number"||typeof n=="boolean")return n;if(typeof n=="string")return(0,Te._)`${n}`}return(0,Te._)`${t}${e}${(0,Te.getProperty)(r)}`}ae.schemaRefOrVal=Gz;function Jz(t){return x0(decodeURIComponent(t))}ae.unescapeFragment=Jz;function Xz(t){return encodeURIComponent(gy(t))}ae.escapeFragment=Xz;function gy(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}ae.escapeJsonPointer=gy;function x0(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}ae.unescapeJsonPointer=x0;function Yz(t,e){if(Array.isArray(t))for(let n of t)e(n);else e(t)}ae.eachItem=Yz;function g0({mergeNames:t,mergeToName:e,mergeValues:n,resultToName:r}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof Te.Name?(s instanceof Te.Name?t(o,s,i):e(o,s,i),i):s instanceof Te.Name?(e(o,i,s),s):n(s,i);return a===Te.Name&&!(c instanceof Te.Name)?r(o,c):c}}ae.mergeEvaluated={props:g0({mergeNames:(t,e,n)=>t.if((0,Te._)`${n} !== true && ${e} !== undefined`,()=>{t.if((0,Te._)`${e} === true`,()=>t.assign(n,!0),()=>t.assign(n,(0,Te._)`${n} || {}`).code((0,Te._)`Object.assign(${n}, ${e})`))}),mergeToName:(t,e,n)=>t.if((0,Te._)`${n} !== true`,()=>{e===!0?t.assign(n,!0):(t.assign(n,(0,Te._)`${n} || {}`),yy(t,n,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:S0}),items:g0({mergeNames:(t,e,n)=>t.if((0,Te._)`${n} !== true && ${e} !== undefined`,()=>t.assign(n,(0,Te._)`${e} === true ? true : ${n} > ${e} ? ${n} : ${e}`)),mergeToName:(t,e,n)=>t.if((0,Te._)`${n} !== true`,()=>t.assign(n,e===!0?!0:(0,Te._)`${n} > ${e} ? ${n} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function S0(t,e){if(e===!0)return t.var("props",!0);let n=t.var("props",(0,Te._)`{}`);return e!==void 0&&yy(t,n,e),n}ae.evaluatedPropsToName=S0;function yy(t,e,n){Object.keys(n).forEach(r=>t.assign((0,Te._)`${e}${(0,Te.getProperty)(r)}`,!0))}ae.setEvaluated=yy;var y0={};function Qz(t,e){return t.scopeValue("func",{ref:e,code:y0[e.code]||(y0[e.code]=new qz._Code(e.code))})}ae.useFunc=Qz;var hy;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(hy||(ae.Type=hy={}));function eH(t,e,n){if(t instanceof Te.Name){let r=e===hy.Num;return n?r?(0,Te._)`"[" + ${t} + "]"`:(0,Te._)`"['" + ${t} + "']"`:r?(0,Te._)`"/" + ${t}`:(0,Te._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,Te.getProperty)(t).toString():"/"+gy(t)}ae.getErrorPath=eH;function v0(t,e,n=t.opts.strictSchema){if(n){if(e=`strict mode: ${e}`,n===!0)throw new Error(e);t.self.logger.warn(e)}}ae.checkStrictMode=v0});var sr=L(_y=>{"use strict";Object.defineProperty(_y,"__esModule",{value:!0});var yt=oe(),tH={data:new yt.Name("data"),valCxt:new yt.Name("valCxt"),instancePath:new yt.Name("instancePath"),parentData:new yt.Name("parentData"),parentDataProperty:new yt.Name("parentDataProperty"),rootData:new yt.Name("rootData"),dynamicAnchors:new yt.Name("dynamicAnchors"),vErrors:new yt.Name("vErrors"),errors:new yt.Name("errors"),this:new yt.Name("this"),self:new yt.Name("self"),scope:new yt.Name("scope"),json:new yt.Name("json"),jsonPos:new yt.Name("jsonPos"),jsonLen:new yt.Name("jsonLen"),jsonPart:new yt.Name("jsonPart")};_y.default=tH});var Ca=L(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.extendErrors=_t.resetErrorsCount=_t.reportExtraError=_t.reportError=_t.keyword$DataError=_t.keywordError=void 0;var fe=oe(),fl=me(),Tt=sr();_t.keywordError={message:({keyword:t})=>(0,fe.str)`must pass "${t}" keyword validation`};_t.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,fe.str)`"${t}" keyword must be ${e} ($data)`:(0,fe.str)`"${t}" keyword is invalid ($data)`};function nH(t,e=_t.keywordError,n,r){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=E0(t,e,n);r??(i||a)?k0(s,c):w0(o,(0,fe._)`[${c}]`)}_t.reportError=nH;function rH(t,e=_t.keywordError,n){let{it:r}=t,{gen:o,compositeRule:s,allErrors:i}=r,a=E0(t,e,n);k0(o,a),s||i||w0(r,Tt.default.vErrors)}_t.reportExtraError=rH;function oH(t,e){t.assign(Tt.default.errors,e),t.if((0,fe._)`${Tt.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,fe._)`${Tt.default.vErrors}.length`,e),()=>t.assign(Tt.default.vErrors,null)))}_t.resetErrorsCount=oH;function sH({gen:t,keyword:e,schemaValue:n,data:r,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,Tt.default.errors,a=>{t.const(i,(0,fe._)`${Tt.default.vErrors}[${a}]`),t.if((0,fe._)`${i}.instancePath === undefined`,()=>t.assign((0,fe._)`${i}.instancePath`,(0,fe.strConcat)(Tt.default.instancePath,s.errorPath))),t.assign((0,fe._)`${i}.schemaPath`,(0,fe.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,fe._)`${i}.schema`,n),t.assign((0,fe._)`${i}.data`,r))})}_t.extendErrors=sH;function k0(t,e){let n=t.const("err",e);t.if((0,fe._)`${Tt.default.vErrors} === null`,()=>t.assign(Tt.default.vErrors,(0,fe._)`[${n}]`),(0,fe._)`${Tt.default.vErrors}.push(${n})`),t.code((0,fe._)`${Tt.default.errors}++`)}function w0(t,e){let{gen:n,validateName:r,schemaEnv:o}=t;o.$async?n.throw((0,fe._)`new ${t.ValidationError}(${e})`):(n.assign((0,fe._)`${r}.errors`,e),n.return(!1))}var Zo={keyword:new fe.Name("keyword"),schemaPath:new fe.Name("schemaPath"),params:new fe.Name("params"),propertyName:new fe.Name("propertyName"),message:new fe.Name("message"),schema:new fe.Name("schema"),parentSchema:new fe.Name("parentSchema")};function E0(t,e,n){let{createErrors:r}=t.it;return r===!1?(0,fe._)`{}`:iH(t,e,n)}function iH(t,e,n={}){let{gen:r,it:o}=t,s=[aH(o,n),cH(t,n)];return uH(t,e,s),r.object(...s)}function aH({errorPath:t},{instancePath:e}){let n=e?(0,fe.str)`${t}${(0,fl.getErrorPath)(e,fl.Type.Str)}`:t;return[Tt.default.instancePath,(0,fe.strConcat)(Tt.default.instancePath,n)]}function cH({keyword:t,it:{errSchemaPath:e}},{schemaPath:n,parentSchema:r}){let o=r?e:(0,fe.str)`${e}/${t}`;return n&&(o=(0,fe.str)`${o}${(0,fl.getErrorPath)(n,fl.Type.Str)}`),[Zo.schemaPath,o]}function uH(t,{params:e,message:n},r){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;r.push([Zo.keyword,o],[Zo.params,typeof e=="function"?e(t):e||(0,fe._)`{}`]),c.messages&&r.push([Zo.message,typeof n=="function"?n(t):n]),c.verbose&&r.push([Zo.schema,i],[Zo.parentSchema,(0,fe._)`${l}${d}`],[Tt.default.data,s]),u&&r.push([Zo.propertyName,u])}});var $0=L(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});Vs.boolOrEmptySchema=Vs.topBoolOrEmptySchema=void 0;var lH=Ca(),dH=oe(),pH=sr(),mH={message:"boolean schema is false"};function fH(t){let{gen:e,schema:n,validateName:r}=t;n===!1?T0(t,!1):typeof n=="object"&&n.$async===!0?e.return(pH.default.data):(e.assign((0,dH._)`${r}.errors`,null),e.return(!0))}Vs.topBoolOrEmptySchema=fH;function hH(t,e){let{gen:n,schema:r}=t;r===!1?(n.var(e,!1),T0(t)):n.var(e,!0)}Vs.boolOrEmptySchema=hH;function T0(t,e){let{gen:n,data:r}=t,o={gen:n,keyword:"false schema",data:r,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,lH.reportError)(o,mH,void 0,e)}});var by=L(Ws=>{"use strict";Object.defineProperty(Ws,"__esModule",{value:!0});Ws.getRules=Ws.isJSONType=void 0;var gH=["string","number","integer","boolean","null","object","array"],yH=new Set(gH);function _H(t){return typeof t=="string"&&yH.has(t)}Ws.isJSONType=_H;function bH(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}Ws.getRules=bH});var xy=L(zr=>{"use strict";Object.defineProperty(zr,"__esModule",{value:!0});zr.shouldUseRule=zr.shouldUseGroup=zr.schemaHasRulesForType=void 0;function xH({schema:t,self:e},n){let r=e.RULES.types[n];return r&&r!==!0&&P0(t,r)}zr.schemaHasRulesForType=xH;function P0(t,e){return e.rules.some(n=>R0(t,n))}zr.shouldUseGroup=P0;function R0(t,e){var n;return t[e.keyword]!==void 0||((n=e.definition.implements)===null||n===void 0?void 0:n.some(r=>t[r]!==void 0))}zr.shouldUseRule=R0});var Oa=L(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.reportTypeError=bt.checkDataTypes=bt.checkDataType=bt.coerceAndCheckDataType=bt.getJSONTypes=bt.getSchemaTypes=bt.DataType=void 0;var SH=by(),vH=xy(),kH=Ca(),ne=oe(),C0=me(),Ks;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Ks||(bt.DataType=Ks={}));function wH(t){let e=O0(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}bt.getSchemaTypes=wH;function O0(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(SH.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}bt.getJSONTypes=O0;function EH(t,e){let{gen:n,data:r,opts:o}=t,s=TH(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,vH.schemaHasRulesForType)(t,e[0]));if(i){let a=vy(e,r,o.strictNumbers,Ks.Wrong);n.if(a,()=>{s.length?$H(t,e,s):ky(t)})}return i}bt.coerceAndCheckDataType=EH;var I0=new Set(["string","number","integer","boolean","null"]);function TH(t,e){return e?t.filter(n=>I0.has(n)||e==="array"&&n==="array"):[]}function $H(t,e,n){let{gen:r,data:o,opts:s}=t,i=r.let("dataType",(0,ne._)`typeof ${o}`),a=r.let("coerced",(0,ne._)`undefined`);s.coerceTypes==="array"&&r.if((0,ne._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>r.assign(o,(0,ne._)`${o}[0]`).assign(i,(0,ne._)`typeof ${o}`).if(vy(e,o,s.strictNumbers),()=>r.assign(a,o))),r.if((0,ne._)`${a} !== undefined`);for(let u of n)(I0.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);r.else(),ky(t),r.endIf(),r.if((0,ne._)`${a} !== undefined`,()=>{r.assign(o,a),PH(t,a)});function c(u){switch(u){case"string":r.elseIf((0,ne._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,ne._)`"" + ${o}`).elseIf((0,ne._)`${o} === null`).assign(a,(0,ne._)`""`);return;case"number":r.elseIf((0,ne._)`${i} == "boolean" || ${o} === null |
| 492 | || (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,ne._)`+${o}`);return;case"integer":r.elseIf((0,ne._)`${i} === "boolean" || ${o} === null |
| 493 | || (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,ne._)`+${o}`);return;case"boolean":r.elseIf((0,ne._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,ne._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":r.elseIf((0,ne._)`${o} === "" || ${o} === 0 || ${o} === false`),r.assign(a,null);return;case"array":r.elseIf((0,ne._)`${i} === "string" || ${i} === "number" |
no test coverage detected