@khanglvm/relay 0.17.1 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,193 @@
1
+ var Ch=Object.defineProperty;var Th=(n,e)=>{for(var t in e)Ch(n,t,{get:e[t],enumerable:!0})};var f={};Th(f,{BRAND:()=>Jh,DIRTY:()=>Nn,EMPTY_PATH:()=>Rh,INVALID:()=>$,NEVER:()=>Lp,OK:()=>Ee,ParseStatus:()=>be,Schema:()=>U,ZodAny:()=>cn,ZodArray:()=>zt,ZodBigInt:()=>Pn,ZodBoolean:()=>Dn,ZodBranded:()=>dr,ZodCatch:()=>Wn,ZodDate:()=>Ln,ZodDefault:()=>zn,ZodDiscriminatedUnion:()=>hi,ZodEffects:()=>We,ZodEnum:()=>Bn,ZodError:()=>Ne,ZodFirstPartyTypeKind:()=>v,ZodFunction:()=>mi,ZodIntersection:()=>jn,ZodIssueCode:()=>S,ZodLazy:()=>Vn,ZodLiteral:()=>Un,ZodMap:()=>vs,ZodNaN:()=>Cs,ZodNativeEnum:()=>qn,ZodNever:()=>it,ZodNull:()=>Mn,ZodNullable:()=>bt,ZodNumber:()=>On,ZodObject:()=>Oe,ZodOptional:()=>qe,ZodParsedType:()=>k,ZodPipeline:()=>fr,ZodPromise:()=>ln,ZodReadonly:()=>Zn,ZodRecord:()=>pi,ZodSchema:()=>U,ZodSet:()=>Es,ZodString:()=>an,ZodSymbol:()=>bs,ZodTransformer:()=>We,ZodTuple:()=>St,ZodType:()=>U,ZodUndefined:()=>$n,ZodUnion:()=>Fn,ZodUnknown:()=>qt,ZodVoid:()=>As,addIssueToContext:()=>w,any:()=>op,array:()=>up,bigint:()=>tp,boolean:()=>al,coerce:()=>Dp,custom:()=>rl,date:()=>np,datetimeRegex:()=>nl,defaultErrorMap:()=>Ut,discriminatedUnion:()=>pp,effect:()=>wp,enum:()=>Ep,function:()=>bp,getErrorMap:()=>ys,getParsedType:()=>xt,instanceof:()=>Qh,intersection:()=>mp,isAborted:()=>di,isAsync:()=>xs,isDirty:()=>fi,isValid:()=>on,late:()=>Xh,lazy:()=>Ap,literal:()=>vp,makeIssue:()=>ur,map:()=>xp,nan:()=>ep,nativeEnum:()=>Cp,never:()=>cp,null:()=>ip,nullable:()=>kp,number:()=>ol,object:()=>dp,objectUtil:()=>Qo,oboolean:()=>Pp,onumber:()=>Op,optional:()=>Ip,ostring:()=>Np,pipeline:()=>_p,preprocess:()=>Rp,promise:()=>Tp,quotelessJson:()=>wh,record:()=>yp,set:()=>Sp,setErrorMap:()=>kh,strictObject:()=>fp,string:()=>il,symbol:()=>sp,transformer:()=>wp,tuple:()=>gp,undefined:()=>rp,union:()=>hp,unknown:()=>ap,util:()=>q,void:()=>lp});var q;(function(n){n.assertEqual=r=>{};function e(r){}n.assertIs=e;function t(r){throw new Error}n.assertNever=t,n.arrayToEnum=r=>{let i={};for(let o of r)i[o]=o;return i},n.getValidEnumValues=r=>{let i=n.objectKeys(r).filter(a=>typeof r[r[a]]!="number"),o={};for(let a of i)o[a]=r[a];return n.objectValues(o)},n.objectValues=r=>n.objectKeys(r).map(function(i){return r[i]}),n.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{let i=[];for(let o in r)Object.prototype.hasOwnProperty.call(r,o)&&i.push(o);return i},n.find=(r,i)=>{for(let o of r)if(i(o))return o},n.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,i=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}n.joinValues=s,n.jsonStringifyReplacer=(r,i)=>typeof i=="bigint"?i.toString():i})(q||(q={}));var Qo;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Qo||(Qo={}));var k=q.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),xt=n=>{switch(typeof n){case"undefined":return k.undefined;case"string":return k.string;case"number":return Number.isNaN(n)?k.nan:k.number;case"boolean":return k.boolean;case"function":return k.function;case"bigint":return k.bigint;case"symbol":return k.symbol;case"object":return Array.isArray(n)?k.array:n===null?k.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?k.promise:typeof Map<"u"&&n instanceof Map?k.map:typeof Set<"u"&&n instanceof Set?k.set:typeof Date<"u"&&n instanceof Date?k.date:k.object;default:return k.unknown}};var S=q.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),wh=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:"),Ne=class n extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(i){return i.message},s={_errors:[]},r=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(r);else if(o.code==="invalid_return_type")r(o.returnTypeError);else if(o.code==="invalid_arguments")r(o.argumentsError);else if(o.path.length===0)s._errors.push(t(o));else{let a=s,c=0;for(;c<o.path.length;){let l=o.path[c];c===o.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(o))):a[l]=a[l]||{_errors:[]},a=a[l],c++}}};return r(this),s}static assert(e){if(!(e instanceof n))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,q.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},s=[];for(let r of this.issues)if(r.path.length>0){let i=r.path[0];t[i]=t[i]||[],t[i].push(e(r))}else s.push(e(r));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};Ne.create=n=>new Ne(n);var Ih=(n,e)=>{let t;switch(n.code){case S.invalid_type:n.received===k.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case S.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,q.jsonStringifyReplacer)}`;break;case S.unrecognized_keys:t=`Unrecognized key(s) in object: ${q.joinValues(n.keys,", ")}`;break;case S.invalid_union:t="Invalid input";break;case S.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${q.joinValues(n.options)}`;break;case S.invalid_enum_value:t=`Invalid enum value. Expected ${q.joinValues(n.options)}, received '${n.received}'`;break;case S.invalid_arguments:t="Invalid function arguments";break;case S.invalid_return_type:t="Invalid function return type";break;case S.invalid_date:t="Invalid date";break;case S.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:q.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case S.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case S.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case S.custom:t="Invalid input";break;case S.invalid_intersection_types:t="Intersection results could not be merged";break;case S.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case S.not_finite:t="Number must be finite";break;default:t=e.defaultError,q.assertNever(n)}return{message:t}},Ut=Ih;var Jc=Ut;function kh(n){Jc=n}function ys(){return Jc}var ur=n=>{let{data:e,path:t,errorMaps:s,issueData:r}=n,i=[...t,...r.path||[]],o={...r,path:i};if(r.message!==void 0)return{...r,path:i,message:r.message};let a="",c=s.filter(l=>!!l).slice().reverse();for(let l of c)a=l(o,{data:e,defaultError:a}).message;return{...r,path:i,message:a}},Rh=[];function w(n,e){let t=ys(),s=ur({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Ut?void 0:Ut].filter(r=>!!r)});n.common.issues.push(s)}var be=class n{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let s=[];for(let r of t){if(r.status==="aborted")return $;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let r of t){let i=await r.key,o=await r.value;s.push({key:i,value:o})}return n.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let r of t){let{key:i,value:o}=r;if(i.status==="aborted"||o.status==="aborted")return $;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||r.alwaysSet)&&(s[i.value]=o.value)}return{status:e.value,value:s}}},$=Object.freeze({status:"aborted"}),Nn=n=>({status:"dirty",value:n}),Ee=n=>({status:"valid",value:n}),di=n=>n.status==="aborted",fi=n=>n.status==="dirty",on=n=>n.status==="valid",xs=n=>typeof Promise<"u"&&n instanceof Promise;var P;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e?.message})(P||(P={}));var ze=class{constructor(e,t,s,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Xc=(n,e)=>{if(on(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new Ne(n.common.issues);return this._error=t,this._error}}};function V(n){if(!n)return{};let{errorMap:e,invalid_type_error:t,required_error:s,description:r}=n;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(o,a)=>{let{message:c}=n;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??s??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??t??a.defaultError}},description:r}}var U=class{get description(){return this._def.description}_getType(e){return xt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:xt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new be,ctx:{common:e.parent.common,data:e.data,parsedType:xt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(xs(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){let s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xt(e)},r=this._parseSync({data:e,path:s.path,parent:s});return Xc(s,r)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xt(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:t});return on(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>on(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xt(e)},r=this._parse({data:e,path:s.path,parent:s}),i=await(xs(r)?r:Promise.resolve(r));return Xc(s,i)}refine(e,t){let s=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,i)=>{let o=e(r),a=()=>i.addIssue({code:S.custom,...s(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,t){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof t=="function"?t(s,r):t),!1))}_refinement(e){return new We({schema:this,typeName:v.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return qe.create(this,this._def)}nullable(){return bt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return zt.create(this)}promise(){return ln.create(this,this._def)}or(e){return Fn.create([this,e],this._def)}and(e){return jn.create(this,e,this._def)}transform(e){return new We({...V(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new zn({...V(this._def),innerType:this,defaultValue:t,typeName:v.ZodDefault})}brand(){return new dr({typeName:v.ZodBranded,type:this,...V(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Wn({...V(this._def),innerType:this,catchValue:t,typeName:v.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return fr.create(this,e)}readonly(){return Zn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},_h=/^c[^\s-]{8,}$/i,Nh=/^[0-9a-z]+$/,Oh=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ph=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Dh=/^[a-z0-9_-]{21}$/i,Lh=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,$h=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Mh=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Fh="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ea,jh=/^(?:(?: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])$/,Vh=/^(?:(?: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])$/,Uh=/^(([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]))$/,Bh=/^(([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])$/,qh=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,zh=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,el="((\\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])))",Wh=new RegExp(`^${el}$`);function tl(n){let e="[0-5]\\d";n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`);let t=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Zh(n){return new RegExp(`^${tl(n)}$`)}function nl(n){let e=`${el}T${tl(n)}`,t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Hh(n,e){return!!((e==="v4"||!e)&&jh.test(n)||(e==="v6"||!e)&&Uh.test(n))}function Gh(n,e){if(!Lh.test(n))return!1;try{let[t]=n.split(".");if(!t)return!1;let s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(s));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function Kh(n,e){return!!((e==="v4"||!e)&&Vh.test(n)||(e==="v6"||!e)&&Bh.test(n))}var an=class n extends U{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==k.string){let i=this._getOrReturnCtx(e);return w(i,{code:S.invalid_type,expected:k.string,received:i.parsedType}),$}let s=new be,r;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(r=this._getOrReturnCtx(e,r),w(r,{code:S.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if(i.kind==="max")e.data.length>i.value&&(r=this._getOrReturnCtx(e,r),w(r,{code:S.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(r=this._getOrReturnCtx(e,r),o?w(r,{code:S.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&w(r,{code:S.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),s.dirty())}else if(i.kind==="email")Mh.test(e.data)||(r=this._getOrReturnCtx(e,r),w(r,{validation:"email",code:S.invalid_string,message:i.message}),s.dirty());else if(i.kind==="emoji")ea||(ea=new RegExp(Fh,"u")),ea.test(e.data)||(r=this._getOrReturnCtx(e,r),w(r,{validation:"emoji",code:S.invalid_string,message:i.message}),s.dirty());else if(i.kind==="uuid")Ph.test(e.data)||(r=this._getOrReturnCtx(e,r),w(r,{validation:"uuid",code:S.invalid_string,message:i.message}),s.dirty());else if(i.kind==="nanoid")Dh.test(e.data)||(r=this._getOrReturnCtx(e,r),w(r,{validation:"nanoid",code:S.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid")_h.test(e.data)||(r=this._getOrReturnCtx(e,r),w(r,{validation:"cuid",code:S.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid2")Nh.test(e.data)||(r=this._getOrReturnCtx(e,r),w(r,{validation:"cuid2",code:S.invalid_string,message:i.message}),s.dirty());else if(i.kind==="ulid")Oh.test(e.data)||(r=this._getOrReturnCtx(e,r),w(r,{validation:"ulid",code:S.invalid_string,message:i.message}),s.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),w(r,{validation:"url",code:S.invalid_string,message:i.message}),s.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),w(r,{validation:"regex",code:S.invalid_string,message:i.message}),s.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(r=this._getOrReturnCtx(e,r),w(r,{code:S.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),s.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(r=this._getOrReturnCtx(e,r),w(r,{code:S.invalid_string,validation:{startsWith:i.value},message:i.message}),s.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(r=this._getOrReturnCtx(e,r),w(r,{code:S.invalid_string,validation:{endsWith:i.value},message:i.message}),s.dirty()):i.kind==="datetime"?nl(i).test(e.data)||(r=this._getOrReturnCtx(e,r),w(r,{code:S.invalid_string,validation:"datetime",message:i.message}),s.dirty()):i.kind==="date"?Wh.test(e.data)||(r=this._getOrReturnCtx(e,r),w(r,{code:S.invalid_string,validation:"date",message:i.message}),s.dirty()):i.kind==="time"?Zh(i).test(e.data)||(r=this._getOrReturnCtx(e,r),w(r,{code:S.invalid_string,validation:"time",message:i.message}),s.dirty()):i.kind==="duration"?$h.test(e.data)||(r=this._getOrReturnCtx(e,r),w(r,{validation:"duration",code:S.invalid_string,message:i.message}),s.dirty()):i.kind==="ip"?Hh(e.data,i.version)||(r=this._getOrReturnCtx(e,r),w(r,{validation:"ip",code:S.invalid_string,message:i.message}),s.dirty()):i.kind==="jwt"?Gh(e.data,i.alg)||(r=this._getOrReturnCtx(e,r),w(r,{validation:"jwt",code:S.invalid_string,message:i.message}),s.dirty()):i.kind==="cidr"?Kh(e.data,i.version)||(r=this._getOrReturnCtx(e,r),w(r,{validation:"cidr",code:S.invalid_string,message:i.message}),s.dirty()):i.kind==="base64"?qh.test(e.data)||(r=this._getOrReturnCtx(e,r),w(r,{validation:"base64",code:S.invalid_string,message:i.message}),s.dirty()):i.kind==="base64url"?zh.test(e.data)||(r=this._getOrReturnCtx(e,r),w(r,{validation:"base64url",code:S.invalid_string,message:i.message}),s.dirty()):q.assertNever(i);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(r=>e.test(r),{validation:t,code:S.invalid_string,...P.errToObj(s)})}_addCheck(e){return new n({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...P.errToObj(e)})}url(e){return this._addCheck({kind:"url",...P.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...P.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...P.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...P.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...P.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...P.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...P.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...P.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...P.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...P.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...P.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...P.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...P.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...P.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...P.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...P.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...P.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...P.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...P.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...P.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...P.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...P.errToObj(t)})}nonempty(e){return this.min(1,P.errToObj(e))}trim(){return new n({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};an.create=n=>new an({checks:[],typeName:v.ZodString,coerce:n?.coerce??!1,...V(n)});function Yh(n,e){let t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=t>s?t:s,i=Number.parseInt(n.toFixed(r).replace(".","")),o=Number.parseInt(e.toFixed(r).replace(".",""));return i%o/10**r}var On=class n extends U{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==k.number){let i=this._getOrReturnCtx(e);return w(i,{code:S.invalid_type,expected:k.number,received:i.parsedType}),$}let s,r=new be;for(let i of this._def.checks)i.kind==="int"?q.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),w(s,{code:S.invalid_type,expected:"integer",received:"float",message:i.message}),r.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(s=this._getOrReturnCtx(e,s),w(s,{code:S.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(s=this._getOrReturnCtx(e,s),w(s,{code:S.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind==="multipleOf"?Yh(e.data,i.value)!==0&&(s=this._getOrReturnCtx(e,s),w(s,{code:S.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),w(s,{code:S.not_finite,message:i.message}),r.dirty()):q.assertNever(i);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,P.toString(t))}gt(e,t){return this.setLimit("min",e,!1,P.toString(t))}lte(e,t){return this.setLimit("max",e,!0,P.toString(t))}lt(e,t){return this.setLimit("max",e,!1,P.toString(t))}setLimit(e,t,s,r){return new n({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:P.toString(r)}]})}_addCheck(e){return new n({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:P.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:P.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:P.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:P.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:P.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&q.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}};On.create=n=>new On({checks:[],typeName:v.ZodNumber,coerce:n?.coerce||!1,...V(n)});var Pn=class n extends U{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==k.bigint)return this._getInvalidInput(e);let s,r=new be;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(s=this._getOrReturnCtx(e,s),w(s,{code:S.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(s=this._getOrReturnCtx(e,s),w(s,{code:S.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),w(s,{code:S.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):q.assertNever(i);return{status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return w(t,{code:S.invalid_type,expected:k.bigint,received:t.parsedType}),$}gte(e,t){return this.setLimit("min",e,!0,P.toString(t))}gt(e,t){return this.setLimit("min",e,!1,P.toString(t))}lte(e,t){return this.setLimit("max",e,!0,P.toString(t))}lt(e,t){return this.setLimit("max",e,!1,P.toString(t))}setLimit(e,t,s,r){return new n({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:P.toString(r)}]})}_addCheck(e){return new n({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:P.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Pn.create=n=>new Pn({checks:[],typeName:v.ZodBigInt,coerce:n?.coerce??!1,...V(n)});var Dn=class extends U{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==k.boolean){let s=this._getOrReturnCtx(e);return w(s,{code:S.invalid_type,expected:k.boolean,received:s.parsedType}),$}return Ee(e.data)}};Dn.create=n=>new Dn({typeName:v.ZodBoolean,coerce:n?.coerce||!1,...V(n)});var Ln=class n extends U{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==k.date){let i=this._getOrReturnCtx(e);return w(i,{code:S.invalid_type,expected:k.date,received:i.parsedType}),$}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return w(i,{code:S.invalid_date}),$}let s=new be,r;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(r=this._getOrReturnCtx(e,r),w(r,{code:S.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),s.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(r=this._getOrReturnCtx(e,r),w(r,{code:S.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),s.dirty()):q.assertNever(i);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new n({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:P.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:P.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};Ln.create=n=>new Ln({checks:[],coerce:n?.coerce||!1,typeName:v.ZodDate,...V(n)});var bs=class extends U{_parse(e){if(this._getType(e)!==k.symbol){let s=this._getOrReturnCtx(e);return w(s,{code:S.invalid_type,expected:k.symbol,received:s.parsedType}),$}return Ee(e.data)}};bs.create=n=>new bs({typeName:v.ZodSymbol,...V(n)});var $n=class extends U{_parse(e){if(this._getType(e)!==k.undefined){let s=this._getOrReturnCtx(e);return w(s,{code:S.invalid_type,expected:k.undefined,received:s.parsedType}),$}return Ee(e.data)}};$n.create=n=>new $n({typeName:v.ZodUndefined,...V(n)});var Mn=class extends U{_parse(e){if(this._getType(e)!==k.null){let s=this._getOrReturnCtx(e);return w(s,{code:S.invalid_type,expected:k.null,received:s.parsedType}),$}return Ee(e.data)}};Mn.create=n=>new Mn({typeName:v.ZodNull,...V(n)});var cn=class extends U{constructor(){super(...arguments),this._any=!0}_parse(e){return Ee(e.data)}};cn.create=n=>new cn({typeName:v.ZodAny,...V(n)});var qt=class extends U{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ee(e.data)}};qt.create=n=>new qt({typeName:v.ZodUnknown,...V(n)});var it=class extends U{_parse(e){let t=this._getOrReturnCtx(e);return w(t,{code:S.invalid_type,expected:k.never,received:t.parsedType}),$}};it.create=n=>new it({typeName:v.ZodNever,...V(n)});var As=class extends U{_parse(e){if(this._getType(e)!==k.undefined){let s=this._getOrReturnCtx(e);return w(s,{code:S.invalid_type,expected:k.void,received:s.parsedType}),$}return Ee(e.data)}};As.create=n=>new As({typeName:v.ZodVoid,...V(n)});var zt=class n extends U{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),r=this._def;if(t.parsedType!==k.array)return w(t,{code:S.invalid_type,expected:k.array,received:t.parsedType}),$;if(r.exactLength!==null){let o=t.data.length>r.exactLength.value,a=t.data.length<r.exactLength.value;(o||a)&&(w(t,{code:o?S.too_big:S.too_small,minimum:a?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(w(t,{code:S.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(w(t,{code:S.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((o,a)=>r.type._parseAsync(new ze(t,o,t.path,a)))).then(o=>be.mergeArray(s,o));let i=[...t.data].map((o,a)=>r.type._parseSync(new ze(t,o,t.path,a)));return be.mergeArray(s,i)}get element(){return this._def.type}min(e,t){return new n({...this._def,minLength:{value:e,message:P.toString(t)}})}max(e,t){return new n({...this._def,maxLength:{value:e,message:P.toString(t)}})}length(e,t){return new n({...this._def,exactLength:{value:e,message:P.toString(t)}})}nonempty(e){return this.min(1,e)}};zt.create=(n,e)=>new zt({type:n,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...V(e)});function Ss(n){if(n instanceof Oe){let e={};for(let t in n.shape){let s=n.shape[t];e[t]=qe.create(Ss(s))}return new Oe({...n._def,shape:()=>e})}else return n instanceof zt?new zt({...n._def,type:Ss(n.element)}):n instanceof qe?qe.create(Ss(n.unwrap())):n instanceof bt?bt.create(Ss(n.unwrap())):n instanceof St?St.create(n.items.map(e=>Ss(e))):n}var Oe=class n extends U{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=q.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==k.object){let l=this._getOrReturnCtx(e);return w(l,{code:S.invalid_type,expected:k.object,received:l.parsedType}),$}let{status:s,ctx:r}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof it&&this._def.unknownKeys==="strip"))for(let l in r.data)o.includes(l)||a.push(l);let c=[];for(let l of o){let u=i[l],d=r.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new ze(r,d,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof it){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of a)c.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(l==="strict")a.length>0&&(w(r,{code:S.unrecognized_keys,keys:a}),s.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of a){let d=r.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new ze(r,d,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let d=await u.key,h=await u.value;l.push({key:d,value:h,alwaysSet:u.alwaysSet})}return l}).then(l=>be.mergeObjectSync(s,l)):be.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return P.errToObj,new n({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{let r=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:P.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new n({...this._def,unknownKeys:"strip"})}passthrough(){return new n({...this._def,unknownKeys:"passthrough"})}extend(e){return new n({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new n({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:v.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new n({...this._def,catchall:e})}pick(e){let t={};for(let s of q.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new n({...this._def,shape:()=>t})}omit(e){let t={};for(let s of q.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new n({...this._def,shape:()=>t})}deepPartial(){return Ss(this)}partial(e){let t={};for(let s of q.objectKeys(this.shape)){let r=this.shape[s];e&&!e[s]?t[s]=r:t[s]=r.optional()}return new n({...this._def,shape:()=>t})}required(e){let t={};for(let s of q.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let i=this.shape[s];for(;i instanceof qe;)i=i._def.innerType;t[s]=i}return new n({...this._def,shape:()=>t})}keyof(){return sl(q.objectKeys(this.shape))}};Oe.create=(n,e)=>new Oe({shape:()=>n,unknownKeys:"strip",catchall:it.create(),typeName:v.ZodObject,...V(e)});Oe.strictCreate=(n,e)=>new Oe({shape:()=>n,unknownKeys:"strict",catchall:it.create(),typeName:v.ZodObject,...V(e)});Oe.lazycreate=(n,e)=>new Oe({shape:n,unknownKeys:"strip",catchall:it.create(),typeName:v.ZodObject,...V(e)});var Fn=class extends U{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function r(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new Ne(a.ctx.common.issues));return w(t,{code:S.invalid_union,unionErrors:o}),$}if(t.common.async)return Promise.all(s.map(async i=>{let o={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(r);{let i,o=[];for(let c of s){let l={...t,common:{...t.common,issues:[]},parent:null},u=c._parseSync({data:t.data,path:t.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new Ne(c));return w(t,{code:S.invalid_union,unionErrors:a}),$}}get options(){return this._def.options}};Fn.create=(n,e)=>new Fn({options:n,typeName:v.ZodUnion,...V(e)});var Bt=n=>n instanceof Vn?Bt(n.schema):n instanceof We?Bt(n.innerType()):n instanceof Un?[n.value]:n instanceof Bn?n.options:n instanceof qn?q.objectValues(n.enum):n instanceof zn?Bt(n._def.innerType):n instanceof $n?[void 0]:n instanceof Mn?[null]:n instanceof qe?[void 0,...Bt(n.unwrap())]:n instanceof bt?[null,...Bt(n.unwrap())]:n instanceof dr||n instanceof Zn?Bt(n.unwrap()):n instanceof Wn?Bt(n._def.innerType):[],hi=class n extends U{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.object)return w(t,{code:S.invalid_type,expected:k.object,received:t.parsedType}),$;let s=this.discriminator,r=t.data[s],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(w(t,{code:S.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),$)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let r=new Map;for(let i of t){let o=Bt(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(r.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);r.set(a,i)}}return new n({typeName:v.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...V(s)})}};function ta(n,e){let t=xt(n),s=xt(e);if(n===e)return{valid:!0,data:n};if(t===k.object&&s===k.object){let r=q.objectKeys(e),i=q.objectKeys(n).filter(a=>r.indexOf(a)!==-1),o={...n,...e};for(let a of i){let c=ta(n[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(t===k.array&&s===k.array){if(n.length!==e.length)return{valid:!1};let r=[];for(let i=0;i<n.length;i++){let o=n[i],a=e[i],c=ta(o,a);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return t===k.date&&s===k.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}var jn=class extends U{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),r=(i,o)=>{if(di(i)||di(o))return $;let a=ta(i.value,o.value);return a.valid?((fi(i)||fi(o))&&t.dirty(),{status:t.value,value:a.data}):(w(s,{code:S.invalid_intersection_types}),$)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([i,o])=>r(i,o)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};jn.create=(n,e,t)=>new jn({left:n,right:e,typeName:v.ZodIntersection,...V(t)});var St=class n extends U{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==k.array)return w(s,{code:S.invalid_type,expected:k.array,received:s.parsedType}),$;if(s.data.length<this._def.items.length)return w(s,{code:S.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),$;!this._def.rest&&s.data.length>this._def.items.length&&(w(s,{code:S.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let i=[...s.data].map((o,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new ze(s,o,s.path,a)):null}).filter(o=>!!o);return s.common.async?Promise.all(i).then(o=>be.mergeArray(t,o)):be.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new n({...this._def,rest:e})}};St.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new St({items:n,typeName:v.ZodTuple,rest:null,...V(e)})};var pi=class n extends U{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==k.object)return w(s,{code:S.invalid_type,expected:k.object,received:s.parsedType}),$;let r=[],i=this._def.keyType,o=this._def.valueType;for(let a in s.data)r.push({key:i._parse(new ze(s,a,s.path,a)),value:o._parse(new ze(s,s.data[a],s.path,a)),alwaysSet:a in s.data});return s.common.async?be.mergeObjectAsync(t,r):be.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof U?new n({keyType:e,valueType:t,typeName:v.ZodRecord,...V(s)}):new n({keyType:an.create(),valueType:e,typeName:v.ZodRecord,...V(t)})}},vs=class extends U{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==k.map)return w(s,{code:S.invalid_type,expected:k.map,received:s.parsedType}),$;let r=this._def.keyType,i=this._def.valueType,o=[...s.data.entries()].map(([a,c],l)=>({key:r._parse(new ze(s,a,s.path,[l,"key"])),value:i._parse(new ze(s,c,s.path,[l,"value"]))}));if(s.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return $;(l.status==="dirty"||u.status==="dirty")&&t.dirty(),a.set(l.value,u.value)}return{status:t.value,value:a}})}else{let a=new Map;for(let c of o){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return $;(l.status==="dirty"||u.status==="dirty")&&t.dirty(),a.set(l.value,u.value)}return{status:t.value,value:a}}}};vs.create=(n,e,t)=>new vs({valueType:e,keyType:n,typeName:v.ZodMap,...V(t)});var Es=class n extends U{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==k.set)return w(s,{code:S.invalid_type,expected:k.set,received:s.parsedType}),$;let r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(w(s,{code:S.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(w(s,{code:S.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function o(c){let l=new Set;for(let u of c){if(u.status==="aborted")return $;u.status==="dirty"&&t.dirty(),l.add(u.value)}return{status:t.value,value:l}}let a=[...s.data.values()].map((c,l)=>i._parse(new ze(s,c,s.path,l)));return s.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,t){return new n({...this._def,minSize:{value:e,message:P.toString(t)}})}max(e,t){return new n({...this._def,maxSize:{value:e,message:P.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Es.create=(n,e)=>new Es({valueType:n,minSize:null,maxSize:null,typeName:v.ZodSet,...V(e)});var mi=class n extends U{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.function)return w(t,{code:S.invalid_type,expected:k.function,received:t.parsedType}),$;function s(a,c){return ur({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ys(),Ut].filter(l=>!!l),issueData:{code:S.invalid_arguments,argumentsError:c}})}function r(a,c){return ur({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ys(),Ut].filter(l=>!!l),issueData:{code:S.invalid_return_type,returnTypeError:c}})}let i={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof ln){let a=this;return Ee(async function(...c){let l=new Ne([]),u=await a._def.args.parseAsync(c,i).catch(p=>{throw l.addIssue(s(c,p)),l}),d=await Reflect.apply(o,this,u);return await a._def.returns._def.type.parseAsync(d,i).catch(p=>{throw l.addIssue(r(d,p)),l})})}else{let a=this;return Ee(function(...c){let l=a._def.args.safeParse(c,i);if(!l.success)throw new Ne([s(c,l.error)]);let u=Reflect.apply(o,this,l.data),d=a._def.returns.safeParse(u,i);if(!d.success)throw new Ne([r(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new n({...this._def,args:St.create(e).rest(qt.create())})}returns(e){return new n({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new n({args:e||St.create([]).rest(qt.create()),returns:t||qt.create(),typeName:v.ZodFunction,...V(s)})}},Vn=class extends U{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Vn.create=(n,e)=>new Vn({getter:n,typeName:v.ZodLazy,...V(e)});var Un=class extends U{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return w(t,{received:t.data,code:S.invalid_literal,expected:this._def.value}),$}return{status:"valid",value:e.data}}get value(){return this._def.value}};Un.create=(n,e)=>new Un({value:n,typeName:v.ZodLiteral,...V(e)});function sl(n,e){return new Bn({values:n,typeName:v.ZodEnum,...V(e)})}var Bn=class n extends U{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return w(t,{expected:q.joinValues(s),received:t.parsedType,code:S.invalid_type}),$}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return w(t,{received:t.data,code:S.invalid_enum_value,options:s}),$}return Ee(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return n.create(e,{...this._def,...t})}exclude(e,t=this._def){return n.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}};Bn.create=sl;var qn=class extends U{_parse(e){let t=q.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==k.string&&s.parsedType!==k.number){let r=q.objectValues(t);return w(s,{expected:q.joinValues(r),received:s.parsedType,code:S.invalid_type}),$}if(this._cache||(this._cache=new Set(q.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let r=q.objectValues(t);return w(s,{received:s.data,code:S.invalid_enum_value,options:r}),$}return Ee(e.data)}get enum(){return this._def.values}};qn.create=(n,e)=>new qn({values:n,typeName:v.ZodNativeEnum,...V(e)});var ln=class extends U{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.promise&&t.common.async===!1)return w(t,{code:S.invalid_type,expected:k.promise,received:t.parsedType}),$;let s=t.parsedType===k.promise?t.data:Promise.resolve(t.data);return Ee(s.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};ln.create=(n,e)=>new ln({type:n,typeName:v.ZodPromise,...V(e)});var We=class extends U{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:o=>{w(s,o),o.fatal?t.abort():t.dirty()},get path(){return s.path}};if(i.addIssue=i.addIssue.bind(i),r.type==="preprocess"){let o=r.transform(s.data,i);if(s.common.async)return Promise.resolve(o).then(async a=>{if(t.value==="aborted")return $;let c=await this._def.schema._parseAsync({data:a,path:s.path,parent:s});return c.status==="aborted"?$:c.status==="dirty"?Nn(c.value):t.value==="dirty"?Nn(c.value):c});{if(t.value==="aborted")return $;let a=this._def.schema._parseSync({data:o,path:s.path,parent:s});return a.status==="aborted"?$:a.status==="dirty"?Nn(a.value):t.value==="dirty"?Nn(a.value):a}}if(r.type==="refinement"){let o=a=>{let c=r.refinement(a,i);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(s.common.async===!1){let a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?$:(a.status==="dirty"&&t.dirty(),o(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(a=>a.status==="aborted"?$:(a.status==="dirty"&&t.dirty(),o(a.value).then(()=>({status:t.value,value:a.value}))))}if(r.type==="transform")if(s.common.async===!1){let o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!on(o))return $;let a=r.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>on(o)?Promise.resolve(r.transform(o.value,i)).then(a=>({status:t.value,value:a})):$);q.assertNever(r)}};We.create=(n,e,t)=>new We({schema:n,typeName:v.ZodEffects,effect:e,...V(t)});We.createWithPreprocess=(n,e,t)=>new We({schema:e,effect:{type:"preprocess",transform:n},typeName:v.ZodEffects,...V(t)});var qe=class extends U{_parse(e){return this._getType(e)===k.undefined?Ee(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};qe.create=(n,e)=>new qe({innerType:n,typeName:v.ZodOptional,...V(e)});var bt=class extends U{_parse(e){return this._getType(e)===k.null?Ee(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};bt.create=(n,e)=>new bt({innerType:n,typeName:v.ZodNullable,...V(e)});var zn=class extends U{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===k.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};zn.create=(n,e)=>new zn({innerType:n,typeName:v.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...V(e)});var Wn=class extends U{_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return xs(r)?r.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ne(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Ne(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};Wn.create=(n,e)=>new Wn({innerType:n,typeName:v.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...V(e)});var Cs=class extends U{_parse(e){if(this._getType(e)!==k.nan){let s=this._getOrReturnCtx(e);return w(s,{code:S.invalid_type,expected:k.nan,received:s.parsedType}),$}return{status:"valid",value:e.data}}};Cs.create=n=>new Cs({typeName:v.ZodNaN,...V(n)});var Jh=Symbol("zod_brand"),dr=class extends U{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}},fr=class n extends U{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?$:i.status==="dirty"?(t.dirty(),Nn(i.value)):this._def.out._parseAsync({data:i.value,path:s.path,parent:s})})();{let r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?$:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,t){return new n({in:e,out:t,typeName:v.ZodPipeline})}},Zn=class extends U{_parse(e){let t=this._def.innerType._parse(e),s=r=>(on(r)&&(r.value=Object.freeze(r.value)),r);return xs(t)?t.then(r=>s(r)):s(t)}unwrap(){return this._def.innerType}};Zn.create=(n,e)=>new Zn({innerType:n,typeName:v.ZodReadonly,...V(e)});function Qc(n,e){let t=typeof n=="function"?n(e):typeof n=="string"?{message:n}:n;return typeof t=="string"?{message:t}:t}function rl(n,e={},t){return n?cn.create().superRefine((s,r)=>{let i=n(s);if(i instanceof Promise)return i.then(o=>{if(!o){let a=Qc(e,s),c=a.fatal??t??!0;r.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=Qc(e,s),a=o.fatal??t??!0;r.addIssue({code:"custom",...o,fatal:a})}}):cn.create()}var Xh={object:Oe.lazycreate},v;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(v||(v={}));var Qh=(n,e={message:`Input not instance of ${n.name}`})=>rl(t=>t instanceof n,e),il=an.create,ol=On.create,ep=Cs.create,tp=Pn.create,al=Dn.create,np=Ln.create,sp=bs.create,rp=$n.create,ip=Mn.create,op=cn.create,ap=qt.create,cp=it.create,lp=As.create,up=zt.create,dp=Oe.create,fp=Oe.strictCreate,hp=Fn.create,pp=hi.create,mp=jn.create,gp=St.create,yp=pi.create,xp=vs.create,Sp=Es.create,bp=mi.create,Ap=Vn.create,vp=Un.create,Ep=Bn.create,Cp=qn.create,Tp=ln.create,wp=We.create,Ip=qe.create,kp=bt.create,Rp=We.createWithPreprocess,_p=fr.create,Np=()=>il().optional(),Op=()=>ol().optional(),Pp=()=>al().optional(),Dp={string:(n=>an.create({...n,coerce:!0})),number:(n=>On.create({...n,coerce:!0})),boolean:(n=>Dn.create({...n,coerce:!0})),bigint:(n=>Pn.create({...n,coerce:!0})),date:(n=>Ln.create({...n,coerce:!0}))};var Lp=$;var H=class extends Error{constructor(e,t="UNKNOWN_ERROR",s){super(e),this.name=this.constructor.name,this.code=t,s?.path!==void 0&&(this.path=s.path),s?.surfaceId!==void 0&&(this.surfaceId=s.surfaceId),s?.functionCallId!==void 0&&(this.functionCallId=s.functionCallId),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},b=class extends H{constructor(e,t,s="VALIDATION_ERROR",r){super(e,s,r),this.details=t}},oe=class extends H{constructor(e,t,s){super(e,"DATA_ERROR",{path:t,surfaceId:s})}},ae=class extends H{constructor(e,t,s,r){super(e,"EXPRESSION_ERROR",r),this.expression=t,this.details=s}},At=class extends H{constructor(e,t){super(e,"STATE_ERROR",t)}},R=class extends H{constructor(e,t="CATALOG_ERROR",s){super(e,t,s)}},xe=class extends b{constructor(e,t,s="INTEGRITY_ERROR",r){super(e,t,s,r),this.name="A2uiIntegrityError"}},Ie=class extends b{constructor(e,t,s="RECURSION_ERROR",r){super(e,t,s,r),this.name="A2uiRecursionError"}},re;(function(n){n.INVALID_FUNCTION_CALL="INVALID_FUNCTION_CALL",n.EXECUTION_ERROR="EXECUTION_ERROR",n.UNKNOWN_FUNCTION="UNKNOWN_FUNCTION",n.UNKNOWN_ERROR="UNKNOWN_ERROR",n.TIMEOUT="TIMEOUT",n.CANCELLED="CANCELLED",n.DISPOSED="DISPOSED",n.DUPLICATE="DUPLICATE",n.NO_LISTENER="NO_LISTENER"})(re||(re={}));var Pe=class extends H{constructor(e,t=re.UNKNOWN_ERROR,s,r){let i=t||re.UNKNOWN_ERROR;super(`[${i}] ${e}`,i),this.functionCallId=s,this.details=r,this.name="A2uiRpcError"}};var $p=/^[vV]?(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;function de(n){if(!n||typeof n!="string")return"";let e=n.trim().replace(/^[vV]/,""),t=e.indexOf("-"),s=e.indexOf("+"),r=e.length;return t!==-1&&s!==-1?r=Math.min(t,s):t!==-1?r=t:s!==-1&&(r=s),`${e.slice(0,r).replace(/_/g,".")}${e.slice(r)}`}function Mp(n){if(!n||typeof n!="string")return null;let e=n.trim().match($p);return e?{major:parseInt(e[1],10),minor:parseInt(e[2],10),patch:e[3]!==void 0?parseInt(e[3],10):0,prerelease:e[4]?e[4].split("."):[],build:e[5]?e[5].split("."):[]}:null}function un(n){if(!n)return null;if(typeof n=="object"){let e=n;return typeof e.major!="number"||!Number.isInteger(e.major)||e.major<0||typeof e.minor=="number"&&(!Number.isInteger(e.minor)||e.minor<0)||typeof e.patch=="number"&&(!Number.isInteger(e.patch)||e.patch<0)?null:{major:e.major,minor:typeof e.minor=="number"?e.minor:0,patch:typeof e.patch=="number"?e.patch:0,prerelease:Array.isArray(e.prerelease)?e.prerelease:[],build:Array.isArray(e.build)?e.build:[]}}return Mp(de(n))}function le(n){if(!n)return null;let e=un(n);if(!e)return null;if(e.patch===0&&e.prerelease.length===0&&e.build.length===0)return`${e.major}.${e.minor}`;let t=e.prerelease.length>0?`-${e.prerelease.join(".")}`:"",s=e.build.length>0?`+${e.build.join(".")}`:"";return`${e.major}.${e.minor}.${e.patch}${t}${s}`}function Fp(n,e){let t=/^\d+$/.test(n),s=/^\d+$/.test(e);return t&&s?n.length!==e.length?n.length-e.length:n<e?-1:n>e?1:0:t?-1:s?1:n<e?-1:n>e?1:0}function jp(n,e){if(n.length===0&&e.length===0)return 0;if(n.length===0)return 1;if(e.length===0)return-1;let t=Math.min(n.length,e.length);for(let s=0;s<t;s++){let r=Fp(n[s],e[s]);if(r!==0)return r}return n.length-e.length}function Wt(n,e){let t=un(n),s=un(e);return!t&&!s?0:t?s?t.major!==s.major?t.major-s.major:t.minor!==s.minor?t.minor-s.minor:t.patch!==s.patch?t.patch-s.patch:jp(t.prerelease,s.prerelease):1:-1}function z(n,e){if(!n)return!1;let t=un(n),s=un(e);return!t||!s?!1:Wt(t,s)>=0}function Ze(n){return typeof n=="object"&&n!==null&&typeof n.then=="function"}function Vp(n){if(Array.isArray(n)||typeof n!="object"||n===null)return!1;let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function Hn(n){if(Ze(n))return Promise.resolve(n).then(Hn);if(Array.isArray(n)){let e=n.map(Hn);return e.some(Ze)?Promise.all(e):n}if(Vp(n)){let e=Object.entries(n).map(([t,s])=>[t,Hn(s)]);return e.some(([,t])=>Ze(t))?Promise.all(e.map(([,t])=>t)).then(t=>Object.fromEntries(e.map(([s],r)=>[s,t[r]]))):n}return n}var dn;(function(n){n.V0_8="v0.8",n.V0_9="v0.9",n.V0_9_1="v0.9.1",n.V1_0="1.0"})(dn||(dn={}));var Up=new RegExp("^[\\p{XID_Start}_][\\p{XID_Continue}]*$","u");function fe(n,e=!1){if(!n)return!1;let t=e&&n.startsWith("@")?n.slice(1):n;return Up.test(t)}function Ts(n,e,t=!1){if(!fe(n,t))throw new R(`Invalid UAX #31 ${e}`)}function Gn(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Bp(n){if(!Gn(n))throw new b("Invalid metadata.extensions: expected a plain object.");for(let e of Object.keys(n))if(!fe(e))throw new b(`Invalid UAX #31 extension identifier: "${e}". Keys MUST be Unicode identifiers (UAX #31).`)}function Kn(n){if(n!==void 0){if(!Gn(n))throw new b("Invalid metadata: expected a plain object.");for(let e of Object.keys(n))if(e!=="extensions")throw new b(`Unexpected property "${e}" in metadata; only "extensions" is allowed.`);"extensions"in n&&n.extensions!==void 0&&Bp(n.extensions)}}function na(n){if(Array.isArray(n)){let e=n.map(t=>na(t));return Object.freeze(e)}if(Gn(n)){let e={};for(let[t,s]of Object.entries(n))s!==void 0&&Object.defineProperty(e,t,{value:na(s),enumerable:!0,configurable:!0,writable:!0});return Object.freeze(e)}return n}function cl(n,e){if(Kn(n),Kn(e),n===void 0&&e===void 0)return;if(n===void 0)return vt(e);if(e===void 0)return vt(n);let t={};if(Gn(n.extensions))for(let[r,i]of Object.entries(n.extensions))Object.defineProperty(t,r,{value:i,enumerable:!0,configurable:!0,writable:!0});if(Gn(e.extensions))for(let[r,i]of Object.entries(e.extensions))Object.defineProperty(t,r,{value:i,enumerable:!0,configurable:!0,writable:!0});let s=Object.keys(t).length>0?{extensions:t}:{};return vt(s)}function vt(n){if(n!==void 0&&(Kn(n),!(!n.extensions||Object.keys(n.extensions).length===0)))return na(n)}function qp(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!hr(n[t],e[t]))return!1;return!0}function zp(n,e){let t=Object.keys(n).filter(r=>n[r]!==void 0),s=Object.keys(e).filter(r=>e[r]!==void 0);if(t.length!==s.length)return!1;for(let r of t)if(!Object.prototype.hasOwnProperty.call(e,r)||!hr(n[r],e[r]))return!1;return!0}function hr(n,e){return Object.is(n,e)?!0:Array.isArray(n)&&Array.isArray(e)?qp(n,e):Gn(n)&&Gn(e)?zp(n,e):!1}function pr(n,e){return hr(n,e)}function ws(n,e){return n._def.a2uiChildRef=e,n}function sa(n){return n?._def?.a2uiChildRef}var Yn=ws(f.string().describe("REF:common_types.json#/$defs/ComponentId|The unique identifier for a component, used for both definitions and references within the same surface."),"component-id"),Jn=f.object({path:f.string().describe("A JSON Pointer path to a value in the data model.").optional(),"@path":f.string().describe("A JSON Pointer path to a value in the data model.").optional()}).refine(n=>n["@path"]!==void 0||n.path!==void 0,{message:"Either '@path' or 'path' must be provided."}).describe("REF:common_types.json#/$defs/DataBinding"),Zt=f.object({call:f.string().describe("The name of the function to call.").optional(),"@call":f.string().describe("The name of the function to call.").optional(),args:f.record(f.string(),f.unknown()).describe("Arguments passed to the function.").optional(),returnType:f.enum(["string","number","boolean","array","object","any","void"]).describe("The expected return type of the function call.").optional(),catalogId:f.string().describe("The catalog ID for this function, overriding any surface-level default catalogId.").optional()}).strict().refine(n=>n["@call"]!==void 0||n.call!==void 0,{message:"Either '@call' or 'call' must be provided."}).describe("REF:common_types.json#/$defs/FunctionCall|Invokes a named function, combining common function properties with the catalog function definition."),gi=f.union([f.string(),Jn,Zt]).describe("REF:common_types.json#/$defs/DynamicString|Represents a string"),ra=f.union([f.boolean(),Jn,Zt]).describe("REF:common_types.json#/$defs/DynamicBoolean|A boolean value that can be a literal, a path, or a function call returning a boolean or a validation result object (coerced to its \\'valid\\' boolean)."),yi=f.object({label:gi.optional(),description:gi.optional(),live:f.enum(["off","polite","assertive"]).default("off").describe("Controls screen reader announcements for dynamic updates (WAI-ARIA aria-live). 'polite' waits for user pause; 'assertive' interrupts immediately for alerts.").optional(),hidden:ra.optional()}).describe("REF:common_types.json#/$defs/AccessibilityAttributes|Attributes to enhance accessibility when using assistive technologies like screen readers or model understanding."),ll=f.record(f.string(),f.unknown()).superRefine((n,e)=>{for(let t in n)fe(t)||e.addIssue({path:[t],code:f.ZodIssueCode.custom,message:`Invalid extension key "${t}": Keys MUST be Unicode identifiers (UAX #31).`})}).describe("REF:#/$defs/Extensions|Optional extension metadata. Keys MUST be Unicode identifiers (UAX #31). Keys starting with 'a2ui_' are reserved for official extensions."),mr=f.object({id:Yn,accessibility:yi.optional(),catalogId:f.string().describe("The catalog ID for this component, overriding any surface-level default catalogId.").optional(),metadata:f.object({extensions:ll.optional()}).strict().describe("Optional component-level metadata for vendor extensions.").optional()}).describe("REF:common_types.json#/$defs/ComponentCommon"),ul=ws(f.union([f.array(Yn).describe("A static list of child component IDs."),f.object({componentId:Yn,path:f.string().describe("The path to the list of component property objects in the data model.")}).describe("A template for generating a dynamic list of children.")]).describe("REF:common_types.json#/$defs/ChildList"),"child-list"),Wp=f.union([f.string(),f.number(),f.boolean(),f.array(f.unknown()),Jn,Zt,f.record(f.string(),f.unknown()).refine(n=>!n||!("@path"in n)&&!("path"in n)&&!("@call"in n)&&!("call"in n))]).describe("REF:common_types.json#/$defs/DynamicValue|A value that can be a literal, a path, or a function call returning any type."),dl=f.union([f.number(),Jn,Zt]).describe("REF:common_types.json#/$defs/DynamicNumber|Represents a value that can be either a literal number, a path to a number in the data model, or a function call returning a number."),Zp=f.union([f.array(f.string()),Jn,Zt]).describe("REF:common_types.json#/$defs/DynamicStringList|Represents a value that can be either a literal array of strings, a path to a string array in the data model, or a function call returning a string array."),fl=f.object({condition:f.union([ra,Jn,Zt]).describe("Path or function call evaluating to a structured validation result object or a boolean."),message:f.string().describe("Optional fallback error message.").optional()}).describe("REF:common_types.json#/$defs/CheckRule|A single validation check rule applied to an input component. The condition function or path evaluates to a structured validation result object or a boolean (which is coerced to a validation result object)."),Hp=f.object({checks:f.array(fl).describe("A list of validation check rules to perform on the component.").optional()}).describe("REF:common_types.json#/$defs/Checkable|Properties for components that support renderer-side checks."),Gp=f.union([f.object({event:f.object({name:f.string().describe("The name of the action to be dispatched to the server."),context:f.record(f.string(),f.unknown()).describe("A JSON object containing the key-value pairs for the action context. Values can be literals or paths. Use literal values unless the value must be dynamically bound to the data model. Do NOT use paths for static IDs.").optional()}).strict().describe("The event to dispatch to the server.")}).strict().describe("Triggers a server-side event."),f.object({functionCall:Zt}).strict().describe("Executes a local client-side function."),f.object({event:f.object({name:f.string().describe("The name of the action to be dispatched to the agent."),userMessage:gi.optional(),context:f.record(f.string(),f.unknown()).describe("A JSON object containing the key-value pairs for the action context. Values can be literals or paths. Use literal values unless the value must be dynamically bound to the data model. Do NOT use paths for static IDs.").optional()}).strict().describe("The event to dispatch to the agent.")}).strict().describe("Triggers an agent-side event."),f.object({functionCall:Zt}).strict().describe("Executes a renderer or agent-side function.")]).describe("REF:common_types.json#/$defs/Action|Defines an interaction handler that can either trigger an agent-side event or execute a local renderer-side function."),hl=f.string().describe("REF:common_types.json#/$defs/CallId|The unique identifier for a function call."),Kp=Yn,Yp=f.object({call:f.string().describe("The name of the function to call.").optional(),"@call":f.string().describe("The name of the function to call.").optional(),catalogId:f.string().describe("The catalog ID for this function, overriding any surface-level default catalogId.").optional()}).refine(n=>n["@call"]!==void 0||n.call!==void 0,{message:"Either '@call' or 'call' must be provided."}).describe("REF:common_types.json#/$defs/FunctionCommon|Baseline envelope properties common to all function calls. Function-specific argument schemas ('args') are defined individually by each function in the active catalog."),Jp=f.object({call:f.literal("@index").optional(),"@call":f.literal("@index").optional(),args:f.object({offset:dl.optional()}).optional()}).refine(n=>n["@call"]!==void 0||n.call!==void 0,{message:"Either '@call' or 'call' must be '@index'."}).describe("REF:common_types.json#/$defs/IndexSystemFunction|Returns the 0-based index of the current item when rendering a dynamic list from a template. This function MUST ONLY be available when evaluating template items within a list context."),Xp=f.object({component:f.literal("Surface").optional(),child:f.literal("root").optional()}).strict().describe("REF:common_types.json#/$defs/Surface|The reserved canonical container component representing an A2UI surface. The Surface component is immutable and always has \\'child\\': \\'root\\'."),Qp=f.object({functionCallId:hl,value:f.unknown().describe("The return value of the function.").optional(),error:f.object({code:f.string(),message:f.string()}).strict().describe("An error object indicating failure of the function execution.").optional()}).strict().describe("REF:common_types.json#/$defs/FunctionResponse|The return response matching a callAgentFunction or callRendererFunction invocation."),gr={ComponentId:Yn,DataBinding:Jn,FunctionCall:Zt,DynamicString:gi,DynamicBoolean:ra,AccessibilityAttributes:yi,Extensions:ll,ComponentCommon:mr,ChildList:ul,DynamicValue:Wp,DynamicNumber:dl,DynamicStringList:Zp,CheckRule:fl,Checkable:Hp,Action:Gp,CallId:hl,Child:Kp,FunctionCommon:Yp,IndexSystemFunction:Jp,Surface:Xp,FunctionResponse:Qp};var xi=Symbol("Let zodToJsonSchema decide on which parser to use");var pl={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},ml=n=>typeof n=="string"?{...pl,name:n}:{...pl,...n};var gl=n=>{let e=ml(n),t=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:t,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([s,r])=>[r._def,{def:r._def,path:[...e.basePath,e.definitionPath,s],jsonSchema:void 0}]))}};function ia(n,e,t,s){s?.errorMessages&&t&&(n.errorMessage={...n.errorMessage,[e]:t})}function W(n,e,t,s,r){n[e]=t,ia(n,e,s,r)}var Si=(n,e)=>{let t=0;for(;t<n.length&&t<e.length&&n[t]===e[t];t++);return[(n.length-t).toString(),...e.slice(t)].join("/")};function ne(n){if(n.target!=="openAi")return{};let e=[...n.basePath,n.definitionPath,n.openAiAnyTypeName];return n.flags.hasReferencedOpenAiAnyType=!0,{$ref:n.$refStrategy==="relative"?Si(e,n.currentPath):e.join("/")}}function yl(n,e){let t={type:"array"};return n.type?._def&&n.type?._def?.typeName!==v.ZodAny&&(t.items=M(n.type._def,{...e,currentPath:[...e.currentPath,"items"]})),n.minLength&&W(t,"minItems",n.minLength.value,n.minLength.message,e),n.maxLength&&W(t,"maxItems",n.maxLength.value,n.maxLength.message,e),n.exactLength&&(W(t,"minItems",n.exactLength.value,n.exactLength.message,e),W(t,"maxItems",n.exactLength.value,n.exactLength.message,e)),t}function xl(n,e){let t={type:"integer",format:"int64"};if(!n.checks)return t;for(let s of n.checks)switch(s.kind){case"min":e.target==="jsonSchema7"?s.inclusive?W(t,"minimum",s.value,s.message,e):W(t,"exclusiveMinimum",s.value,s.message,e):(s.inclusive||(t.exclusiveMinimum=!0),W(t,"minimum",s.value,s.message,e));break;case"max":e.target==="jsonSchema7"?s.inclusive?W(t,"maximum",s.value,s.message,e):W(t,"exclusiveMaximum",s.value,s.message,e):(s.inclusive||(t.exclusiveMaximum=!0),W(t,"maximum",s.value,s.message,e));break;case"multipleOf":W(t,"multipleOf",s.value,s.message,e);break}return t}function Sl(){return{type:"boolean"}}function bi(n,e){return M(n.type._def,e)}var bl=(n,e)=>M(n.innerType._def,e);function oa(n,e,t){let s=t??e.dateStrategy;if(Array.isArray(s))return{anyOf:s.map((r,i)=>oa(n,e,r))};switch(s){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return em(n,e)}}var em=(n,e)=>{let t={type:"integer",format:"unix-time"};if(e.target==="openApi3")return t;for(let s of n.checks)switch(s.kind){case"min":W(t,"minimum",s.value,s.message,e);break;case"max":W(t,"maximum",s.value,s.message,e);break}return t};function Al(n,e){return{...M(n.innerType._def,e),default:n.defaultValue()}}function vl(n,e){return e.effectStrategy==="input"?M(n.schema._def,e):ne(e)}function El(n){return{type:"string",enum:Array.from(n.values)}}var tm=n=>"type"in n&&n.type==="string"?!1:"allOf"in n;function Cl(n,e){let t=[M(n.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),M(n.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(i=>!!i),s=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,r=[];return t.forEach(i=>{if(tm(i))r.push(...i.allOf),i.unevaluatedProperties===void 0&&(s=void 0);else{let o=i;if("additionalProperties"in i&&i.additionalProperties===!1){let{additionalProperties:a,...c}=i;o=c}else s=void 0;r.push(o)}}),r.length?{allOf:r,...s}:void 0}function Tl(n,e){let t=typeof n.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(n.value)?"array":"object"}:e.target==="openApi3"?{type:t==="bigint"?"integer":t,enum:[n.value]}:{type:t==="bigint"?"integer":t,const:n.value}}var aa,ot={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:()=>(aa===void 0&&(aa=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),aa),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-_]*$/};function Ai(n,e){let t={type:"string"};if(n.checks)for(let s of n.checks)switch(s.kind){case"min":W(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,s.value):s.value,s.message,e);break;case"max":W(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,s.value):s.value,s.message,e);break;case"email":switch(e.emailStrategy){case"format:email":at(t,"email",s.message,e);break;case"format:idn-email":at(t,"idn-email",s.message,e);break;case"pattern:zod":ke(t,ot.email,s.message,e);break}break;case"url":at(t,"uri",s.message,e);break;case"uuid":at(t,"uuid",s.message,e);break;case"regex":ke(t,s.regex,s.message,e);break;case"cuid":ke(t,ot.cuid,s.message,e);break;case"cuid2":ke(t,ot.cuid2,s.message,e);break;case"startsWith":ke(t,RegExp(`^${ca(s.value,e)}`),s.message,e);break;case"endsWith":ke(t,RegExp(`${ca(s.value,e)}$`),s.message,e);break;case"datetime":at(t,"date-time",s.message,e);break;case"date":at(t,"date",s.message,e);break;case"time":at(t,"time",s.message,e);break;case"duration":at(t,"duration",s.message,e);break;case"length":W(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,s.value):s.value,s.message,e),W(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,s.value):s.value,s.message,e);break;case"includes":{ke(t,RegExp(ca(s.value,e)),s.message,e);break}case"ip":{s.version!=="v6"&&at(t,"ipv4",s.message,e),s.version!=="v4"&&at(t,"ipv6",s.message,e);break}case"base64url":ke(t,ot.base64url,s.message,e);break;case"jwt":ke(t,ot.jwt,s.message,e);break;case"cidr":{s.version!=="v6"&&ke(t,ot.ipv4Cidr,s.message,e),s.version!=="v4"&&ke(t,ot.ipv6Cidr,s.message,e);break}case"emoji":ke(t,ot.emoji(),s.message,e);break;case"ulid":{ke(t,ot.ulid,s.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{at(t,"binary",s.message,e);break}case"contentEncoding:base64":{W(t,"contentEncoding","base64",s.message,e);break}case"pattern:zod":{ke(t,ot.base64,s.message,e);break}}break}case"nanoid":ke(t,ot.nanoid,s.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return t}function ca(n,e){return e.patternStrategy==="escape"?sm(n):n}var nm=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function sm(n){let e="";for(let t=0;t<n.length;t++)nm.has(n[t])||(e+="\\"),e+=n[t];return e}function at(n,e,t,s){n.format||n.anyOf?.some(r=>r.format)?(n.anyOf||(n.anyOf=[]),n.format&&(n.anyOf.push({format:n.format,...n.errorMessage&&s.errorMessages&&{errorMessage:{format:n.errorMessage.format}}}),delete n.format,n.errorMessage&&(delete n.errorMessage.format,Object.keys(n.errorMessage).length===0&&delete n.errorMessage)),n.anyOf.push({format:e,...t&&s.errorMessages&&{errorMessage:{format:t}}})):W(n,"format",e,t,s)}function ke(n,e,t,s){n.pattern||n.allOf?.some(r=>r.pattern)?(n.allOf||(n.allOf=[]),n.pattern&&(n.allOf.push({pattern:n.pattern,...n.errorMessage&&s.errorMessages&&{errorMessage:{pattern:n.errorMessage.pattern}}}),delete n.pattern,n.errorMessage&&(delete n.errorMessage.pattern,Object.keys(n.errorMessage).length===0&&delete n.errorMessage)),n.allOf.push({pattern:wl(e,s),...t&&s.errorMessages&&{errorMessage:{pattern:t}}})):W(n,"pattern",wl(e,s),t,s)}function wl(n,e){if(!e.applyRegexFlags||!n.flags)return n.source;let t={i:n.flags.includes("i"),m:n.flags.includes("m"),s:n.flags.includes("s")},s=t.i?n.source.toLowerCase():n.source,r="",i=!1,o=!1,a=!1;for(let c=0;c<s.length;c++){if(i){r+=s[c],i=!1;continue}if(t.i){if(o){if(s[c].match(/[a-z]/)){a?(r+=s[c],r+=`${s[c-2]}-${s[c]}`.toUpperCase(),a=!1):s[c+1]==="-"&&s[c+2]?.match(/[a-z]/)?(r+=s[c],a=!0):r+=`${s[c]}${s[c].toUpperCase()}`;continue}}else if(s[c].match(/[a-z]/)){r+=`[${s[c]}${s[c].toUpperCase()}]`;continue}}if(t.m){if(s[c]==="^"){r+=`(^|(?<=[\r
2
+ ]))`;continue}else if(s[c]==="$"){r+=`($|(?=[\r
3
+ ]))`;continue}}if(t.s&&s[c]==="."){r+=o?`${s[c]}\r
4
+ `:`[${s[c]}\r
5
+ ]`;continue}r+=s[c],s[c]==="\\"?i=!0:o&&s[c]==="]"?o=!1:!o&&s[c]==="["&&(o=!0)}try{new RegExp(r)}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`),n.source}return r}function vi(n,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"&&n.keyType?._def.typeName===v.ZodEnum)return{type:"object",required:n.keyType._def.values,properties:n.keyType._def.values.reduce((s,r)=>({...s,[r]:M(n.valueType._def,{...e,currentPath:[...e.currentPath,"properties",r]})??ne(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let t={type:"object",additionalProperties:M(n.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return t;if(n.keyType?._def.typeName===v.ZodString&&n.keyType._def.checks?.length){let{type:s,...r}=Ai(n.keyType._def,e);return{...t,propertyNames:r}}else{if(n.keyType?._def.typeName===v.ZodEnum)return{...t,propertyNames:{enum:n.keyType._def.values}};if(n.keyType?._def.typeName===v.ZodBranded&&n.keyType._def.type._def.typeName===v.ZodString&&n.keyType._def.type._def.checks?.length){let{type:s,...r}=bi(n.keyType._def,e);return{...t,propertyNames:r}}}return t}function Il(n,e){if(e.mapStrategy==="record")return vi(n,e);let t=M(n.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||ne(e),s=M(n.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||ne(e);return{type:"array",maxItems:125,items:{type:"array",items:[t,s],minItems:2,maxItems:2}}}function kl(n){let e=n.values,s=Object.keys(n.values).filter(i=>typeof e[e[i]]!="number").map(i=>e[i]),r=Array.from(new Set(s.map(i=>typeof i)));return{type:r.length===1?r[0]==="string"?"string":"number":["string","number"],enum:s}}function Rl(n){return n.target==="openAi"?void 0:{not:ne({...n,currentPath:[...n.currentPath,"not"]})}}function _l(n){return n.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var yr={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Ol(n,e){if(e.target==="openApi3")return Nl(n,e);let t=n.options instanceof Map?Array.from(n.options.values()):n.options;if(t.every(s=>s._def.typeName in yr&&(!s._def.checks||!s._def.checks.length))){let s=t.reduce((r,i)=>{let o=yr[i._def.typeName];return o&&!r.includes(o)?[...r,o]:r},[]);return{type:s.length>1?s:s[0]}}else if(t.every(s=>s._def.typeName==="ZodLiteral"&&!s.description)){let s=t.reduce((r,i)=>{let o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":return[...r,o];case"bigint":return[...r,"integer"];case"object":if(i._def.value===null)return[...r,"null"];default:return r}},[]);if(s.length===t.length){let r=s.filter((i,o,a)=>a.indexOf(i)===o);return{type:r.length>1?r:r[0],enum:t.reduce((i,o)=>i.includes(o._def.value)?i:[...i,o._def.value],[])}}}else if(t.every(s=>s._def.typeName==="ZodEnum"))return{type:"string",enum:t.reduce((s,r)=>[...s,...r._def.values.filter(i=>!s.includes(i))],[])};return Nl(n,e)}var Nl=(n,e)=>{let t=(n.options instanceof Map?Array.from(n.options.values()):n.options).map((s,r)=>M(s._def,{...e,currentPath:[...e.currentPath,"anyOf",`${r}`]})).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0));return t.length?{anyOf:t}:void 0};function Pl(n,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(n.innerType._def.typeName)&&(!n.innerType._def.checks||!n.innerType._def.checks.length))return e.target==="openApi3"?{type:yr[n.innerType._def.typeName],nullable:!0}:{type:[yr[n.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let s=M(n.innerType._def,{...e,currentPath:[...e.currentPath]});return s&&"$ref"in s?{allOf:[s],nullable:!0}:s&&{...s,nullable:!0}}let t=M(n.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return t&&{anyOf:[t,{type:"null"}]}}function Dl(n,e){let t={type:"number"};if(!n.checks)return t;for(let s of n.checks)switch(s.kind){case"int":t.type="integer",ia(t,"type",s.message,e);break;case"min":e.target==="jsonSchema7"?s.inclusive?W(t,"minimum",s.value,s.message,e):W(t,"exclusiveMinimum",s.value,s.message,e):(s.inclusive||(t.exclusiveMinimum=!0),W(t,"minimum",s.value,s.message,e));break;case"max":e.target==="jsonSchema7"?s.inclusive?W(t,"maximum",s.value,s.message,e):W(t,"exclusiveMaximum",s.value,s.message,e):(s.inclusive||(t.exclusiveMaximum=!0),W(t,"maximum",s.value,s.message,e));break;case"multipleOf":W(t,"multipleOf",s.value,s.message,e);break}return t}function Ll(n,e){let t=e.target==="openAi",s={type:"object",properties:{}},r=[],i=n.shape();for(let a in i){let c=i[a];if(c===void 0||c._def===void 0)continue;let l=im(c);l&&t&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),l=!1);let u=M(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});u!==void 0&&(s.properties[a]=u,l||r.push(a))}r.length&&(s.required=r);let o=rm(n,e);return o!==void 0&&(s.additionalProperties=o),s}function rm(n,e){if(n.catchall._def.typeName!=="ZodNever")return M(n.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(n.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function im(n){try{return n.isOptional()}catch{return!0}}var $l=(n,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return M(n.innerType._def,e);let t=M(n.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return t?{anyOf:[{not:ne(e)},t]}:ne(e)};var Ml=(n,e)=>{if(e.pipeStrategy==="input")return M(n.in._def,e);if(e.pipeStrategy==="output")return M(n.out._def,e);let t=M(n.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),s=M(n.out._def,{...e,currentPath:[...e.currentPath,"allOf",t?"1":"0"]});return{allOf:[t,s].filter(r=>r!==void 0)}};function Fl(n,e){return M(n.type._def,e)}function jl(n,e){let s={type:"array",uniqueItems:!0,items:M(n.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return n.minSize&&W(s,"minItems",n.minSize.value,n.minSize.message,e),n.maxSize&&W(s,"maxItems",n.maxSize.value,n.maxSize.message,e),s}function Vl(n,e){return n.rest?{type:"array",minItems:n.items.length,items:n.items.map((t,s)=>M(t._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((t,s)=>s===void 0?t:[...t,s],[]),additionalItems:M(n.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:n.items.length,maxItems:n.items.length,items:n.items.map((t,s)=>M(t._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((t,s)=>s===void 0?t:[...t,s],[])}}function Ul(n){return{not:ne(n)}}function Bl(n){return ne(n)}var ql=(n,e)=>M(n.innerType._def,e);var zl=(n,e,t)=>{switch(e){case v.ZodString:return Ai(n,t);case v.ZodNumber:return Dl(n,t);case v.ZodObject:return Ll(n,t);case v.ZodBigInt:return xl(n,t);case v.ZodBoolean:return Sl();case v.ZodDate:return oa(n,t);case v.ZodUndefined:return Ul(t);case v.ZodNull:return _l(t);case v.ZodArray:return yl(n,t);case v.ZodUnion:case v.ZodDiscriminatedUnion:return Ol(n,t);case v.ZodIntersection:return Cl(n,t);case v.ZodTuple:return Vl(n,t);case v.ZodRecord:return vi(n,t);case v.ZodLiteral:return Tl(n,t);case v.ZodEnum:return El(n);case v.ZodNativeEnum:return kl(n);case v.ZodNullable:return Pl(n,t);case v.ZodOptional:return $l(n,t);case v.ZodMap:return Il(n,t);case v.ZodSet:return jl(n,t);case v.ZodLazy:return()=>n.getter()._def;case v.ZodPromise:return Fl(n,t);case v.ZodNaN:case v.ZodNever:return Rl(t);case v.ZodEffects:return vl(n,t);case v.ZodAny:return ne(t);case v.ZodUnknown:return Bl(t);case v.ZodDefault:return Al(n,t);case v.ZodBranded:return bi(n,t);case v.ZodReadonly:return ql(n,t);case v.ZodCatch:return bl(n,t);case v.ZodPipeline:return Ml(n,t);case v.ZodFunction:case v.ZodVoid:case v.ZodSymbol:return;default:return(s=>{})(e)}};function M(n,e,t=!1){let s=e.seen.get(n);if(e.override){let a=e.override?.(n,e,s,t);if(a!==xi)return a}if(s&&!t){let a=om(s,e);if(a!==void 0)return a}let r={def:n,path:e.currentPath,jsonSchema:void 0};e.seen.set(n,r);let i=zl(n,n.typeName,e),o=typeof i=="function"?M(i(),e):i;if(o&&am(n,e,o),e.postProcess){let a=e.postProcess(o,n,e);return r.jsonSchema=o,a}return r.jsonSchema=o,o}var om=(n,e)=>{switch(e.$refStrategy){case"root":return{$ref:n.path.join("/")};case"relative":return{$ref:Si(e.currentPath,n.path)};case"none":case"seen":return n.path.length<e.currentPath.length&&n.path.every((t,s)=>e.currentPath[s]===t)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),ne(e)):e.$refStrategy==="seen"?ne(e):void 0}},am=(n,e,t)=>(n.description&&(t.description=n.description,e.markdownDescription&&(t.markdownDescription=n.description)),t);var Fe=(n,e)=>{let t=gl(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[l,u])=>({...c,[l]:M(u._def,{...t,currentPath:[...t.basePath,t.definitionPath,l]},!0)??ne(t)}),{}):void 0,r=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,i=M(n._def,r===void 0?t:{...t,currentPath:[...t.basePath,t.definitionPath,r]},!1)??ne(t),o=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;o!==void 0&&(i.title=o),t.flags.hasReferencedOpenAiAnyType&&(s||(s={}),s[t.openAiAnyTypeName]||(s[t.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:t.$refStrategy==="relative"?"1":[...t.basePath,t.definitionPath,t.openAiAnyTypeName].join("/")}}));let a=r===void 0?s?{...i,[t.definitionPath]:s}:i:{$ref:[...t.$refStrategy==="relative"?[]:t.basePath,t.definitionPath,r].join("/"),[t.definitionPath]:{...s,[r]:i}};return t.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(t.target==="jsonSchema2019-09"||t.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),t.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 Wl=new WeakSet;function Zl(n){let e=f.any().superRefine((t,s)=>{let r=0;for(let i of n)if(i.safeParse(t).success&&++r>1){s.addIssue({code:f.ZodIssueCode.custom,message:"Value matched more than one schema in oneOf"});return}});return Wl.add(e._def),e.pipe(f.union(n))}var He=(n,e)=>{let t=n;if(!t.in||!t.out||!Wl.has(t.in._def))return xi;let r=t.out._def.options.map((i,o)=>M(i._def,{...e,currentPath:[...e.currentPath,"oneOf",`${o}`]})).filter(i=>i!==void 0);return n.description===void 0?{oneOf:r}:{oneOf:r,description:n.description}};var xr=new WeakMap;function br(n){return xr.get(n)}function Gl(n,e){for(let[t,s]of Object.entries(e)){let r=!1,i;Object.defineProperty(n,t,{enumerable:!0,get(){return r||(i=s(),r=!0),i}})}}function la(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Hl(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"):void 0}var Ei=class{constructor(e,t,s){this.name=e,xr.set(this,t),Gl(this,{schema:()=>s(t),allowedParents:()=>Hl(t.allowedParents),allowedChildren:()=>Hl(t.allowedChildren),metadata:()=>la(t.metadata)?t.metadata:void 0}),Object.freeze(this)}get jsonSchema(){return xr.get(this)}},Sr=class{constructor(e,t,s){this.name=e,xr.set(this,t);let r=la(t.properties)?t.properties:void 0,i=o=>{let a=r?.[o];return la(a)?a.const:void 0};Gl(this,{schema:()=>s(t),returnType:()=>{let o=t.returnType??i("returnType");return typeof o=="string"?o:"any"},description:()=>typeof t.description=="string"?t.description:void 0,allowedCallers:()=>t.allowedCallers??i("allowedCallers"),requiresUserActivation:()=>t.requiresUserActivation??i("requiresUserActivation")}),Object.freeze(this)}get jsonSchema(){return xr.get(this)}};var cm=new WeakMap;function Is(n){return typeof n=="object"&&n!==null?cm.get(n):void 0}var Kl={childRefNames:new Set(["ComponentId","Child","ChildComponentId"]),childListRefNames:new Set(["ChildList","TemplateChildList"]),childPropertyNames:new Set(["child","entryPointChild","contentChild"])},Yl={ComponentId:{description:"The unique identifier for a component, used for both definitions and references within the same surface.",type:"string"},TextItem:{additionalProperties:!1,description:"The value of the text field. This can be a literal string or a reference to a value in the data model ('path', e.g. '/user/name').",properties:{literalString:{type:"string"},path:{type:"string"}},type:"object"},UrlItem:{additionalProperties:!1,description:"The URL of the audio to be played. This can be a literal string ('literal') or a reference to a value in the data model ('path', e.g. '/song/url').",properties:{literalString:{type:"string"},path:{type:"string"}},type:"object"},AltTextItem:{additionalProperties:!1,description:"The alt text for the image. This can be a literal string ('literal') or a reference to a value in the data model ('path', e.g. '/thumbnail/altText').",properties:{literalString:{type:"string"},path:{type:"string"}},type:"object"},NameItem:{additionalProperties:!1,description:"The name of the icon to display. This can be a literal string or a reference to a value in the data model ('path', e.g. '/form/submit').",properties:{literalString:{enum:["accountCircle","add","arrowBack","arrowForward","attachFile","calendarToday","call","camera","check","close","delete","download","edit","event","error","favorite","favoriteOff","folder","help","home","info","locationOn","lock","lockOpen","mail","menu","moreVert","moreHoriz","notificationsOff","notifications","payment","person","phone","photo","print","refresh","search","send","settings","share","shoppingCart","star","starHalf","starOff","upload","visibility","visibilityOff","warning"],type:"string"},path:{type:"string"}},type:"object"},DescriptionItem:{additionalProperties:!1,description:"A description of the audio, such as a title or summary. This can be a literal string or a reference to a value in the data model ('path', e.g. '/song/title').",properties:{literalString:{type:"string"},path:{type:"string"}},type:"object"},ChildrenItem:{additionalProperties:!1,description:"Defines the children. Use 'explicitList' for a fixed set of children, or 'template' to generate children from a data list.",properties:{explicitList:{items:{type:"string"},type:"array"},template:{$ref:"#/$defs/TemplateItem",description:"A template for generating a dynamic list of children from a data model list. `componentId` is the component to use as a template, and `dataBinding` is the path to the map of components in the data model. Values in the map will define the list of children."}},type:"object"},TemplateItem:{additionalProperties:!1,description:"A template for generating a dynamic list of children from a data model list. `componentId` is the component to use as a template, and `dataBinding` is the path to the map of components in the data model. Values in the map will define the list of children.",properties:{componentId:{type:"string"},dataBinding:{type:"string"}},required:["componentId","dataBinding"],type:"object"},TabItemItem:{additionalProperties:!1,properties:{child:{type:"string"},title:{$ref:"#/$defs/TitleItem"}},required:["title","child"],type:"object"},TitleItem:{additionalProperties:!1,description:"The tab title. Defines the value as either a literal value or a path to data model value (e.g. '/options/title').",properties:{literalString:{type:"string"},path:{type:"string"}},type:"object"},ActionItem:{additionalProperties:!1,description:"The client-side action to be dispatched when the button is clicked. It includes the action's name and an optional context payload.",properties:{context:{items:{$ref:"#/$defs/ContextItem"},type:"array"},name:{type:"string"}},required:["name"],type:"object"},ContextItem:{additionalProperties:!1,properties:{key:{type:"string"},value:{$ref:"#/$defs/ValueItem",description:"Defines the value to be included in the context as either a literal value or a path to a data model value (e.g. '/user/name')."}},required:["key","value"],type:"object"},ValueItem:{additionalProperties:!1,description:"The current value of the slider. This can be a literal number ('literalNumber') or a reference to a value in the data model ('path', e.g. '/restaurant/cost').",properties:{literalNumber:{type:"number"},path:{type:"string"}},type:"object"},LabelItem:{additionalProperties:!1,description:"The label for the slider. This can be a literal string or a reference to a value in the data model ('path').",properties:{literalString:{type:"string"},path:{type:"string"}},type:"object"},OptionItem:{additionalProperties:!1,properties:{label:{$ref:"#/$defs/LabelItem",description:"The text to display for this option. This can be a literal string or a reference to a value in the data model (e.g. '/option/label')."},value:{description:"The value to be associated with this option when selected.",type:"string"}},required:["label","value"],type:"object"},SelectionItem:{additionalProperties:!1,description:"The currently selected values for the component. This can be a literal array of strings or a path to an array in the data model('path', e.g. '/hotel/options').",properties:{literalArray:{items:{type:"string"},type:"array"},path:{type:"string"}},type:"object"}};var Jl={childRefNames:new Set(["ComponentId","Child","ChildComponentId"]),childListRefNames:new Set(["ChildList","TemplateChildList","ChildrenItem","TemplateItem"])},Xn={ComponentId:{type:"string",description:"The unique identifier for a component, used for both definitions and references within the same surface."},AccessibilityAttributes:{type:"object",description:"Attributes to enhance accessibility when using assistive technologies like screen readers.",properties:{label:{$ref:"#/$defs/DynamicString",description:"A short string, typically 1 to 3 words, used by assistive technologies to convey the purpose or intent of an element. For example, an input field might have an accessible label of 'User ID' or a button might be labeled 'Submit'."},description:{$ref:"#/$defs/DynamicString",description:"Additional information provided by assistive technologies about an element such as instructions, format requirements, or result of an action. For example, a mute button might have a label of 'Mute' and a description of 'Silences notifications about this conversation'."}}},ComponentCommon:{type:"object",properties:{id:{$ref:"#/$defs/ComponentId"},accessibility:{$ref:"#/$defs/AccessibilityAttributes"}},required:["id"]},ChildList:{oneOf:[{type:"array",description:"A static list of child component IDs.",items:{$ref:"#/$defs/ComponentId"}},{type:"object",description:"A template for generating a dynamic list of children from a data model list. The `componentId` is the component to use as a template.",properties:{componentId:{$ref:"#/$defs/ComponentId"},path:{type:"string",description:"The path to the list of component property objects in the data model."}},required:["componentId","path"],additionalProperties:!1}]},DataBinding:{type:"object",properties:{path:{type:"string",description:"A JSON Pointer path to a value in the data model."}},required:["path"],additionalProperties:!1},DynamicValue:{description:"A value that can be a literal, a path, or a function call returning any type.",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{$ref:"#/$defs/DataBinding"},{$ref:"#/$defs/FunctionCall"}]},DynamicString:{description:"Represents a string",oneOf:[{type:"string"},{$ref:"#/$defs/DataBinding"},{allOf:[{$ref:"#/$defs/FunctionCall"},{properties:{returnType:{const:"string"}}}]}]},DynamicNumber:{description:"Represents a value that can be either a literal number, a path to a number in the data model, or a function call returning a number.",oneOf:[{type:"number"},{$ref:"#/$defs/DataBinding"},{allOf:[{$ref:"#/$defs/FunctionCall"},{properties:{returnType:{const:"number"}}}]}]},DynamicBoolean:{description:"A boolean value that can be a literal, a path, or a function call returning a boolean.",oneOf:[{type:"boolean"},{$ref:"#/$defs/DataBinding"},{allOf:[{$ref:"#/$defs/FunctionCall"},{properties:{returnType:{const:"boolean"}}}]}]},DynamicStringList:{description:"Represents a value that can be either a literal array of strings, a path to a string array in the data model, or a function call returning a string array.",oneOf:[{type:"array",items:{type:"string"}},{$ref:"#/$defs/DataBinding"},{allOf:[{$ref:"#/$defs/FunctionCall"},{properties:{returnType:{const:"array"}}}]}]},FunctionCall:{type:"object",description:"Invokes a named function on the client.",properties:{call:{type:"string",description:"The name of the function to call."},args:{type:"object",description:"Arguments passed to the function.",additionalProperties:{anyOf:[{$ref:"#/$defs/DynamicValue"},{type:"object",description:"A literal object argument (e.g. configuration)."}]}},returnType:{type:"string",description:"The expected return type of the function call.",enum:["string","number","boolean","array","object","any","void"],default:"boolean"}},required:["call"],oneOf:[{$ref:"catalog.json#/$defs/anyFunction"}]},CheckRule:{type:"object",description:"A single validation rule applied to an input component.",properties:{condition:{$ref:"#/$defs/DynamicBoolean"},message:{type:"string",description:"The error message to display if the check fails."}},required:["condition","message"],additionalProperties:!1},Checkable:{type:"object",description:"Properties for components that support client-side checks.",properties:{checks:{type:"array",description:"A list of checks to perform. These are function calls that must return a boolean indicating validity.",items:{$ref:"#/$defs/CheckRule"}}}},Action:{description:"Defines an interaction handler that can either trigger a server-side event or execute a local client-side function.",oneOf:[{type:"object",description:"Triggers a server-side event.",properties:{event:{type:"object",description:"The event to dispatch to the server.",properties:{name:{type:"string",description:"The name of the action to be dispatched to the server."},context:{type:"object",description:"A JSON object containing the key-value pairs for the action context. Values can be literals or paths. Use literal values unless the value must be dynamically bound to the data model. Do NOT use paths for static IDs.",additionalProperties:{$ref:"#/$defs/DynamicValue"}}},required:["name"],additionalProperties:!1}},required:["event"],additionalProperties:!1},{type:"object",description:"Executes a local client-side function.",properties:{functionCall:{$ref:"#/$defs/FunctionCall"}},required:["functionCall"],additionalProperties:!1}]}};var ua={childRefNames:new Set(["ComponentId","Child","ChildComponentId"]),childListRefNames:new Set(["ChildList","TemplateChildList","ChildrenItem","TemplateItem"])},ks={ComponentId:{type:"string",description:"The unique identifier for a component, used for both definitions and references within the same surface."},CallId:{type:"string",description:"The unique identifier for a function call."},AccessibilityAttributes:{type:"object",description:"Attributes to enhance accessibility when using assistive technologies like screen readers or model understanding.",properties:{label:{$ref:"#/$defs/DynamicString",description:"A short string, typically 1 to 3 words, used by assistive technologies to convey the purpose or intent of an element. For example, an input field might have an accessible label of 'User ID' or a button might be labeled 'Submit'."},description:{$ref:"#/$defs/DynamicString",description:"Additional information provided by assistive technologies about an element such as instructions, format requirements, or result of an action. For example, a mute button might have a label of 'Mute' and a description of 'Silences notifications about this conversation'."},live:{type:"string",description:"Controls screen reader announcements for dynamic updates (WAI-ARIA aria-live). 'polite' waits for user pause; 'assertive' interrupts immediately for alerts.",enum:["off","polite","assertive"],default:"off"},hidden:{$ref:"#/$defs/DynamicBoolean",description:"Hides the element and its children from assistive technologies when true. Default is false."}},additionalProperties:!1},Extensions:{type:"object",description:"Optional extension metadata. Keys MUST be Unicode identifiers (UAX #31). Keys starting with 'a2ui_' are reserved for official extensions.",patternProperties:{"^[\\p{XID_Start}_][\\p{XID_Continue}]*$":{}},additionalProperties:!1},ComponentCommon:{type:"object",properties:{id:{$ref:"#/$defs/ComponentId"},catalogId:{type:"string",description:"The catalog ID for this component, overriding any surface-level default catalogId."},accessibility:{$ref:"#/$defs/AccessibilityAttributes"},metadata:{type:"object",description:"Optional component-level metadata for vendor extensions.",properties:{extensions:{$ref:"#/$defs/Extensions"}},additionalProperties:!1}},required:["id"]},Child:{$ref:"#/$defs/ComponentId",description:"A reference to a single child component ID."},ChildList:{oneOf:[{type:"array",description:"A static list of child component IDs.",items:{$ref:"#/$defs/ComponentId"}},{type:"object",description:"A template for generating a dynamic list of children from a data model list. The `componentId` is the component to use as a template.",properties:{componentId:{$ref:"#/$defs/ComponentId"},path:{type:"string",description:"The path to the list of component property objects in the data model."}},required:["componentId","path"],additionalProperties:!1}]},DataBinding:{type:"object",properties:{"@path":{type:"string",description:"A JSON Pointer path to a value in the data model."}},required:["@path"],additionalProperties:!1},DynamicValue:{description:"A value that can be a literal, a path, or a function call returning any type.",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{type:"object",propertyNames:{not:{pattern:"^@([^@]|$)"}},not:{anyOf:[{required:["@path"]},{required:["@call"]}]}},{$ref:"#/$defs/DataBinding"},{$ref:"#/$defs/FunctionCall"}]},DynamicString:{description:"Represents a string",oneOf:[{type:"string"},{$ref:"#/$defs/DataBinding"},{$ref:"#/$defs/FunctionCall"}]},DynamicNumber:{description:"Represents a value that can be either a literal number, a path to a number in the data model, or a function call returning a number.",oneOf:[{type:"number"},{$ref:"#/$defs/DataBinding"},{$ref:"#/$defs/FunctionCall"}]},DynamicBoolean:{description:"A boolean value that can be a literal, a path, or a function call returning a boolean or a validation result object (coerced to its 'valid' boolean).",oneOf:[{type:"boolean"},{$ref:"#/$defs/DataBinding"},{$ref:"#/$defs/FunctionCall"}]},DynamicStringList:{description:"Represents a value that can be either a literal array of strings, a path to a string array in the data model, or a function call returning a string array.",oneOf:[{type:"array",items:{type:"string"}},{$ref:"#/$defs/DataBinding"},{$ref:"#/$defs/FunctionCall"}]},FunctionCommon:{type:"object",description:"Baseline envelope properties common to all function calls. Function-specific argument schemas ('args') are defined individually by each function in the active catalog.",properties:{"@call":{type:"string",description:"The name of the function to call."},catalogId:{type:"string",description:"The catalog ID for this function, overriding any surface-level default catalogId."}},required:["@call"]},IndexSystemFunction:{type:"object",description:"Returns the 0-based index of the current item when rendering a dynamic list from a template. This function MUST ONLY be available when evaluating template items within a list context.",properties:{"@call":{const:"@index"},args:{type:"object",properties:{offset:{$ref:"#/$defs/DynamicNumber",description:"Optional. An offset to add to the 0-based index (e.g., 1 for 1-based indexing). Defaults to 0.",default:0}},unevaluatedProperties:!1}},required:["@call"],unevaluatedProperties:!1},FunctionCall:{type:"object",description:"Invokes a named function, combining common function properties with the catalog function definition.",allOf:[{$ref:"#/$defs/FunctionCommon"},{oneOf:[{$ref:"catalog.json#/$defs/anyFunction"},{$ref:"#/$defs/IndexSystemFunction"}]}],unevaluatedProperties:!1},CheckRule:{type:"object",description:"A single validation check rule applied to an input component. The condition function or path evaluates to a structured validation result object or a boolean (which is coerced to a validation result object).",properties:{condition:{description:"Path or function call evaluating to a structured validation result object or a boolean.",oneOf:[{$ref:"#/$defs/DataBinding"},{$ref:"#/$defs/FunctionCall"}]},message:{type:"string",description:"Optional fallback error message."}},required:["condition"],additionalProperties:!1},Checkable:{type:"object",description:"Properties for components that support renderer-side checks.",properties:{checks:{type:"array",description:"A list of validation check rules to perform on the component.",items:{$ref:"#/$defs/CheckRule"}}}},Action:{description:"Defines an interaction handler that can either trigger an agent-side event or execute a local renderer-side function.",oneOf:[{type:"object",description:"Triggers an agent-side event.",properties:{event:{type:"object",description:"The event to dispatch to the agent.",properties:{name:{type:"string",description:"The name of the action to be dispatched to the agent."},userMessage:{$ref:"#/$defs/DynamicString",description:"An optional human-readable message describing the action performed by the user, resolved by the renderer and included in the outbound action message."},context:{type:"object",description:"A JSON object containing the key-value pairs for the action context. Values can be literals or paths. Use literal values unless the value must be dynamically bound to the data model. Do NOT use paths for static IDs.",additionalProperties:{$ref:"#/$defs/DynamicValue"}}},required:["name"],additionalProperties:!1}},required:["event"],additionalProperties:!1},{type:"object",description:"Executes a renderer or agent-side function.",properties:{functionCall:{$ref:"#/$defs/FunctionCall"}},required:["functionCall"],additionalProperties:!1}]},Surface:{title:"Surface Container Component",description:"The reserved canonical container component representing an A2UI surface. The Surface component is immutable and always has 'child': 'root'.",type:"object",allowedParents:[],properties:{component:{const:"Surface"},child:{const:"root"}},additionalProperties:!1},FunctionResponse:{type:"object",description:"The return response matching a callAgentFunction or callRendererFunction invocation.",properties:{functionCallId:{$ref:"#/$defs/CallId",description:"The unique ID matching the initiating function call."},value:{description:"The return value of the function."},error:{type:"object",description:"An error object indicating failure of the function execution.",properties:{code:{type:"string"},message:{type:"string"}},required:["code","message"],additionalProperties:!1}},required:["functionCallId"],oneOf:[{required:["value"]},{required:["error"]}],additionalProperties:!1}};var fn="common_types.json",Xl={"0.8":Yl,"0.9":Xn,"0.9.1":Xn,"1.0":ks};function ga(n){if(n){let e=le(n)??de(n);if(e in Xl)return Xl[e];if(z(n,"1.0"))return ks}return Xn}function Ql(n){return JSON.parse(JSON.stringify(n))}function Ge(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var ya=8;function eu(n){return n===null?"null":Array.isArray(n)?"array":typeof n}function ha(n,e,t){let s=n;for(let r=0;Ge(s)&&typeof s.$ref=="string";r++){if(r+t>ya)return;s=e(s.$ref)}return Ge(s)?s:void 0}function tu(n){let e=n.type;if(typeof e=="string"||Array.isArray(e))return new Set([].concat(e).map(t=>t==="integer"?"number":String(t)));if(Object.hasOwn(n,"const"))return new Set([eu(n.const)]);if(Array.isArray(n.enum))return new Set(n.enum.map(eu))}function nu(n){let e;if(Object.hasOwn(n,"const"))e=[n.const];else if(Array.isArray(n.enum))e=n.enum;else return;if(!e.some(t=>typeof t=="object"&&t!==null))return e.map(t=>JSON.stringify(t))}function pa(n,e,t){let s=new Set;if(Array.isArray(n.required))for(let r of n.required)s.add(String(r));if(t<ya&&Array.isArray(n.allOf))for(let r of n.allOf){let i=ha(r,e,t+1);if(i)for(let o of pa(i,e,t+1))s.add(o)}return s}function su(n){if(n.additionalProperties!==!1||Object.hasOwn(n,"patternProperties"))return;let e=n.properties;return new Set(Ge(e)?Object.keys(e):[])}function ru(n,e){let t=n.properties;return Ge(t)?t[e]:void 0}function au(n,e,t,s=0){if(s>ya)return!1;let r=ha(n,t,s),i=ha(e,t,s);if(!r||!i)return!1;let o=tu(r),a=tu(i);if(o&&a&&![...o].some(g=>a.has(g)))return!0;let c=nu(r),l=nu(i);if(c&&l&&!c.some(g=>l.includes(g)))return!0;let u=g=>g!==void 0&&g.size===1&&g.has("object");if(!u(o)||!u(a))return!1;let d=pa(r,t,s),h=pa(i,t,s),p=su(r),m=su(i);return p&&[...h].some(g=>!p.has(g))||m&&[...d].some(g=>!m.has(g))?!0:[...d].some(g=>h.has(g)&&au(ru(r,g),ru(i,g),t,s+1))}function Qn(n){return n._def}var da=new Set(["id","component"]);function cu(n){return Rs(n).mixins!==void 0}function lu(n){return Object.keys(Rs(n)).length>0}function Ht(n,e,t=new Set){if(!Ge(n)||n.default!==void 0)return!1;if(Array.isArray(n.required)&&n.required.length>0||typeof n.minProperties=="number"&&n.minProperties>0)return!0;let s=n.$ref;if(typeof s=="string"&&e&&s.startsWith("#/$defs/")&&!t.has(s)){let r=e;for(let i of s.slice(8).split("/")){let o=i.replace(/~1/g,"/").replace(/~0/g,"~");r=Ge(r)&&Object.hasOwn(r,o)?r[o]:void 0}if(r!==void 0&&Ht(r,e,new Set(t).add(s)))return!0}return!!(Array.isArray(n.allOf)&&n.allOf.some(r=>Ht(r,e,t))||Array.isArray(n.oneOf)&&n.oneOf.length>0&&n.oneOf.every(r=>Ht(r,e,t))||Array.isArray(n.anyOf)&&n.anyOf.length>0&&n.anyOf.every(r=>Ht(r,e,t)))}function Rs(n,e){let t=[],s=e?Is(e):void 0,r=n;for(;r&&typeof r=="object"&&"_def"in r;){let i=Is(r);if(e!==void 0&&(r===e||i&&i===s))break;i&&t.push(i);let o=Ar(r);if(!o)break;r=o}return t.reduceRight((i,o)=>({...i,...o}),{})}function Ar(n){let e=Qn(n);switch(e.typeName){case"ZodOptional":case"ZodDefault":case"ZodCatch":case"ZodReadonly":return e.innerType;case"ZodEffects":return e.schema;case"ZodBranded":return e.type;default:return}}var vr=class{constructor(e,t=fn){this.commonTypesUri=t,this.standardDefsInCatalog=new Map,this.isV08=!z(e,"0.9"),this.isV10=z(e,"1.0"),this.standardDefs=ga(e)}componentSchema(e,t,s,r){let i=new Map,o;if(this.isV08){o=this.toJson(t,i);let a=o.properties;if(Ge(a))for(let c of da)delete a[c];if(Array.isArray(o.required)){let c=o.required.filter(l=>!da.has(l));c.length>0?o.required=c:delete o.required}}else{let a=Rs(t),c=a.mixins??[],l=new Set(da),u=[];for(let A of c){u.push({$ref:this.mixinRef(A,i)});for(let I of this.mixinProperties(A))l.add(I)}let d=fa(t),h=lm(t),p=this.objectSchema(d,a,A=>!l.has(A),i),m={component:{const:e},...p.properties},g=["component",...p.required??[]],E={type:"object"};h!==void 0&&!this.isV10&&(E.description=h),E.properties=m,E.required=g,o={type:"object"},this.isV10?(h!==void 0&&(o.description=h),u.length>0?o.allOf=[...u,E]:(o.properties=m,o.required=g)):(o.allOf=[...u,E],o.unevaluatedProperties=!1)}return s&&s.length>0&&(o.allowedParents=[...s]),r&&r.length>0&&(o.allowedChildren=[...r]),{schema:o,catalogDefs:i}}functionSchema(e,t,s,r){let i=this.toJson(t.schema,r),o=Ht(i,s),a={type:"object"};return t.description&&(a.description=t.description),this.isV10?(a.returnType=t.returnType,t.allowedCallers&&(a.allowedCallers=t.allowedCallers),t.requiresUserActivation&&(a.requiresUserActivation=!0),a.properties={"@call":{const:e},args:i},a.required=o?["@call","args"]:["@call"],a):(t.allowedCallers&&(a.allowedCallers=t.allowedCallers),t.requiresUserActivation&&(a.requiresUserActivation=!0),a.properties={call:{const:e},args:i,returnType:{const:t.returnType}},a.required=o?["call","args"]:["call"],a.unevaluatedProperties=!1,a)}defSchema(e,t){return this.toJson(e,t,!0)}mixinRef(e,t){if(typeof e=="string")return`${this.commonTypesUri}#/$defs/${e}`;let s=Rs(e).defName;if(s===void 0)throw new Error("A component mixin model must be named with specDef().");return t.set(s,e),`#/$defs/${s}`}mixinProperties(e){if(typeof e!="string"){let r=fa(e);return Qn(r).typeName==="ZodObject"?Object.keys(r.shape):[]}let t=[],s=(r,i)=>{if(!(!Ge(r)||i.has(r))){i.add(r),Ge(r.properties)&&t.push(...Object.keys(r.properties));for(let o of Array.isArray(r.allOf)?r.allOf:[]){let a=Ge(o)?o.$ref:void 0,c=typeof a=="string"&&a.startsWith("#/$defs/")?this.standardDefs[a.substring(8)]:o;s(c,i)}}};return s(this.standardDefs[e],new Set),t}toJson(e,t,s=!1){let r=Rs(e),i=ma(e),o=iu(e),a=r,c=o,l,u=i;if(!s&&t!==void 0&&r.defName!==void 0&&r.defModel!==void 0){t.set(r.defName,r.defModel),l={$ref:`#/$defs/${r.defName}`},a=Rs(e,r.defModel);let h=ma(r.defModel);u=i!==h?i:void 0;let p=iu(r.defModel);c=o!==p?o:void 0}else if(i!==void 0&&i.startsWith("REF:")){let h=i.substring(4),p=h.indexOf("|"),m=p===-1?h:h.substring(0,p);u=p===-1?void 0:h.substring(p+1),l={$ref:this.refTarget(m)}}else l=this.coreJson(fa(e),r,t);a.keywords&&Object.assign(l,Ql(a.keywords));let d=a.allOf?{allOf:[l,...a.allOf.map(h=>Ql(h))]}:l;return u&&(d.description=u),c!==void 0&&(d.default=c),d}resolveStandardRef(e){let t=`${this.commonTypesUri}#/$defs/`;if(!e.startsWith(t))return;let s=e.substring(t.length);if(s.includes("/")||!Object.hasOwn(this.standardDefs,s))return;let r=this.standardDefsInCatalog.get(s);if(r)return r;let i=this.standardDefs[s];if(!Ge(i))return;let o=this.withCatalogRefs(i);return this.standardDefsInCatalog.set(s,o),o}withCatalogRefs(e){if(Array.isArray(e))return e.map(s=>this.withCatalogRefs(s));if(!Ge(e))return e;let t={};for(let[s,r]of Object.entries(e))t[s]=s==="$ref"&&typeof r=="string"?this.refTarget(r):this.withCatalogRefs(r);return t}refTarget(e){return e.startsWith("#/$defs/")?`${this.commonTypesUri}${e}`:e}coreJson(e,t,s){let r=Qn(e);switch(r.typeName){case"ZodObject":return this.objectSchema(e,t,()=>!0,s);case"ZodString":return um(r);case"ZodNumber":return dm(r);case"ZodBoolean":return{type:"boolean"};case"ZodNull":return{type:"null"};case"ZodEnum":return{type:"string",enum:[...r.values]};case"ZodLiteral":return{const:r.value};case"ZodAny":case"ZodUnknown":return{};case"ZodNever":return{not:{}};case"ZodArray":{let i={type:"array",items:this.toJson(r.type,s)},o=r.minLength,a=r.maxLength;return o&&(i.minItems=o.value),a&&(i.maxItems=a.value),i}case"ZodUnion":case"ZodDiscriminatedUnion":{let o=[...r.options].map(l=>this.toJson(l,s)),a=l=>{if(l.startsWith("#/$defs/")&&s!==void 0){let u=l.substring(8),d=s.get(u);if(d!==void 0)return this.defSchema(d,s)}return this.resolveStandardRef(l)};return{[o.every((l,u)=>o.slice(u+1).every(d=>au(l,d,a)))?"oneOf":"anyOf"]:o}}case"ZodRecord":return{type:"object",additionalProperties:this.toJson(r.valueType,s)};case"ZodLazy":return this.toJson(r.getter(),s);default:return fm(e)}}objectSchema(e,t,s,r){let i=Qn(e);if(i.typeName!=="ZodObject")return this.toJson(e,r);let o=e.shape,a={},c=[];for(let[g,E]of Object.entries(o))s(g)&&(a[g]=this.toJson(E,r),E.isOptional()||c.push(g));let l={type:"object",properties:a},u=t.required?.filter(g=>c.includes(g)),d=c.filter(g=>!u?.includes(g));c.length>0&&(l.required=u?[...u,...d]:c);let h=i.unknownKeys,p=i.catchall,m=t.closure??(h==="strict"?"additionalProperties":"none");return p&&Qn(p).typeName!=="ZodNever"?l[m==="none"?"additionalProperties":m]=this.toJson(p,r):m!=="none"&&(l[m]=h==="passthrough"),l}};function fa(n){let e=n;for(let t=Ar(e);t;t=Ar(e))e=t;return e}function ma(n){for(let e=n;e;e=Ar(e)){let t=Qn(e).description;if(typeof t=="string")return t}}function lm(n){let e=ma(n);return e!==void 0&&!e.startsWith("REF:")?e:void 0}function iu(n){for(let e=n;e;e=Ar(e)){let t=Qn(e);if(t.typeName==="ZodDefault")return t.defaultValue()}}var ou={email:"email",url:"uri",uuid:"uuid",datetime:"date-time",date:"date",time:"time"};function um(n){let e={type:"string"};for(let t of n.checks??[])t.kind==="regex"?e.pattern=t.regex.source:t.kind==="min"?e.minLength=t.value:t.kind==="max"?e.maxLength=t.value:t.kind in ou&&(e.format=ou[t.kind]);return e}function dm(n){let e=n.checks??[],t={type:e.some(s=>s.kind==="int")?"integer":"number"};for(let s of e)s.kind==="min"?t[s.inclusive?"minimum":"exclusiveMinimum"]=s.value:s.kind==="max"&&(t[s.inclusive?"maximum":"exclusiveMaximum"]=s.value);return t}function fm(n){let e=Fe(n,{target:"jsonSchema2019-09",$refStrategy:"none",override:He});return delete e.$schema,delete e.definitions,delete e.$defs,e}var hm=new Set(["anyComponent","anyFunction"]),Aa=["theme","themeSchema","styles"];function ue(n){return n===void 0?n:JSON.parse(JSON.stringify(n))}function hn(n){if(typeof n=="object"&&n!==null&&!Object.isFrozen(n)){Object.freeze(n);for(let e of Object.values(n))hn(e)}return n}function va(n){return typeof n!="object"||n===null||Object.isFrozen(n)?n:hn(ue(n))}function Et(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Ci(n,e){if(Array.isArray(n)){for(let s of n)Ci(s,e);return}if(!Et(n))return;let t=n.$ref;typeof t=="string"&&t.startsWith("#/$defs/")&&e.add(t.slice(8).split("/")[0].replace(/~1/g,"/").replace(/~0/g,"~"));for(let s of Object.values(n))Ci(s,e)}function xa(n,e){let t=new Set,s=new Set;for(let r of n)Ci(r,s);for(;s.size>0;){let[r]=s;s.delete(r),!t.has(r)&&(t.add(r),r in e&&Ci(e[r],s))}return t}function Sa(n,e){let t=br(n);if(!Et(t))return;let s=e??{};for(let r of xa([t],s))if(!(r in s)&&!hm.has(r))return;return t}function uu(n){return typeof n.name=="string"&&!("properties"in n)}function hu(n,e,t,s){if(!n)return n;let r=u=>u.map(d=>Sa(d,n)).filter(d=>d!==void 0),i=xa(r(e),n),o=Object.keys(n).filter(u=>!i.has(u)),a=xa([...r(t),s,...o.map(u=>n[u])],n),c={},l=!1;for(let[u,d]of Object.entries(n))!i.has(u)||a.has(u)?c[u]=d:l=!0;return l?c:n}function ba(n,e,t=fn){if(Array.isArray(n)){for(let s of n)ba(s,e,t);return}if(Et(n)){if(typeof n.description=="string"&&n.description.startsWith("REF:")){let s=n.description.substring(4),r=s.indexOf("|"),i=r===-1?s:s.substring(0,r),o=r===-1?"":s.substring(r+1),a=n.default;for(let u of Object.keys(n))delete n[u];let c=i.split(/#\/(?:\$defs|definitions)\//)[1],l=c?.split("/")[0];n.$ref=l===void 0||i.startsWith("#")&&e.has(l)?i:`${t}#/$defs/${c}`,a!==void 0&&(n.default=a),o&&(n.description=o);return}for(let s of["additionalProperties","unevaluatedProperties"]){let r=n[s];Et(r)&&Object.keys(r).length===0&&(n[s]=!0)}delete n.$schema;for(let s of Object.values(n))ba(s,e,t)}}function Ea(n,e,t=fn){if(!n||typeof n!="object"||!("safeParse"in n))return{type:"object",properties:{}};let s=Fe(n,{target:"jsonSchema2019-09",$refStrategy:"none",override:He});return delete s.definitions,delete s.$defs,ba(s,e,t),s}function pm(n){if(n.type!=="object")return;let e=n.unevaluatedProperties??n.additionalProperties;delete n.additionalProperties,n.unevaluatedProperties=typeof e=="boolean"||Et(e)?e:!1}function mm(n,e,t,s=fn){let r=Ea(e.schema,t,s),{component:i,id:o,...a}=Et(r.properties)?r.properties:{},c=Array.isArray(r.required)?r.required.filter(d=>d!=="component"&&d!=="id"):[],l=r.unevaluatedProperties??r.additionalProperties,u={type:"object",properties:{component:{const:n},...a},required:["component",...c],unevaluatedProperties:typeof l=="boolean"||Et(l)?l:!1};return e.allowedParents&&e.allowedParents.length>0&&(u.allowedParents=[...e.allowedParents]),e.allowedChildren&&e.allowedChildren.length>0&&(u.allowedChildren=[...e.allowedChildren]),e.metadata!==void 0&&(u.metadata=ue(e.metadata)),u}function du(n,e,t,s,r,i=fn,o){let a=Ea(e.schema,t,i);if(r)return{name:n,...e.description?{description:e.description}:{},returnType:e.returnType,parameters:a,...e.allowedCallers?{allowedCallers:e.allowedCallers}:{},...e.requiresUserActivation!==void 0?{requiresUserActivation:e.requiresUserActivation}:{}};pm(a);let c=Ht(a,o),l={type:"object"};return e.description&&(l.description=e.description),s?(l.returnType=e.returnType,e.allowedCallers&&(l.allowedCallers=e.allowedCallers),e.requiresUserActivation!==void 0&&(l.requiresUserActivation=e.requiresUserActivation),l.properties={"@call":{const:n},args:a},l.required=c?["@call","args"]:["@call"],l):(e.allowedCallers&&(l.allowedCallers=e.allowedCallers),e.requiresUserActivation!==void 0&&(l.requiresUserActivation=e.requiresUserActivation),l.properties={call:{const:n},args:a,returnType:{const:e.returnType}},l.required=c?["call","args"]:["call"],l.unevaluatedProperties=!1,l)}function gm(n,e,t=fn){let s=Ea(n,e,t);return{type:"object",properties:Et(s.properties)?s.properties:{},...Array.isArray(s.required)&&s.required.length>0?{required:s.required}:{},additionalProperties:s.additionalProperties!==void 0?s.additionalProperties:!0}}var pu={not:{}};function Ca(n){let e=[...n].map(t=>({$ref:`#/components/${mu(t)}`}));return e.length===0?{...pu}:{oneOf:e,discriminator:{propertyName:"component"}}}function Ta(n){let e=[...n].map(t=>({$ref:`#/functions/${mu(t)}`}));return e.length===0?{...pu}:{oneOf:e}}function mu(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}var fu=new WeakMap;function wa(n){let e=fu.get(n);return e||(e=ym(n),fu.set(n,e)),e}function ym(n){let e=new vr(n.protocolVersion,n.commonTypesUri),t=new Map,s=new Map;for(let[u,d]of n.components){if(br(d)||!cu(d.schema))continue;let{schema:h,catalogDefs:p}=e.componentSchema(u,d.schema,d.allowedParents,d.allowedChildren);d.metadata!==void 0&&(h.metadata=ue(d.metadata)),s.set(u,hn(h));for(let[m,g]of p)t.set(m,g)}for(let u of n.defModels??[]){let d=Is(u)?.defName;if(d===void 0)throw new Error("A catalog definition model must be named with specDef().");t.set(d,u)}let r=new Map,i=new Map;for(let[u,d]of n.functions)!br(d)&&lu(d.schema)&&(i.set(u,d),e.toJson(d.schema,t));let o={...n.defs},a=new Set;for(;[...t.keys()].some(u=>!a.has(u)&&!(u in o));)for(let[u,d]of[...t])a.has(u)||u in o||(a.add(u),o[u]=e.defSchema(d,t));let c={...n.extensionFields};if(n.themeLocation==="styles"&&n.themeSchema&&!gu(n)){let u=e.defSchema(n.themeSchema);c.styles=Et(u.properties)?u.properties:{}}let l=new Map;for(let[u,d]of n.components)l.set(u,s.get(u)??Sa(d,o));for(let[u,d]of n.functions){let h=Sa(d,o);r.set(u,h??(i.has(u)?hn(e.functionSchema(u,d,o,t)):void 0))}return{components:l,functions:r,defs:hn(o),extensionFields:hn(c)}}function gu(n){return Et(n.defs?.theme)||Aa.some(e=>n.extensionFields?.[e]!==void 0)}function yu(n){let e=z(n.protocolVersion,"1.0"),t=wa(n),s=new Set(Object.keys(t.defs)),r={};n.schemaUri!==void 0&&(r.$schema=n.schemaUri),n.schemaId!==void 0&&(r.$id=n.schemaId),typeof n.declaredProtocolVersion=="string"?r.protocolVersion=n.declaredProtocolVersion:n.declaredProtocolVersion===void 0&&(r.protocolVersion=le(n.protocolVersion)??n.protocolVersion),n.title!==void 0&&(r.title=n.title),n.description!==void 0&&(r.description=n.description),n.declaresCatalogId!==!1&&(r.catalogId=n.id),n.instructions!==void 0&&(r.instructions=n.instructions);let i=n.commonTypesUri??fn;if(n.declaresComponents!==!1||n.components.size>0){let d={};for(let[h,p]of n.components){let m=t.components.get(h);d[h]=m?ue(m):mm(h,p,s,i)}r.components=d}let o=[...n.functions].filter(([d,h])=>br(h)!==void 0||!d.startsWith("@")),a=o.map(([d])=>d);if(n.functionsLayout==="list")r.functions=o.map(([d,h])=>{let p=t.functions.get(d);return p&&uu(p)?ue(p):du(d,h,s,e,!0,i,t.defs)});else if(n.functionsLayout==="map"||o.length>0){let d={};for(let[h,p]of o){let m=t.functions.get(h);d[h]=m&&!uu(m)?ue(m):du(h,p,s,e,!1,i,t.defs)}r.functions=d}for(let[d,h]of Object.entries(t.extensionFields))d in r||(r[d]=ue(h));let c=ue({...t.defs});(n.themeLocation??(e?void 0:"defs"))==="defs"&&n.themeSchema&&!gu(t)&&(c.theme=Is(n.themeSchema)?new vr(n.protocolVersion,n.commonTypesUri).defSchema(n.themeSchema):gm(n.themeSchema,s,i));let u=n.unions??{anyComponent:e||n.components.size>0,anyFunction:e||a.length>0};if(u.anyComponent&&!("anyComponent"in c)){let d=c.anyFunction;d!==void 0&&delete c.anyFunction,c.anyComponent=Ca(n.components.keys()),d!==void 0&&(c.anyFunction=d)}return u.anyFunction&&!("anyFunction"in c)&&(c.anyFunction=Ta(a)),(n.defs!==void 0||Object.keys(c).length>0)&&(r.$defs=c),r}var xm="0.9";function wi(n,e){if(!e.startsWith("#/"))return;let t=e.slice(2).split("/").map(r=>r.replace(/~1/g,"/").replace(/~0/g,"~")),s=n;for(let r of t)if(s&&typeof s=="object"&&r in s)s=s[r];else return;return typeof s=="object"&&s!==null?s:void 0}function Tu(n){let e=n.split(/#\/(?:\$defs|definitions)\//)[1];return e&&Object.hasOwn(gr,e)?gr[e]:void 0}function Sm(n){return n.length===0?f.unknown():n.every(e=>typeof e=="string")?f.enum(n):n.length===1?f.literal(n[0]):f.union(n.map(e=>f.literal(e)))}function Cr(n){return n===null||typeof n!="object"?JSON.stringify(n):Array.isArray(n)?`[${n.map(Cr).join(",")}]`:`{${Object.keys(n).sort().map(s=>`${JSON.stringify(s)}:${Cr(n[s])}`).join(",")}}`}function Ct(n,e,t,s,r){let i=n;if(e.not&&typeof e.not=="object"){let o=es(e.not,t,new Set(s),r);i=i.refine(a=>!o.safeParse(a).success,{message:'Value matched prohibited "not" schema'})}return e.default!==void 0&&(i=i.default(e.default)),typeof e.description=="string"&&(i=i.describe(e.description)),i}function bm(n,e,t,s,r){let i=Tu(n);if(i){let o=n.split(/#\/(?:\$defs|definitions)\//)[1],a=typeof e.description=="string"?`REF:common_types.json#/$defs/${o}|${e.description}`:i.description;return a?i.describe(a):i}if(t&&n.startsWith("#/")){let o=wi(t,n);if(!o)return f.unknown().superRefine((c,l)=>{l.addIssue({code:f.ZodIssueCode.custom,message:`Unresolvable schema reference: '${n}'`})});if(s.has(n)){let c=r.get(n);return f.lazy(()=>(c||(c=r.get(n)??es(o,t,new Set([n]),r),r.set(n,c)),c))}let a=r.get(n);if(!a){let c=new Set(s);c.add(n),a=es(o,t,c,r),r.set(n,a)}return typeof e.description=="string"&&(a=a.describe(e.description)),a}}function Am(n,e,t,s){let r=Array.isArray(n.oneOf),o=(n.oneOf||n.anyOf).filter(h=>typeof h=="object"&&h!==null);if(o.length===0)return;let a=o.find(h=>Array.isArray(h.enum)),c=o.some(h=>typeof h.$ref=="string"&&h.$ref.includes("DataBinding")),l=o.map(h=>es(h,e,new Set(t),s)),u;if(l.length===1)u=l[0];else{let h=[l[0],l[1],...l.slice(2)];u=r?Zl(h):f.union(h)}n.default!==void 0&&(u=u.default(n.default));let d=(typeof n.description=="string"?n.description:void 0)||(a&&c?"REF:common_types.json#/$defs/DynamicString":void 0);return d?u.describe(d):u}function vm(n,e,t,s){let i=n.allOf.filter(c=>typeof c=="object"&&c!==null);if(i.length===0)return;if(e){let c=Ti(n,e,new Set(t),!1);if(c.length>0){let l=new Set;for(let m of c)if(m.kind==="json"&&Array.isArray(m.schema.required))for(let g of m.schema.required)typeof g=="string"&&l.add(g);if(Array.isArray(n.required))for(let m of n.required)typeof m=="string"&&l.add(m);let u={};for(let m of c){if(m.kind==="zod"){Object.assign(u,m.properties);continue}let g=Ii(m.schema.properties||{},l,!1,e,new Set(t),s);Object.assign(u,g)}let d=f.object(u),p=n.additionalProperties===!1||n.unevaluatedProperties===!1||c.some(m=>m.kind==="json"&&(m.schema.additionalProperties===!1||m.schema.unevaluatedProperties===!1))?d.strict():d.passthrough();return Ct(p,n,e,t,s)}}let o=i.map(c=>es(c,e,new Set(t),s)),a=o[0];for(let c=1;c<o.length;c++)a=a.and(o[c]);return Ct(a,n,e,t,s)}function es(n,e,t=new Set,s=new Map){if(!n||typeof n!="object")return f.unknown();if(n instanceof f.ZodType)return n;if(n.$ref&&typeof n.$ref=="string"){let r=bm(n.$ref,n,e,t,s);if(r)return r}if(Array.isArray(n.oneOf)||Array.isArray(n.anyOf)){let r=Am(n,e,t,s);if(r)return r}if(Array.isArray(n.allOf)&&n.allOf.length>0){let r=vm(n,e,t,s);if(r)return r}if(n.const!==void 0){let r=f.literal(n.const);return Ct(r,n,e,t,s)}if(Array.isArray(n.enum)&&n.enum.length>0){let r=Sm(n.enum);return Ct(r,n,e,t,s)}if(n.type==="array"){let r=n.items&&typeof n.items=="object"?es(n.items,e,new Set(t),s):f.unknown(),i=f.array(r);return typeof n.minItems=="number"&&(i=i.min(n.minItems)),typeof n.maxItems=="number"&&(i=i.max(n.maxItems)),n.uniqueItems===!0&&(i=i.refine(o=>new Set(o.map(Cr)).size===o.length,{message:"Array items must be unique"})),Ct(i,n,e,t,s)}switch(n.type){case"string":{let r=f.string();if(typeof n.minLength=="number"&&(r=r.min(n.minLength)),typeof n.maxLength=="number"&&(r=r.max(n.maxLength)),typeof n.pattern=="string")try{r=r.regex(new RegExp(n.pattern,"u"))}catch{}return Ct(r,n,e,t,s)}case"integer":case"number":{let r=n.type==="integer"?f.number().int():f.number();return typeof n.minimum=="number"&&(r=r.min(n.minimum)),typeof n.maximum=="number"&&(r=r.max(n.maximum)),typeof n.exclusiveMinimum=="number"&&(r=r.gt(n.exclusiveMinimum)),typeof n.exclusiveMaximum=="number"&&(r=r.lt(n.exclusiveMaximum)),typeof n.multipleOf=="number"&&(r=r.multipleOf(n.multipleOf)),Ct(r,n,e,t,s)}case"boolean":return Ct(f.boolean(),n,e,t,s);case"object":{let r=n.properties,i;if(typeof r=="object"&&r!==null){let o=Array.isArray(n.required)?new Set(n.required.filter(l=>typeof l=="string")):new Set,a=f.object(Ii(r,o,!1,e,t,s));i=n.additionalProperties===!1||n.unevaluatedProperties===!1?a.strict():a.passthrough()}else i=f.record(f.unknown());return Ct(i,n,e,t,s)}default:return Ct(f.unknown(),n,e,t,s)}}function wu(n){return n==="id"||n==="component"||n==="catalogId"}function Ii(n,e,t=!1,s,r,i=new Map){let o={};for(let[a,c]of Object.entries(n)){if(t&&wu(a))continue;let l=es(typeof c=="object"&&c!==null?c:{},s,r?new Set(r):new Set,i);e.has(a)?l.safeParse(void 0).success?o[a]=l.refine(u=>u!==void 0,{message:"Required"}):o[a]=l:o[a]=l.optional()}return o}function Ti(n,e,t=new Set,s=!1){if(!n||typeof n!="object")return[];let r=[],i=[],o=[];if(Array.isArray(n.allOf)){for(let c of n.allOf)if(!(!c||typeof c!="object"))if(typeof c.$ref=="string"){let l=c.$ref;if(l.includes("common_types.json")&&l.includes("ComponentCommon")){let{accessibility:u,metadata:d}=mr.shape;r.push({kind:"zod",properties:s?{accessibility:u,metadata:d}:{accessibility:u}})}else if(l.startsWith("#/")){if(!t.has(l)){t.add(l);let u=wi(e,l);u&&i.push(...Ti(u,e,t,s))}}else{let u=Tu(l);u instanceof f.ZodObject&&r.push({kind:"zod",properties:{...u.shape}})}}else o.push(...Ti(c,e,t,s))}let a=[...r,...i,...o];return n.properties&&a.push({kind:"json",schema:n}),a}function Iu(n,e,t=!0,s=new Map,r=!1){let i={},o=Ti(n,e,void 0,r),a=new Set;for(let u of o)u.kind==="json"&&Array.isArray(u.schema.required)&&u.schema.required.forEach(d=>{typeof d=="string"&&a.add(d)});for(let u of o){if(u.kind==="zod"){for(let[h,p]of Object.entries(u.properties))t&&wu(h)||(i[h]=p);continue}let d=Ii(u.schema.properties||{},a,t,e,void 0,s);Object.assign(i,d)}let c=f.object(i);return n.unevaluatedProperties===!0||typeof n.unevaluatedProperties=="object"&&n.unevaluatedProperties!==null||n.additionalProperties===!0||typeof n.additionalProperties=="object"&&n.additionalProperties!==null?c.passthrough():c.strict()}function Tr(n){if(!n||typeof n!="object"||Array.isArray(n))return!1;let e=n;return Object.keys(e).length>0&&e.properties===void 0&&typeof e.type!="string"&&!("$ref"in e)&&!("allOf"in e)&&!("oneOf"in e)&&!("anyOf"in e)&&!("not"in e)&&Object.values(e).every(t=>t!==null&&(typeof t=="object"||typeof t=="boolean"))}function xu(n){return n.unevaluatedProperties===!0||typeof n.unevaluatedProperties=="object"&&n.unevaluatedProperties!==null||n.additionalProperties===!0||typeof n.additionalProperties=="object"&&n.additionalProperties!==null}function Ia(n,e,t=new Set){let s={schemas:[],hasUnresolvable:!1};if(!n||typeof n!="object"||Array.isArray(n))return s;if(Tr(n))return s.schemas.push({type:"object",properties:n}),s;if(typeof n.$ref=="string"){let r=n.$ref;if(r.startsWith("#/")){if(!e)s.hasUnresolvable=!0;else if(!t.has(r)){t.add(r);let i=wi(e,r);if(i){let o=Ia(i,e,t);s.schemas.push(...o.schemas),o.hasUnresolvable&&(s.hasUnresolvable=!0)}else s.hasUnresolvable=!0}}else s.hasUnresolvable=!0}if(Array.isArray(n.allOf)){for(let r of n.allOf)if(r&&typeof r=="object"&&!Array.isArray(r)){let i=Ia(r,e,t);s.schemas.push(...i.schemas),i.hasUnresolvable&&(s.hasUnresolvable=!0)}}return(Array.isArray(n.anyOf)||Array.isArray(n.oneOf))&&(s.hasUnresolvable=!0),(n.properties||n.required||n.additionalProperties!==void 0||n.unevaluatedProperties!==void 0)&&s.schemas.push(n),s}function Su(n,e,t=new Map){let s=Ia(n,e),r=new Set;for(let c of s.schemas)if(Array.isArray(c.required))for(let l of c.required)typeof l=="string"&&r.add(l);let i={};for(let c of s.schemas)if(c.properties&&typeof c.properties=="object"&&!Array.isArray(c.properties)){let l=Ii(c.properties,r,!1,e,void 0,t);Object.assign(i,l)}let o=f.object(i);return s.hasUnresolvable||s.schemas.some(xu)||xu(n)?o.passthrough():o.strict()}function bu(n,e){if(!n||typeof n!="object"||Array.isArray(n))return[];let t=n,s=[],r=new Set,i=o=>{if(!o||typeof o!="object"||Array.isArray(o))return;let a=o;if(typeof a.$ref=="string"&&e&&a.$ref.startsWith("#/")&&!r.has(a.$ref)){r.add(a.$ref);let c=wi(e,a.$ref);c&&i(c)}if(a.properties&&typeof a.properties=="object"&&a.properties!==null&&!Array.isArray(a.properties)&&s.push(...Object.keys(a.properties)),Array.isArray(a.allOf))for(let c of a.allOf)i(c)};return t.properties&&typeof t.properties=="object"&&t.properties!==null&&!Array.isArray(t.properties)||Array.isArray(t.allOf)||typeof t.$ref=="string"?(i(t),s):Tr(t)?Object.keys(t):[]}function Em(n,e,t,s=!1){let r=[];if(!n)return r;let i=new Map,o=(a,c)=>{if(s){Ts(a,`function identifier: '${a}'`);for(let l of c)Ts(l,`argument identifier: '${l}' in function '${a}'`)}};if(Array.isArray(n)){for(let a of n)if(a&&typeof a=="object"&&typeof a.name=="string"){let c=bu(a.parameters,e);if(o(a.name,c),t&&!t.has(a.name))continue;r.push(new Sr(a.name,a,l=>l.parameters&&typeof l.parameters=="object"?Su(l.parameters,e,i):f.record(f.unknown())))}return r}if(typeof n=="object"&&n!==null)for(let[a,c]of Object.entries(n)){let u=Au(c&&typeof c=="object"?c:{}),d=bu(u,e);o(a,d),!(t&&!t.has(a))&&(!c||typeof c!="object"||r.push(new Sr(a,c,h=>{let p=Au(h);return p?Su(p,e,i):f.record(f.unknown())})))}return r}function Au(n){let e=n.properties&&typeof n.properties=="object"&&n.properties!==null&&!Array.isArray(n.properties)?n.properties:void 0,t=e?.args??n.args??n.parameters;return!t&&e&&!("call"in e)&&!("@call"in e)&&!("function"in e)?t=n:Tr(t)&&(t={type:"object",properties:t,required:n.required,additionalProperties:n.additionalProperties}),t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function vu(n,e){if(!Array.isArray(n))return;let t=new Set;for(let s of n)if(typeof s?.$ref=="string"&&s.$ref.startsWith(e)){let i=s.$ref.slice(e.length).replace(/~([01])/g,(o,a)=>a==="1"?"/":"~");t.add(i)}return t}function Cm(n,e,t,s){let r=[],i=new Map;for(let[o,a]of Object.entries(n)){let c=a||{};if(t){Ts(o,`component identifier: '${o}'`);let l=c.properties;if(l&&typeof l=="object")for(let d of Object.keys(l))Ts(d,`property identifier: '${d}' in component '${o}'`);let u=c.metadata;if(u!==void 0)try{Kn(u)}catch(d){throw new R(d instanceof Error?d.message:String(d))}}s&&!s.has(o)||r.push(new Ei(o,c,l=>Iu(l,e,!0,i,t)))}return r}function Tm(n,e){let t=n.theme??n.themeSchema??n.styles??e?.theme;if(t&&typeof t=="object"){let s=t,r="properties"in s||"allOf"in s||s.type==="object"?s:{type:"object",properties:s},i=Iu(r,n,!1);return r.additionalProperties===!1||r.unevaluatedProperties===!1?i:i.passthrough()}}function wm(n){if(n.startsWith("#"))return!0;let e=n.indexOf("#"),t=e===-1?n:n.slice(0,e);return t==="catalog.json"?!0:t.split("/").pop()==="common_types.json"}function Im(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}function ka(n,e){if(Array.isArray(n)){n.forEach((t,s)=>ka(t,`${e}/${s}`));return}if(Er(n))for(let[t,s]of Object.entries(n)){let r=`${e}/${Im(t)}`;if(t==="$ref"&&typeof s=="string"&&!wm(s))throw new R(`Unsupported external $ref '${s}' at ${r}: a v1.0 catalog may only reference its own components and functions (#/...) or common_types.json.`);ka(s,r)}}function ku(n,e,t){let s=ue(n),r=t??s.catalogId??s.$id??s.id;if(!r||typeof r!="string")throw new Error("Catalog ID must be specified via catalog metadata ('catalogId' or '$id').");let i=s.$defs,o=i?.anyComponent,a=vu(o?.oneOf,"#/components/"),c=e??s.protocolVersion??xm,l=z(c,"1.0");l&&ka(s,"");let u=s.components??{},d=Cm(u,s,l,a),h=i?.anyFunction,p=vu(h?.oneOf,"#/functions/"),m=Em(s.functions,s,p,l),g=Tm(s,i);return hn(s),{id:r,protocolVersion:c,components:d,functions:m,themeSchema:g,...Rm(s,d,m)}}var Eu={$schema:"schemaUri",$id:"schemaId",title:"title",description:"description",instructions:"instructions"},km=new Set(["protocolVersion","catalogId","components"]);function Er(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Cu(n,e){return Cr(n)===Cr(e)}function Rm(n,e,t){let s={},r={};for(let[i,o]of Object.entries(n))if(i in Eu&&typeof o=="string")s[Eu[i]]=o;else if(i==="protocolVersion"&&typeof o=="string")s.declaredProtocolVersion=o;else if(i==="functions"&&(Array.isArray(o)||Er(o)))s.functionsLayout=Array.isArray(o)?"list":"map";else if(i==="$defs"&&Er(o)){let a=Cu(o.anyComponent,Ca(e.map(u=>u.name))),c=Cu(o.anyFunction,Ta(t.map(u=>u.name)));s.unions={anyComponent:a,anyFunction:c};let l={};for(let[u,d]of Object.entries(o))u==="anyComponent"&&a||u==="anyFunction"&&c||(l[u]=d);s.defs=Object.freeze(l)}else(!km.has(i)||i==="components"&&!Er(o))&&(r[i]=o);return s.declaredProtocolVersion??=null,s.declaresCatalogId=typeof n.catalogId=="string",s.declaresComponents=Er(n.components),s.unions??={anyComponent:!1,anyFunction:!1},Object.keys(r).length>0&&(s.extensionFields=Object.freeze(r)),s}function _m(n,e){return e?.standardDefs?e.standardDefs:ga(e?.protocolVersion??n.protocolVersion)}var Oa=/^[^#]+#\/(?:\$defs|definitions)\/([^/]+)(\/.*)?$/;function _u(n){let e=Oa.exec(n);return e?`#/$defs/${e[1]}${e[2]??""}`:`#/$defs/${n.split("/").pop()}`}function Nm(n){if(n.startsWith("#/$defs/"))return n.substring(8).split("/")[0].replace(/~1/g,"/").replace(/~0/g,"~")}function Om(n){if(typeof n.description!="string"||!n.description.startsWith("REF:"))return!1;let e=n.description.substring(4),t=e.indexOf("|"),s=t===-1?e:e.substring(0,t),r=t===-1?"":e.substring(t+1),i=n.default;for(let o of Object.keys(n))delete n[o];return n.$ref=s.startsWith("#")?s:_u(s),i!==void 0&&(n.default=i),r&&(n.description=r),!0}function Pm(n,e={}){if(Array.isArray(n.allOf)){let t=n.allOf.filter(r=>!(typeof r=="object"&&r!==null&&Object.keys(r).length===0)),s=t.length===1?t[0]:void 0;typeof s=="object"&&s!==null&&!Array.isArray(s)&&Object.keys(s).every(r=>!(r in n)||r==="allOf")?(delete n.allOf,Object.assign(n,s)):t.length===0?delete n.allOf:n.allOf=t}e.stripAdditionalProperties?(delete n.additionalProperties,delete n.unevaluatedProperties):(n.additionalProperties&&typeof n.additionalProperties=="object"&&Object.keys(n.additionalProperties).length===0&&(n.additionalProperties=!0),n.unevaluatedProperties&&typeof n.unevaluatedProperties=="object"&&Object.keys(n.unevaluatedProperties).length===0&&(n.unevaluatedProperties=!0)),"$schema"in n&&delete n.$schema}function Gt(n,e=new Set,t={}){if(typeof n!="object"||n===null||e.has(n))return;if(e.add(n),Array.isArray(n)){for(let r of n)Gt(r,e,t);return}let s=n;if(!Om(s)){Pm(s,t);for(let r of Object.keys(s))Gt(s[r],e,t)}}function De(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var Dm=new Set(["description","title","default","deprecated","readOnly","writeOnly","examples"]),Ru=new Set(["id","component","catalogId"]),Lm=new Set(["anyComponent","anyFunction","theme"]),$m=/^(?:([^#]*common_types\.json))?#\/\$defs\/([^/]+)(\/.*)?$/,Mm=/\/(ComponentCommon|Checkable)$/;function Ra(n,e,t,s=""){if(n.$ref=`#/$defs/${e}${s}`,s||n.description!==void 0)return;let r=t[e];De(r)&&typeof r.description=="string"&&(n.description=r.description)}function wr(n,e,t){if(Array.isArray(n)){for(let i of n)wr(i,e,t);return}if(!De(n))return;let s=n.$ref,r=typeof s=="string"?$m.exec(s):null;if(r){let[,i,o,a]=r;if(i!==void 0||o in e){if(t){for(let c of Object.keys(n))c!=="$ref"&&!Dm.has(c)&&delete n[c];Ra(n,o,e,a);return}Ra(n,o,e,a)}}for(let i of Object.values(n))wr(i,e,t)}function Fm(n,e){if(!e.startsWith("#/"))return;let t=n;for(let s of e.substring(2).split("/")){let r=s.replace(/~([01])/g,(i,o)=>o==="1"?"/":"~");if(!De(t)||!(r in t))return;t=t[r]}return t}function _a(n,e,t){let s=[],r=[],i=[];for(let a of Array.isArray(n.allOf)?n.allOf:[]){if(!De(a))continue;let c=a.$ref;if(typeof c!="string"){s.push(..._a(a,e,t));continue}let l=Mm.exec(c)?.[1],u=c.startsWith("#/")?Fm(e.rootDoc,c):void 0;if(l===void 0&&De(u)){t.has(c)||(t.add(c),r.push(..._a(u,e,t)));continue}let d=Oa.exec(c),h=l??(d&&!d[2]?d[1]:void 0),p=h!==void 0?e.standardDefs[h]:void 0;De(p)&&De(p.properties)&&i.push({properties:ue(p.properties),...Array.isArray(p.required)?{required:p.required}:{}})}let o=[...i,...r,...s];return("properties"in n||"description"in n)&&o.push(n),o}function jm(n,e){let t=_a(n,e,new Set),s,r={},i=new Set;for(let a of t)if(typeof a.description=="string"&&(s=a.description),De(a.properties)&&Object.assign(r,a.properties),Array.isArray(a.required))for(let c of a.required)typeof c=="string"&&i.add(c);let o={};for(let[a,c]of Object.entries(r)){if(Ru.has(a))continue;let l=ue(c);wr(l,e.standardDefs,!0),o[a]=l}return{props:o,required:[...i].filter(a=>!Ru.has(a)).sort(),...s!==void 0?{description:s}:{}}}function Vm(n,e){let t=e.model.functions.get(n);if(!t)return;let s=De(t.properties)?t.properties:void 0,r=s?.args??t.args??t.parameters;if(r!==void 0)return De(r)?Tr(r)?{type:"object",properties:r,...t.required!==void 0?{required:t.required}:{},...t.additionalProperties!==void 0?{additionalProperties:t.additionalProperties}:{}}:r:{};let i=s&&("call"in s||"@call"in s||"function"in s);if(!s||i)return{};let{description:o,title:a,name:c,returnType:l,allowedCallers:u,requiresUserActivation:d,...h}=t;return h}function Um(n){let e=Aa.map(t=>n.extensionFields[t]).find(t=>t!==void 0)??n.defs.theme;if(De(e))return"properties"in e||"allOf"in e||e.type==="object"?e:{type:"object",properties:e}}function Bm(n){return(le(n.protocolVersion)??n.protocolVersion)==="0.8"||n.id.includes("v0_8")||n.id.includes("v0.8")}function qm(n,e,t,s){if(!n.themeSchema)return;let r=Bm(n),i=Um(s.model);if(i){let l=ue({...i});!r&&l.additionalProperties===void 0&&l.unevaluatedProperties===void 0&&(l.additionalProperties=!0),e.theme=l;return}let o=Fe(n.themeSchema,{target:"jsonSchema2019-09",$refStrategy:"none",override:He});Gt(o),Pa(o,e,t);let a=o.additionalProperties===!1,c={type:"object",...typeof o.description=="string"&&!o.description.startsWith("REF:")?{description:o.description}:{},properties:o.properties||{},...Array.isArray(o.required)&&o.required.length>0?{required:o.required}:{},...a?{additionalProperties:!1}:r?{}:{additionalProperties:o.additionalProperties!==void 0?o.additionalProperties:!0}};t.push(c),e.theme=c}function Pa(n,e,t){let s=De(n.definitions)?n.definitions:De(n.$defs)?n.$defs:void 0;delete n.definitions,delete n.$defs,s&&(Object.assign(e,s),t.push(s))}function zm(n,e,t){if(!n.schema||typeof n.schema!="object"||!("safeParse"in n.schema))return{props:{},reqList:[],additionalProps:void 0};let s=Fe(n.schema,{target:"jsonSchema2019-09",$refStrategy:"none",override:He});Gt(s),Pa(s,e,t);let r=s.properties||{},i=Array.isArray(s.required)?s.required.filter(c=>c!=="component"&&c!=="id"):[],o=s.unevaluatedProperties??s.additionalProperties,a=typeof o=="boolean"||De(o)?o:void 0;return{props:r,reqList:i,additionalProps:a}}function Wm(n){let e=n.schema?.description;return typeof e=="string"&&!e.startsWith("REF:")?e:void 0}function Zm(n){return n.unevaluatedProperties??n.additionalProperties}function Hm(n,e,t,s,r,i){let o,a,c,l,u=r.model.components.get(n);if(u)({props:o,required:a,description:c}=jm(u,r)),l=Zm(u)??(r.isV10?void 0:!1);else{let E=zm(e,t,s),{component:A,id:I,...D}=E.props;s.push(D),o=D,a=E.reqList,c=Wm(e),l=r.isV10?void 0:E.additionalProps??!1}let d={};Ra(d,"ComponentId",r.standardDefs);let h={id:d,...o,component:{const:n}},p=["id",...a,"component"],m=l!==void 0?{unevaluatedProperties:l}:{},g;return i?.componentEnvelopeRef?g={...c!==void 0?{description:c}:{},allOf:[{$ref:i.componentEnvelopeRef},{type:"object",properties:h,required:p}],...m}:g={type:"object",...c!==void 0?{description:c}:{},properties:h,required:p,...m},e.allowedParents&&e.allowedParents.length>0&&(g.allowedParents=e.allowedParents),e.allowedChildren&&e.allowedChildren.length>0&&(g.allowedChildren=e.allowedChildren),g}function Gm(n,e,t,s,r,i){if(n.components.size===0){e.components={};return}let o={};for(let[a,c]of n.components.entries())o[a]=Hm(a,c,t,s,r,i);e.components=o,t.anyComponent={oneOf:Array.from(n.components.keys()).map(a=>({$ref:`#/components/${a}`})),discriminator:{propertyName:"component"}}}function Km(n,e,t,s,r){let i,o=Vm(n,r);if(o)i=ue(o),wr(i,r.standardDefs,!1);else if(e.schema&&typeof e.schema=="object"&&"safeParse"in e.schema){let a=Fe(e.schema,{target:"jsonSchema2019-09",$refStrategy:"none",override:He});Gt(a),Pa(a,t,s),s.push(a),i=a}else i={type:"object",properties:{}};if(i.type==="object"){let a=i.additionalProperties;delete i.additionalProperties,i.unevaluatedProperties=i.unevaluatedProperties??a??!1}return i}function Ym(n,e,t,s,r){let i=Km(n,e,t,s,r),o=Ht(i,{...r.defs,...t}),a=r.isV10?"@call":"call",c=o?[a,"args"]:[a];return r.isV10?{type:"object",...e.description?{description:e.description}:{},returnType:e.returnType,...e.allowedCallers!==void 0?{allowedCallers:e.allowedCallers}:{},...e.requiresUserActivation!==void 0?{requiresUserActivation:e.requiresUserActivation}:{},properties:{"@call":{const:n},args:i},required:c}:{type:"object",...e.description?{description:e.description}:{},properties:{call:{const:n},args:i,returnType:{const:e.returnType}},required:c,unevaluatedProperties:!1}}function Jm(n,e,t,s,r){let i=Array.from(n.functions.keys()).filter(a=>!a.startsWith("@"));if(i.length===0)return;let o={};for(let a of i)o[a]=Ym(a,n.functions.get(a),t,s,r);e.functions=o,t.anyFunction={oneOf:i.map(a=>({$ref:`#/functions/${a}`}))}}var Xm=new Map(Object.values(gr).flatMap(n=>{let e=n.description;if(typeof e!="string"||!e.startsWith("REF:"))return[];let t=e.substring(4),s=t.indexOf("|");return s===-1?[]:[[t.substring(0,s).split("/").pop(),t.substring(s+1)]]}));function _s(n,e,t=new Set){if(typeof n!="object"||n===null||t.has(n))return;if(t.add(n),Array.isArray(n)){for(let i of n)_s(i,e,t);return}let s=n,r=s.$ref;if(typeof r=="string"&&!r.startsWith("#")&&r!==e){if(!Oa.test(r))throw new Error(`Cannot bundle the external schema reference '${r}'.`);s.$ref=_u(r)}for(let i of Object.values(s))_s(i,e,t)}function Na(n,e,t=new Set){if(typeof n!="object"||n===null||t.has(n))return;if(t.add(n),Array.isArray(n)){for(let i of n)Na(i,e,t);return}let s=n,r=s.$ref;if(typeof r=="string"&&r.startsWith("#/$defs/")){let i=r.substring(8),o=i.includes("/")?void 0:e[i],a=s.description===void 0||s.description===Xm.get(i);o&&a&&(typeof o.description=="string"?s.description=o.description:delete s.description)}for(let i of Object.values(s))Na(i,e,t)}function ki(n,e,t=new Set){if(!(typeof n!="object"||n===null)&&!t.has(n)){if(t.add(n),typeof n.$ref=="string"){let s=Nm(n.$ref);s!==void 0&&e.add(s)}if(Array.isArray(n))for(let s of n)ki(s,e,t);else for(let s of Object.values(n))ki(s,e,t)}}function Nu(n,e){let t={$schema:"https://json-schema.org/draft/2020-12/schema",...typeof n.declaredProtocolVersion=="string"?{protocolVersion:n.declaredProtocolVersion.trim().replace(/^[vV](?=\d)/,"")}:{},catalogId:n.id};n.instructions&&(t.instructions=n.instructions);let s=_m(n,e),r=e?.protocolVersion??n.protocolVersion,i=wa(n),o=i.defs,a={standardDefs:s,model:i,defs:o,rootDoc:{$defs:o},isV10:!!r&&z(r,"1.0")},c={},l=[];qm(n,c,l,a),Gm(n,t,c,l,a,e),Jm(n,t,c,l,a),_s(t,e?.componentEnvelopeRef),_s(c);for(let d of l)Na(d,s);let u;do{u=Object.keys(c).length;let d=new Set;ki(t,d),ki(c,d),(d.has("DynamicString")||d.has("DynamicNumber")||d.has("DynamicBoolean")||d.has("DynamicValue"))&&(d.add("DataBinding"),d.add("FunctionCall"));for(let h of d)if(!(h in c)){if(h in s){let p=ue(s[h]);_s(p),c[h]=p}else if(!Lm.has(h)&&h in o){let p=ue(o[h]);wr(p,s,!1),_s(p),c[h]=p}}d.has("anyFunction")&&!("anyFunction"in c)&&(c.anyFunction={not:{}})}while(Object.keys(c).length>u);return Object.keys(c).length>0&&(t.$defs=c),t}function Ir(n){if(!n)return"";let e=n.lastIndexOf("#");return(e!==-1?n.slice(e+1):n).split("/").filter(Boolean).pop()??""}function Ou(n,e){if(!n?._def)return null;if(e){if(e.has(n))return null;e.add(n)}switch(n._def.typeName){case"ZodOptional":case"ZodNullable":case"ZodDefault":case"ZodReadonly":return n._def.innerType;case"ZodBranded":return n._def.type;case"ZodEffects":return n._def.schema;case"ZodLazy":return n._def.getter();default:return null}}function Qm(n){let e=[],t=new Set,s=n;for(;s;){s.description&&e.push(s.description),s._def?.description&&e.push(s._def.description);let r=Ou(s,t);if(!r)break;s=r}return e}function pn(n){let e=new Set,t=n;for(;t;){let s=Ou(t,e);if(!s)break;t=s}return t}function e1(n,e){if(!n)return null;let t=Ir(n),s=e.childListRefNames,r=e.childRefNames;return s.has(t)?{isChild:!1,isChildList:!0}:r.has(t)?{isChild:!0,isChildList:!1}:null}function t1(n,e){let t=!1;for(let s of n){if(typeof s!="object"||s===null)continue;let r=Da(s,e);if(r.isChildList)return{isChild:!1,isChildList:!0};r.isChild&&(t=!0)}return t?{isChild:!0,isChildList:!1}:null}function n1(n,e){let t=!1;for(let s of["oneOf","anyOf","allOf"]){let r=n[s];if(!Array.isArray(r))continue;let i=t1(r,e);if(i?.isChildList)return i;i?.isChild&&(t=!0)}return t?{isChild:!0,isChildList:!1}:null}function Da(n,e){let t=typeof n.$ref=="string"?n.$ref:"",s=e1(t,e);if(s)return s;if(n.type==="array"&&n.items){let i=Da(n.items,e);if(i.isChild||i.isChildList)return{isChild:!1,isChildList:!0}}let r=n1(n,e);return r||(n.type==="object"&&n.properties&&("componentId"in n.properties&&("path"in n.properties||"dataBinding"in n.properties)||"explicitList"in n.properties||"template"in n.properties)?{isChild:!1,isChildList:!0}:{isChild:!1,isChildList:!1})}function s1(n){if(n?._def?.typeName==="ZodObject"&&typeof n._def.shape=="function"){let e=n._def.shape();return!!(e.componentId&&(e.path||e.dataBinding)||e.explicitList||e.template)}return!1}function r1(n,e){if(n?._def?.typeName==="ZodArray"){let t=pn(n._def.type);return ts(t,e).isChild}return!1}function i1(n,e){let t=!1,s=!1,r=!1;for(let i of n){let o=pn(i);s1(o)&&(t=!0),r1(o,e)&&(s=!0);let a=ts(o,e);if(a.isChildList)return{isChild:!1,isChildList:!0};a.isChild&&(r=!0)}return t||s?{isChild:!1,isChildList:!0}:r?{isChild:!0,isChildList:!1}:{isChild:!1,isChildList:!1}}function o1(n,e){if(!n)return!1;if(n.startsWith("REF:")){let r=Ir(n.substring(4).split("|")[0]);if(e.has(r))return!0}let t=Ir(n.split("|")[0]);if(t&&e.has(t))return!0;let s=n.trim();return!!e.has(s)}function a1(n,e){if(!n)return!1;if(n.startsWith("REF:")){let r=Ir(n.substring(4).split("|")[0]);if(e.has(r))return!0}let t=Ir(n.split("|")[0]);if(t&&e.has(t))return!0;let s=n.trim();return!!e.has(s)}function c1(n,e){let t=e.childListRefNames,s=e.childRefNames;for(let r of n){if(o1(r,t))return{isChild:!1,isChildList:!0};if(a1(r,s))return{isChild:!0,isChildList:!1}}return null}function l1(n,e){let t=ts(n,e);return t.isChild||t.isChildList?{isChild:!1,isChildList:!0}:{isChild:!1,isChildList:!1}}function ts(n,e){if(!n||typeof n!="object")return{isChild:!1,isChildList:!1};let t=sa(n);if(t==="component-id")return{isChild:!0,isChildList:!1};if(t==="child-list")return{isChild:!1,isChildList:!0};let s=c1(Qm(n),e);if(s)return s;let r=pn(n);if(!r?._def)return Da(n,e);let i=sa(r);if(i==="component-id")return{isChild:!0,isChildList:!1};if(i==="child-list")return{isChild:!1,isChildList:!0};let o=r._def.typeName;if(o==="ZodArray"){let a=pn(r._def.type);return l1(a,e)}if(o==="ZodUnion"){let a=r._def.options??[];return i1(a,e)}if(o==="ZodObject"&&typeof r._def.shape=="function"){let a=r._def.shape();if(a.componentId&&(a.path||a.dataBinding)||a.explicitList||a.template)return{isChild:!1,isChildList:!0}}return{isChild:!1,isChildList:!1}}function Pu(n,e,t){let s=n.nestedRefs[e];if(s){s.add(t);return}n.nestedRefs[e]=new Set([t])}function u1(n,e,t,s){let r=ts(e,s);if(r.isChildList){t.listRefs.add(n);return}if(r.isChild){t.singleRefs.add(n);return}let i=pn(e);if(s.childPropertyNames?.has(n)&&i?._def?.typeName==="ZodString"){t.singleRefs.add(n);return}if(i?._def?.typeName!=="ZodArray")return;let o=pn(i._def.type);if(o?._def?.typeName!=="ZodObject"||typeof o._def.shape!="function")return;let a=o._def.shape();for(let[c,l]of Object.entries(a)){let u=ts(l,s),d=pn(l);(u.isChild||u.isChildList||s.childPropertyNames?.has(c)&&d?._def?.typeName==="ZodString")&&(t.listRefs.add(n),Pu(t,n,c))}}function d1(n){if(typeof n!="object"||n===null)return null;let e=n;if(e.type!=="array"&&!("items"in e))return null;let t=e.items;if(typeof t!="object"||t===null)return null;let s=t.properties;return typeof s!="object"||s===null?null:s}function f1(n,e,t){for(let[s,r]of Object.entries(n)){let i=ts(r,t);if(i.isChildList){e.listRefs.add(s);continue}if(i.isChild){e.singleRefs.add(s);continue}if(t.childPropertyNames?.has(s)&&typeof r=="object"&&r!==null&&r.type==="string"){e.singleRefs.add(s);continue}let o=d1(r);if(o)for(let[a,c]of Object.entries(o)){let l=ts(c,t);(l.isChild||l.isChildList||t.childPropertyNames?.has(a)&&typeof c=="object"&&c!==null&&c.type==="string")&&(e.listRefs.add(s),Pu(e,s,a))}}}function h1(n,e,t){if(!n)return;let s=pn(n);if(s?._def?.typeName==="ZodObject"&&typeof s._def.shape=="function"){let r=s._def.shape();for(let[i,o]of Object.entries(r))u1(i,o,e,t);return}if(typeof n=="object"&&n!==null&&"properties"in n){let r=n.properties;typeof r=="object"&&r!==null&&f1(r,e,t)}}function La(n,e){let t={},s=typeof n?.components?.values=="function"?Array.from(n.components.values()):Array.isArray(n)?n:Array.from(n.values());for(let r of s){let i={singleRefs:new Set,listRefs:new Set,nestedRefs:{}};h1(r.schema,i,e),t[r.name]={singleRefs:i.singleRefs,listRefs:i.listRefs,nestedRefs:i.nestedRefs}}return t}var p1=Symbol.for("preact-signals");function Oi(){if(Kt>1){Kt--;return}let n,e=!1;for((function(){let t=Ri;for(Ri=void 0;t!==void 0;){let s=t.S;if(s.v===t.v)for(let r=s.t;r!==void 0;r=r.x)r.i===t.i&&(r.i=s.i);t=t.o}})();Rr!==void 0;){let t=Rr;for(Rr=void 0,_i++;t!==void 0;){let s=t.u;if(t.u=void 0,t.f&=-3,!(8&t.f)&&Mu(t))try{t.c()}catch(r){e||(n=r,e=!0)}t=s}}if(_i=0,Kt--,e)throw n}function Du(n){if(Kt>0)return n();$a=++m1,Kt++;try{return n()}finally{Oi()}}var se,kr,Rr;function Pi(n){let e=se,t=kr;se=void 0,kr=void 0;try{return n()}finally{se=e,kr=t}}var Ri,Kt=0,_i=0,m1=0,$a=0,Ni=0;function Lu(n){if(se===void 0)return;let e=n.n;if(e===void 0||e.t!==se)return e={i:0,S:n,p:se.s,n:void 0,t:se,e:void 0,x:void 0,r:e},se.s!==void 0&&(se.s.n=e),se.s=e,n.n=e,32&se.f&&n.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=se.s,e.n=void 0,se.s.n=e,se.s=e),e}function Re(n,e){this.v=n,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}Re.prototype.brand=p1;Re.prototype.h=function(){return!0};Re.prototype.S=function(n){let e=this.t;e!==n&&n.e===void 0&&(n.x=e,this.t=n,e!==void 0?e.e=n:Pi(()=>{var t;(t=this.W)==null||t.call(this)}))};Re.prototype.U=function(n){if(this.t!==void 0){let e=n.e,t=n.x;e!==void 0&&(e.x=t,n.e=void 0),t!==void 0&&(t.e=e,n.x=void 0),n===this.t&&(this.t=t,t===void 0&&Pi(()=>{var s;(s=this.Z)==null||s.call(this)}))}};Re.prototype.subscribe=function(n){return Fa(()=>{let e=this.value;Pi(()=>n(e))},{name:"sub"})};Re.prototype.valueOf=function(){return this.value};Re.prototype.toString=function(){return this.value+""};Re.prototype.toJSON=function(){return this.value};Re.prototype.peek=function(){return Pi(()=>this.value)};Object.defineProperty(Re.prototype,"value",{get(){let n=Lu(this);return n!==void 0&&(n.i=this.i),this.v},set(n){if(n!==this.v){if(_i>100)throw new Error("Cycle detected");(function(e){Kt!==0&&_i===0&&e.l!==$a&&(e.l=$a,Ri={S:e,v:e.v,i:e.i,o:Ri})})(this),this.v=n,this.i++,Ni++,Kt++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Oi()}}}});function $u(n,e){return new Re(n,e)}function Mu(n){for(let e=n.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function Fu(n){for(let e=n.s;e!==void 0;e=e.n){let t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){n.s=e;break}}}function ju(n){let e,t=n.s;for(;t!==void 0;){let s=t.p;t.i===-1?(t.S.U(t),s!==void 0&&(s.n=t.n),t.n!==void 0&&(t.n.p=s)):e=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=s}n.s=e}function Yt(n,e){Re.call(this,void 0,e),this.x=n,this.s=void 0,this.g=Ni-1,this.f=4}Yt.prototype=new Re;Yt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Ni))return!0;if(this.g=Ni,this.f|=1,this.i>0&&!Mu(this))return this.f&=-2,!0;let n=se;try{Fu(this),se=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return se=n,ju(this),this.f&=-2,!0};Yt.prototype.S=function(n){if(this.t===void 0){this.f|=36;for(let e=this.s;e!==void 0;e=e.n)e.S.S(e)}Re.prototype.S.call(this,n)};Yt.prototype.U=function(n){if(this.t!==void 0&&(Re.prototype.U.call(this,n),this.t===void 0)){this.f&=-33;for(let e=this.s;e!==void 0;e=e.n)e.S.U(e)}};Yt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let n=this.t;n!==void 0;n=n.x)n.t.N()}};Object.defineProperty(Yt.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");let n=Lu(this);if(this.h(),n!==void 0&&(n.i=this.i),16&this.f)throw this.v;return this.v}});function Vu(n,e){return new Yt(n,e)}function Uu(n){let e=n.j;if(n.j=void 0,typeof e=="function"){Kt++;let t=se;se=void 0;try{e()}catch(s){throw n.f&=-2,n.f|=8,Ma(n),s}finally{se=t,Oi()}}}function Ma(n){for(let e=n.s;e!==void 0;e=e.n)e.S.U(e);n.x=void 0,n.s=void 0,Uu(n)}function g1(n){if(se!==this)throw new Error("Out-of-order effect");ju(this),se=n,this.f&=-2;try{8&this.f&&Ma(this)}finally{Oi()}}function Ns(n,e){this.x=n,this.j=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e?.name,kr&&kr.push(this)}Ns.prototype.c=function(){let n=this.S();try{if(8&this.f||this.x===void 0)return;let e=this.x();typeof e=="function"&&(this.j=e)}finally{n()}};Ns.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Uu(this),Fu(this),Kt++;let n=se;return se=this,g1.bind(this,n)};Ns.prototype.N=function(){2&this.f||(this.f|=2,this.u=Rr,Rr=this)};Ns.prototype.d=function(){this.f|=8,1&this.f||Ma(this)};Ns.prototype.dispose=function(){this.d()};function Fa(n,e){let t=new Ns(n,e);try{t.c()}catch(r){throw t.d(),r}let s=t.d.bind(t);return s[Symbol.dispose]=s,s}var Bu,qu,zu,Wu,Zu,Hu,Gu,Ku,y1={signal:$u,computed:Vu,effect:Fa,batchWrite:Du,isSignal:n=>typeof n=="function"||!!n&&typeof n=="object"&&("value"in n||"peek"in n),getValue:n=>typeof n=="function"?n():n.value,setValue:(n,e)=>{if(typeof n?.set=="function"){n.set(e);return}if(n instanceof Yt||typeof n=="function")throw new TypeError("Cannot set value of a read-only computed signal.");n.value=e},peekValue:n=>typeof n?.peek=="function"?n.peek():typeof n=="function"?n():n&&typeof n=="object"&&"value"in n?n.value:n};x1(y1);function x1(n){Bu=n.signal,qu=n.computed,zu=n.effect,Wu=n.batchWrite,Zu=n.isSignal,Hu=n.getValue,Gu=n.setValue,Ku=n.peekValue}function Ae(n){return Bu(n)}function Os(n){return qu(n)}function Ps(n){return zu(n)}function Ds(n){return Wu(n)}function Ls(n){return Zu(n)}function je(n){return Hu(n)}function Ce(n,e){Gu(n,e)}function he(n){return Ku(n)}function _r(n){return/^(0|[1-9]\d*)$/.test(n)}var mn=1e4,S1=new Set(["__proto__","constructor","prototype"]),Tt=class{constructor(e={}){this.data={},this.signals=new Map,this.subscriptions=new Set,this.data=e}getSignal(e){let t=this.normalizePath(e);return this.signals.has(t)||this.signals.set(t,Ae(this.get(t))),this.signals.get(t)}set(e,t,s=!1){if(e==null)throw new oe("Path cannot be null or undefined.");let r=this.parsePath(e);if(r.length===0)return this.data=t??{},this.notifyAllSignals(),this;let i=r.pop(),o=t===void 0||!s&&t===null;if(o&&this.get(e)===void 0)return this;if(this.data===void 0||this.data===null)this.data={};else if(typeof this.data!="object")throw new oe(`Cannot set path '${e}': the data model root is a primitive value.`,e);let a=this.data;for(let c=0;c<r.length;c++){let l=r[c];if(Array.isArray(a)){if(!_r(l))throw new oe(`Cannot use non-numeric segment '${l}' on an array in path '${e}'.`,e);let u=parseInt(l,10);if(u>mn)throw new oe(`Cannot set path '${e}': array index '${l}' exceeds maximum supported index (${mn}).`,e);let d=a[u];if(d!=null&&typeof d!="object")throw new oe(`Cannot set path '${e}': segment '${l}' is a primitive value.`,e);if(d==null){let h=c<r.length-1?r[c+1]:i;if(_r(h)){if(parseInt(h,10)>mn)throw new oe(`Cannot set path '${e}': array index '${h}' exceeds maximum supported index (${mn}).`,e);a[u]=[]}else a[u]={}}}else{let u=Object.prototype.hasOwnProperty.call(a,l);if(u){let d=a[l];if(d!=null&&typeof d!="object")throw new oe(`Cannot set path '${e}': segment '${l}' is a primitive value.`,e)}if(!u||a[l]===void 0||a[l]===null){let d=c<r.length-1?r[c+1]:i;if(_r(d)){if(parseInt(d,10)>mn)throw new oe(`Cannot set path '${e}': array index '${d}' exceeds maximum supported index (${mn}).`,e);a[l]=[]}else a[l]={}}}a=a[l]}if(Array.isArray(a)){if(!_r(i))throw new oe(`Cannot use non-numeric segment '${i}' on an array in path '${e}'.`,e);if(parseInt(i,10)>mn)throw new oe(`Cannot set path '${e}': array index '${i}' exceeds maximum supported index (${mn}).`,e)}if(o)if(Array.isArray(a)){let c=parseInt(i,10);c<a.length&&(a[c]=void 0)}else delete a[i];else a[i]=t;return this.notifySignals(e),this}delete(e){return this.set(e,void 0)}static resolvePath(e,t){return e.startsWith("/")?e:t?`${t.endsWith("/")?t:`${t}/`}${e}`:`/${e}`}get(e){if(e==null)throw new oe("Path cannot be null or undefined.");if(e==="/"||e==="")return this.data;let t=this.parsePath(e),s=this.data;for(let r of t){if(s==null||typeof s!="object")return;if(Array.isArray(s)){if(!_r(r))return;let i=parseInt(r,10);if(i<0||i>=s.length)return;s=s[i]}else{if(!Object.prototype.hasOwnProperty.call(s,r))return;s=s[r]}}return s}hasPath(e){return e==null?!1:this.get(e)!==void 0}subscribe(e,t){let s=this.getSignal(e),r=!0,i=he(s),o=Ps(()=>{let a=je(s);i=a,r||t(a)});return r=!1,this.subscriptions.add(o),{get value(){return i},unsubscribe:()=>{o(),this.subscriptions.delete(o)}}}dispose(){for(let e of this.subscriptions)e();this.subscriptions.clear(),this.signals.clear()}normalizePath(e){let t=e.split("/").filter(s=>s.length>0);return t.length===0?"/":`/${t.join("/")}`}parsePath(e){return e.split("/").filter(t=>t.length>0).map(t=>{let s=t.replace(/~([01])/g,(r,i)=>i==="1"?"/":"~");if(S1.has(s))throw new oe(`Forbidden path segment '${s}' in path '${e}'.`,e);return s})}notifySignals(e){let t=this.normalizePath(e);Ds(()=>{this.updateSignal(t);let s=t;for(;s!=="/"&&s!=="";)s=s.substring(0,s.lastIndexOf("/"))||"/",this.updateSignal(s);for(let r of this.signals.keys())this.isDescendant(r,t)&&this.updateSignal(r)})}updateSignal(e){let t=this.signals.get(e);if(t){let s=this.get(e);Array.isArray(s)?Ce(t,s.slice()):typeof s=="object"&&s!==null?Ce(t,{...s}):Ce(t,s)}}notifyAllSignals(){Ds(()=>{for(let e of this.signals.keys())this.updateSignal(e)})}isDescendant(e,t){return t==="/"||t===""?e!=="/":e.startsWith(t+"/")}};var $s=1e3;var V7=f.object({component:f.string().describe("The type name of the component."),id:f.lazy(()=>Yn).optional(),weight:f.number().optional()}).passthrough().describe("A generic A2UI component definition.");function Nr(n,e,t){if(e!==void 0){let s=n.availableCatalogs?.get(e);if(!s)throw new R(`Catalog not found: ${e}`);return s}if(!n.defaultCatalog)throw new R(`${t} names no catalogId and surface '${n.id}' has no default catalogId.`);return n.defaultCatalog}var ja=new WeakMap,b1="a2ui:system-functions",Yu;function A1(){return Yu??=new ct(b1,dn.V1_0,[],ed),Yu}function Ms(n){if(ja.has(n))return ja.get(n);let e=(()=>{let t=n;for(;t;){if(t instanceof f.ZodObject||t._def?.typeName==="ZodObject"){if(t._def?.unknownKeys==="passthrough")return null;let s=typeof t.shape=="function"?t.shape():t.shape;return s&&typeof s=="object"?new Set(Object.keys(s)):null}if(t instanceof f.ZodEffects||t._def?.typeName==="ZodEffects"){t=t._def.schema;continue}if(t instanceof f.ZodOptional||t instanceof f.ZodNullable||t._def?.typeName==="ZodOptional"||t._def?.typeName==="ZodNullable"){t=t._def.innerType;continue}if(t instanceof f.ZodDefault||t._def?.typeName==="ZodDefault"){t=t._def.innerType;continue}if(t instanceof f.ZodCatch||t._def?.typeName==="ZodCatch"){t=t._def.innerType;continue}if(t instanceof f.ZodIntersection||t._def?.typeName==="ZodIntersection"){let s=Ms(t._def.left),r=Ms(t._def.right);return!s||!r?null:new Set([...s,...r])}if(t instanceof f.ZodUnion||t._def?.typeName==="ZodUnion"){let s=t._def.options,r=new Set;for(let i of s){let o=Ms(i);if(!o)return null;for(let a of o)r.add(a)}return r}return null}return null})();return ja.set(n,e),e}function Ju(n,e,t){if(!e||typeof e!="object"||Array.isArray(e))return;let s=Object.keys(e);if(s.length>$s)throw new ae(`Function call '${n}' exceeds maximum allowed arguments count (${$s})`,n);let r=t?.functions?.get?.(n)??(n==="@index"&&t?.protocolVersion&&z(t.protocolVersion,dn.V1_0)?Fs:void 0);if(!r?.schema)return;let i=Ms(r.schema);if(i){for(let o of s)if(!i.has(o))throw new ae(`Unknown argument '${o}' passed to function '${n}'`,n);if(s.length>i.size)throw new ae(`Too many arguments for function '${n}': expected at most ${i.size}, received ${s.length}`,n)}}function v1(n){return n.startsWith("@")&&!n.startsWith("@@")}function Xu(n){return n.startsWith("@@")?n.slice(1):n}var Qu=new Set(["@path","@call"]);function Li(n,e){if(z(e,"1.0")){for(let t of n)if(v1(t)&&!Qu.has(t))throw new b(`Unrecognized reserved protocol directive '${t}' in v1.0 dynamic object. Reserved keys must be in ${Array.from(Qu).join(", ")}, or escaped with prefix doubling (e.g. '@${t}').`,void 0,"INVALID_RESERVED_KEY")}}function Va(n){let e=n;for(;e;){if(e.explicitIndex!==void 0&&Number.isFinite(e.explicitIndex))return e.explicitIndex;if(!(e instanceof wt)&&typeof e.getIndex=="function"){let t=e.getIndex();if(t!==void 0&&Number.isFinite(t))return t}if(!(e instanceof wt)&&typeof e.index=="number"&&Number.isFinite(e.index))return e.index;if(typeof e.path=="string"){let t=e.path.split("/").filter(Boolean);if(t.length>0&&/^\d+$/.test(t[t.length-1]))return parseInt(t[t.length-1],10)}e=e.parent}}var Di=1e3,wt=class n{constructor(e,t,s,r){this.path=t,this._isUserActivated=!1,this._isPassiveEvaluation=!1,this._isActionExecution=!1,e instanceof Tt?(this.surface=void 0,this.dataModel=e,this.functionInvoker=()=>{}):(this.surface=e,this.dataModel=e.dataModel,this.functionInvoker=e.defaultCatalog?.invoker??((i,...o)=>Nr(e,void 0,`Function call '${i}'`).invoker(i,...o))),this.explicitIndex=s,this.parent=r,this.warnedPaths=r?r.warnedPaths:new Set}get isUserActivated(){return this._isUserActivated||!!this.parent?.isUserActivated}get isPassiveEvaluation(){return this._isPassiveEvaluation||!!this.parent?.isPassiveEvaluation}getIndex(){return Va(this)}get index(){return this.getIndex()}set(e,t){let s=this.resolvePath(e),r=!!(this.surfaceProtocolVersion&&!this.atLeastV10);this.dataModel.set(s,t,r)}get surfaceProtocolVersion(){return this.surface?.protocolVersion??this.surface?.defaultCatalog?.protocolVersion}get atLeastV10(){return this._cachedAtLeastV10===void 0&&(this._cachedAtLeastV10=z(this.surfaceProtocolVersion,"1.0")),this._cachedAtLeastV10}isDataBindingObject(e){return(this.atLeastV10?"@path"in e&&typeof e["@path"]=="string":"path"in e&&typeof e.path=="string")&&!("componentId"in e)}isFunctionCallObject(e){return this.atLeastV10?"@call"in e&&typeof e["@call"]=="string":"call"in e&&typeof e.call=="string"}containsDynamicValue(e){if(e===null||typeof e!="object"||Ze(e))return!1;if(Array.isArray(e))return e.some(s=>this.containsDynamicValue(s));let t=e;if(this.isDataBindingObject(t)||this.isFunctionCallObject(t))return!0;if(this.atLeastV10){for(let s of Object.keys(t))if(s.startsWith("@"))return!0}return Object.values(t).some(s=>this.containsDynamicValue(s))}emitMissingDataBindingWarning(e){typeof this.dataModel?.hasPath=="function"&&!this.dataModel.hasPath(e)&&!this.warnedPaths.has(e)&&(this.warnedPaths.add(e),this.surface?.dispatchWarning?.({code:"MISSING_DATA_BINDING",path:e,message:`Preflight DataBinding Warning: The bound JSON Pointer '${e}' does not physically exist in the active DataModel. Evaluating to None.`}))}resolveDynamicValue(e,t=0,s=!1){if(t>Di){let i=new ae(`Maximum dynamic value nesting depth exceeded (${Di})`);this.dispatchExpressionError(i,"DynamicValue");return}if(e===null||typeof e!="object"||Ze(e))return e;if(Array.isArray(e))return this.containsDynamicValue(e)?e.map(i=>this.resolveDynamicValue(i,t+1,s)):e;let r=e;if(this.isDataBindingObject(r)){let i=r["@path"]??r.path,o=this.resolvePath(i),a=this.dataModel.get(o);return a===void 0&&this.emitMissingDataBindingWarning(o),a}return this.isFunctionCallObject(r)?this.resolveFunctionCallValue(r,t,s):this.resolvePlainObjectValue(r,t,s)}resolveFunctionCallValue(e,t=0,s=!1){let r=e["@call"]??e.call,i=this.resolveCallCatalog(r,e);if(!i)return;try{Ju(r,e.args,i)}catch(u){this.dispatchExpressionError(u,r);return}let o={};for(let[u,d]of Object.entries(e.args??{}))o[u]=this.resolveDynamicValue(d,t+1,s);let a=new AbortController,c=this._isUserActivated;this._isUserActivated=c||s;let l;try{l=this.evaluateFunctionReactive(r,o,i.invoker,a.signal)}finally{this._isUserActivated=c}if(l!==void 0)return Ze(l)?t>0?l:Promise.resolve(l).then(u=>u,u=>{this.dispatchExpressionError(u,r)}):Ls(l)?he(l):l}resolvePlainObjectValue(e,t=0,s=!1){if(this.atLeastV10&&Li(Object.keys(e),this.surfaceProtocolVersion),!this.containsDynamicValue(e))return e;let r={};for(let[i,o]of Object.entries(e)){let a=this.atLeastV10?Xu(i):i;r[a]=this.resolveDynamicValue(o,t+1,s)}return r}subscribeDynamicValue(e,t){let s=this.resolveSignal(e),r=!0,i=he(s),o=Ps(()=>{let a=je(s);i=a,r||t(a)});return r=!1,{get value(){return i},unsubscribe:()=>{o(),s.unsubscribe?.()}}}resolveSignal(e,t=0){if(t>Di){let a=new ae(`Maximum dynamic value nesting depth exceeded (${Di})`);return this.dispatchExpressionError(a,typeof e=="object"&&e&&("@call"in e||"call"in e)?e["@call"]??e.call:"DynamicValue"),Ae(void 0)}if(typeof e!="object"||e===null)return Ae(e);if(Ze(e)){let a=Ae(void 0);return this.settleIntoSignal(a,e,"DynamicValue"),a}if(Array.isArray(e)){if(!this.containsDynamicValue(e))return Ae(e);let a=e.map(l=>this.resolveSignal(l,t+1)),c=Os(()=>a.map(l=>je(l)));return c.unsubscribe=()=>{for(let l of a)l.unsubscribe?.()},c}let s=e;if(this.isDataBindingObject(s)){let a=s["@path"]??s.path,c=this.resolvePath(a);return this.emitMissingDataBindingWarning(c),this.dataModel.getSignal(c)}if(this.isFunctionCallObject(s)){let a=s,c=a["@call"]??a.call,l=this.resolveCallCatalog(c,a);if(!l)return Ae(void 0);try{Ju(c,a.args,l)}catch(A){return this.dispatchExpressionError(A,c),Ae(void 0)}let u={};for(let[A,I]of Object.entries(a.args??{}))u[A]=this.resolveSignal(I,t+1);if(Object.keys(u).length===0){let A=new AbortController,I=this.evaluateFunctionPassive({name:c,args:{},abortSignal:A.signal,invoker:l.invoker}),D;if(Ls(I))D=I;else if(Ze(I)){let O=Ae(void 0);this.settleIntoSignal(O,I,c,A.signal),D=O}else D=Ae(I);return D.unsubscribe=()=>A.abort(),D}let d=Object.keys(u),h=Ae(void 0),p,m,g=Os(()=>{let A={};for(let I=0;I<d.length;I++)A[d[I]]=je(u[d[I]]);return A}),E=Ps(()=>{try{let A=je(g);p&&p.abort(),m&&(m(),m=void 0),p=new AbortController;let I=this.evaluateFunctionPassive({name:c,args:A,abortSignal:p.signal,invoker:l.invoker});Ls(I)?(Ce(h,he(I)),m=Ps(()=>{Ce(h,je(I))})):Ze(I)?this.settleIntoSignal(h,I,c,p.signal):Ce(h,I)}catch(A){this.dispatchExpressionError(A,c),Ce(h,void 0)}});return h.unsubscribe=()=>{E(),m&&m(),p&&p.abort();for(let A=0;A<d.length;A++)u[d[A]].unsubscribe?.()},h}if(this.atLeastV10&&Li(Object.keys(s),this.surfaceProtocolVersion),!this.containsDynamicValue(s))return Ae(e);let r=Object.entries(s).map(([a,c])=>[this.atLeastV10?Xu(a):a,this.resolveSignal(c,t+1)]),i=Os(()=>{let a={};for(let[c,l]of r)a[c]=je(l);return a}),o=i.unsubscribe?.bind(i);return i.unsubscribe=()=>{o?.();for(let[,a]of r)a.unsubscribe?.()},i}handleInvalidAction(e){this.surface?.dispatchError({code:"INVALID_ACTION",surfaceId:this.surface?.id,message:e})}resolveActionEventObject(e){if(typeof e.name!="string"||e.name.length===0)return this.handleInvalidAction("Action event is missing required 'name' string.");let t;if(e.context&&typeof e.context=="object"&&!Array.isArray(e.context)){t={};for(let[r,i]of Object.entries(e.context))t[r]=this.resolveDynamicValue(i)}let s={...e,...t!==void 0?{context:t}:{}};if(e.context===void 0&&delete s.context,e.userMessage!==void 0){let r=this.resolveDynamicValue(e.userMessage);if(typeof r!="string")return this.handleInvalidAction("Action event 'userMessage' must resolve to a string.");s.userMessage=r}return s}executeActionFunctionCall(e,t){let s="functionCall"in e?e.functionCall:e;if(s&&typeof s=="object"){let a=s["@call"]??s.call;typeof a=="string"&&(s=this.atLeastV10&&!("@call"in s)?{"@call":a,...s}:!this.atLeastV10&&!("call"in s)?{call:a,...s}:s)}let r=t?.userActivation??!0,i=this._isActionExecution,o=this._isPassiveEvaluation;this._isActionExecution=!0,t?.userActivation===!1&&(this._isPassiveEvaluation=!0);try{return this.resolveDynamicValue(s,0,r)}finally{this._isActionExecution=i,this._isPassiveEvaluation=o}}resolveAction(e,t){if("event"in e&&typeof e.event=="object"&&e.event!==null){let s=this.resolveActionEventObject(e.event);return s===void 0?void 0:{...e,event:s}}return"name"in e?this.resolveActionEventObject(e):"functionCall"in e||"call"in e||"@call"in e?this.executeActionFunctionCall(e,t):e}resolveFunctionCatalog(e,t,s){if(this.atLeastV10&&e.startsWith("@")){if(s)throw new ae(`System function '${e}' belongs to no catalog and must not name a catalogId.`,e);return A1()}if(!this.surface)throw new R(`No surface available to resolve catalog: ${t??"default"}`);return Nr(this.surface,this.atLeastV10?t:void 0,`Function call '${e}'`)}resolveCallCatalog(e,t){try{return this.resolveFunctionCatalog(e,t.catalogId,"catalogId"in t)}catch(s){s instanceof R&&this.surface?this.surface.dispatchError({code:"CATALOG_ERROR",message:s.message,expression:e}):this.dispatchExpressionError(s,e);return}}evaluateFunctionPassive(e){let{name:t,args:s,invoker:r,abortSignal:i}=e,o=this._isPassiveEvaluation;this._isPassiveEvaluation=!0;try{return this.evaluateFunctionReactive(t,s,r,i)}finally{this._isPassiveEvaluation=o}}evaluateFunctionReactive(e,t,s,r){try{return s(e,t,this,r)}catch(i){this.dispatchExpressionError(i,e);return}}settleIntoSignal(e,t,s,r){Promise.resolve(t).then(i=>{r?.aborted||Ce(e,i)},i=>{r?.aborted||(this.dispatchExpressionError(i,s),Ce(e,void 0))})}dispatchExpressionError(e,t){if(this.surface)if(e instanceof f.ZodError||typeof e=="object"&&e!==null&&e.name==="ZodError"){let s=e,r=new ae(`Validation failed for function '${t}': ${s.message}`,t,s.errors??s.issues);this.surface.dispatchError({code:"EXPRESSION_ERROR",message:r.message,expression:t,details:r.details})}else if(e instanceof ae)this.surface.dispatchError({code:"EXPRESSION_ERROR",message:e.message,expression:e.expression,details:e.details});else{let s=typeof e=="object"&&e!==null?e:{};this.surface.dispatchError({code:this._isActionExecution?"EXECUTION_ERROR":"EXPRESSION_ERROR",message:s.message??`An unexpected error occurred in function ${t}.`,expression:t})}}nested(e,t){let s=this.resolvePath(e);return new n(this.surface??this.dataModel,s,t,this)}resolvePath(e){if(e.startsWith("/"))return e;let t=this.path;return t.endsWith("/")&&t.length>1&&(t=t.slice(0,-1)),e===""||e==="."?t||"/":(t==="/"&&(t=""),`${t}/${e}`)}};var Or=ws(f.string().describe("REF:#/$defs/ComponentId|The unique identifier for a component, used for both definitions and references within the same surface."),"component-id"),Ua=f.string().describe("REF:#/$defs/CallId|The unique identifier for a function call."),gn=f.object({"@path":f.string().describe("A JSON Pointer path to a value in the data model.").optional(),path:f.string().describe("A JSON Pointer path to a value in the data model.").optional()}).refine(n=>n["@path"]!==void 0||n.path!==void 0,{message:"Either '@path' or 'path' must be provided."}).describe("REF:#/$defs/DataBinding"),E1=f.object({"@call":f.string().describe("The name of the function to call.").optional(),call:f.string().describe("The name of the function to call.").optional(),catalogId:f.string().describe("The catalog ID for this function, overriding any surface-level default catalogId.").optional()}).refine(n=>n["@call"]!==void 0||n.call!==void 0,{message:"Either '@call' or 'call' must be provided."}).describe("REF:#/$defs/FunctionCommon|Baseline envelope properties common to all function calls. Function-specific argument schemas ('args') are defined individually by each function in the active catalog."),lt=f.record(f.string(),f.any()).and(f.intersection(E1,f.any())).describe("REF:#/$defs/FunctionCall|Invokes a named function, combining common function properties with the catalog function definition."),$i=f.union([f.string(),gn,lt]).describe("REF:#/$defs/DynamicString|Represents a string"),td=f.union([f.boolean(),gn,lt]).describe("REF:#/$defs/DynamicBoolean|A boolean value that can be a literal, a path, or a function call returning a boolean or a validation result object (coerced to its 'valid' boolean)."),C1=f.object({label:$i.optional(),description:$i.optional(),live:f.enum(["off","polite","assertive"]).describe("Controls screen reader announcements for dynamic updates (WAI-ARIA aria-live). 'polite' waits for user pause; 'assertive' interrupts immediately for alerts.").default("off"),hidden:td.optional()}).strict().describe("REF:#/$defs/AccessibilityAttributes|Attributes to enhance accessibility when using assistive technologies like screen readers or model understanding."),Ba=f.record(f.string(),f.unknown()).superRefine((n,e)=>{for(let t in n)fe(t)||e.addIssue({path:[t],code:f.ZodIssueCode.custom,message:`Invalid extension key "${t}": Keys MUST be Unicode identifiers (UAX #31).`})}).describe("REF:#/$defs/Extensions|Optional extension metadata. Keys MUST be Unicode identifiers (UAX #31). Keys starting with 'a2ui_' are reserved for official extensions."),nd=f.object({id:Or,catalogId:f.string().describe("The catalog ID for this component, overriding any surface-level default catalogId.").optional(),accessibility:C1.optional(),metadata:f.object({extensions:Ba.optional()}).strict().describe("Optional component-level metadata for vendor extensions.").optional()}).describe("REF:#/$defs/ComponentCommon");var T1=ws(f.union([f.array(Or).describe("A static list of child component IDs."),f.object({componentId:Or,path:f.string().describe("The path to the list of component property objects in the data model.")}).strict().describe("A template for generating a dynamic list of children from a data model list. The `componentId` is the component to use as a template.")]).describe("REF:#/$defs/ChildList"),"child-list"),sd=f.union([f.string(),f.number(),f.boolean(),f.array(f.any()),f.record(f.string(),f.unknown()).refine(n=>!n||!("@path"in n)&&!("path"in n)&&!("@call"in n)&&!("call"in n)),gn,lt]).describe("REF:#/$defs/DynamicValue|A value that can be a literal, a path, or a function call returning any type."),rd=f.union([f.number(),gn,lt]).describe("REF:#/$defs/DynamicNumber|Represents a value that can be either a literal number, a path to a number in the data model, or a function call returning a number."),w1=f.union([f.array(f.string()),gn,lt]).describe("REF:#/$defs/DynamicStringList|Represents a value that can be either a literal array of strings, a path to a string array in the data model, or a function call returning a string array."),iS=f.object({"@call":f.literal("@index").optional(),call:f.literal("@index").optional(),args:f.object({offset:rd.optional()}).optional()}).refine(n=>n["@call"]!==void 0||n.call!==void 0,{message:"Either '@call' or 'call' must be '@index'."}).describe("REF:#/$defs/IndexSystemFunction"),I1=f.object({condition:f.union([gn,lt]).describe("Path or function call evaluating to a structured validation result object or a boolean."),message:f.string().describe("Optional fallback error message.").optional()}).strict().describe("REF:#/$defs/CheckRule|A single validation check rule applied to an input component. The condition function or path evaluates to a structured validation result object or a boolean (which is coerced to a validation result object)."),oS=f.object({checks:f.array(I1).describe("A list of validation check rules to perform on the component.").optional()}).describe("REF:#/$defs/Checkable|Properties for components that support renderer-side checks."),aS=f.union([f.object({event:f.object({name:f.string().describe("The name of the action to be dispatched to the agent."),userMessage:$i.optional(),context:f.record(f.string(),sd).describe("A JSON object containing the key-value pairs for the action context. Values can be literals or paths. Use literal values unless the value must be dynamically bound to the data model. Do NOT use paths for static IDs.").optional()}).strict().describe("The event to dispatch to the agent.")}).strict().describe("Triggers an agent-side event."),f.object({functionCall:lt}).strict().describe("Executes a renderer or agent-side function.")]).describe("REF:#/$defs/Action|Defines an interaction handler that can either trigger an agent-side event or execute a local renderer-side function."),cS=f.object({component:f.literal("Surface").optional(),child:f.literal("root").optional()}).strict().describe("REF:#/$defs/Surface|The reserved canonical container component representing an A2UI surface. The Surface component is immutable and always has 'child': 'root'."),id=f.object({functionCallId:Ua,value:f.any().describe("The return value of the function.").optional(),error:f.object({code:f.string(),message:f.string()}).strict().describe("An error object indicating failure of the function execution.").optional()}).strict().superRefine((n,e)=>{let t="value"in n,s="error"in n;(t&&s||!t&&!s)&&e.addIssue({code:f.ZodIssueCode.custom,message:'FunctionResponse must have either "value" or "error", but not both or neither.'})}).describe("REF:#/$defs/FunctionResponse|The return response matching a callAgentFunction or callRendererFunction invocation.");var Fs={name:"@index",returnType:"number",allowedCallers:"rendererOnly",schema:f.object({offset:f.union([gn,lt,f.coerce.number()]).optional()})},qa=od(Fs,(n,e)=>{let t=typeof n.offset=="number"&&Number.isFinite(n.offset)?n.offset:0,s=Va(e);if(s===void 0||!Number.isFinite(s))throw new b("@index function can only be evaluated inside a collection template iteration scope.");return s+t}),ed=[qa];var k1=/^REF:[^|#]*#\/\$defs\/DynamicBoolean(?:\||$)/;function R1(n){if(typeof n!="object"||n===null||Array.isArray(n))return;let e=n.valid;return typeof e=="boolean"?e:void 0}function za(n){let e=n._def;switch(e.typeName){case"ZodOptional":case"ZodNullable":case"ZodDefault":case"ZodCatch":case"ZodBranded":case"ZodReadonly":return e.innerType;case"ZodEffects":return e.schema;case"ZodLazy":return e.getter?.();default:return}}function _1(n){let e=n;for(;e;){if(typeof e.description=="string"&&k1.test(e.description))return!0;e=za(e)}return!1}function N1(n){let e=n;for(let t=za(e);t;t=za(e))e=t;return e}function O1(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Mi(n,e){if(typeof e!="object"||e===null)return e;if(_1(n))return R1(e)??e;let t=N1(n),s=t._def;if(s.typeName==="ZodArray"&&Array.isArray(e)&&s.type){let r=s.type,i=!1,o=e.map(a=>{let c=Mi(r,a);return i||=c!==a,c});return i?o:e}if(s.typeName==="ZodObject"&&O1(e)){let r=t.shape,i=!1,o={};for(let[a,c]of Object.entries(e)){let l=r[a],u=l?Mi(l,c):c;i||=u!==c,o[a]=u}return i?o:e}return e}function od(n,e){return{name:n.name,returnType:n.returnType,schema:n.schema,allowedCallers:n.allowedCallers,requiresUserActivation:n.requiresUserActivation,description:n.description,execute:e}}var ct=class n{get validationSchema(){return this.cachedValidationSchema||(this.cachedValidationSchema=Nu(this)),ue(this.cachedValidationSchema)}get catalogSchema(){return this.validationSchema}toJson(){return this.cachedDocument||(this.cachedDocument=yu(this)),ue(this.cachedDocument)}withEntries(e,t){return this.rebuild(e,t,{id:this.id,schemaId:this.schemaId,title:this.title,description:this.description,instructions:this.instructions})}derive(e){let t=(s,r,i)=>i===void 0?[...r.values()]:i.map(o=>{if(typeof o!="string")return o;let a=r.get(o);if(!a)throw new R(`Catalog '${this.id}' has no ${s} '${o}' to derive catalog '${e.catalogId}' from.`);return a});return this.rebuild(t("component",this.components,e.components),t("function",this.functions,e.functions),{id:e.catalogId,instructions:e.instructions})}rebuild(e,t,s){let r=e.length!==this.components.size||e.some(c=>this.components.get(c.name)!==c),i=t.length!==this.functions.size||t.some(c=>this.functions.get(c.name)!==c),o=this.defs;if(o&&(r||i)){let c={...o};r&&delete c.anyComponent,i&&delete c.anyFunction,o=c}let a=this.unions?{anyComponent:this.unions.anyComponent||r,anyFunction:this.unions.anyFunction||i}:void 0;return new n(s.id,this.protocolVersion,e,t,{themeSchema:this.themeSchema,instructions:s.instructions,schemaUri:this.schemaUri,schemaId:s.schemaId,title:s.title,description:s.description,declaredProtocolVersion:this.declaredProtocolVersion,declaresCatalogId:this.declaresCatalogId,declaresComponents:this.declaresComponents,functionsLayout:this.functionsLayout,unions:a,defs:hu(o,[...this.components.values(),...this.functions.values()],[...e,...t],this.extensionFields),extensionFields:this.extensionFields,commonTypesUri:this.commonTypesUri,themeLocation:this.themeLocation,defModels:this.defModels})}get componentRefMap(){if(!this._componentRefMap){let e=z(this.protocolVersion,"1.0")?ua:z(this.protocolVersion,"0.9")?Jl:Kl;this._componentRefMap=La(this,e)}return this._componentRefMap}constructor(e,t,s,r,i,o){let a,c,l,u,d;if(typeof t!="string"?(a="0.9",c=t??[],l=s??[],u=r,d=i):(a=t,c=s??[],l=r??[],u=i,d=o),!a)throw new R("protocolVersion must be provided.");this.id=e,this.protocolVersion=a;let h=new Map;for(let g of c)h.set(g.name,g);this.components=h;let p=new Map;for(let g of l)p.set(g.name,g);this.functions=p;let m=P1(u)?{themeSchema:u}:u??{};this.themeSchema=m.themeSchema,this.instructions=m.instructions??d,this.schemaUri=m.schemaUri,this.schemaId=m.schemaId,this.title=m.title,this.description=m.description,this.declaredProtocolVersion=m.declaredProtocolVersion,this.declaresCatalogId=m.declaresCatalogId??!0,this.declaresComponents=m.declaresComponents??!0,this.functionsLayout=m.functionsLayout,this.unions=m.unions?Object.freeze({...m.unions}):void 0,this.defs=va(m.defs),this.extensionFields=va(m.extensionFields),this.commonTypesUri=m.commonTypesUri,this.themeLocation=m.themeLocation,this.defModels=m.defModels?Object.freeze([...m.defModels]):void 0,this.invoker=D1(this.id,this.protocolVersion,this.functions)}static fromJson(e,t,s){let{id:r,protocolVersion:i,components:o,functions:a,...c}=ku(e,t,s);return new n(r,i,o,a,c)}static fromSchema(e,t){return n.fromJson(e,t)}};function P1(n){return typeof n=="object"&&n!==null&&typeof n.safeParse=="function"}function D1(n,e,t){return(s,r,i,o)=>{let a=t.get(s)??(z(e,dn.V1_0)&&s==="@index"?qa:void 0);if(!a)throw new ae(`Function not found in catalog '${n}': ${s}`,s);L1(a),$1(a,i);let c=a.execute;if(typeof c!="function")throw new ae(`Function '${s}' in catalog '${n}' is schema-only and has no implementation.`,s);let l=d=>{try{let h=z(e,dn.V1_0)?Mi(a.schema,d):d,p=a.schema.parse(h);return c.call(a,p,i,o)}catch(h){throw h?.name==="ZodError"||h instanceof f.ZodError?new ae(`Validation failed for function '${s}': ${h.message}`,s,h.errors??h.issues):h}},u=Hn(r);return Ze(u)?Promise.resolve(u).then(d=>o?.aborted?void 0:l(d)):l(u)}}function L1(n){if(n.allowedCallers==="agentOnly")throw new ae(`Function '${n.name}' cannot be called by renderer (allowedCallers is agentOnly).`,n.name)}function $1(n,e){if(!n.requiresUserActivation)return;let t=!!e?.isPassiveEvaluation,r=!!!e?.isUserActivated&&typeof navigator<"u"&&!(navigator.userActivation?.isActive??!0);if(t||r)throw new ae(`Function '${n.name}' requires user activation and cannot be evaluated without an active user gesture.`,n.name)}var It=(n,e)=>{let t=Object.keys(n).filter(s=>n[s]!==void 0);t.length!==1&&e.addIssue({code:f.ZodIssueCode.custom,message:`Must define exactly one property, found ${t.length} (${t.join(", ")}).`})},Ke=f.object({path:f.string().optional(),literalString:f.string().optional(),literal:f.string().optional()}).strict().superRefine(It),ad=f.lazy(()=>f.object({key:f.string(),valueString:f.string().optional(),valueNumber:f.number().optional(),valueBoolean:f.boolean().optional(),valueMap:f.array(ad).optional()}).strict().superRefine((n,e)=>{let t=0;n.valueString!==void 0&&t++,n.valueNumber!==void 0&&t++,n.valueBoolean!==void 0&&t++,n.valueMap!==void 0&&t++,t!==1&&e.addIssue({code:f.ZodIssueCode.custom,message:`Value map item must have exactly one value property (valueString, valueNumber, valueBoolean, valueMap), found ${t}.`})}));function M1(n={}){let e=n.maxDepth??5;return ad.superRefine((t,s)=>{let r=(i,o)=>{if(o>e){s.addIssue({code:f.ZodIssueCode.custom,message:`valueMap recursion exceeded maximum depth of ${e}.`});return}if(i.valueMap&&Array.isArray(i.valueMap))for(let a of i.valueMap)r(a,o+1)};r(t,1)})}var cd=M1(),PS=f.object({path:f.string().optional(),literalNumber:f.number().optional(),literal:f.number().optional()}).strict().superRefine(It),DS=f.object({path:f.string().optional(),literalBoolean:f.boolean().optional(),literal:f.boolean().optional()}).strict().superRefine(It),F1=f.object({name:f.string().describe("A unique name identifying the action (e.g., 'submitForm')."),context:f.array(f.object({key:f.string(),value:f.object({path:f.string().describe("A data binding reference to a location in the data model (e.g., '/user/name').").optional(),literalString:f.string().describe("A fixed, hardcoded string value.").optional(),literalNumber:f.number().optional(),literalBoolean:f.boolean().optional()}).describe("The dynamic value. Define EXACTLY ONE of the nested properties.").strict().superRefine(It)})).describe("A key-value map of data bindings to be resolved when the action is triggered.").optional()}),LS=f.object({text:Ke,usageHint:f.enum(["h1","h2","h3","h4","h5","caption","body"]).optional()}),$S=f.object({url:Ke,usageHint:f.enum(["icon","avatar","smallFeature","mediumFeature","largeFeature","header"]).optional(),fit:f.enum(["contain","cover","fill","none","scale-down"]).optional(),altText:Ke.optional()}),MS=f.object({name:Ke}),FS=f.object({url:Ke}),jS=f.object({url:Ke,description:Ke.optional().describe("A label, title, or placeholder text.")}),VS=f.object({tabItems:f.array(f.object({title:f.object({path:f.string().describe("A data binding reference to a location in the data model (e.g., '/user/name').").optional(),literalString:f.string().describe("A fixed, hardcoded string value.").optional()}),child:f.string().describe("A reference to a component instance by its unique ID.")}).strict().superRefine((n,e)=>{n.title||e.addIssue({code:f.ZodIssueCode.custom,message:"Tab item is missing 'title'."}),n.child||e.addIssue({code:f.ZodIssueCode.custom,message:"Tab item is missing 'child'."}),n.title&&It(n.title,e)})).describe("A list of tabs, each with a title and a child component ID.")}),US=f.object({axis:f.enum(["horizontal","vertical"]).optional().describe("The orientation."),color:f.string().optional().describe("The color of the divider (e.g., hex code or semantic name)."),thickness:f.number().optional().describe("The thickness of the divider.")}),BS=f.object({entryPointChild:f.string().describe("The ID of the component (e.g., a button) that triggers the modal."),contentChild:f.string().describe("The ID of the component to display as the modal's content.")}),qS=f.object({child:f.string().describe("The ID of the component to display as the button's content."),action:F1.describe("Represents a user-initiated action."),primary:f.boolean().optional().describe("Indicates if this button should be styled as the primary action.")}),zS=f.object({label:Ke,value:f.object({path:f.string().describe("A data binding reference to a location in the data model (e.g., '/user/name').").optional(),literalBoolean:f.boolean().optional()}).strict().superRefine(It)}),WS=f.object({text:Ke.optional(),label:Ke.describe("A label, title, or placeholder text."),textFieldType:f.enum(["shortText","number","date","longText","obscured"]).optional(),validationRegexp:f.string().optional().describe("A regex string to validate the input.")}),ZS=f.object({value:Ke,enableDate:f.boolean().optional(),enableTime:f.boolean().optional(),outputFormat:f.string().optional().describe("The string format for the output (e.g., 'YYYY-MM-DD').")}),HS=f.object({selections:f.object({path:f.string().describe("A data binding reference to a location in the data model (e.g., '/user/name').").optional(),literalArray:f.array(f.string()).optional()}).strict().superRefine(It),options:f.array(f.object({label:f.object({path:f.string().describe("A data binding reference to a location in the data model (e.g., '/user/name').").optional(),literalString:f.string().describe("A fixed, hardcoded string value.").optional()}).strict().superRefine(It),value:f.string()})).optional(),maxAllowedSelections:f.number().optional(),type:f.enum(["checkbox","chips"]).optional(),filterable:f.boolean().optional()}),GS=f.object({value:f.object({path:f.string().describe("A data binding reference to a location in the data model (e.g., '/user/name').").optional(),literalNumber:f.number().optional()}).strict().superRefine(It),minValue:f.number().optional(),maxValue:f.number().optional(),label:Ke.optional()}),j1=f.object({componentId:f.string(),dataBinding:f.string()}),Wa=f.object({explicitList:f.array(f.string()).optional(),template:j1.describe("A template for generating a dynamic list of children from a data model list. `componentId` is the component to use as a template, and `dataBinding` is the path to the map of components in the data model. Values in the map will define the list of children.").optional()}).strict().superRefine(It),KS=f.object({children:Wa,distribution:f.enum(["start","center","end","spaceBetween","spaceAround","spaceEvenly"]).optional(),alignment:f.enum(["start","center","end","stretch"]).optional()}),YS=f.object({children:Wa,distribution:f.enum(["start","center","end","spaceBetween","spaceAround","spaceEvenly"]).optional(),alignment:f.enum(["start","center","end","stretch"]).optional()}),JS=f.object({children:Wa,direction:f.enum(["vertical","horizontal"]).optional(),alignment:f.enum(["start","center","end","stretch"]).optional()}),XS=f.object({child:f.string().describe("The ID of the component to be rendered inside the card.")});var V1=cd.describe("A single data entry. Exactly one 'value*' property should be provided alongside the key."),U1=f.record(f.any()).refine(n=>Object.keys(n).length===1,"A wrapper object that MUST contain exactly one key, which is the name of the component type (e.g., 'Heading').");var B1=f.object({id:f.string().describe("The unique identifier for this component."),weight:f.number().optional().describe("The relative weight of this component within a Row or Column. This corresponds to the CSS 'flex-grow' property. Note: this may ONLY be set when the component is a direct descendant of a Row or Column."),component:U1.describe("A wrapper object that MUST contain exactly one key, which is the name of the component type (e.g., 'Heading'). The value is an object containing the properties for that specific component.")}).strict().describe("Represents a *single* component in a UI widget tree. This component could be one of many supported types."),q1=f.object({surfaceId:f.string().describe("The unique identifier for the UI surface to be rendered."),catalogId:f.string().optional().describe("The identifier of the component catalog to use for this surface. If omitted, the client MUST default to the standard catalog for this A2UI version (https://a2ui.org/specification/v0_8/standard_catalog_definition.json)."),root:f.string().describe("The ID of the root component to render."),styles:f.object({font:f.string().optional().describe("The primary font for the UI."),primaryColor:f.string().regex(/^#[0-9a-fA-F]{6}$/).optional().describe("The primary UI color as a hexadecimal code (e.g., '#00BFFF').")}).strict().optional().describe("Styling information for the UI.")}).strict().describe("Signals the client to begin rendering a surface with a root component and specific styles."),z1=f.object({surfaceId:f.string().describe("The unique identifier for the UI surface to be updated. If you are adding a new surface this *must* be a new, unique identified that has never been used for any existing surfaces shown."),components:f.array(B1).min(1).describe("A list containing all UI components for the surface.")}).strict().superRefine((n,e)=>{let t=new Set;for(let r of n.components)r.id&&(t.has(r.id)&&e.addIssue({code:f.ZodIssueCode.custom,message:`Duplicate component ID found: ${r.id}`,path:["components"]}),t.add(r.id));let s=(r,i)=>{for(let o of r)o&&!t.has(o)&&e.addIssue({code:f.ZodIssueCode.custom,message:`Component '${i}' references non-existent component ID '${o}'.`,path:["components"]})};for(let r of n.components){if(!r.id||!r.component)continue;let i=Object.keys(r.component);if(i.length!==1)continue;let o=i[0],a=r.component[o];switch(o){case"Row":case"Column":case"List":if(a.children&&!Array.isArray(a.children)){let c=!!a.children.explicitList,l=!!a.children.template;(c&&l||!c&&!l)&&e.addIssue({code:f.ZodIssueCode.custom,message:`Component '${r.id}' must have either 'explicitList' or 'template' in children, but not both or neither.`}),c&&s(a.children.explicitList,r.id),l&&s([a.children.template?.componentId],r.id)}break;case"Card":a.child&&s([a.child],r.id);break;case"Tabs":a.tabItems&&Array.isArray(a.tabItems)&&a.tabItems.forEach(c=>{c.child&&s([c.child],r.id)});break;case"Modal":s([a.entryPointChild,a.contentChild],r.id);break;case"Button":a.child&&s([a.child],r.id);break}}}).describe("Updates a surface with a new set of components."),W1=f.object({surfaceId:f.string().describe("The unique identifier for the UI surface this data model update applies to."),path:f.string().optional().describe("An optional path to a location within the data model (e.g., '/user/name'). If omitted, or set to '/', the entire data model will be replaced."),contents:f.array(V1).describe("An array of data entries. Each entry must contain a 'key' and exactly one corresponding typed 'value*' property.")}).strict().describe("Updates the data model for a surface."),Z1=f.object({surfaceId:f.string().describe("The unique identifier for the UI surface to be deleted.")}).strict().describe("Signals the client to delete the surface identified by 'surfaceId'."),ld=f.object({beginRendering:q1.optional(),surfaceUpdate:z1.optional(),dataModelUpdate:W1.optional(),deleteSurface:Z1.optional()}).strict().superRefine((n,e)=>{Object.keys(n).filter(s=>["beginRendering","surfaceUpdate","dataModelUpdate","deleteSurface"].includes(s)).length!==1&&e.addIssue({code:f.ZodIssueCode.custom,message:"A2UI Protocol message must have exactly one of: surfaceUpdate, dataModelUpdate, beginRendering, deleteSurface."})}).describe("Describes a JSON payload for an A2UI (Agent to UI) message, which is used to dynamically construct and update user interfaces. A message MUST contain exactly ONE of the action properties: 'beginRendering', 'surfaceUpdate', 'dataModelUpdate', or 'deleteSurface'.");var Se=class{constructor(){this.listeners=new Set}subscribe(e){return this.listeners.add(e),{unsubscribe:()=>this.listeners.delete(e)}}async emit(e){for(let t of this.listeners)try{let s=t(e);s&&typeof s.then=="function"&&await s}catch(s){console.error("EventEmitter error:",s)}}dispose(){this.listeners.clear()}};var js=50,Fi=5,Za=/^(?:(?:\/(?:[^~/]|~[01])*)*|(?:[^~/]|~[01])+(?:\/(?:[^~/]|~[01])*)*)$/;function*ji(n,e,t){if(typeof n=="string")yield[n,e];else if(Array.isArray(n))for(let s=0;s<n.length;s++){let r=n[s],i=`${e}[${s}]`;yield*ji(r,i,t)}else if(typeof n=="object"&&n!==null){let s=n;if("componentId"in s&&typeof s.componentId=="string"&&("path"in s||"dataBinding"in s))yield[s.componentId,`${e}.componentId`];else if(t?.size)for(let r of t)r in s&&(yield*ji(s[r],`${e}.${r}`));else for(let[r,i]of Object.entries(s))yield*ji(i,`${e}.${r}`)}}function H1(n){return n.componentRefMap}function*Vs(n,e){if(!n||typeof n!="object")return;let t=e instanceof ct?H1(e):e,s=n.component,r="",i=n;if(typeof s=="string")r=s;else if(typeof s=="object"&&s!==null){let u=s;r=Object.keys(u)[0]??"",i=u[r]??{}}if(!r||typeof i!="object"||i===null)return;let o=t[r],a=o?o.singleRefs:new Set,c=o?o.listRefs:new Set,l=o?.nestedRefs;for(let[u,d]of Object.entries(i))(a.has(u)||c.has(u))&&(yield*ji(d,u,l?.[u]))}var Vi=Object.freeze({allowOrphanComponents:!1,allowDanglingReferences:!1,allowMissingRoot:!1,allowUnknownElements:!1}),G1=Object.freeze({allowOrphanComponents:!0,allowDanglingReferences:!0,allowMissingRoot:!0,allowUnknownElements:!0});function ns(n,e,t){if(e>js)throw new Ie(`Global recursion limit exceeded: Depth > ${js}`);if(Array.isArray(n)){for(let s of n)ns(s,e+1,t);return}if(typeof n=="object"&&n!==null){let s=n;for(let o of[s.path,s["@path"]])if(typeof o=="string"&&!Za.test(o))throw new b(`Invalid path syntax: '${o}'`);let r="functionCall"in s&&typeof s.functionCall=="object"&&s.functionCall!==null,i=("call"in s||"@call"in s)&&"args"in s;if(r){if(t>=Fi)throw new Ie(`Recursion limit exceeded: functionCall depth > ${Fi}`);for(let[o,a]of Object.entries(s))o==="functionCall"?ns(a,e+1,t+1):ns(a,e+1,t)}else if(i){if(t>=Fi)throw new Ie(`Recursion limit exceeded: functionCall depth > ${Fi}`);for(let[o,a]of Object.entries(s))o==="args"?ns(a,e+1,t+1):ns(a,e+1,t)}else for(let o of Object.values(s))ns(o,e+1,t)}}function Ha(n){ns(n,0,0)}var Us=class{constructor(e){this.components=new Map,this._onCreated=new Se,this._onDeleted=new Se,this.onCreated=this._onCreated,this.onDeleted=this._onDeleted,e&&this.setCatalog(e)}setCatalog(e){this.refMap=e instanceof ct?e.componentRefMap:e}get(e){return this.components.get(e)}getAll(){return new Map(this.components)}has(e){return this.components.has(e)}get entries(){return this.components.entries()}get keys(){return this.components.keys()}get values(){return this.components.values()}get size(){return this.components.size}get componentsMap(){return this.components}addComponent(e){if(this.components.has(e.id))throw new At(`Component with id '${e.id}' already exists.`);this.components.set(e.id,e),this._onCreated.emit(e)}insertComponent(e,t){if(this.components.has(t.id))throw new At(`Component with id '${t.id}' already exists.`);if(e<this.components.size){let s=[...this.components].slice(Math.max(0,e));for(let[r]of s)this.components.delete(r);this.components.set(t.id,t);for(let[r,i]of s)this.components.set(r,i)}else this.components.set(t.id,t);this._onCreated.emit(t)}removeComponent(e){let t=this.components.get(e);t&&(this.components.delete(e),t.dispose(),this._onDeleted.emit(e))}getChildReferences(e){let t=this.components.get(e);if(!t)return[];let s=t.catalog.components.size?t.catalog.componentRefMap:this.refMap??t.catalog.componentRefMap;return Array.from(Vs(t.componentTree,s))}getChildIds(e){return this.getChildReferences(e).map(([t])=>t)}detectCycles(e={}){let t=e.rootId??"root",s=e.maxDepth??js,r=e.allowMissingRoot??!1;for(let c of this.components.values())for(let[l,u]of this.getChildReferences(c.id))if(l===c.id)throw new Ie(`Circular reference detected: Component '${c.id}' references itself in field '${u}' (Self-reference detected)`);let i=new Set,o=new Set,a=(c,l)=>{if(l>s)throw new Ie(`Global recursion limit exceeded: logical depth > ${s}`);i.add(c),o.add(c);let u=this.getChildIds(c);for(let d of u)if(this.components.has(d)){if(!i.has(d))a(d,l+1);else if(o.has(d))throw new Ie(`Circular reference detected involving component '${d}'`)}o.delete(c)};if(r){let c=Array.from(this.components.keys()).sort();for(let l of c)i.has(l)||a(l,0)}else this.components.has(t)&&a(t,0);return i}validateTopology(e={}){if(this.components.size===0)return;let t=e.rootId??"root",s=e.allowMissingRoot??!1,r=e.allowDanglingReferences??!1,i=e.allowOrphanComponents??!1;if(!s&&!this.components.has(t))throw new xe(`Missing root component: No component has id='${t}'`);if(!r){for(let a of this.components.values())for(let[c,l]of this.getChildReferences(a.id))if(!this.components.has(c))throw new xe(`Component '${a.id}' references non-existent component '${c}' in field '${l}' (Dangling reference '${c}' in component '${a.id}')`)}let o=this.detectCycles({rootId:t,allowMissingRoot:s,maxDepth:e.maxDepth});if(!i&&!s&&o.size<this.components.size){let a=Array.from(this.components.keys()).filter(c=>!o.has(c)).sort();if(a.length>0)throw new xe(`Component '${a[0]}' is not reachable from '${t}' (Orphaned component '${a[0]}' is not reachable from root)`)}}validateReferences(e={}){let t=[];try{this.validateTopology(e)}catch(s){s instanceof b?t.push(s):s instanceof Error&&t.push(new b(s.message))}return t}dispose(){let e=Array.from(this.components.keys());for(let t of this.components.values())t.dispose();this.components.clear();for(let t of e)this._onDeleted.emit(t);this._onCreated.dispose(),this._onDeleted.dispose()}};function K1(n){if(!n)return;let e=le(n);return e?z(e,"1.0")?e:`v${e}`:n}var kt=class{constructor(e,t,s=new Map,r={},i=!1,o,a="root",c,l){this.id=e,this.defaultCatalog=t,this.rootId=a,this._onAction=new Se,this._onError=new Se,this._onWarning=new Se,this._onMetadataChanged=new Se,this.onAction=this._onAction,this.onError=this._onError,this.onWarning=this._onWarning,this.onMetadataChanged=this._onMetadataChanged,this._metadataSignal=Ae(vt(c)),this.metadataSignal=Os(()=>je(this._metadataSignal)),this.protocolVersion=K1(l??t?.protocolVersion);let u,d={},h=!1;if(s!=null&&!(s instanceof Map))if(typeof s=="object"&&!Array.isArray(s))d=s,h=r===!0,o=i instanceof Tt?i:void 0,u=void 0;else throw new TypeError("availableCatalogs must be a Map, or undefined/null. Note that availableCatalogs is now the 3rd argument to SurfaceModel and theme is the 4th argument.");else u=s,d=r??{},h=!!i;this.theme=d,this.sendDataModel=h;let p=new Map(u??[]);t?.id&&!p.has(t.id)&&p.set(t.id,t),this.availableCatalogs=p,this.dataModel=o??new Tt({}),this.componentsModel=new Us(t)}get catalog(){return this.defaultCatalog}resolveCatalog(e,t="Item"){return Nr(this,e,t)}get metadata(){return he(this._metadataSignal)}set metadata(e){let t=vt(e);pr(he(this._metadataSignal),t)||(Ce(this._metadataSignal,t),this._onMetadataChanged.emit(t))}get extensions(){return he(this._metadataSignal)?.extensions}setExtension(e,t){if(t===void 0){this.removeExtension(e);return}let s=he(this._metadataSignal),r={...s?.extensions??{},[e]:t};this.metadata={...s??{},extensions:r}}removeExtension(e){let t=he(this._metadataSignal),s=t?.extensions;if(!s||!(e in s))return;let r={...s};delete r[e];let i={...t};delete i.extensions,Object.keys(r).length>0?this.metadata={...i,extensions:r}:Object.keys(i).length>0?this.metadata=i:this.metadata=void 0}async dispatchAction(e,t,s){if(!e||typeof e!="object")return;let r=Y1(e);if(!r)return;let i=r.name;if(!i||typeof i!="string")return;let o=r.context,a=o&&typeof o=="object"&&!Array.isArray(o)?o:{},c={name:i,surfaceId:this.id,sourceComponentId:t,timestamp:new Date().toISOString(),context:a},l=r.catalogId??e.catalogId;typeof l=="string"&&l&&(c.catalogId=l),typeof r.userMessage=="string"&&r.userMessage.length>0&&(c.userMessage=r.userMessage);let u=r.metadata??e.metadata,d=cl(u,s);d!==void 0&&(c.metadata=d),await this._onAction.emit(c)}async dispatchError(e){await this._onError.emit({...e,surfaceId:this.id})}async dispatchWarning(e){await this._onWarning.emit({...e,surfaceId:this.id})}dispose(){this.dataModel.dispose(),this.componentsModel.dispose(),this._onAction.dispose(),this._onError.dispose(),this._onWarning.dispose(),this._onMetadataChanged.dispose()}};function Y1(n){return"event"in n&&n.event&&typeof n.event=="object"?n.event:"name"in n&&typeof n.name=="string"?n:null}var Ui=class{constructor(){this.surfaces=new Map,this.surfaceUnsubscribers=new Map,this.surfaceErrorUnsubscribers=new Map,this._onSurfaceCreated=new Se,this._onSurfaceDeleted=new Se,this._onAction=new Se,this._onError=new Se,this.onSurfaceCreated=this._onSurfaceCreated,this.onSurfaceDeleted=this._onSurfaceDeleted,this.onAction=this._onAction,this.onError=this._onError}emitError(e){this._onError.emit(e)}addSurface(e){if(this.surfaces.has(e.id)){console.warn(`Surface ${e.id} already exists. Ignoring.`);return}this.surfaces.set(e.id,e);let t=e.onAction.subscribe(r=>{this._onAction.emit(r)});this.surfaceUnsubscribers.set(e.id,t);let s=e.onError.subscribe(r=>{this._onError.emit(r)});this.surfaceErrorUnsubscribers.set(e.id,s),this._onSurfaceCreated.emit(e)}deleteSurface(e){let t=this.surfaces.get(e);if(t){let s=this.surfaceUnsubscribers.get(e);s&&(s.unsubscribe(),this.surfaceUnsubscribers.delete(e));let r=this.surfaceErrorUnsubscribers.get(e);r&&(r.unsubscribe(),this.surfaceErrorUnsubscribers.delete(e)),this.surfaces.delete(e),t.dispose(),this._onSurfaceDeleted.emit(e)}}getSurface(e){return this.surfaces.get(e)}get surfacesMap(){return this.surfaces}dispose(){for(let e of Array.from(this.surfaces.keys()))this.deleteSurface(e);this._onSurfaceCreated.dispose(),this._onSurfaceDeleted.dispose(),this._onAction.dispose(),this._onError.dispose()}};var _e=class{constructor(e,t,s,r,i){this.id=e,this.type=t,this._onUpdated=new Se,this._onMetadataChanged=new Se,this.onUpdated=this._onUpdated,this.onMetadataChanged=this._onMetadataChanged,this._properties=s,this.catalog=r,this._metadataSignal=Ae(vt(i))}get metadataSignal(){return this._metadataSignal}get metadata(){return he(this._metadataSignal)}set metadata(e){let t=vt(e);pr(he(this._metadataSignal),t)||(Ce(this._metadataSignal,t),this._onMetadataChanged.emit(t))}get extensions(){return he(this._metadataSignal)?.extensions}setExtension(e,t){if(t===void 0){this.removeExtension(e);return}let s=he(this._metadataSignal),r={...s?.extensions??{},[e]:t};this.metadata={...s??{},extensions:r}}removeExtension(e){let t=he(this._metadataSignal),s=t?.extensions;if(!s||!(e in s))return;let r={...s};delete r[e];let i={...t};delete i.extensions,Object.keys(r).length>0?this.metadata={...i,extensions:r}:Object.keys(i).length>0?this.metadata=i:this.metadata=void 0}get properties(){return this._properties}set properties(e){this._properties=e,this._onUpdated.emit(this)}applyUpdate(e,t){let s=vt(t),r=!hr(this._properties,e),i=!pr(he(this._metadataSignal),s);r&&(this._properties=e),i&&Ce(this._metadataSignal,s),r&&this._onUpdated.emit(this),i&&this._onMetadataChanged.emit(s)}dispose(){this._onUpdated.dispose(),this._onMetadataChanged.dispose()}get componentTree(){let e=this.metadata;return{...this._properties,id:this.id,component:this.type,...e!==void 0?{metadata:e}:{}}}};var dd=["createSurface","updateComponents","updateDataModel","deleteSurface","callRendererFunction","agentFunctionResponse","beginRendering","surfaceUpdate","dataModelUpdate"];function ud(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function yn(n,e){if(!ud(n))return{version:e};let t=typeof n.version=="string"?n.version:e,s=dd.find(c=>Object.hasOwn(n,c));if(!s)return{version:t};let r=s==="callRendererFunction",i=n[s];if(!ud(i))return{actionType:s,isCallRendererFunction:r,version:t};let o=typeof i.surfaceId=="string"?i.surfaceId:void 0,a=typeof i.functionCallId=="string"?i.functionCallId:void 0;return{surfaceId:o,functionCallId:a,actionType:s,isCallRendererFunction:r,version:t}}function fd(n){return n.length>0&&dd.includes(n[0])?n.slice(1):n}function hd(n){if(!n)return;if(n.startsWith("/"))return n;let e=n.replace(/\[(\d+)\]/g,"/$1").replace(/\./g,"/").replace(/^\/+/,"");if(!e)return"/";let t=fd(e.split("/").filter(Boolean));return t.length>0?`/${t.join("/")}`:void 0}function pd(n,e){let t=[];for(let r of n)if(r.code===f.ZodIssueCode.invalid_union&&"unionErrors"in r){let i=r.unionErrors.flatMap(o=>o.issues);t.push(...pd(i,e))}else t.push(r);if(!e)return t;let s=t.filter(r=>r.path[0]===e&&r.path.length>1);return s.length>0?s:t}function J1(n,e){let t;if(n instanceof f.ZodError)t=n.issues;else if(Array.isArray(n)&&n.length>0){let o=n[0];if(typeof o?.path=="string")return hd(o.path);Array.isArray(o?.path)&&(t=n)}if(!t||t.length===0)return;let s=pd(t,e)[0];if(!s)return;let r=s.path.map(o=>String(o).replace(/~/g,"~0").replace(/\//g,"~1"));s.code===f.ZodIssueCode.unrecognized_keys&&"keys"in s&&Array.isArray(s.keys)&&s.keys.length>0&&r.push(String(s.keys[0]).replace(/~/g,"~0").replace(/\//g,"~1"));let i=fd(r);return i.length>0?`/${i.join("/")}`:void 0}function X1(n){return n==="v0.8"||n==="0.8"?"v0.8":n==="v0.9.1"||n==="0.9.1"?"v0.9.1":n&&z(n,"1.0")?"1.0":"v0.9"}function Q1(n,e){return n instanceof Ie?"RECURSION_LIMIT_EXCEEDED":n instanceof xe||n instanceof At?"INTEGRITY_ERROR":n instanceof R?"CATALOG_NOT_FOUND":n instanceof oe?"DATA_ERROR":n instanceof ae?"EXPRESSION_ERROR":n instanceof b?(n.code==="UNALLOWED_PARENT"||n.code==="UNALLOWED_CHILD")&&e?n.code:"VALIDATION_FAILED":n instanceof H&&n.code||"INTERNAL_ERROR"}function Bi(n,e={}){let t=X1(e.version),s=t==="1.0",r=n instanceof H?n:void 0,i=n instanceof Error?n.message:String(n),o=r?.functionCallId??e.functionCallId;if(n instanceof Pe||s&&(e.isCallRendererFunction||e.actionType==="callRendererFunction"||o!==void 0)){let h=n instanceof Pe?n.code:"INVALID_FUNCTION_CALL";if(o!==void 0)return{version:t,error:{code:h,functionCallId:o,message:i}};let p=r?.surfaceId??e.surfaceId??"";return{version:t,error:{code:h,surfaceId:p,message:i}}}let c=Q1(n,s),l=r?.surfaceId??e.surfaceId??"",u=r?.path??(n instanceof b?J1(n.details,e.actionType):void 0),d=hd(u);return d===void 0&&(c==="VALIDATION_FAILED"||c==="UNALLOWED_PARENT"||c==="UNALLOWED_CHILD")&&(d="/"),{version:t,error:{code:c,surfaceId:l,...d!==void 0?{path:d}:{},message:i}}}var Pr=class n{constructor(){this.children=new Map,this.parents=new Map,this.heights=new Map,this.maxHeight=0}static of(e){let t=new n;for(let[r,i]of e)t.setChildren(r,i);let s=new Set;for(let r of e.keys()){if(t.heights.has(r))continue;let i=[{id:r,childIndex:0,height:0}];for(s.add(r);i.length>0;){let o=i[i.length-1],a=t.children.get(o.id)??[],c=!0;for(;o.childIndex<a.length;){let l=a[o.childIndex];if(o.childIndex++,!e.has(l))continue;let u=t.heights.get(l);if(u===void 0){if(s.has(l))return;o.childIndex--,i.push({id:l,childIndex:0,height:0}),s.add(l),c=!1;break}u>=o.height&&(o.height=u+1)}c&&(t.heights.set(o.id,o.height),o.height>t.maxHeight&&(t.maxHeight=o.height),s.delete(o.id),i.pop())}}return t}childrenOf(e){return this.children.get(e)??[]}parentsOf(e){return this.parents.get(e)??new Set}setChildren(e,t){for(let s of this.children.get(e)??[])this.parents.get(s)?.delete(e);for(let s of t){let r=this.parents.get(s);r||(r=new Set,this.parents.set(s,r)),r.add(e)}this.children.set(e,t)}admits(e,t,s){for(let[o,a]of e)this.setChildren(o,a);if(this.maxHeight>t)return!1;for(let[o,a]of e)if(a.includes(o))return!1;let r=o=>e.has(o)||s(o),i=[];for(let[o,a]of e){let c=0;for(let l of a){let u=this.heights.get(l)??0;r(l)&&u>=c&&(c=u+1)}this.heights.set(o,c),i.push(o)}for(let o=0;o<i.length;o++){let a=i[o],c=this.heights.get(a)??0;if(c>t)return!1;c>this.maxHeight&&(this.maxHeight=c);for(let l of this.parents.get(a)??[])(this.heights.get(l)??0)<=c&&(this.heights.set(l,c+1),i.push(l))}return!0}},Bs=class n{constructor(){this.count=0,this.seenCatalogs=new Set}static of(e){let t=md.get(e);return t||(t=new n,t.watch(e),md.set(e,t)),t}get changes(){return this.count}get catalogs(){return this.seenCatalogs}watch(e){let t=new Map,s=()=>{this.count++},r=i=>{this.seenCatalogs.add(i.catalog),t.get(i.id)?.unsubscribe(),t.set(i.id,i.onUpdated.subscribe(s))};for(let i of e.values)r(i);e.onCreated.subscribe(i=>{this.count++,r(i)}),e.onDeleted.subscribe(i=>{this.count++,t.get(i)?.unsubscribe(),t.delete(i)})}},md=new WeakMap;var gd=new WeakMap;function yd(n,e,t,s,r){let i=n.componentsModel,o=r.get(i);if(r.delete(i),!t||!Sd(t)){Ga(n,e,s,t),Ka(n,e,s,t);return}let a=eg(n,e,s),c=t.rootId??n.rootId;if(a&&o&&o.changes===Bs.of(i).changes&&(t.allowMissingRoot||a.children.has(c)||i.has(c))){let{bound:u}=o,d=new Map;for(let m of a.children.keys())d.set(m,u.childrenOf(m));let h=u.admits(a.children,t.maxDepth??js,m=>i.has(m));if(tg(n,a,d,u,t)||Ga(n,e,s,t),h)return u;let p=Ka(n,e,s,t,!0);return p?Pr.of(p):void 0}Ga(n,e,s,t);let l=Ka(n,e,s,t,!0);return l?Pr.of(l):void 0}function xd(n,e,t){t.set(n,{bound:e,changes:Bs.of(n).changes})}function Sd(n){return n!==void 0&&n.allowDanglingReferences===!0&&(n.allowOrphanComponents===!0||n.allowMissingRoot===!0)}function eg(n,e,t){let s={children:new Map,types:new Map,catalogs:new Map};for(let r of e){let{id:i,component:o,...a}=r;if(typeof i!="string"||!i)continue;let c=t(r,n);delete a.catalogId,delete a.metadata;let l=(typeof o=="string"?o:n.componentsModel.get(i)?.type)||"";if(!l||c.components.size===0)return;let u=Array.from(Vs({...a,id:i,component:l},c.componentRefMap),([d])=>d);s.children.set(i,u),s.types.set(i,l),s.catalogs.set(i,c)}return s}function tg(n,e,t,s,r){if(!bd(n,e.catalogs.values(),r))return!0;let i=Ad(n,r),o=n.componentsModel,a={get:p=>e.types.get(p)??o.get(p)?.type},c=new Set,l=new Map;for(let[p,m]of e.children){for(let g of m)e.children.has(g)||c.add(g);for(let g of t.get(p)??[])e.children.has(g)||c.add(g);for(let g of s.parentsOf(p)){if(e.children.has(g))continue;let E=l.get(g);E?E.push(p):l.set(g,[p])}}let u=p=>{let m=a.get(p);if(!m)return;let E=(e.catalogs.get(p)??o.get(p)?.catalog)?.components.get(m);return E?{componentType:m,componentApi:E}:void 0},d=p=>{let m=u(p);if(!m)return;let{componentType:g,componentApi:E}=m;if(E.allowedParents&&E.allowedParents.length>0){let A=Array.from(s.parentsOf(p),I=>({parentId:I,parentType:a.get(I)||"Unknown"}));vd(p,g,E.allowedParents,A,i)}},h=(p,m)=>{let g=u(p);if(!g)return;let{componentType:E,componentApi:A}=g;A.allowedChildren&&A.allowedChildren.length>0&&Ed(p,E,A.allowedChildren,m,a)};try{for(let p of e.children.keys())d(p),h(p,s.childrenOf(p));for(let p of c)d(p);for(let[p,m]of l)h(p,m)}catch{return!1}return!0}function bd(n,e,t){let s=i=>{let o=gd.get(i);return o===void 0&&(o=Array.from(i.components.values()).some(a=>a.allowedParents!==void 0&&a.allowedParents.length>0||a.allowedChildren!==void 0&&a.allowedChildren.length>0),gd.set(i,o)),o};for(let i of e)if(s(i))return!0;if(Sd(t)){for(let i of Bs.of(n.componentsModel).catalogs)if(s(i))return!0;return!1}let r=new Set(n.availableCatalogs.values());n.defaultCatalog&&r.add(n.defaultCatalog);for(let i of r)if(s(i))return!0;for(let i of n.componentsModel.values)if(!r.has(i.catalog)&&s(i.catalog))return!0;return!1}function Ad(n,e){return e?.rootId??n.rootId??"root"}function vd(n,e,t,s,r,i,o,a){if(n===r&&!t.includes("Surface")){let c=o!==void 0?`/components/${o}`:"/components",l=`Component '${n}' (${e}) cannot be placed under parent 'Surface' (Surface). Allowed parents: ${JSON.stringify(t)}.`,u=[{path:c,code:"UNALLOWED_PARENT",message:l,...i!==void 0?{surfaceId:i}:{}}];throw new b(l,u,"UNALLOWED_PARENT",{path:c,surfaceId:i})}for(let c of s??[])if(!t.includes(c.parentType)){let l=o??a?.get(c.parentId),u=l!==void 0?`/components/${l}`:"/components",d=`Component '${n}' (${e}) cannot be placed under parent '${c.parentId}' (${c.parentType||"unknown"}). Allowed parents: ${JSON.stringify(t)}.`,h=[{path:u,code:"UNALLOWED_PARENT",message:d,...i!==void 0?{surfaceId:i}:{}}];throw new b(d,h,"UNALLOWED_PARENT",{path:u,surfaceId:i})}}function Ed(n,e,t,s,r,i,o,a,c){for(let l of s){let u=r.get(l);if(u&&!t.includes(u)){let d;if(o!==void 0){let g=(a?.get(l)??"children").replace(/\[(\d+)\]/g,"/$1").replace(/\./g,"/").replace(/^\/+/,"");d=`/components/${o}${g?`/${g}`:""}`}else{let m=c?.get(l);d=m!==void 0?`/components/${m}`:"/components"}let h=`Container '${n}' (${e}) cannot contain child '${l}' (${u}). Allowed children: ${JSON.stringify(t)}.`,p=[{path:d,code:"UNALLOWED_CHILD",message:h,...i!==void 0?{surfaceId:i}:{}}];throw new b(h,p,"UNALLOWED_CHILD",{path:d,surfaceId:i})}}}function ng(n,e,t){let s=new Map,r=new Map,i=new Map,o=new Map,a=new Map;for(let[l,u]of n.componentsModel.entries){s.set(l,u.type),r.set(l,u.catalog);let d=n.componentsModel.getChildReferences(l);d.length>0&&(i.set(l,d.map(([h])=>h)),o.set(l,new Map(d)))}for(let l=0;l<e.length;l++){let u=e[l],{id:d,component:h,...p}=u;if(typeof d!="string")continue;a.set(d,l);let m=t(u,n);r.set(d,m);let g=n.componentsModel.get(d),E=(typeof h=="string"?h:g?.type)??"";E&&s.set(d,E);let A={id:d,component:E,...p},I=Array.from(Vs(A,m));I.length>0?(i.set(d,I.map(([D])=>D)),o.set(d,new Map(I))):(i.delete(d),o.delete(d))}let c=new Map;for(let[l,u]of i.entries()){let d=s.get(l)||"Unknown";for(let h of u){let p=c.get(h)??[];p.push({parentId:l,parentType:d}),c.set(h,p)}}return{typeMap:s,compCatalogMap:r,childMap:i,childPathMap:o,parentMap:c,compIndexMap:a}}function Ga(n,e,t,s){let r=e.filter(h=>typeof h.id=="string").map(h=>t(h,n));if(!bd(n,r,s))return;let{typeMap:i,compCatalogMap:o,childMap:a,childPathMap:c,parentMap:l,compIndexMap:u}=ng(n,e,t),d=Ad(n,s);for(let[h,p]of i.entries()){let g=o.get(h)?.components.get(p);g&&(g.allowedParents&&g.allowedParents.length>0&&vd(h,p,g.allowedParents,l.get(h),d,n.id,u.get(h),u),g.allowedChildren&&g.allowedChildren.length>0&&Ed(h,p,g.allowedChildren,a.get(h)||[],i,n.id,u.get(h),c.get(h),u))}}function Ka(n,e,t,s,r=!1){if(!s)return;let i=new Us(n.defaultCatalog);for(let[a,c]of n.componentsModel.entries)i.addComponent(new _e(a,c.type,c.properties,c.catalog));for(let a of e){let{id:c,component:l,...u}=a;if(typeof c!="string"||!c)continue;let d=t(a,n);delete u.catalogId,delete u.metadata;let h=i.get(c),p=(typeof l=="string"?l:h?.type)||"";p&&(h?p!==h.type||h.catalog.id!==d.id?(i.removeComponent(c),i.addComponent(new _e(c,p,u,d))):h.properties=u:i.addComponent(new _e(c,p,u,d)))}if(i.validateTopology({...s,rootId:s.rootId??n.rootId}),!r)return;let o=new Map;for(let a of i.keys)o.set(a,i.getChildIds(a));return o}function Jt(n){let e=n.path.join(".")||"root";switch(n.code){case f.ZodIssueCode.invalid_union:{let t=n.unionErrors?.flatMap(s=>s.issues);return t&&t.length>0?t.map(Jt).join("; "):`${e}: Invalid union`}case f.ZodIssueCode.unrecognized_keys:{let t=n.keys.map(s=>`'${s}'`).join(", ");return`${e}: Unrecognized key(s) in object: ${t}`}case f.ZodIssueCode.invalid_enum_value:{let t=n,s=t.options.map(r=>String(r)).join(" | ");return`${e}: Invalid enum value. Expected ${s}, received '${String(t.received)}'`}case f.ZodIssueCode.invalid_type:{let t=n;return`${e}: Expected ${t.expected}, received ${t.received}`}case f.ZodIssueCode.custom:return`${e}: ${n.message}`;default:return n.message?`${e}: ${n.message}`:`${e}: Validation error (${n.code})`}}var sg={"0.8":new Set(["0.8"]),"0.9":new Set(["0.9","0.9.1"]),"0.9.1":new Set(["0.9.1","0.9"]),"1.0":new Set(["1.0"])};function Rt(n,e,t=sg){if(!n||!e)return!1;let s=le(n),r=le(e);if(s&&r){if(s===r)return!0;let a=t[r];if(a&&a.has(s))return!0;let c=un(n),l=un(e);return!!(c&&l&&c.major>=1&&c.major===l.major)}if(typeof n!="string"||typeof e!="string")return!1;let i=de(n),o=de(e);return i.length>0&&i===o}var Ya;function Cd(n){Ya=n}function rg(n,e){for(let t of e){let s=n[t];if(s&&typeof s=="object"){let r=s;if("surfaceId"in r&&r.surfaceId!==void 0&&typeof r.surfaceId!="string"){let i="surfaceId must be a string";throw new b(i,[{path:`/${t}/surfaceId`,code:"type_mismatch",message:i}],"VALIDATION_ERROR",{path:"/surfaceId"})}}}}var xn=class{get compatibleCatalogVersions(){let e=le(this.version);return e?new Set([e]):new Set}get validActions(){return new Set(this.getNativeActionKeys())}isCatalogCompatible(e){return e?Rt(e,this.version):!1}extractOperations(e){if(!e||typeof e!="object")return[];if(Array.isArray(e))return e.flatMap(a=>this.extractOperations(a));let t=e;if(Array.isArray(t.messages))return this.extractOperations(t.messages);let s=this.getNativeActionKeys();rg(t,s);let r=s.filter(a=>a in t).sort();if(r.length>1)throw new b(`Message contains multiple conflicting update actions: ${r.join(", ")}.`);if(r.length===0){let a=Ya?Ya():new Set(s),c=Object.keys(t).find(u=>a.has(u)&&!s.includes(u)),l=s.slice().sort().join(", ");if(c){let u=`Invalid ${this.version} message: action '${c}' is not supported in protocol version ${this.version}. Allowed actions: ${l}.`;throw new b(u,[{path:"/version",code:"invalid_value",message:u}],"VALIDATION_ERROR",{path:"/version"})}throw new b(`Invalid ${this.version} message: message must contain exactly one update action: ${l}.`)}let i=this.preparePayloadForValidation(t),o=this.schema.safeParse(i);if(!o.success){let a=o.error.errors.map(Jt).join("; "),c=yn(t,this.version),l=new b(`Invalid ${this.version} message: ${a}`,o.error,"VALIDATION_ERROR"),u=Bi(l,c);throw l.path=u.error.path,l.surfaceId=u.error.surfaceId||void 0,l.functionCallId=u.error.functionCallId,l}return this.extractOperationsFromObject(t)}preparePayloadForValidation(e){return"version"in e?e:{version:this.version,...e}}};function Td(n){if(!n||typeof n!="object")return{id:"",component:""};let e=n,t=typeof e.component=="string"?e.component:"",s={};for(let[r,i]of Object.entries(e))r!=="component"&&r!=="id"&&(s[r]=i);if(e.component&&typeof e.component=="object"){let r=e.component,i=Object.keys(r);if(i.length>0){t=i[0];let o=r[i[0]];o&&typeof o=="object"&&o!==null&&!Array.isArray(o)&&Object.assign(s,o)}}return{...s,id:String(e.id??""),component:t}}var qi=class extends xn{constructor(){super(...arguments),this.version="v0.8",this.schema=ld}getNativeActionKeys(){return["beginRendering","surfaceUpdate","dataModelUpdate","deleteSurface"]}preparePayloadForValidation(e){let t={...e};return delete t.version,t}extractOperationsFromObject(e){let t=[];if("beginRendering"in e){let s=e.beginRendering;t.push({type:"createSurface",surfaceId:String(s?.surfaceId??""),catalogId:typeof s?.catalogId=="string"?s.catalogId:void 0,theme:s?.theme??s?.styles,sendDataModel:!!s?.sendDataModel,components:Array.isArray(s?.components)?s.components.map(Td):void 0,dataModel:s?.dataModel&&typeof s.dataModel=="object"&&!Array.isArray(s.dataModel)?s.dataModel:void 0,version:typeof e.version=="string"?e.version:this.version,rootId:typeof s?.root=="string"&&s.root?s.root:void 0})}if("surfaceUpdate"in e){let s=e.surfaceUpdate;t.push({type:"updateComponents",surfaceId:String(s?.surfaceId??""),components:Array.isArray(s?.components)?s.components.map(Td):[]})}if("dataModelUpdate"in e){let s=e.dataModelUpdate,r=String(s?.surfaceId??""),i=typeof s?.path=="string"?s.path.trim():"",o=i&&i!=="/"?(i.startsWith("/")?i:`/${i}`).replace(/\/+$/,""):"",a=c=>{if("valueNumber"in c)return c.valueNumber;if("valueString"in c)return c.valueString;if("valueBoolean"in c)return c.valueBoolean;if("valueObject"in c)return c.valueObject;if("valueArray"in c)return c.valueArray;if(Array.isArray(c.valueMap)){let l={};for(let u of c.valueMap)u&&typeof u=="object"&&typeof u.key=="string"&&(l[u.key]=a(u));return l}return c.value};if(Array.isArray(s?.contents)){for(let c of s.contents)if(c&&typeof c=="object"&&typeof c.key=="string"){let l=a(c),u=c.key.replace(/^\/+/,""),d=u==="."||u===""?o||"/":`${o}/${u}`;t.push({type:"updateDataModel",surfaceId:r,path:d,value:l})}}else t.push({type:"updateDataModel",surfaceId:r,path:typeof s?.path=="string"?s.path:void 0,value:s?.value})}if("deleteSurface"in e){let s=e.deleteSurface;t.push({type:"deleteSurface",surfaceId:String(s?.surfaceId??"")})}return t}};var zi=f.object({version:f.enum(["v0.9","v0.9.1"]),createSurface:f.object({surfaceId:f.string().describe("The unique identifier for the UI surface to be rendered."),catalogId:f.string().describe("A string that uniquely identifies this catalog. It is recommended to prefix this with an internet domain that you own, to avoid conflicts e.g. mycompany.com:somecatalog'."),theme:f.any().optional(),sendDataModel:f.boolean().describe("If true, the client will send the full data model of this surface in the metadata of every A2A message sent to the server that created the surface. Defaults to false.").optional()}).strict().describe("Signals the client to create a new surface and begin rendering it. It is an error to send 'createSurface' for a surfaceId that already exists without first deleting it. When this message is sent, the client will expect 'updateComponents' and/or 'updateDataModel' messages for the same surfaceId that define the component tree.")}).strict(),Wi=f.object({version:f.enum(["v0.9","v0.9.1"]),updateComponents:f.object({surfaceId:f.string().describe("The unique identifier for the UI surface to be updated."),components:f.array(f.record(f.string(),f.any())).min(1).describe("A list containing all UI components for the surface.")}).strict().describe("Updates a surface with a new set of components. This message can be sent multiple times to update the component tree of an existing surface. One of the components in one of the components lists MUST have an 'id' of 'root' to serve as the root of the component tree. A createSurface message MUST have been previously sent for the 'surfaceId' in this message; the surface's catalog is the one specified by that createSurface.")}).strict(),Zi=f.object({version:f.enum(["v0.9","v0.9.1"]),updateDataModel:f.object({surfaceId:f.string().describe("The unique identifier for the UI surface this data model update applies to."),path:f.string().describe("An optional path to a location within the data model (e.g., '/user/name'). If omitted, or set to '/', refers to the entire data model.").optional(),value:f.any().describe("The data to be updated in the data model. If present, the value at 'path' is replaced (or created). If omitted, the key at 'path' is removed.").optional()}).strict().describe("Updates the data model for an existing surface. This message can be sent multiple times to update the data model. A createSurface message MUST have been previously sent for the 'surfaceId' in this message; the surface's catalog is the one specified by that createSurface.")}).strict(),Hi=f.object({version:f.enum(["v0.9","v0.9.1"]),deleteSurface:f.object({surfaceId:f.string().describe("The unique identifier for the UI surface to be deleted.")}).strict().describe("Signals the client to delete the surface identified by 'surfaceId'. A createSurface message MUST have been previously sent for the 'surfaceId' in this message; the surface's catalog is the one specified by that createSurface.")}).strict(),Ja=f.union([zi,Wi,Zi,Hi]),ig=f.array(Ja).describe("A list of messages."),K3=f.object({messages:ig}).strict().describe("An object wrapping a list of messages.");var Dr=class extends xn{constructor(){super(...arguments),this.version="v0.9",this.schema=Ja}get compatibleCatalogVersions(){return new Set(["0.9","0.9.1"])}getNativeActionKeys(){return["createSurface","updateComponents","updateDataModel","deleteSurface"]}extractOperationsFromObject(e){let t=[];if("createSurface"in e){let s=e.createSurface;t.push({type:"createSurface",surfaceId:String(s?.surfaceId||""),catalogId:typeof s?.catalogId=="string"?s.catalogId:void 0,theme:s?.theme,sendDataModel:!!s?.sendDataModel,components:Array.isArray(s?.components)?s.components:void 0,dataModel:s?.dataModel&&typeof s.dataModel=="object"&&!Array.isArray(s.dataModel)?s.dataModel:void 0,version:typeof e.version=="string"?e.version:this.version})}if("updateComponents"in e){let s=e.updateComponents;t.push({type:"updateComponents",surfaceId:String(s?.surfaceId||""),components:Array.isArray(s?.components)?s.components:[]})}if("updateDataModel"in e){let s=e.updateDataModel;t.push({type:"updateDataModel",surfaceId:String(s?.surfaceId||""),path:typeof s?.path=="string"?s.path:void 0,value:s?.value})}if("deleteSurface"in e){let s=e.deleteSurface;t.push({type:"deleteSurface",surfaceId:String(s?.surfaceId||"")})}return t}};var Xa=["createSurface","updateComponents","updateDataModel","deleteSurface","callRendererFunction","agentFunctionResponse"];function wd(n){return typeof n=="object"&&n!==null&&"type"in n&&typeof n.type=="string"&&Xa.includes(n.type)}var sb=f.object({componentId:f.lazy(()=>Or),path:f.string().describe("The path to the list of component property objects in the data model.")}).strict().describe("REF:#/$defs/TemplateChildList|A template for generating a dynamic list of children from a data model list. The `componentId` is the component to use as a template.");var og=f.lazy(()=>nd.extend({component:f.string()}).passthrough().refine(n=>n.component!=="Surface",{message:'Component type cannot be "Surface". "Surface" is a top-level protocol container defined in createSurface, not a child component.'})),Qa=f.array(og).min(1),rb=f.record(f.string(),f.any());var Gi=f.object({version:f.literal("1.0"),createSurface:f.object({surfaceId:f.string().describe("The unique identifier for the UI surface to be rendered. It must be globally unique for the renderer's lifetime."),catalogId:f.string().describe("A string that uniquely identifies the default catalog for this surface. It is recommended to prefix this with an internet domain that you own, to avoid conflicts e.g. 'mycompany.com:somecatalog'. Components and function calls that do not explicitly specify a catalogId will use this surface-level default catalogId.").optional(),sendDataModel:f.boolean().describe("If true, the renderer will send the full data model of this surface in the metadata of every A2A message sent to the agent that created the surface. Defaults to false.").optional(),components:Qa.optional(),dataModel:f.record(f.string(),f.any()).describe("The initial root data model object for the surface.").optional(),metadata:f.object({extensions:Ba.optional()}).strict().describe("Optional surface-level metadata.").optional()}).strict().describe("Signals the renderer to create a new surface and begin rendering it. Creating a surface implicitly instantiates the canonical 'Surface' container component ('common_types.json#/$defs/Surface') with 'child': 'root'. It is an error to try to create a surface with an existing ID without first deleting it; surfaceId MUST be globally unique for the renderer's lifetime. The component tree and initial data model may be provided inline via 'components' and 'dataModel', or sent later in 'updateComponents' and/or 'updateDataModel' messages for the same surfaceId.")}).strict(),Ki=f.object({version:f.literal("1.0"),updateComponents:f.object({surfaceId:f.string().describe("The unique identifier for the UI surface to be updated. It must be globally unique for the renderer's lifetime."),components:Qa}).strict().describe("Updates a surface with a new set of components. This message can be sent multiple times to update the component tree of an existing surface. One of the components in one of the components lists MUST have an 'id' of 'root' to serve as the root of the component tree. The createSurface message MUST have been previously sent for this surfaceId.")}).strict(),Yi=f.object({version:f.literal("1.0"),updateDataModel:f.object({surfaceId:f.string().describe("The unique identifier for the UI surface this data model update applies to. It must be globally unique for the renderer's lifetime."),path:f.string().describe("An optional path to a location within the data model (e.g., '/user/name'). If omitted, or set to '/', refers to the entire data model.").optional(),value:f.any().describe("The data to be updated in the data model. To delete the key/value at 'path', set 'value' explicitly to null.")}).strict().describe("Updates the data model for an existing surface. This message can be sent multiple times to update the data model. The createSurface message MUST have been previously sent for this surfaceId.")}).strict(),Ji=f.object({version:f.literal("1.0"),deleteSurface:f.object({surfaceId:f.string().describe("The unique identifier for the UI surface to be deleted. It must be globally unique for the renderer's lifetime.")}).strict().describe("Signals the renderer to delete the surface identified by 'surfaceId'. The createSurface message MUST have been previously sent for this surfaceId.")}).strict(),Xi=f.object({version:f.literal("1.0"),callRendererFunction:f.object({surfaceId:f.string().describe("Optional ID of the surface whose data model provides the evaluation context for this call. If omitted, the function executes in a surface-independent root context with an empty data model.").optional(),functionCallId:Ua,callFunction:f.intersection(lt,f.object({catalogId:f.string()}).passthrough())}).strict().describe("Signals the renderer to execute a function locally on behalf of the agent.")}).strict(),Qi=f.object({version:f.literal("1.0"),agentFunctionResponse:id}).strict(),ec=f.union([Gi,Ki,Yi,Ji,Xi,Qi]);function ag(n,e,t){if(Object.hasOwn(n,"args")&&n.args!==void 0&&(typeof n.args!="object"||n.args===null||Array.isArray(n.args)))throw new b(`Invalid ${e} message: callRendererFunction.callFunction.args: Expected object, received ${Array.isArray(n.args)?"array":typeof n.args}`,void 0,"VALIDATION_ERROR",{functionCallId:t||void 0})}function cg(n,e){let t=n?.callFunction||{},s=String(n?.functionCallId||"");return ag(t,e,s),{type:"callRendererFunction",surfaceId:typeof n?.surfaceId=="string"?n.surfaceId:void 0,functionCallId:s,call:String(t?.["@call"]||t?.call||""),version:e,catalogId:typeof t?.catalogId=="string"?t?.catalogId:void 0,args:t?.args&&typeof t.args=="object"&&!Array.isArray(t.args)?t.args:{}}}var eo=class extends xn{constructor(){super(...arguments),this.version="1.0",this.schema=ec}getNativeActionKeys(){return[...Xa]}extractOperationsFromObject(e){let t=[];if("createSurface"in e){let s=e.createSurface;t.push({type:"createSurface",surfaceId:String(s?.surfaceId||""),catalogId:typeof s?.catalogId=="string"?s.catalogId:void 0,theme:s?.theme,sendDataModel:!!s?.sendDataModel,components:Array.isArray(s?.components)?s.components:void 0,dataModel:s?.dataModel&&typeof s.dataModel=="object"&&!Array.isArray(s.dataModel)?s.dataModel:void 0,version:typeof e.version=="string"?e.version:this.version,metadata:s?.metadata&&typeof s.metadata=="object"&&!Array.isArray(s.metadata)?s.metadata:void 0})}if("updateComponents"in e){let s=e.updateComponents;t.push({type:"updateComponents",surfaceId:String(s?.surfaceId||""),components:Array.isArray(s?.components)?s.components:[]})}if("updateDataModel"in e){let s=e.updateDataModel;t.push({type:"updateDataModel",surfaceId:String(s?.surfaceId||""),path:typeof s?.path=="string"?s.path:void 0,value:s?.value})}if("deleteSurface"in e){let s=e.deleteSurface;t.push({type:"deleteSurface",surfaceId:String(s?.surfaceId||"")})}if("callRendererFunction"in e&&t.push(cg(e.callRendererFunction,this.version)),"agentFunctionResponse"in e){let s=e.agentFunctionResponse;t.push({type:"agentFunctionResponse",functionCallId:String(s?.functionCallId||""),version:this.version,value:s?.value,error:s?.error&&typeof s.error=="object"?s.error:void 0})}return t}};var tc=class{constructor(){this.adapters=new Map([["0.8",new qi],["0.9",new Dr],["0.9.1",new Dr],["1.0",new eo]])}getAllKnownActions(){let e=new Set;for(let t of this.adapters.values())if(t.validActions)for(let s of t.validActions)e.add(s);return e}registerAdapter(e){let t=le(e.version)??de(e.version);this.adapters.set(t,e)}getAdapter(e){let t=le(e)??de(e),s=this.adapters.get(t);if(!s){let r=Array.from(new Set(Array.from(this.adapters.entries()).map(([i,o])=>i==="0.9.1"?"v0.9.1":o.version))).sort().join(", ");throw new b(`[VersionAdapterFactory] Unsupported protocol version '${e}'. Supported versions: ${r}.`)}return s}resolveFromPayload(e){let t=Array.isArray(e)?e[0]:e;if(typeof t=="object"&&t!==null){if("messages"in t&&Array.isArray(t.messages))return this.resolveFromPayload(t.messages);if("version"in t){let s=t.version;if(typeof s!="string")throw new b(`[VersionAdapterFactory] Message payload is missing a valid 'version' string: 'version' property must be a string, got ${typeof s}.`);return this.getAdapter(s)}if("beginRendering"in t||"surfaceUpdate"in t||"dataModelUpdate"in t||"deleteSurface"in t)return this.getAdapter("v0.8")}throw new b("[VersionAdapterFactory] Message payload is missing a valid 'version' string.")}static registerAdapter(e){ss.registerAdapter(e)}static getAdapter(e){return ss.getAdapter(e)}static resolveFromPayload(e){return ss.resolveFromPayload(e)}static getAllKnownActions(){return ss.getAllKnownActions()}},ss=new tc;Cd(()=>ss.getAllKnownActions());var lg=["id","component","catalogId","metadata"];function ug(n){return n===Fs.name?Fs:void 0}function dg(n,e){if(e.catalogId!==void 0)throw new b(`System function '${n}' belongs to no catalog and must not name a catalogId.`)}function nc(n){return`Function call '${n}' has a non-string 'catalogId'.`}function sc(n,e,{catalogIsDefault:t}){return n===void 0?t:n===e}var Sn=class{constructor(e,t){this.catalog=e,this.config=t,this.enforceIdentifiers=z(e.protocolVersion,"1.0")}get allowUnknown(){return this.config?this.config.allowUnknownElements??!1:!0}validateComponent(e,t,s){let r=e.id;if(typeof r!="string"||!r){let p=`Component '${e.component}' is missing an 'id'; entries require a valid string 'id'.`;throw new b(p,[{path:"/id",code:"missing_field",message:p}],"VALIDATION_ERROR",{path:"/id"})}this.assertIdentifier(r,`Component id '${r}' must be a valid UAX #31 identifier`,!1,"/id");let i=e.component,o=typeof i=="string"?i:t;if(!o){let p=`Cannot create component ${r} without a type.`;throw new b(p,[{path:"/component",code:"missing_field",message:p}],"VALIDATION_ERROR",{path:"/component"})}let a=e.catalogId,c=typeof a=="string"?a:void 0,l=fg(e),u=this.catalog.components.get(o);if(!u){if(!this.allowUnknown){let p=`Unknown component type '${o}' not found in catalog '${this.catalog.id}'.`;throw new b(p,[{path:"/component",code:"invalid_value",message:p}],"VALIDATION_ERROR",{path:"/component"})}s?.skipNestedFunctions||this.validateNestedFunctions(l,c);return}let d=Ms(u.schema);this.validateCommonEnvelopeFields(l,d,o,r,c);let h=u.schema.safeParse(l);if(!h.success){let p=h.error.errors.map(Jt).join(", "),m=Lr(h.error.issues),E=new Set(m.map(A=>A.path)).size===1?m[0]?.path:void 0;throw new b(`Validation failed for component '${o}' (${r}): ${p}`,m,"VALIDATION_ERROR",{path:E&&E!=="/"?E:void 0})}s?.skipNestedFunctions||this.validateNestedFunctions(l,c)}validateCommonEnvelopeFields(e,t,s,r,i){if("accessibility"in e&&!t?.has("accessibility")){let o=e.accessibility;delete e.accessibility;let a=yi.optional().safeParse(o);if(!a.success){let c=a.error.errors.map(Jt).join(", "),l=Lr(a.error.issues,"/accessibility");throw new b(`Validation failed for component '${s}' (${r}): ${c}`,l,"VALIDATION_ERROR",{path:l[0]?.path})}this.validateNestedFunctions(o,i,"/accessibility")}if("metadata"in e&&!t?.has("metadata")){let o=e.metadata;delete e.metadata;let a=mr.shape.metadata.safeParse(o);if(!a.success){let c=a.error.errors.map(Jt).join(", "),l=Lr(a.error.issues,"/metadata");throw new b(`Validation failed for component '${s}' (${r}): ${c}`,l,"VALIDATION_ERROR",{path:l[0]?.path})}}}assertFunctionIdentifiers(e,t){if(this.assertIdentifier(e,`Function name '${e}' must be a valid UAX #31 identifier`,!0),this.enforceIdentifiers&&t!==void 0&&t!==null&&(typeof t!="object"||Array.isArray(t)))throw new b(`Validation failed for function '${e}': Expected object, received ${Array.isArray(t)?"array":typeof t}`);if(t&&typeof t=="object"&&!Array.isArray(t)){let s=Object.keys(t);if(s.length>$s)throw new b(`Function call '${e}' exceeds maximum allowed arguments count (${$s})`);for(let r of s)this.assertIdentifier(r,`Function argument '${r}' in function '${e}' must be a valid UAX #31 identifier`)}}checkNestedCallRecord(e,t,s){let r=e.args,i=r!==void 0?r:{};if(!this.enforceIdentifiers){this.validateFunction(t,i);return}if(t.startsWith("@")){dg(t,e),this.validateFunction(t,i);return}let o=e.catalogId;if(o!==void 0&&typeof o!="string")throw new b(nc(t));sc(o,this.catalog.id,{catalogIsDefault:s===void 0})?this.validateFunction(t,i):this.assertFunctionIdentifiers(t,i)}validateNestedFunctions(e,t,s=""){if(Array.isArray(e)){for(let o=0;o<e.length;o++)this.validateNestedFunctions(e[o],t,`${s}/${o}`);return}if(typeof e!="object"||e===null)return;let r=e;this.enforceIdentifiers&&Li(Object.keys(r),this.catalog.protocolVersion);let i=this.enforceIdentifiers?r["@call"]:r.call??r.function;if(typeof i=="string"&&(this.enforceIdentifiers||i.length>0))try{this.checkNestedCallRecord(r,i,t)}catch(o){throw o instanceof b&&s&&(o.path=o.path&&o.path!=="/"?`${s}${o.path}`:s),o}for(let[o,a]of Object.entries(r))this.validateNestedFunctions(a,t,`${s}/${o}`)}validateFunction(e,t){this.assertFunctionIdentifiers(e,t);let s=this.enforceIdentifiers&&e.startsWith("@")?ug(e):this.catalog.functions.get(e);if(!s){if(!this.allowUnknown)throw new b(`Unrecognized function '${e}'`);return t??{}}if(!s.schema){if(t!==void 0&&(typeof t!="object"||t===null||Array.isArray(t)))throw new b(`Validation failed for function '${e}': Expected object, received ${Array.isArray(t)?"array":typeof t}`,void 0,"VALIDATION_ERROR",{path:"/args"});return t??{}}let r=s.schema.safeParse(t??{});if(!r.success){let i=r.error.errors.map(Jt).join(", "),o=Lr(r.error.issues,"/args");throw new b(`Validation failed for function '${e}': ${i}`,o,"VALIDATION_ERROR",{path:o[0]?.path})}return r.data}validateTheme(e){let t=this.catalog.themeSchema;if(!t)return e;let s=t.safeParse(e);if(!s.success){let r=s.error.errors.map(Jt).join(", "),i=Lr(s.error.issues,"/theme");throw new b(`Validation failed for theme: ${r}`,i,"VALIDATION_ERROR",{path:i[0]?.path??"/theme"})}return s.data}assertIdentifier(e,t,s=!1,r){if(this.enforceIdentifiers&&!fe(e,s))throw new b(t,r?[{path:r,code:"invalid_value",message:t}]:void 0,"VALIDATION_ERROR",{path:r})}};function Lr(n,e=""){return n.map(t=>{let s=t.path.map(a=>String(a).replace(/~/g,"~0").replace(/\//g,"~1"));t.code==="unrecognized_keys"&&"keys"in t&&Array.isArray(t.keys)&&t.keys.length>0&&s.push(String(t.keys[0]).replace(/~/g,"~0").replace(/\//g,"~1"));let r=s.length>0?`/${s.join("/")}`:"",i=`${e}${r}`||"/",o=t.code==="invalid_type"&&"received"in t&&t.received==="undefined"||t.message==="Required";return{path:i,code:o?"missing_field":"invalid_value",message:t.message}})}function fg(n){let e={};for(let[t,s]of Object.entries(n))lg.includes(t)||(e[t]=s);return e}var to=class{constructor(e,t){if(this.pendingAgentCalls=new Map,this.isDisposed=!1,Array.isArray(e))this.catalogs=e,this.outboundListener=t,this.defaultTimeoutMs=3e4;else{let s=e??{};this.catalogs=s.catalogs??[],this.outboundListener=s.outboundListener,this.defaultTimeoutMs=s.defaultTimeoutMs??3e4}}get disposed(){return this.isDisposed}async handleCallRendererFunction(e,t,s=!1){let r=this.validateInboundMessage(e);if(r)return await this.emitOutboundResponse(r),r;let{version:i,callRendererFunction:o}=e,{surfaceId:a,functionCallId:c,callFunction:l}=o;if(a!==void 0&&t?.surface?.id!==a){let O=this.createResponseError(c,re.INVALID_FUNCTION_CALL,`Surface not found: ${a}`,i);return await this.emitOutboundResponse(O),O}let u=l["@call"]??l.call,{catalogId:d,args:h}=l,p=this.resolveFunctionImplementation(d,u,t,i);if("error"in p){let O=this.createResponseError(c,re.INVALID_FUNCTION_CALL,p.error,i);return await this.emitOutboundResponse(O),O}let m=this.checkExecutionPermissions(p.funcImpl,u,s);if(m){let O=this.createResponseError(c,re.INVALID_FUNCTION_CALL,m,i);return await this.emitOutboundResponse(O),O}let g=this.ensureDataContext(t,p.catalog,c),E=this.resolveDynamicArguments(h,g,s);if("error"in E){let O=this.createResponseError(c,re.EXECUTION_ERROR,E.error,i);return await this.emitOutboundResponse(O),O}let A;try{A=await Hn(E.args)}catch(O){let te=this.createResponseError(c,re.EXECUTION_ERROR,this.extractErrorMessage(O)||"An error occurred during function execution.",i);return await this.emitOutboundResponse(te),te}let I=this.parseArguments(p.catalog,p.funcImpl,A,u);if("error"in I){let O=this.createResponseError(c,re.INVALID_FUNCTION_CALL,I.error,i);return await this.emitOutboundResponse(O),O}let D=await this.executeFunctionSafely(p.funcImpl,I.args,g,c,i);return await this.emitOutboundResponse(D),D}handleAgentFunctionResponse(e){if(!e||!e.agentFunctionResponse)return;let{functionCallId:t,value:s,error:r}=e.agentFunctionResponse,i=this.pendingAgentCalls.get(t);if(i)if(this.pendingAgentCalls.delete(t),r){let o=r.code??re.UNKNOWN_ERROR,a=r.message??"Agent function execution failed";i.reject(new Pe(a,o,t,r))}else i.resolve(s)}callAgentFunction(e,t,s){if(this.isDisposed)return Promise.reject(new Pe("RpcHandler has been disposed.",re.DISPOSED));if(!this.outboundListener)return Promise.reject(new Pe("Cannot call agent function without outboundListener configured.",re.NO_LISTENER));let r=t?.["@call"]??t?.call;if(!t||!r)return Promise.reject(new Pe("Missing or invalid function call name.",re.INVALID_FUNCTION_CALL));let i=s??{},o=i.functionCallId??this.generateFunctionCallId(),a=i.timeoutMs??this.defaultTimeoutMs;if(this.pendingAgentCalls.has(o))return Promise.reject(new Pe(`A call with functionCallId '${o}' is already pending.`,re.DUPLICATE,o));let c={functionCallId:o,call:t,effectiveTimeoutMs:a,version:i.version};return this.dispatchAgentCall(e,c)}dispose(){if(!this.isDisposed){this.isDisposed=!0;for(let[e,t]of this.pendingAgentCalls.entries())t.reject(new Pe(`RpcHandler disposed while call '${e}' was pending.`,re.CANCELLED,e));this.pendingAgentCalls.clear()}}async emitOutboundResponse(e){if(this.outboundListener)try{let t=this.outboundListener(e);t&&typeof t.catch=="function"&&await t}catch{}}validateInboundMessage(e){if(!e)return this.createResponseError("unknown",re.INVALID_FUNCTION_CALL,"Inbound message is null or undefined.","unknown");let t=e.version;return this.isDisposed?this.createResponseError(e.callRendererFunction?.functionCallId??"unknown",re.DISPOSED,"RpcHandler has been disposed.",t):e.callRendererFunction?.callFunction?null:this.createResponseError(e.callRendererFunction?.functionCallId??"unknown",re.INVALID_FUNCTION_CALL,"Malformed message: missing callRendererFunction or callFunction.",t)}resolveFunctionImplementation(e,t,s,r){let i;if(e&&(i=s?.surface?.availableCatalogs?.get(e)??this.catalogs.find(a=>a.id===e),!i))return{error:`Catalog not found: ${e}`};if(!i)return{error:"No catalog available for function resolution."};if(i.protocolVersion&&r&&!Rt(i.protocolVersion,r))return{error:`Catalog '${i.id}' specification version (${i.protocolVersion}) does not match message protocol version (${r}).`};let o=i.functions?.get(t);return o?{funcImpl:o,catalog:i}:{error:`Function not found: ${t}`}}ensureDataContext(e,t,s){if(e instanceof wt&&e.surface)return e;let r=new Map;for(let o of this.catalogs)t.protocolVersion&&o.protocolVersion&&Rt(t.protocolVersion,o.protocolVersion)&&r.set(o.id,o);r.set(t.id,t);let i=new kt(`_rpc_fallback_${s||"default"}`,t,r);return new wt(i,"/")}resolveDynamicArguments(e,t,s){if(e===void 0||typeof e!="object"||e===null||Array.isArray(e))return{args:e};let r={},i,o=t.surface?.onError.subscribe(a=>{!i&&a?.code==="EXPRESSION_ERROR"&&(i=a.message||"An error occurred during function execution.")});try{for(let[a,c]of Object.entries(e))r[a]=t.resolveDynamicValue(c,1,s)}catch(a){i=this.extractErrorMessage(a)||"An error occurred during function execution."}finally{o?.unsubscribe()}return i?{error:i}:{args:r}}checkExecutionPermissions(e,t,s){let r=e.allowedCallers??"rendererOnly";return r==="rendererOrAgent"||r==="agentOnly"?e.requiresUserActivation&&!s?`Function '${t}' requires user activation context to execute.`:null:`Function '${t}' cannot be called by agent (allowedCallers is ${r}).`}parseArguments(e,t,s,r){try{return{args:new Sn(e,{allowUnknownElements:!1}).validateFunction(r,s)}}catch(i){let o=this.extractErrorMessage(i);return{error:`Invalid function arguments for '${r}': ${o}`}}}async executeFunctionSafely(e,t,s,r,i){let o=i||"1.0";try{let a=await Promise.resolve(e.execute(t,s)),c=Ls(a)?je(a):a;return{version:o,rendererFunctionResponse:{functionCallId:r,value:c!==void 0?c:null}}}catch(a){let c=this.extractErrorMessage(a);return{version:o,rendererFunctionResponse:{functionCallId:r,error:{code:re.EXECUTION_ERROR,message:c||"An error occurred during function execution."}}}}}generateFunctionCallId(){if(typeof globalThis.crypto?.randomUUID=="function")return globalThis.crypto.randomUUID();let e=Math.random().toString(36).substring(2,15).padEnd(13,"0");return`call-${Date.now()}-${e}`}dispatchAgentCall(e,t){let{functionCallId:s,call:r,effectiveTimeoutMs:i,version:o}=t;return new Promise((a,c)=>{let l,u=()=>{l&&(clearTimeout(l),l=void 0),this.pendingAgentCalls.delete(s)},d=(r["@call"]??r.call)||"unknown";l=this.createTimeoutTimer(s,d,i,u,c),this.pendingAgentCalls.set(s,{resolve:h=>{u(),a(h)},reject:h=>{u(),c(h)}}),this.sendOutboundMessage(e,s,r,o,u,c)})}createTimeoutTimer(e,t,s,r,i){if(!(s<=0))return setTimeout(()=>{this.pendingAgentCalls.delete(e)&&(r(),i(new Pe(`Agent function call '${t}' timed out after ${s}ms.`,re.TIMEOUT,e)))},s)}sendOutboundMessage(e,t,s,r,i,o){let{call:a,"@call":c,...l}=s,u={"@call":c??a,...l},d={version:r||"1.0",callAgentFunction:{surfaceId:e,functionCallId:t,callFunction:u}};try{let h=this.outboundListener(d);h&&typeof h.catch=="function"&&h.catch(p=>{i(),o(p)})}catch(h){i(),o(h)}}extractErrorMessage(e){return e instanceof Error?e.message:String(e)}createResponseError(e,t,s,r){return{version:r||"1.0",rendererFunctionResponse:{functionCallId:e,error:{code:t,message:s}}}}};var $r=class{constructor(e,t,s){this.actionHandler=t,this.graphBounds=new WeakMap,this.registeredCatalogs=e,this.model=new Ui,this.adapterRegistry=s?.adapterRegistry??ss,this.defaultVersion=s?.version,this.errorHandler=s?.errorHandler,this.reportErrorsOnly=s?.reportErrorsOnly??!1,this.rpc=new to({catalogs:this.registeredCatalogs,outboundListener:s?.outboundListener,defaultTimeoutMs:s?.defaultTimeoutMs}),this.validationConfig=s?.validationConfig?Id(s.validationConfig):void 0,this.actionHandler&&this.model.onAction.subscribe(this.actionHandler)}get catalogs(){return[...this.registeredCatalogs]}callAgentFunction(e,t,s){return this.rpc.callAgentFunction(e,t,s)}dispose(){this.rpc.dispose()}getRendererCapabilities(e){let t=e?.versions??(e?.version?[e.version]:void 0);if(!t||t.length===0)throw new b("At least one protocol version must be provided in CapabilitiesOptions to generate renderer capabilities.");let s={};for(let r of t){let i={supportedCatalogIds:this.registeredCatalogs.map(a=>a.id)},o=e?.includeInlineCatalogs?this.registeredCatalogs.map(a=>Wt(r,"1.0")>=0?this.generateInlineCatalog(a):this.generateLegacyInlineCatalog(a,e?.componentEnvelopeRef??"common_types.json#/$defs/ComponentCommon")):void 0;o&&(i.inlineCatalogs=o),s[r]=i}return s}getClientCapabilities(e){let t=e?.versions&&e.versions.length>0?e.versions:[e?.version??"v0.9"];return this.getRendererCapabilities({...e,versions:t})}generateInlineCatalog(e){let t=e.toJson();t.catalogId=e.id;let s=typeof t.protocolVersion=="string"?t.protocolVersion:le(e.protocolVersion)??e.protocolVersion;return t.protocolVersion=s.trim().replace(/^[vV](?=\d)/,""),t}generateLegacyInlineCatalog(e,t="common_types.json#/$defs/ComponentCommon"){let s={};for(let[o,a]of e.components.entries()){let c={},l=[];if(a.schema&&typeof a.schema=="object"&&"safeParse"in a.schema){let p=Fe(a.schema,{target:"jsonSchema2019-09",$refStrategy:"none",override:He});Gt(p,void 0,{stripAdditionalProperties:!0}),c=p.properties||{},l=Array.isArray(p.required)?p.required.filter(m=>m!=="component"&&m!=="id"):[]}let{component:u,id:d,...h}=c;s[o]={allOf:[{$ref:t},{properties:{component:{const:o},...h},required:["component",...l]}]}}let r=[];for(let o of e.functions.values()){let a={type:"object",properties:{}};if(o.schema&&typeof o.schema=="object"&&"safeParse"in o.schema){let c=Fe(o.schema,{target:"jsonSchema2019-09",$refStrategy:"none",override:He});Gt(c,void 0,{stripAdditionalProperties:!0}),a=c}r.push({name:o.name,...o.description?{description:o.description}:{},returnType:o.returnType,parameters:a})}let i;if(e.themeSchema){let o=Fe(e.themeSchema,{target:"jsonSchema2019-09",$refStrategy:"none",override:He});Gt(o,void 0,{stripAdditionalProperties:!0}),i=o.properties||void 0}return{catalogId:e.id,...Object.keys(s).length>0?{components:s}:{},...r.length>0?{functions:r}:{},...i?{theme:i}:{}}}getRendererDataModel(e){let t=Array.from(this.model.surfacesMap.values()).filter(o=>o.sendDataModel);if(t.length===0)return;if(e!==void 0){let o={};for(let a of t){let c=a.protocolVersion;(!c||Rt(c,e))&&(o[a.id]=a.dataModel.get("/"))}return Object.keys(o).length===0?void 0:{version:e,surfaces:o}}let s=new Set;for(let o of t)if(o.protocolVersion){let a=le(o.protocolVersion),c=a?Wt(a,"1.0")>=0?a:`v${a}`:o.protocolVersion;s.add(c)}if(s.size>1)throw new b(`Multiple protocol versions detected among active surfaces: ${Array.from(s).sort().join(", ")}. Specify a target protocol version in getRendererDataModel(version).`);let r=s.size===1?s.values().next().value:"1.0",i={};for(let o of t)i[o.id]=o.dataModel.get("/");return{version:r,surfaces:i}}getClientDataModel(e){return this.getRendererDataModel(e)}resolvePath(e,t){return Tt.resolvePath(e,t)}getSurfaces(){return this.model.surfacesMap}getSurface(e){return this.model.getSurface(e)}onSurfaceCreated(e){return this.model.onSurfaceCreated.subscribe(e)}onSurfaceDeleted(e){return this.model.onSurfaceDeleted.subscribe(e)}processMessages(e,t){this.withValidationConfig(t,()=>{let s=yn(Array.isArray(e)?e[0]:e,this.defaultVersion),r=s;try{let i=this.prepareOperations(e,o=>{r=o});for(let o of i)r=this.contextFromOperation(o,s),this.processOperation(o,t)}catch(i){if(this.handleProcessingError(i,r),!this.reportErrorsOnly)throw i}})}processMessagesWithErrors(e,t){return this.withValidationConfig(t,()=>{let s=Array.isArray(e)?e:[e],r=[];for(let i of s){let o=yn(i,this.defaultVersion),a=o;try{let c=this.prepareOperations(i,l=>{a=l});for(let l of c)a=this.contextFromOperation(l,o),this.processOperation(l,t)}catch(c){r.push(this.handleProcessingError(c,a))}}return r})}async processMessagesAsync(e,t){let s=yn(Array.isArray(e)?e[0]:e,this.defaultVersion),r=s;try{let i=this.withValidationConfig(t,()=>this.prepareOperations(e,a=>{r=a})),o=[];for(let a of i){r=this.contextFromOperation(a,s);let c=await this.processOperationAsync(a,t);c&&o.push(c)}return o}catch(i){if(this.handleProcessingError(i,r),!this.reportErrorsOnly)throw i;return[]}}contextFromOperation(e,t){let s=e.envelopeContext??t,r="surfaceId"in e&&e.surfaceId?e.surfaceId:s.surfaceId,i="functionCallId"in e&&e.functionCallId?e.functionCallId:s.functionCallId,o="version"in e?e.version:void 0,a=r?this.model.getSurface(r)?.protocolVersion:void 0;return{surfaceId:r,functionCallId:i,actionType:e.type,version:o??a??s.version??this.defaultVersion}}handleProcessingError(e,t){let s=Bi(e,t),r={code:s.error.code,message:s.error.message,surfaceId:s.error.surfaceId,details:e instanceof b?e.details:void 0},i=s.error.surfaceId?this.model.getSurface(s.error.surfaceId):void 0;return i?i.dispatchError(r):this.model.emitError(r),this.errorHandler?.(s),s}extractSingleMessageOperations(e){let t=yn(e,this.defaultVersion),s;try{s=this.adapterRegistry.resolveFromPayload(e)}catch(o){if(this.isImplicitV09Payload(e)){let a=this.catalogs.some(c=>c.protocolVersion==="0.9.1"||c.protocolVersion==="v0.9.1");s=this.adapterRegistry.getAdapter(a?"v0.9.1":"v0.9")}else throw o}let r=s.extractOperations(e),i=t.version;for(let o of r)i&&le(i)&&("version"in o&&o.version||(o.version=i)),o.envelopeContext=t;return r}withValidationConfig(e,t){let s=e?.validationConfig;if(!s)return t();let r=this.validationConfig;this.validationConfig=Id(s);try{return t()}finally{this.validationConfig=r}}prepareSingleItem(e,t){return t?.(yn(e,this.defaultVersion)),this.validationConfig&&Ha(e),this.validationConfig?.targetVersion&&this.validateTargetVersion(e),wd(e)?[e]:this.extractSingleMessageOperations(e)}prepareOperations(e,t){return!e||Array.isArray(e)&&e.length===0?[]:Array.isArray(e)?e.flatMap(s=>this.prepareSingleItem(s,t)):this.prepareSingleItem(e,t)}isImplicitV09Payload(e){if(this.validationConfig||this.catalogs.length===0||this.catalogs.some(s=>z(s.protocolVersion,"1.0")))return!1;let t=Array.isArray(e)?e[0]:e;return typeof t=="object"&&t!==null&&"messages"in t&&Array.isArray(t.messages)&&(t=t.messages[0]),typeof t!="object"||t===null||"version"in t?!1:["createSurface","updateComponents","updateDataModel","deleteSurface"].some(s=>s in t)}validateTargetVersion(e){let t=this.validationConfig?.targetVersion;if(!t)return;let s=r=>{if(typeof r=="object"&&r!==null&&"version"in r){let i=r.version;if(i){let o=le(i)??i,a=le(t)??t;if(o!==a)throw new b(`Message version '${i}' does not match expected target version '${t}'`)}}};if(Array.isArray(e))for(let r of e)s(r);else s(e)}applyStateOperation(e){if(this.validationConfig?.allowedMessages&&!this.validationConfig.allowedMessages.includes(e.type))throw new b(`Operation '${e.type}' is not permitted by ValidationConfig.allowedMessages`);switch(e.type){case"createSurface":this.processCreateSurfaceOp(e);break;case"deleteSurface":this.processDeleteSurfaceOp(e);break;case"updateComponents":this.processUpdateComponentsOp(e);break;case"updateDataModel":this.processUpdateDataModelOp(e);break;case"agentFunctionResponse":this.rpc.handleAgentFunctionResponse({version:e.version??"1.0",agentFunctionResponse:{functionCallId:e.functionCallId,value:e.value,error:e.error}});break;case"callRendererFunction":break}}resolveRpcDataContext(e){if(e.surfaceId!==void 0){let i=this.model.surfacesMap.get(e.surfaceId);return i?new wt(i,"/"):void 0}let t=e.catalogId?this.registeredCatalogs.find(i=>i.id===e.catalogId):void 0;if(!t)return;let s=`_rpc_fallback_${e.functionCallId||"default"}`,r=new Map;for(let i of this.registeredCatalogs)t?.protocolVersion&&i.protocolVersion&&Rt(t.protocolVersion,i.protocolVersion)&&r.set(i.id,i);return t&&r.set(t.id,t),new wt(new kt(s,t,r),"/")}processOperation(e,t){if(e.type==="callRendererFunction"){let s=this.resolveRpcDataContext(e),r=t?.isUserActivated??e.isUserActivated??!1,i={version:e.version??"1.0",callRendererFunction:{...e.surfaceId!==void 0?{surfaceId:e.surfaceId}:{},functionCallId:e.functionCallId,callFunction:{"@call":e.call,catalogId:e.catalogId,args:e.args}}};this.rpc.handleCallRendererFunction(i,s,r).catch(o=>{console.error(`Unhandled error in callRendererFunction (${e.call}):`,o)});return}this.withValidationConfig(t,()=>this.applyStateOperation(e))}async processOperationAsync(e,t){if(e.type==="callRendererFunction"){let s=this.resolveRpcDataContext(e),r=t?.isUserActivated??e.isUserActivated??!1,i={version:e.version??"1.0",callRendererFunction:{...e.surfaceId!==void 0?{surfaceId:e.surfaceId}:{},functionCallId:e.functionCallId,callFunction:{"@call":e.call,catalogId:e.catalogId,args:e.args}}};return await this.rpc.handleCallRendererFunction(i,s,r)}return this.withValidationConfig(t,()=>this.applyStateOperation(e)),null}validateSurfaceTheme(e,t,s){if(!e||!t?.themeSchema)return e;try{return new Sn(t,this.validationConfig).validateTheme(e)}catch(r){if(r instanceof b){let i=Array.isArray(r.details)?r.details.map(o=>typeof o=="object"&&o!==null?{...o,surfaceId:s}:o):r.details;throw new b(r.message.replace(/^Validation failed for theme:/,`Validation failed for theme on surface '${s}':`),i,r.code,{path:r.path,surfaceId:s})}throw r}}processCreateSurfaceOp(e){let{surfaceId:t,catalogId:s,theme:r,sendDataModel:i,components:o,dataModel:a}=e,c=e.version,l=s===void 0&&c!==void 0&&z(c,"1.0"),u=l?void 0:pg(this.registeredCatalogs,s,c);if(!u&&!l)throw s!==void 0?new R(`Catalog not found: ${s}`,"CATALOG_ERROR",{surfaceId:t}):new R(`No default catalog available for surface '${t}'.`,"CATALOG_ERROR",{surfaceId:t});if(u?.protocolVersion&&c&&!Rt(u.protocolVersion,c)){let g=`Surface '${t}' catalog '${s??u.id}' specification version (${u.protocolVersion}) does not match message protocol version (${c}).`;throw z(c,"1.0")?new R(g,"CATALOG_ERROR",{surfaceId:t}):new b(g,void 0,"VALIDATION_ERROR",{surfaceId:t})}if(this.model.getSurface(t))throw new xe(`Surface ${t} already exists.`,void 0,"INTEGRITY_ERROR",{surfaceId:t});let d=this.validateSurfaceTheme(r,u,t),h=u?.protocolVersion??c,p=new Map(this.registeredCatalogs.filter(g=>Rt(g.protocolVersion,h)).map(g=>[g.id,g])),m=new kt(t,u,p,d,i??!1,void 0,e.rootId??"root",e.metadata,h);this.model.addSurface(m),a&&m.dataModel.set("/",a),o&&o.length>0&&this.processUpdateComponentsOp({type:"updateComponents",surfaceId:t,components:o})}processDeleteSurfaceOp(e){e.surfaceId&&this.model.deleteSurface(e.surfaceId)}validateComponentProperties(e,t){let{id:s,component:r}=e;if(typeof s!="string"||!s)throw new b(`Component '${r}' is missing an 'id'; entries require a valid string 'id'.`);let i=this.resolveComponentCatalog(e,t);"metadata"in e&&e.metadata!==void 0&&Kn(e.metadata);let o=t.componentsModel.get(s),a=!this.validationConfig&&!z(t.protocolVersion,"1.0");new Sn(i,this.validationConfig).validateComponent(this.componentPayloadForValidation(e,t,i),o?.type,{skipNestedFunctions:a}),!a&&this.validateNestedFunctionCalls(e,t,i)}componentPayloadForValidation(e,t,s){let{catalogId:r,...i}=e;return z(t.protocolVersion,"1.0")&&s!==t.defaultCatalog&&(i.catalogId=s.id),i}resolveComponentCatalog(e,t){let{id:s,component:r,catalogId:i}=e,o=`Component '${s}'`,a=z(t.protocolVersion,"1.0");if(typeof i=="string"&&(i||a))return this.resolveSurfaceItemCatalog(t,i,o);if(!a){let c=typeof s=="string"?t.componentsModel.get(s):void 0;if(c&&(typeof r!="string"||!r||r===c.type))return c.catalog}return this.resolveSurfaceItemCatalog(t,void 0,o)}validateSingleNestedCall(e,t,s,r,i){let o=e.catalogId;if(o!==void 0&&typeof o!="string")throw new b(nc(t),void 0,"VALIDATION_ERROR",{path:i||void 0,surfaceId:s.id});let a=this.resolveNestedCallCatalog(s,o,t,i);sc(o,r.id,{catalogIsDefault:r===s.defaultCatalog})||this.validateExternalCatalogFunction(a,t,e.args,s.id,i)}resolveNestedCallCatalog(e,t,s,r){try{return this.resolveSurfaceItemCatalog(e,t,`Function call '${s}'`)}catch(i){throw i instanceof H&&(i.surfaceId=e.id,r&&(i.path=r)),i}}validateExternalCatalogFunction(e,t,s,r,i){try{new Sn(e,this.validationConfig).validateFunction(t,s??{})}catch(o){throw o instanceof H&&(o.surfaceId=r,i&&(o.path=o.path&&o.path!=="/"?`${i}${o.path}`:i)),o}}validateNestedFunctionCalls(e,t,s){if(!z(t.protocolVersion,"1.0"))return;let r=(i,o)=>{if(Array.isArray(i)){for(let l=0;l<i.length;l++)r(i[l],`${o}/${l}`);return}if(typeof i!="object"||i===null)return;let a=i,c=a["@call"];typeof c=="string"&&!c.startsWith("@")&&this.validateSingleNestedCall(a,c,t,s,o);for(let[l,u]of Object.entries(a))r(u,`${o}/${l}`)};for(let[i,o]of Object.entries(e))i==="id"||i==="component"||i==="catalogId"||i==="metadata"||r(o,`/${i}`)}resolveSurfaceItemCatalog(e,t,s){if(t!==void 0&&!e.availableCatalogs.has(t)){let r=this.registeredCatalogs.find(i=>i.id===t);if(r)throw new R(`${s} names catalog '${t}', whose specification version (${r.protocolVersion}) does not match surface '${e.id}' version (${e.protocolVersion}).`)}return e.resolveCatalog(t,s)}applyComponentUpdate(e,t){let{id:s,component:r,catalogId:i,metadata:o,...a}=e;if(typeof s!="string")return;let c=hg(o),l=this.resolveComponentCatalog(e,t),u=t.componentsModel.get(s);if(u){let d=typeof r=="string"?r:u.type;if(d!==u.type||u.catalog.id!==l.id){t.componentsModel.removeComponent(s);let h=new _e(s,d,a,l,c);t.componentsModel.addComponent(h)}else Ds(()=>{u.applyUpdate(a,c)})}else{if(typeof r!="string"||!r)throw new b(`Cannot create component ${s} without a type.`);let d=new _e(s,r,a,l,c);t.componentsModel.addComponent(d)}}rebaseComponentValidationError(e,t,s){if(e instanceof H&&(e.surfaceId||(e.surfaceId=s),e instanceof b&&(e.path=e.path&&e.path!=="/"?`/components/${t}${e.path}`:`/components/${t}`,Array.isArray(e.details))))for(let r of e.details)typeof r=="object"&&r!==null&&!("surfaceId"in r)&&(r.surfaceId=s)}validateComponentsBatch(e,t){let s=new Set;for(let r=0;r<e.components.length;r++){let i=e.components[r];if(i&&typeof i=="object"&&typeof i.id=="string"){if(s.has(i.id))throw new xe(`Duplicate component ID: '${i.id}'`,[i.id],"INTEGRITY_ERROR",{surfaceId:e.surfaceId,path:`/components/${r}/id`});s.add(i.id)}try{this.validateComponentProperties(i,t)}catch(o){throw this.rebaseComponentValidationError(o,r,e.surfaceId),o}}}validateSurfaceComponentGraph(e,t){try{return yd(t,e.components,this.validationConfig,(s,r)=>this.resolveComponentCatalog(s,r),this.graphBounds)}catch(s){throw s instanceof H&&!s.surfaceId&&(s.surfaceId=e.surfaceId),s}}processUpdateComponentsOp(e){if(!e.surfaceId)return;let t=this.model.getSurface(e.surfaceId);if(!t)throw new xe(`Surface not found for message: ${e.surfaceId}`,void 0,"INTEGRITY_ERROR",{surfaceId:e.surfaceId});this.validateComponentsBatch(e,t);let s=this.validateSurfaceComponentGraph(e,t);Ds(()=>{for(let r of e.components)this.applyComponentUpdate(r,t)}),s&&xd(t.componentsModel,s,this.graphBounds)}processUpdateDataModelOp(e){if(!e.surfaceId)return;let t=this.model.getSurface(e.surfaceId);if(!t)throw new xe(`Surface not found for message: ${e.surfaceId}`,void 0,"INTEGRITY_ERROR",{surfaceId:e.surfaceId});if(e.path!==void 0&&e.path!==""&&(!e.path.startsWith("/")||!Za.test(e.path))){let i=`Invalid path syntax: '${e.path}' (path must be a valid RFC 6901 JSON Pointer starting with '/')`;throw new b(i,[{path:"/path",code:"invalid_value",message:i,surfaceId:e.surfaceId}],"VALIDATION_ERROR",{path:"/path",surfaceId:e.surfaceId})}let s=e.path||"/",r=e.value;try{t.dataModel.set(s,r)}catch(i){throw i instanceof oe&&!i.surfaceId&&(i.surfaceId=e.surfaceId),i}}};function hg(n){if(n&&typeof n=="object"&&!Array.isArray(n))return n}function pg(n,e,t){return e!==void 0?n.find(s=>s.id===e):n.find(s=>t?Rt(s.protocolVersion,t):!0)??n[0]}function Id(n){return{allowOrphanComponents:!1,allowDanglingReferences:!1,allowMissingRoot:!1,allowUnknownElements:!1,...n}}var Mr=class extends H{constructor(e){super(e,"PARSE_ERROR"),this.name="ParseError"}},ut=class extends H{constructor(e,t){let s=[e];if(t.line!==void 0){let r=`Line ${t.line}`;t.column!==void 0&&(r+=`, Col ${t.column}`),s.push(r)}t.helpMessage&&s.push(`Help: ${t.helpMessage}`),super(s.join(" - "),"COMPILATION_ERROR"),this.name="A2uiCompilationError",this.detail=e,this.rawContent=t.rawContent,this.line=t.line,this.column=t.column,this.helpMessage=t.helpMessage,this.partialResults=t.partialResults??[]}},Fr=class extends ut{constructor(e,t){super(e,t),this.name="A2uiCompilationParseError"}},jr=class extends ut{constructor(e,t){super(e,t),this.name="A2uiCompilationValidationError"}};function qs(n,e){return n instanceof H&&(n.partialResults=e),n}function pe(n){let e=de(n);if(!e)throw new R("A protocol version is required, but none was given.");return z(e,"1.0")?e:`v${e}`}function no(n){let e=pe(n);return e==="v0.9.1"?"v0.9":e}function kd(n){if(!n||n.length===0)throw new R("Parser requires at least one catalog.");let e=new Set,t=new Set;for(let s of n){if(e.has(s.id))throw new R(`Duplicate catalog ID '${s.id}' provided.`);e.add(s.id);let r=pe(s.protocolVersion||"1.0"),i=r;(r==="v0.9.1"||r==="v0.9")&&(i="v0.9"),t.add(i)}if(t.size>1)throw new R(`The catalogs target incompatible protocol versions: ${Array.from(t).sort().join(", ")}.`);return pe(n[0].protocolVersion||"1.0")}var rc="createSurface",ic="updateComponents",oc="updateDataModel",ac="deleteSurface";var mg="<a2ui-json>",gg="</a2ui-json>",zs="<a2ui>",Ws="</a2ui>";var R9=`
6
+ The generated response MUST follow these rules:
7
+ - The response can contain one or more A2UI JSON blocks.
8
+ - Each A2UI JSON block MUST be wrapped in literal \`${mg}\` and \`${gg}\` tags (always include both the opening and closing tags; do NOT wrap the tags in backticks or replace the opening tag with a markdown code fence such as \`\`\`json).
9
+ - Between or around these blocks, you can provide conversational text.
10
+ - The JSON part MUST be a single, raw JSON object (usually a list of A2UI messages) and MUST validate against the provided A2UI JSON SCHEMA.
11
+ - Top-Down Component Ordering: Within the \`components\` list of a message:
12
+ - The 'root' component MUST be the FIRST element.
13
+ - Parent components MUST appear before their child components.
14
+ This specific ordering allows the streaming parser to yield and render the UI incrementally as it arrives.
15
+ `;var yg="callRendererFunction",xg="agentFunctionResponse",Sg={[rc]:zi,[ic]:Wi,[oc]:Zi,[ac]:Hi},bg={[rc]:Gi,[ic]:Ki,[oc]:Yi,[ac]:Ji,[yg]:Xi,[xg]:Qi};function Ag(n){let e=de(n);if(e==="0.9"||e.startsWith("0.9."))return Sg;if(e==="1.0")return bg;throw new R(`No message schemas for protocol version '${n}'.`)}function vg(n){for(let s of n.issues)if(s.code==="invalid_type"&&s.received==="undefined"){let r=s.path[s.path.length-1];if(typeof r=="string")return`Validation failed: '${r}' is a required property (${s.message})`}let e=n.issues[0],t=e.path.length>0?` at '${e.path.join(".")}'`:"";return`Validation failed: ${e.message}${t}`}function Rd(n,e){let t=Ag(e),r=Object.keys(t).find(o=>o in n);if(!r){let o=Object.keys(n).join(", ");throw new b(`Validation failed: unknown message type in envelope. Present keys: [${o}]`)}let i=t[r].safeParse(n);if(!i.success)throw new b(vg(i.error))}var cc={"v0.9":["v0.9","v0.9.1"],"1.0":["1.0"]},_d=["createSurface"],Eg=["updateComponents","updateDataModel","deleteSurface"],Cg=Object.freeze({allowDanglingReferences:!0,allowMissingRoot:!0,allowOrphanComponents:!0,allowUnknownElements:!1}),Tg=/^(0|[1-9][0-9]*)$/,lc,Ye=class n{constructor(e){if(this.assumed=new Set,this.changed=new Map,this.baseline=new Map,this.log=[],this.open=0,this.runaway=0,this.calls=[],!e||e.length===0)throw new R("A renderer state requires at least one catalog.");let t=kd(e);if(this.releaseLine=no(t),!Object.prototype.hasOwnProperty.call(cc,this.releaseLine))throw new R(`The catalogs target ${t}, which a renderer state does not support. It supports ${Object.values(cc).flat().join(", ")}.`);this._catalogs=[...e],this.processor=lc??new $r(this._catalogs)}static of(e){lc=e;try{return new n(e.catalogs)}finally{lc=void 0}}get catalogs(){return[...this._catalogs]}get surfaceIds(){return[...this.processor.model.surfacesMap.keys()]}getSurface(e){return this.processor.model.getSurface(e)}dropProvisionalComponent(e,t){let s=this.processor.model.getSurface(e);if(!s)return;let r=this.baseline.get(e);if(!r||!r.has(t))return;let i=r.get(t)??null;r.delete(t),this.record(()=>r.set(t,i));let o=s.componentsModel,a=o.get(t);if(a){let l=1/0,u=0;for(let h of o.keys){if(h===t){l=u;break}u++}let d=new _e(t,a.type,structuredClone(a.properties),a.catalog,structuredClone(a.metadata));o.removeComponent(t),i!==null&&o.insertComponent(i.position,new _e(t,i.type,structuredClone(i.properties),i.catalog,structuredClone(i.metadata))),this.record(()=>{let h=this.processor.model.getSurface(e)?.componentsModel;h&&(h.removeComponent(t),h.insertComponent(l,d))})}let c=this.changed.get(e);c?.has(t)&&(c.delete(t),this.record(()=>c.add(t)))}get assumesUnknownSurfaces(){return!1}apply(e){this.checkNoRunaway();let t=Ig(e);t.forEach((r,i)=>this.checkMessage(r,i));let s=new Set;return this.frame(()=>{for(let r=0;r<t.length;r++){let i=this.applyMessage(t,r);i!==void 0&&s.add(i)}}),[...s]}checkTopology(e){this.checkNoRunaway();let t=[...new Set(e)];for(let s of t){if(this.assumed.has(s))continue;let r=this.processor.model.getSurface(s);if(!r)continue;let i=r.componentsModel;if(i.size===0)continue;let o=r.rootId||"root",a=Nd(()=>(i.validateTopology({...Vi,rootId:o,allowOrphanComponents:!0}),i.detectCycles({rootId:o}))),c=[...this.changed.get(s)??[]].filter(l=>i.has(l)&&!a.has(l)).sort();if(c.length>0)throw new xe(`Component '${c[0]}' is not reachable from '${o}' (Orphaned component '${c[0]}' is not reachable from root)`)}this.markChecked(t.filter(s=>!this.assumed.has(s)))}markChecked(e){this.checkNoRunaway();for(let t of new Set(e))this.forgetChanged(t)}transaction(e){return this.checkNoRunaway(),this.frame(()=>{let t=e(this);if(wg(t)){this.runaway++;let s=()=>{this.runaway--};throw Promise.resolve(t).then(s,s),new TypeError("A renderer state transaction must be synchronous.")}return t})}checkNoRunaway(){if(this.runaway>0)throw new TypeError("A renderer state takes no changes while a promise that a transaction function returned is still running.")}frame(e){let t=this.log.length;this.open++;let s;try{s=e()}catch(r){throw this.revert(t),r}finally{this.open--,this.open===0&&(this.log.length=0)}return this.open===0&&this.runCalls(),s}runCalls(){let e=this.calls.splice(0);e.length>0&&this.processUnlogged(e)}revert(e){for(;this.log.length>e;)try{this.log.pop()()}catch{}}record(e){this.open>0&&this.log.push(e)}setAssumed(e,t){this.assumed.has(e)!==t&&(t?(this.assumed.add(e),this.record(()=>this.assumed.delete(e))):(this.assumed.delete(e),this.record(()=>this.assumed.add(e))))}noteBaseline(e,t){if(t.size===0)return;let s=this.baseline.get(e);s||(s=new Map,this.baseline.set(e,s),this.record(()=>this.baseline.delete(e)));let r=[...t].filter(l=>!s.has(l));if(r.length===0)return;let o=(this.assumed.has(e)?void 0:this.processor.model.getSurface(e))?.componentsModel,a=new Map;if(o){let l=new Set(r.filter(u=>o.has(u)));if(l.size>0){let u=0;for(let d of o.keys)l.has(d)&&a.set(d,u),u++}}for(let l of r){let u=o?.get(l);u?s.set(l,{position:a.get(l)??1/0,type:u.type,properties:structuredClone(u.properties),catalog:u.catalog,metadata:structuredClone(u.metadata)}):s.set(l,null)}let c=s;this.record(()=>r.forEach(l=>c.delete(l)))}noteChanged(e,t){let s=this.changed.get(e);s||(s=new Set,this.changed.set(e,s),this.record(()=>this.changed.delete(e)));let r=[];for(let i of t)s.has(i)||(s.add(i),r.push(i));if(r.length>0){let i=s;this.record(()=>r.forEach(o=>i.delete(o)))}}holdCall(e){this.calls.push(e),this.record(()=>this.calls.pop())}forgetChanged(e){let t=this.changed.get(e);t!==void 0&&(this.changed.delete(e),this.record(()=>this.changed.set(e,t)));let s=this.baseline.get(e);s!==void 0&&(this.baseline.delete(e),this.record(()=>this.baseline.set(e,s)))}process(e){let t=this.undoFor(e);try{this.processUnlogged([e])}catch(s){try{t?.()}catch{}throw s}t&&this.record(t)}processUnlogged(e){Nd(()=>this.processor.processMessages(e,{validationConfig:Cg}))}undoFor(e){let t=this.processor.model,s=so(e,"createSurface");if(s){let a=s.surfaceId;return typeof a!="string"||t.getSurface(a)?void 0:()=>t.deleteSurface(a)}let r=so(e,"deleteSurface");if(r){let a=r.surfaceId,c=typeof a=="string"?t.getSurface(a):void 0;return c?this.surfaceRestorer(c):void 0}let i=so(e,"updateComponents");if(i)return this.componentsRestorer(i);let o=so(e,"updateDataModel");if(o)return this.dataModelRestorer(o)}componentsRestorer(e){let t=this.processor.model,s=e.surfaceId;if(typeof s!="string"||!Array.isArray(e.components))return;let r=t.getSurface(s);if(!r)return;let i=[],o=new Set;for(let c of e.components){let l=c?.id;if(typeof l!="string")continue;let u=r.componentsModel.get(l);i.push({id:l,existing:u,properties:u?.properties??{},copy:u?structuredClone(u.properties):{},metadata:u?structuredClone(u.metadata):void 0}),u&&this.replaces(c,u,r)&&o.add(l)}if(i.length===0)return;let a=new Map;if(o.size>0){let c=0;for(let l of r.componentsModel.keys)o.has(l)&&a.set(l,c),c++}return()=>{let c=t.getSurface(s)?.componentsModel;if(!c)return;let l=[];for(let{id:u,existing:d,properties:h,copy:p,metadata:m}of[...i].reverse()){let g=c.get(u);if(!d)c.removeComponent(u);else if(g&&g.type===d.type&&g.catalog===d.catalog){if(g===d&&g.properties===h)continue;g.metadata=m,g.properties=p}else c.removeComponent(u),l.push([a.get(u)??1/0,new _e(u,d.type,p,d.catalog,m)])}l.sort(([u],[d])=>u-d);for(let[u,d]of l)c.insertComponent(u,d)}}replaces(e,t,s){if((typeof e.component=="string"?e.component:t.type)!==t.type)return!0;let i=this.releaseLine!=="v0.9",o=e.catalogId;return typeof o=="string"&&(o!==""||i)?o!==t.catalog.id:i&&s.defaultCatalog?.id!==t.catalog.id}dataModelRestorer(e){let t=this.processor.model,s=e.surfaceId;if(typeof s!="string")return;let r=t.getSurface(s);if(!r)return;let i=typeof e.path=="string"?e.path:"/",o=Ng(i),a=r.dataModel.get("/");if(o.length===0)return()=>t.getSurface(s)?.dataModel.set("/",a);let c=a;for(let l=0;l<o.length;l++){if(!c||typeof c!="object")return;let u=o[l],[d,h]=Pg(c,u);if(d&&l<o.length-1&&h&&typeof h=="object"){c=h;continue}let p=o.slice(0,l),m=Array.isArray(c)?c.length:0,E=d&&!Array.isArray(c)&&l===o.length-1&&(e.value===void 0||e.value===null)?Object.keys(c).indexOf(u):-1;return()=>{let A=t.getSurface(s)?.dataModel;if(!A)return;let I=Og(p),D=A.get(I);!D||typeof D!="object"||(Array.isArray(D)?d?D[Number(u)]=h:(delete D[Number(u)],D.length=m):d?Dg(D,u,h,E):delete D[u],A.set(I,D))}}}surfaceRestorer(e){let t=e.id,s=e.defaultCatalog,r=new Map(e.availableCatalogs),i=structuredClone(e.theme),o=e.sendDataModel,a=e.rootId,c=structuredClone(e.metadata),l=e.protocolVersion,u=[...e.componentsModel.values].map(h=>({id:h.id,type:h.type,properties:structuredClone(h.properties),catalog:h.catalog,metadata:structuredClone(h.metadata)})),d=structuredClone(e.dataModel.get("/"));return()=>{let h=this.processor.model;if(h.getSurface(t))return;let p=new kt(t,s,r,i,o,void 0,a,c,l);p.dataModel.set("/",d);for(let m of u)p.componentsModel.addComponent(new _e(m.id,m.type,m.properties,m.catalog,m.metadata));h.addSurface(p)}}applyMessage(e,t){let s=e[t],[r,i]=ro(s);if(r===void 0){"callRendererFunction"in s?this.holdCall(s):this.process(s);return}let o="deleteSurface"in s,a=o?void 0:Rg(s);return a&&a.size>0&&this.noteBaseline(r,a),i?this.process(s):o?(this.process(s),this.setAssumed(r,!1),this.forgetChanged(r)):!this.processor.model.getSurface(r)&&this.assumes(r,e,t)?this.assumeSurface(r,e,t):this.process(s),a&&a.size>0&&this.noteChanged(r,a),r}assumes(e,t,s){if(!this.assumesUnknownSurfaces||t.slice(0,s).some(r=>ro(r)[0]===e))return!1;for(let r of t.slice(s+1)){let[i,o]=ro(r);if(i===e){if(o)return!1;if("deleteSurface"in r)break}}return!0}assumeSurface(e,t,s){let r=t[s],i=kg(e,t,s),o=_g(i),a=this._catalogs.filter(l=>[...o].every(u=>l.components.has(u)));a.length===0&&(a=[this._catalogs[0]]);let c=[];for(let l of a){let u={version:r.version,createSurface:{surfaceId:e,catalogId:l.id}};try{this.processUnlogged([u,...i])}catch(d){if(!(d instanceof b))throw d;c.push(d);continue}finally{this.processor.model.deleteSurface(e)}this.process(u),this.process(r),this.setAssumed(e,!0);return}throw c[0]}checkMessage(e,t){let s=cc[this.releaseLine],r=e.version;if(typeof r=="string"&&s.includes(r)){Rd(e,this.releaseLine);return}if(r==null)throw new b(`Message ${t} states no version, which ${this.releaseLine} messages require.`);let i=[...s].sort().map(o=>`'${o}'`).join(" or ");throw new b(`Message ${t} states version '${String(r)}', but the catalogs target ${this.releaseLine}, whose messages state ${i}.`)}};function wg(n){return typeof n=="object"&&n!==null&&typeof n.then=="function"}function Nd(n){try{return n()}catch(e){throw e instanceof b||!(e instanceof H)?e:new b(e.message,e.details)}}function Od(n){return typeof n=="object"&&n!==null&&Symbol.iterator in n}function Ig(n){return(Od(n)?[...n]:[n]).map((t,s)=>{if(!t||typeof t!="object"||Od(t))throw new b(`Message ${s} is not a JSON object.`);return structuredClone(t)})}function ro(n){let e=[..._d,...Eg].filter(r=>r in n);if(e.length!==1)return[void 0,!1];let t=e[0],s=n[t];if(s&&typeof s=="object"){let r=s.surfaceId;if(typeof r=="string")return[r,_d.includes(t)]}return[void 0,!1]}function kg(n,e,t){let s=[];for(let r of e.slice(t)){let[i,o]=ro(r);if(i===n){if(s.length>0&&(o||"deleteSurface"in r))break;s.push(r)}}return s}function Pd(n){let e=[];for(let t of["createSurface","updateComponents"]){let s=n[t],r=s&&typeof s=="object"?s.components:void 0;Array.isArray(r)&&e.push(r)}return e}function Rg(n){let e=new Set;for(let t of Pd(n))for(let s of t){let r=s?.id;typeof r=="string"&&e.add(r)}return e}function _g(n){let e=new Set;for(let t of n)for(let s of Pd(t))for(let r of s){if(!r||typeof r!="object"||"catalogId"in r)continue;let i=r.component;typeof i=="string"&&e.add(i)}return e}function so(n,e){let t=n[e];return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Ng(n){return n.split("/").filter(e=>e.length>0).map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~"))}function Og(n){return"/"+n.map(e=>e.replace(/~/g,"~0").replace(/\//g,"~1")).join("/")}function Pg(n,e){if(Array.isArray(n)){if(!Tg.test(e))return[!1,void 0];let t=Number(e);return Object.prototype.hasOwnProperty.call(n,t)?[!0,n[t]]:[!1,void 0]}return Object.prototype.hasOwnProperty.call(n,e)?[!0,n[e]]:[!1,void 0]}function Dg(n,e,t,s){if(s<0||Object.prototype.hasOwnProperty.call(n,e)){n[e]=t;return}let r=Object.keys(n).slice(s),i=r.map(o=>n[o]);for(let o of r)delete n[o];n[e]=t,r.forEach((o,a)=>{n[o]=i[a]})}var io=class{emptyState(){return new Ye(this.catalogs)}parseResponse(e,{wrapped:t=!0,state:s}={}){let r=s??this.emptyState(),i=[];return r.transaction(()=>{let o=new Set,a=new Set;try{let c=t?this.unwrap(e):[{type:"a2ui",a2uiRaw:e,isFinal:!0}];for(let l of c){if(l.type==="text"){i.push({type:"text",text:l.text});continue}let u=this.compileBlock(l.a2uiRaw,l.isFinal);for(let d of r.apply(u))o.add(d),l.isFinal||a.add(d);i.push({type:"a2ui",a2ui:u})}}catch(c){throw qs(c,i)}try{let c=[...o].filter(l=>!a.has(l));c.length>0&&r.checkTopology(c)}catch(c){throw qs(c,i.filter(l=>l.type==="text"))}return r.markChecked(a),i})}compileBlock(e,t){try{return this.compile(e,t)}catch(s){if(s instanceof H)throw s;let r=s instanceof Error?s.message:String(s);throw new ut(`Failed to compile A2UI block: ${r}`,{rawContent:e})}}get supportsStreaming(){return!1}openStream(e={}){throw new Error(`Streaming is not supported by ${this.constructor.name}`)}};var oo=class{constructor(e){if(this.catalogs=e,e.length===0)throw new R("A prompt snippet needs at least one active catalog.")}generateCatalogInstructions(e){return(e?[e]:this.catalogs).map(s=>this.renderCatalogInstructions(s)).filter(s=>s.length>0).join(`
16
+
17
+ `)}generateExamples(e){return(e?[e]:this.catalogs).map(s=>this.renderExamples(s)).filter(s=>s.length>0).join(`
18
+
19
+ `)}generate(){return[this.generateBaseRules(),this.generateCatalogInstructions(),this.generateExamples()].filter(e=>e.length>0).join(`
20
+
21
+ `)}};import*as Dd from"fs";function uc(n,e,t,s){let r=typeof n.catalogId=="string"?n.catalogId:void 0;if(s!==void 0&&r!==void 0&&s!==r)throw new R(`Catalog ID mismatch in ${e}. Provider: ${s}, document: ${r}`);let i=r??s;if(i===void 0)throw new R(`No catalog ID for ${e}: the document has no catalogId and the provider was given none.`);let o=typeof n.protocolVersion=="string"?n.protocolVersion:void 0;if(t!==void 0&&o!==void 0&&de(t)!==de(o))throw new R(`Protocol version mismatch in ${e}. Provider: ${t}, document: ${o}`);let a=o??t;if(a===void 0)throw new R(`No protocol version for ${e}: the document has no protocolVersion and the provider was given none.`);let c;try{c=ct.fromJson(n,pe(a),i)}catch(l){throw new R(`Failed to build catalog from schema in ${e}: ${l.message}`)}return c}var ao=class{constructor(e,t,s){this.path=e,this.protocolVersion=t,this.catalogId=s}load(){let e;try{e=Dd.readFileSync(this.path,"utf8")}catch(s){throw new R(`Failed to read catalog file at ${this.path}: ${s.message}`)}let t;try{t=JSON.parse(e)}catch(s){throw new R(`Failed to parse JSON in catalog file at ${this.path}: ${s.message}`)}return uc(t,this.path,this.protocolVersion,this.catalogId)}};var co=class n{constructor(e,t){this.catalog=e,this.transformers=t}get transformedCatalog(){if(!this._transformedCatalogMemo){let e=this.catalog;if(this.transformers)for(let t of this.transformers)e=t.transform(e);this._transformedCatalogMemo=e}return this._transformedCatalogMemo}static fromPath(e,t,s,r){let o=new ao(e,s,r).load();return new n(o,t)}};var Lg=["supportedCatalogIds","inlineCatalogs"];function Ld(n){if(typeof n!="object"||n===null||Array.isArray(n))return!1;let e=Object.getPrototypeOf(n);return e===null||e===Object.prototype}function $d(n){let e=pe(n.protocolVersion||"1.0");return e==="v0.9.1"?"v0.9":e}function $g(n,e){if(!Ld(n))throw new b("Renderer capabilities must be an object.");let t=Object.hasOwn(n,e)?n[e]:void 0;if(t===void 0&&Lg.some(s=>Object.hasOwn(n,s))&&(t=n),t==null)throw new b(`The renderer capabilities have no '${e}' entry, which the registered catalogs read.`);if(!Ld(t))throw new b(`Invalid '${e}' renderer capabilities: entry must be an object.`);if(t.supportedCatalogIds!==void 0&&(!Array.isArray(t.supportedCatalogIds)||!t.supportedCatalogIds.every(s=>typeof s=="string")))throw new b(`Invalid '${e}' renderer capabilities: supportedCatalogIds must be an array of strings.`);return t}function Md(n,e,t=!1){let s=n.map(l=>l.transformedCatalog);if(!e)return s;if(s.length===0)throw new R("Agent has no configured catalogs");let r=$d(s[0]);for(let l=1;l<s.length;l++){let u=s[l],d=$d(u);if(d!==r)throw new R(`The registered catalogs read different capabilities entries: '${s[0].id}' reads '${r}' and '${u.id}' reads '${d}'.`)}let i=$g(e,r),o=i.inlineCatalogs??[];if(!Array.isArray(o))throw new R("inlineCatalogs in the renderer capabilities must be an array");let a=o.map(l=>{if(typeof l!="object"||l===null||Array.isArray(l))throw new R("Each entry in inlineCatalogs must be a catalog object");return uc(l,"inline catalog",r==="v0.9"?"v0.9":void 0)}),c=[];for(let l of i.supportedCatalogIds??[]){let u=s.find(d=>d.id===l);u&&!c.includes(u)&&c.push(u)}if(t&&c.push(...a),c.length===0)throw new R("No catalog in common with the renderer: it names no catalog the agent holds and declares no inline catalog the agent accepts.");return c}var dc=class extends Ye{get assumesUnknownSurfaces(){return!0}};function Fd(n,e){let t=new dc(n);t.checkTopology(t.apply(e))}var Le;(function(n){n[n.NORMAL=0]="NORMAL",n[n.IN_A2UI=1]="IN_A2UI",n[n.IN_STRING=2]="IN_STRING",n[n.IN_COMMENT=3]="IN_COMMENT",n[n.IN_BLOCK_COMMENT=4]="IN_BLOCK_COMMENT"})(Le||(Le={}));var Mg=/^```[a-zA-Z0-9_-]*\s*/i,Fg=/\s*```[a-zA-Z0-9_-]*$/i,fc=/^[ \t]*```[a-zA-Z0-9_-]*[ \t]*\r?\n?/gm,jg=/\r?\n?[ \t]*```[ \t]*\r?\n?$/,hc=/^[ \t]*(?:surface\s*\(|deleteSurface\s*\(|\$[a-zA-Z0-9_/]*\s*=(?!=)|[a-zA-Z_][a-zA-Z0-9_]*\s*=(?!=))/m;var lo=class{constructor(e="<a2ui>",t="</a2ui>",s=new Set(["'",'"']),r=new Set(["#"]),i=hc,o=!1,a=[]){if(this.openTagPattern=this.toStickyRegExp(e,!1),this.openTagSearchPattern=this.toSearchRegExp(e,!1),this.closeTagPattern=this.toStickyRegExp(t,!0),this.closeTagSearchPattern=this.toSearchRegExp(t,!0),this.stringDelimiters=s,this.singleLineComments=r,this.payloadStartPattern=i,this.stripEdgeBackticks=o,this.blockComments=a,a.some(([c,l])=>!c||!l))throw new Error("Block comment markers must be non-empty strings.")}toStickyRegExp(e,t){if(typeof e=="string"){let i=e.replace(/[<>/]/g,"");return t?new RegExp(`</${i}\\s*>`,"iy"):new RegExp(`<${i}(?:\\s[^>]*)?>`,"iy")}let s=e.flags;s.includes("y")||(s+="y");let r=e.source;return r.startsWith("^")&&(r=r.substring(1)),new RegExp(r,s)}toSearchRegExp(e,t){if(typeof e=="string"){let i=e.replace(/[<>/]/g,"");return t?new RegExp(`</${i}\\s*>`,"i"):new RegExp(`<${i}(?:\\s[^>]*)?>`,"i")}let s=e.flags.replace(/[yg]/g,""),r=e.source;return r.startsWith("^")&&(r=r.substring(1)),new RegExp(r,s)}cleanMarkdown(e){if(!e)return"";let t=e.trim();return t=t.replace(Mg,""),t=t.replace(Fg,""),t=t.trim(),/^`*$/.test(t)?"":t}cleanRaw(e){return this.cleanMarkdown(e).replace(/^`+|`+$/g,"").trim()}addText(e,t){let s=this.cleanMarkdown(t);s&&e.push({type:"text",text:s,isFinal:!0})}scanBlock(e,t,s){let r=t,i=Le.IN_A2UI,o=null,a=!1,c="";for(;r<s;){if(i===Le.IN_A2UI){if(this.closeTagPattern.lastIndex=r,this.closeTagPattern.exec(e)&&this.closeTagPattern.lastIndex<=s)return[r,this.closeTagPattern.lastIndex];let u=e[r];if(this.stringDelimiters.has(u)){r+2<s&&e.startsWith(u.repeat(3),r)?(o=u.repeat(3),a=!0,r+=3):(o=u,a=!1,r+=1),i=Le.IN_STRING;continue}let d=this.blockComments.find(([p])=>e.startsWith(p,r));if(d){r+=d[0].length,c=d[1],i=Le.IN_BLOCK_COMMENT;continue}let h=!1;for(let p of this.singleLineComments)if(e.startsWith(p,r)){r+=p.length,i=Le.IN_COMMENT,h=!0;break}if(h)continue;r+=1;continue}if(i===Le.IN_STRING){if(e[r]==="\\"){r+=2;continue}if(a){if(e.startsWith(o,r)){r+=3,i=Le.IN_A2UI;continue}}else if(e[r]===o){r+=1,i=Le.IN_A2UI;continue}r+=1;continue}if(i===Le.IN_COMMENT){if(this.closeTagPattern.lastIndex=r,this.closeTagPattern.exec(e)&&this.closeTagPattern.lastIndex<=s)return[r,this.closeTagPattern.lastIndex];let u=e[r];(u===`
22
+ `||u==="\r")&&(i=Le.IN_A2UI),r+=1;continue}if(i===Le.IN_BLOCK_COMMENT){if(e.startsWith(c,r)){r+=c.length,i=Le.IN_A2UI;continue}r+=1;continue}}return null}tryRecoverUnmatchedClose(e,t,s,r){let i=t.slice(s,r);if(!this.closeTagSearchPattern.test(i))return null;let o=Array.from(i.matchAll(fc));for(let E=0;E<o.length;E+=2){let A=o[E],I=A.index??0,D=I+A[0].length,O=this.scanBlock(i,D,i.length);if(!O)continue;let[te,Q]=O,Mt=i.slice(D,te).replace(jg,"");if(fc.lastIndex=0,fc.test(Mt))continue;let Ft=this.cleanRaw(Mt);if(Ft)return this.addText(e,i.slice(0,I)),e.push({type:"a2ui",a2uiRaw:Ft,isFinal:!0}),s+Q}let a=0,c=0;for(;c+1<o.length;){let E=o[c+1],A=(E.index??0)+E[0].length;if(!this.scanBlock(i,A,i.length))break;a=A,c+=2}let l=i.slice(a),u=this.payloadStartPattern.exec(l);if(!u||u.index===void 0)return null;let d=a+u.index,h=this.scanBlock(i,d,i.length);if(!h)return null;let[p,m]=h,g=this.cleanRaw(i.slice(d,p));return g?(this.addText(e,i.slice(0,d)),e.push({type:"a2ui",a2uiRaw:g,isFinal:!0}),s+m):null}tokenize(e){let t=[],s=e.length,r=0,i=!1;for(;r<s;){let o=e.slice(r),a=this.openTagSearchPattern.exec(o),c=a&&a.index!==void 0?r+a.index:null,l=c??s;if(!i&&l>r){let g=this.tryRecoverUnmatchedClose(t,e,r,l);if(g!==null){i=!0,r=g;continue}}if(c===null||!a)break;let u=e.slice(r,c);this.stripEdgeBackticks&&u.endsWith("`")&&(u=u.replace(/`+$/,"")),this.addText(t,u);let d=c+a[0].length,h=this.scanBlock(e,d,s);if(!h)return t.push({type:"a2ui",a2uiRaw:this.cleanRaw(e.slice(d)),isFinal:!1}),t;let[p,m]=h;if(t.push({type:"a2ui",a2uiRaw:this.cleanRaw(e.slice(d,p)),isFinal:!0}),r=m,this.stripEdgeBackticks)for(;r<s&&e[r]==="`";)r++}return this.addText(t,e.slice(r)),t}};var uo=class{constructor(){this.started=!1,this.heldSpace=""}emit(e,t){let s=(this.started?t:t.trimStart()).trimEnd();if(!s){this.started&&(this.heldSpace+=t);return}let r=this.started?0:t.indexOf(s);e.push({type:"text",text:`${this.heldSpace}${s}`}),this.heldSpace=t.slice(r+s.length),this.started=!0}reset(){this.started=!1,this.heldSpace=""}};var Zs=class extends H{constructor(e,t){super(e,"EXPRESS_COMPILER_ERROR"),this.name="ExpressCompilerError",this.helpMessage=t}},Je=class extends Zs{constructor(e,t){super(e,t),this.name="ExpressParseError"}},_=class extends Zs{constructor(e,t){super(e,t),this.name="ExpressValidationError"}},fo=class extends _{constructor(e){super(`Component '${e}' is not defined in the catalog.`),this.name="ExpressUnknownComponentError",this.compName=e}},ho=class extends _{constructor(e,t){super(`Component '${e}' is missing required property '${t}'.`),this.name="ExpressMissingRequiredPropertyError",this.compName=e,this.propName=t}},po=class extends _{constructor(e,t,s){let r=`Property '${t}' is not a valid property of component '${e}'.`,i=s.length>0?`Component '${e}' accepts properties: ${[...s].sort().join(", ")}.`:`Component '${e}' has no configurable properties.`;super(r,i),this.name="ExpressUnknownPropertyError",this.compName=e,this.propName=t,this.validProps=s}},mo=class extends _{constructor(e,t){let s=`Property '${t}' of component '${e}' was provided multiple times.`,r=`Remove duplicate specification of property '${t}' for component '${e}'.`;super(s,r),this.name="ExpressDuplicatePropertyError",this.compName=e,this.propName=t}},go=class extends _{constructor(e){super(`Function '${e}' is not defined in the catalog.`),this.name="ExpressUnknownFunctionError",this.fnName=e}},Vr=class extends _{constructor(e,t,s){let r=`Argument '${t}' is not a valid parameter of function '${e}'.`,i=s.length>0?`Function '${e}' accepts parameters: ${[...s].sort().join(", ")}.`:`Function '${e}' accepts no parameters.`;super(r,i),this.name="ExpressInvalidParamError",this.fnName=e,this.paramName=t,this.validParams=s}},Ur=class extends _{constructor(e,t){let s=`Argument '${t}' of function '${e}' was provided multiple times.`,r=`Remove duplicate specification of parameter '${t}' for function '${e}'.`;super(s,r),this.name="ExpressDuplicateParamError",this.fnName=e,this.paramName=t}},yo=class extends _{constructor(e,t){let s=`Property '${t}' of component '${e}' does not support dynamic data bindings (paths).`,r=`Property '${t}' on '${e}' must be a static literal value, not a dynamic databinding ($path).`;super(s,r),this.name="ExpressForbiddenDatabindingError",this.compName=e,this.propName=t}},Xt=class extends Je{constructor(e){let t=`Root target '${e}' is not defined.`,s=`Ensure root component '${e}' is assigned in your Express DSL.`;super(t,s),this.name="ExpressUndefinedRootError",this.rootTarget=e}};var _t=class extends Je{constructor(e,t,s,r){super(e),this.name="ExpressSyntaxError",this.line=t,this.column=s,this.isLexer=r}},Br=class extends _{constructor(e){super(`Generated inline component ID '${e}' collides with an existing component or variable ID.`),this.name="ExpressIdCollisionError",this.idName=e}};var Vg=/(?:^|\/)common_types\.json#\/(?:\$defs|definitions)\/(\w+)$/;function dt(n){if(typeof n!="string")return;let e=Vg.exec(n);return e?e[1]:void 0}function qr(n){if(!n||typeof n!="object")return!1;let e=n;if(typeof e.$ref=="string"&&dt(e.$ref)==="Action")return!0;for(let t of["allOf","oneOf","anyOf"]){let s=e[t];if(Array.isArray(s)&&s.some(r=>qr(r)))return!0}return!1}function pc(n){if(!n||typeof n!="object")return!1;let e=n;if("items"in e){let t=e.items,s=r=>{if(!r||typeof r!="object")return!1;let i=r;if(i.properties&&typeof i.properties=="object"&&"label"in i.properties&&"value"in i.properties)return!0;for(let o of["allOf","oneOf","anyOf"]){let a=i[o];if(Array.isArray(a)&&a.some(s))return!0}return!1};return s(t)}for(let t of["allOf","oneOf","anyOf"]){let s=e[t];if(Array.isArray(s)&&s.some(r=>pc(r)))return!0}return!1}function Xe(n){if(!n||typeof n!="object")return;let e=n.$ref;return typeof e=="string"&&e.startsWith("#/")?e:void 0}function Ug(n){switch(pe(n)){case"v0.9":case"v0.9.1":return Xn;case"1.0":return ks;default:throw new R(`No common types for protocol version '${n}'.`)}}function Bg(n){switch(pe(n)){case"v0.9":case"v0.9.1":return{path:"path",call:"call"};default:return{path:"@path",call:"@call"}}}var Hs=class{constructor(e,t){this.componentProperties=new Map,this.componentRequired=new Map,this.checkRuleProperties=new Map,this.inheritedCheckRulePropertyNames=new Map,this.inheritedCheckRuleSchemas=new Map,this.componentPropertyEnums=new Map,this.functionProperties=new Map,this.functionRequired=new Map,this.catalog=e.toJson();try{this.commonTypes={$defs:Ug(t)},this.commonTypesLoaded=!0}catch{this.commonTypes={$defs:{}},this.commonTypesLoaded=!1}this.keys=Bg(t);let s=this.catalog.components??{},r=new Map;for(let[a,c]of Object.entries(s))e.components.has(a)&&c&&typeof c=="object"&&r.set(a,c);this.components=r;let i=this.catalog.functions??{},o=new Map;for(let[a,c]of Object.entries(i))e.functions.has(a)&&c&&typeof c=="object"&&o.set(a,c);this.functions=o,this.loadMappings()}lookupCommonDef(e){let t=this.commonTypes.$defs??this.commonTypes.definitions;return t?t[e]:void 0}resolveJsonPointer(e,t){if(!t.startsWith("#/"))return;let s=t.slice(2).split("/"),r=e;for(let i of s){if(!r||typeof r!="object")return;let o=i.replace(/~1/g,"/").replace(/~0/g,"~");r=r[o]}return r}resolveLocalRef(e){let t=Xe(e);return t?this.resolveJsonPointer(this.catalog,t):void 0}orderedComponentSubSchemas(e){let t=[],s=[];if(Array.isArray(e.allOf))for(let a of e.allOf){if(Xe(a)){let u=this.resolveLocalRef(a);u&&typeof u=="object"&&(a=u)}if(!a||typeof a!="object")continue;let c=a,l=c.properties;l&&typeof l=="object"&&"component"in l?t.push(c):s.push(c)}let r=[e],i=new Set([e]),o=a=>{let c=a;if(Xe(c)){let l=this.resolveLocalRef(c);l&&typeof l=="object"&&(c=l)}if(!i.has(c)&&(i.add(c),r.push(c),Array.isArray(c.allOf)))for(let l of c.allOf)l&&typeof l=="object"&&o(l)};for(let a of[...t,...s])o(a);return r}getCheckRuleDefName(e){if(typeof e!="string")return;let t=dt(e);if(t)return t;if(e.startsWith("#/$defs/"))return e.slice(8);if(e.startsWith("#/definitions/"))return e.slice(14)}isCheckRuleArraySchema(e){if(!e||typeof e!="object")return!1;let t=e;if(t.type!=="array")return!1;let s=t.items;if(!s||typeof s!="object")return!1;let r=s.$ref;return dt(r)==="CheckRule"}loadMappings(){let e=t=>{if(t&&typeof t=="object"){let s=t,r=new Set,i=Xe(s);for(;i&&!r.has(i);){r.add(i);let o=this.resolveJsonPointer(this.catalog,i);if(o&&typeof o=="object")s=o,i=Xe(s);else break}if(Array.isArray(s.enum))return s.enum;for(let o of["oneOf","anyOf","allOf"]){let a=s[o];if(Array.isArray(a))for(let c of a){let l=e(c);if(l)return l}}}};for(let[t,s]of this.components.entries()){let r={},i=[],o=this.orderedComponentSubSchemas(s),a;for(let d of o)if(!d.$ref){if(d.properties&&typeof d.properties=="object"){for(let[h,p]of Object.entries(d.properties))if(this.isCheckRuleArraySchema(p)){a=h;break}}if(a)break}let c,l;if(!a)for(let d of o){if(typeof d.$ref!="string")continue;let h=dt(d.$ref);if(h){let p=this.lookupCommonDef(h);if(p&&typeof p=="object"){let m=p;if(m.properties&&typeof m.properties=="object"){for(let[g,E]of Object.entries(m.properties))if(E&&typeof E=="object"){let A=E;if(A.type==="array"&&A.items&&typeof A.items=="object"){let I=A.items.$ref;if(this.getCheckRuleDefName(I)==="CheckRule"){c=g,l=A;break}}}}}}if(c)break}a?this.checkRuleProperties.set(t,a):c&&(this.checkRuleProperties.set(t,c),this.inheritedCheckRulePropertyNames.set(t,c),l&&this.inheritedCheckRuleSchemas.set(t,l));for(let d of o){if(d.properties&&typeof d.properties=="object")for(let[h,p]of Object.entries(d.properties)){if(Object.hasOwn(r,h))continue;r[h]=p;let m=e(p);m&&this.componentPropertyEnums.set(`${t}.${h}`,m)}if(Array.isArray(d.required))for(let h of d.required)i.includes(h)||i.push(h)}let u=[];for(let d of Object.keys(r))d!=="component"&&d!=="id"&&u.push(d);c&&!u.includes(c)&&u.push(c),this.componentProperties.set(t,u),this.componentRequired.set(t,i)}for(let[t,s]of this.functions.entries()){let r=[s],i=[];if(Array.isArray(s.allOf))for(let c of s.allOf)Xe(c)?i.push(c):r.push(c);r.push(...i);let o={},a=[];for(let c of r){if(!c||typeof c!="object")continue;if(Xe(c)){let u=this.resolveLocalRef(c);u&&typeof u=="object"&&(c=u)}let l=c;if(l.properties&&typeof l.properties=="object"){let u=l.properties.args;if(u&&typeof u=="object"){let d=u.properties;d&&typeof d=="object"&&Object.assign(o,d);let h=u.required;Array.isArray(h)&&a.push(...h)}}}this.functionProperties.set(t,Object.keys(o)),this.functionRequired.set(t,a)}}getComponentProperties(e){return this.componentProperties.get(e)??[]}getComponentRequired(e){return this.componentRequired.get(e)??[]}isCheckable(e){return this.getCheckRuleProperty(e)!==void 0}getCheckRuleProperty(e){return this.checkRuleProperties.get(e)}getFunctionProperties(e){return this.functionProperties.get(e)??[]}getFunctionRequired(e){return this.functionRequired.get(e)??[]}getFunctionPropertySchema(e,t){let s=this.functions.get(e);if(!s)return;let r=[s],i=[];if(Array.isArray(s.allOf))for(let o of s.allOf)Xe(o)?i.push(o):r.push(o);r.push(...i);for(let o of r)if(o&&typeof o=="object"){if(Xe(o)){let c=this.resolveLocalRef(o);c&&typeof c=="object"&&(o=c)}let a=o;if(a.properties&&typeof a.properties=="object"){let c=a.properties.args;if(c&&typeof c=="object"){let l=c.properties;if(l&&typeof l=="object"&&t in l)return l[t]}}}}getPropertyEnum(e,t){return this.componentPropertyEnums.get(`${e}.${t}`)}getComponentDescription(e){let t=this.components.get(e);if(t){if(typeof t.description=="string")return t.description;if(Array.isArray(t.allOf))for(let s of t.allOf){if(Xe(s)){let r=this.resolveLocalRef(s);r&&typeof r=="object"&&(s=r)}if(s&&typeof s=="object"&&typeof s.description=="string")return s.description}}}getFunctionDescription(e){let t=this.functions.get(e);if(t)return typeof t.description=="string"?t.description:void 0}getPropertySchema(e,t){let s=this.components.get(e);if(s){for(let r of this.orderedComponentSubSchemas(s))if(r.properties&&typeof r.properties=="object"){let i=r.properties;if(t in i){let o=i[t];if(!o||typeof o!="object")return;let a=o,c=new Set,l=Xe(a),u=a;for(;l&&!c.has(l);){c.add(l);let d=this.resolveJsonPointer(this.catalog,l);if(d&&typeof d=="object")u={...d,...u},l=Xe(d);else break}return u}}}}getCheckRulePropertySchema(e){let t=this.getCheckRuleProperty(e);if(!t)return;let s=this.getPropertySchema(e,t);return s||this.inheritedCheckRuleSchemas.get(e)}admitsPath(e){let t=new Set,s=(r,i)=>{if(!r||typeof r!="object"||t.has(r))return!1;t.add(r);let o=r;if(o.properties&&typeof o.properties=="object"){let a=o.properties;if("path"in a||"@path"in a)return!0}if(typeof o.$ref=="string"){let a=o.$ref,c=dt(a);if(c){let l=this.lookupCommonDef(c);if(l&&s(l,!0))return!0}else if(i&&(a.startsWith("#/$defs/")||a.startsWith("#/definitions/"))){let l=a.startsWith("#/$defs/")?a.slice(8):a.slice(14),u=this.lookupCommonDef(l);if(u&&s(u,!0))return!0}else if(a.startsWith("#/")){let l=this.resolveJsonPointer(this.catalog,a);if(l&&s(l,!1))return!0}}for(let a of["allOf","oneOf","anyOf"]){let c=o[a];if(Array.isArray(c)){for(let l of c)if(s(l,i))return!0}}return!1};return s(e,!1)}acceptsNumber(e){let t=new Set,s=(r,i)=>{if(!r||typeof r!="object"||t.has(r))return!1;t.add(r);let o=r,a=o.type;if(a==="number"||a==="integer"||Array.isArray(a)&&(a.includes("number")||a.includes("integer"))||typeof o.const=="number"||Array.isArray(o.enum)&&o.enum.some(l=>typeof l=="number"))return!0;if(typeof o.$ref=="string"){let l=o.$ref,u=dt(l);if(u){let d=this.lookupCommonDef(u);if(!d||s(d,!0))return!0}else if(i&&(l.startsWith("#/$defs/")||l.startsWith("#/definitions/"))){let d=l.startsWith("#/$defs/")?l.slice(8):l.slice(14),h=this.lookupCommonDef(d);if(!h||s(h,!0))return!0}else if(l.startsWith("#/")){let d=this.resolveJsonPointer(this.catalog,l);if(!d||s(d,!1))return!0}else if(l.startsWith("catalog.json#/")){let d=this.resolveJsonPointer(this.catalog,l.slice(12));if(!d||s(d,!1))return!0}else return!0}for(let l of["allOf","oneOf","anyOf"]){let u=o[l];if(Array.isArray(u)){for(let d of u)if(s(d,i))return!0}}return!["type","const","enum","$ref","allOf","oneOf","anyOf","properties","items","prefixItems","not"].some(l=>l in o)};return s(e,!1)}resolveItemSchema(e){return this.resolveAt(e,void 0)}resolvePropertySchema(e,t){return this.resolveAt(e,t)}resolveAt(e,t){let s=new Set,r=(i,o)=>{if(!i||typeof i!="object"||s.has(i))return;s.add(i);let a=i;if(t===void 0){if(a.items&&typeof a.items=="object")return a.items}else{if(a.properties&&typeof a.properties=="object"){let c=a.properties,l=Object.hasOwn(c,t)?c[t]:void 0;if(l&&typeof l=="object")return l}if(a.additionalProperties&&typeof a.additionalProperties=="object")return a.additionalProperties}if(typeof a.$ref=="string"){let c=a.$ref,l=dt(c);if(l){let u=this.lookupCommonDef(l),d=r(u,!0);if(d)return d}else if(o&&(c.startsWith("#/$defs/")||c.startsWith("#/definitions/"))){let u=c.startsWith("#/$defs/")?c.slice(8):c.slice(14),d=this.lookupCommonDef(u),h=r(d,!0);if(h)return h}else if(c.startsWith("#/")){let u=this.resolveJsonPointer(this.catalog,c),d=r(u,!1);if(d)return d}}for(let c of["allOf","oneOf","anyOf"]){let l=a[c];if(Array.isArray(l))for(let u of l){let d=r(u,o);if(d)return d}}};return r(e,!1)}};function bn(n){let e=Array.isArray(n)?n:[n];if(e.length===0)throw new R("Express requires at least one catalog.");return e}function xo(n){return n.split(".").slice(0,2).join(".")}function mc(n){if(n.length===0)throw new R("Express requires at least one catalog.");let e=pe(n[0].protocolVersion),t=xo(e),s=new Set;for(let r of n){if(s.has(r.id))throw new R(`Duplicate catalog ID: '${r.id}'`);s.add(r.id);let i=pe(r.protocolVersion);if(xo(i)!==t)throw new R(`Express catalogs must share one protocol version, but '${n[0].id}' is '${e}' and '${r.id}' is '${i}'.`)}if(n.length>1&&Wt(t,"1.0.0")<0)throw new R(`Several catalogs need A2UI v1.0 or later, where components and function calls carry their own catalogId, but got '${t}'.`);return e}function Nt(n,e){let t=mc(n);if(!e)return t;let s=pe(e);if(xo(s)!==xo(t))throw new R(`Requested protocol version '${e}' does not match catalog version '${t}'`);return s}function jd(n){return n.length===1?n[0].id:void 0}function Qt(n,e,t){let s=[];for(let[r,i]of n.entries())(e==="component"?i.components:i.functions).has(t)&&s.push(r);return s}function Gs(n,e){return new Map(n.map(t=>[t.id,new Hs(t,e)]))}function Ks(n,e,t){let s=t.map(r=>`'${r.id}'`).join(", ");return new _(`${n} targets unknown catalog '${e}'. Active catalogs: ${s}.`)}function zr(n,e,t,s){let r=Qt(s,n,e);if(r.length===0)return n==="component"?new fo(e):new go(e);let i=n==="component"?"Component":"Function";return new _(`${i} '${e}' is not in catalog '${t}'. It is defined in: ${r.map(o=>`'${o}'`).join(", ")}.`)}var qg=Object.defineProperty,y=(n,e)=>qg(n,"name",{value:e,configurable:!0}),Co;(n=>{n.EOF=-1,n.UNKNOWN_SOURCE_NAME="<unknown>"})(Co||(Co={}));var x;(n=>{n.INVALID_TYPE=0,n.EPSILON=-2,n.MIN_USER_TOKEN_TYPE=1,n.EOF=Co.EOF,n.DEFAULT_CHANNEL=0,n.HIDDEN_CHANNEL=1,n.MIN_USER_CHANNEL_VALUE=2})(x||(x={}));var zg=y(n=>{let e=n;return e.tokenSource!==void 0&&e.channel!==void 0},"isToken"),Lt=class{static{y(this,"BitSet")}data;constructor(n){n?this.data=new Uint32Array(n.map(e=>e>>>0)):this.data=new Uint32Array(1)}[Symbol.iterator](){let n=this.data.length,e=0,t=this.data[e],s=this.data;return{[Symbol.iterator](){return this},next:y(()=>{for(;e<n;)if(t!==0){let r=t&-t,i=(e<<5)+this.bitCount(r-1);return t^=r,{done:!1,value:i}}else e++,e<n&&(t=s[e]);return{done:!0,value:void 0}},"next")}}clear(n){n===void 0?this.data=new Uint32Array:(this.resize(n),this.data[n>>>5]&=~(1<<n))}or(n){let e=Math.min(this.data.length,n.data.length);for(let t=0;t<e;++t)this.data[t]|=n.data[t];if(this.data.length<n.data.length){this.resize((n.data.length<<5)-1);let t=n.data.length;for(let s=e;s<t;++s)this.data[s]=n.data[s]}}get(n){if(n<0)throw new RangeError("index cannot be negative");let e=n>>>5;return e>=this.data.length?!1:(this.data[e]&1<<n%32)!==0}get length(){let n=0,e=this.data.length,t=this.data;for(let s=0;s<e;s++)n+=this.bitCount(t[s]);return n}values(){let n=new Array(this.length),e=0,t=this.data.length;for(let s=0;s<t;++s){let r=this.data[s];for(;r!==0;){let i=r&-r;n[e++]=(s<<5)+this.bitCount(i-1),r^=i}}return n}nextSetBit(n){if(n<0)throw new RangeError("index cannot be negative");for(let e of this)if(e>=n)return e}set(n){if(n<0)throw new RangeError("index cannot be negative");this.resize(n),this.data[n>>>5]|=1<<n%32}toString(){return"{"+this.values().join(", ")+"}"}resize(n){let e=n+32>>>5;if(e<=this.data.length)return;let t=new Uint32Array(e);t.set(this.data),t.fill(0,this.data.length),this.data=t}bitCount(n){return n=n-(n>>1&1431655765),n=(n&858993459)+(n>>2&858993459),n=n+(n>>4)&252645135,n=n+(n>>8),n=n+(n>>16),n&63}},Wg=3432918353,Zg=461845907,Vd=15,Ud=13,Hg=5,Gg=3864292196,C=class Zr{static{y(this,"MurmurHash")}static defaultSeed=701;constructor(){}static initialize(e=Zr.defaultSeed){return e}static updateFromComparable(e,t){return this.update(e,t?.hashCode()??0)}static update(e,t){return t=Math.imul(t,Wg),t=t<<Vd|t>>>32-Vd,t=Math.imul(t,Zg),e=e^t,e=e<<Ud|e>>>32-Ud,e=Math.imul(e,Hg)+Gg,e}static finish(e,t){return e^=t*4,e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^=e>>>16,e}static hashCode(e,t){return Zr.finish(Zr.update(t??Zr.defaultSeed,e),1)}},cs=class ef{static{y(this,"ObjectEqualityComparator")}static instance=new ef;hashCode(e){return e==null?0:e.hashCode()}equals(e,t){return e==null?t==null:e.equals(t)}},tf=class nf{static{y(this,"DefaultEqualityComparator")}static instance=new nf;hashCode(e){return e==null?0:cs.instance.hashCode(e)}equals(e,t){return e==null?t==null:typeof e=="string"||typeof e=="number"?e===t:cs.instance.equals(e,t)}},tt=class ht{static{y(this,"HashSet")}static defaultLoadFactor=.75;static initialCapacity=16;comparator;buckets;threshold;itemCount=0;constructor(e,t=ht.initialCapacity){if(e instanceof ht){this.comparator=e.comparator,this.buckets=e.buckets.slice(0);for(let s=0;s<this.buckets.length;s++){let r=this.buckets[s];r&&(this.buckets[s]=r.slice(0))}this.itemCount=e.itemCount,this.threshold=e.threshold}else this.comparator=e??tf.instance,this.buckets=this.createBuckets(t),this.threshold=Math.floor(ht.initialCapacity*ht.defaultLoadFactor)}getOrAdd(e){this.itemCount>this.threshold&&this.expand();let t=this.getBucket(e),s=this.buckets[t];if(!s)return s=[e],this.buckets[t]=s,++this.itemCount,e;for(let r of s)if(this.comparator.equals(r,e))return r;return s.push(e),++this.itemCount,e}get(e){if(e==null)return e;let t=this.getBucket(e),s=this.buckets[t];if(s){for(let r of s)if(this.comparator.equals(r,e))return r}}remove(e){if(e==null)return!1;let t=this.getBucket(e),s=this.buckets[t];if(!s)return!1;for(let r=0;r<s.length;r++){let i=s[r];if(this.comparator.equals(i,e))return s.splice(r,1),--this.itemCount,!0}return!1}hashCode(){let e=C.initialize();for(let t of this.buckets)if(t!=null)for(let s of t){if(s==null)break;e=C.update(e,this.comparator.hashCode(s))}return e=C.finish(e,this.size),e}equals(e){return e===this?!0:!(e instanceof ht)||e.size!==this.size?!1:this.containsAll(e)}add(e){return this.getOrAdd(e)===e}contains(e){return this.containsFast(e)}containsFast(e){return e==null?!1:this.get(e)!==void 0}*[Symbol.iterator](){yield*this.toArray()}toArray(){let e=new Array(this.size),t=0;for(let s of this.buckets)if(s!=null)for(let r of s){if(r==null)break;e[t++]=r}return e}containsAll(e){if(e instanceof ht){for(let t of e.buckets)if(t!=null)for(let s of t){if(s==null)break;if(!this.containsFast(s))return!1}}else for(let t of e)if(!this.containsFast(t))return!1;return!0}addAll(e){let t=!1;for(let s of e)this.getOrAdd(s)!==s&&(t=!0);return t}clear(){this.buckets=this.createBuckets(ht.initialCapacity),this.itemCount=0,this.threshold=Math.floor(ht.initialCapacity*ht.defaultLoadFactor)}toString(){if(this.size===0)return"{}";let e="{",t=!0;for(let s of this.buckets)if(s!=null)for(let r of s){if(r==null)break;t?t=!1:e+=", ",e+=r.toString()}return e+="}",e}toTableString(){let e="";for(let t of this.buckets){if(t==null){e+=`null
23
+ `;continue}e+="[";let s=!0;for(let r of t)s?s=!1:e+=" ",r==null?e+="_":e+=r.toString();e+=`]
24
+ `}return e}getBucket(e){return this.comparator.hashCode(e)&this.buckets.length-1}expand(){let e=this.buckets,t=this.buckets.length*2,s=this.createBuckets(t);this.buckets=s,this.threshold=Math.floor(t*ht.defaultLoadFactor);for(let r of e)if(r)for(let i of r){let o=this.getBucket(i),a=this.buckets[o];a||(a=[],this.buckets[o]=a),a.push(i)}}get size(){return this.itemCount}get isEmpty(){return this.itemCount===0}createBuckets(e){return new Array(e)}},Y=class Qe{static{y(this,"Interval")}static INVALID_INTERVAL=new Qe(-1,-2);static INTERVAL_POOL_MAX_VALUE=1e3;static cache=[];start;stop;cachedHashCode;constructor(e,t){this.start=e,this.stop=t,this.cachedHashCode=Math.imul(651+e,31)+t}static of(e,t){return e!==t||e<0||e>Qe.INTERVAL_POOL_MAX_VALUE?new Qe(e,t):(Qe.cache[e]||(Qe.cache[e]=new Qe(e,e)),Qe.cache[e])}equals(e){return this.start===e.start&&this.stop===e.stop}hashCode(){return this.cachedHashCode}startsBeforeDisjoint(e){return this.start<e.start&&this.stop<e.start}startsBeforeNonDisjoint(e){return this.start<=e.start&&this.stop>=e.start}startsAfter(e){return this.start>e.start}startsAfterDisjoint(e){return this.start>e.stop}startsAfterNonDisjoint(e){return this.start>e.start&&this.start<=e.stop}disjoint(e){return this.startsBeforeDisjoint(e)||this.startsAfterDisjoint(e)}adjacent(e){return this.start===e.stop+1||this.stop===e.start-1}properlyContains(e){return e.start>=this.start&&e.stop<=this.stop}union(e){return Qe.of(Math.min(this.start,e.start),Math.max(this.stop,e.stop))}intersection(e){return Qe.of(Math.max(this.start,e.start),Math.min(this.stop,e.stop))}differenceNotProperlyContained(e){let t=null;return e.startsBeforeNonDisjoint(this)?t=Qe.of(Math.max(this.start,e.stop+1),this.stop):e.startsAfterNonDisjoint(this)&&(t=Qe.of(this.start,e.start-1)),t}toString(){return`${this.start}..${this.stop}`}get length(){return this.stop<this.start?0:this.stop-this.start+1}},yt=class Pt{static{y(this,"Vocabulary")}static EMPTY_NAMES=[];static EMPTY_VOCABULARY=new Pt(Pt.EMPTY_NAMES,Pt.EMPTY_NAMES,Pt.EMPTY_NAMES);maxTokenType;literalNames;symbolicNames;displayNames;constructor(e,t,s){this.literalNames=e??Pt.EMPTY_NAMES,this.symbolicNames=t??Pt.EMPTY_NAMES,this.displayNames=s??Pt.EMPTY_NAMES,this.maxTokenType=Math.max(this.displayNames.length,Math.max(this.literalNames.length,this.symbolicNames.length))-1}static fromTokenNames(e){if(e==null||e.length===0)return Pt.EMPTY_VOCABULARY;let t=[...e],s=[...e];for(let r=0;r<e.length;r++){let i=e[r];if(i!=null){if(i.length>0){let o=i.codePointAt(0);if(o===39){s[r]=null;continue}else if(o>=65&&o<=90){t[r]=null;continue}}t[r]=null,s[r]=null}}return new Pt(t,s,e)}getMaxTokenType(){return this.maxTokenType}getLiteralName(e){return e>=0&&e<this.literalNames.length?this.literalNames[e]:null}getSymbolicName(e){return e>=0&&e<this.symbolicNames.length?this.symbolicNames[e]:e===x.EOF?"EOF":null}getDisplayName(e){if(e>=0&&e<this.displayNames.length){let r=this.displayNames[e];if(r!=null)return r}let t=this.getLiteralName(e);if(t!=null)return t;let s=this.getSymbolicName(e);return s??`${e}`}getLiteralNames(){return this.literalNames}getSymbolicNames(){return this.symbolicNames}getDisplayNames(){return this.displayNames}},mt=class Ve{static{y(this,"IntervalSet")}intervals=[];cachedHashCode;constructor(e){if(e)if(Array.isArray(e))for(let t of e)this.addOne(t);else this.addSet(e)}static of(e,t){let s=new Ve;return s.addRange(e,t),s}static or(e){let t=new Ve;for(let s of e)t.addSet(s);return t}[Symbol.iterator](){return this.intervals[Symbol.iterator]()}get(e){return this.intervals[e]}get minElement(){return this.intervals.length===0?x.INVALID_TYPE:this.intervals[0].start}get maxElement(){return this.intervals.length===0?x.INVALID_TYPE:this.intervals[this.intervals.length-1].stop}clear(){this.cachedHashCode=void 0,this.intervals=[]}addOne(e){this.addInterval(new Y(e,e))}addRange(e,t){this.addInterval(new Y(e,t))}addInterval(e){if(this.cachedHashCode=void 0,this.intervals.length===0)this.intervals.push(e);else{for(let t=0;t<this.intervals.length;t++){let s=this.intervals[t];if(e.equals(s))return;if(e.adjacent(s)||!e.disjoint(s)){let r=e.union(s);this.intervals[t]=r;for(let i=t+1;i<this.intervals.length;){let o=this.intervals[i];if(!r.adjacent(o)&&r.disjoint(o))break;this.intervals.splice(i,1),this.intervals[t]=r.union(o)}return}if(e.startsBeforeDisjoint(s)){this.intervals.splice(t,0,e);return}}this.intervals.push(e)}}addSet(e){return e.intervals.forEach(t=>this.addInterval(t),this),this}complementWithVocabulary(e){let t=new Ve;return!e||e.length===0?t:(t.addSet(e),t.subtract(this))}complement(e,t){let s=new Ve;return s.addInterval(new Y(e,t)),s.subtract(this)}or(e){let t=new Ve;return t.addSet(this),e.forEach(s=>t.addSet(s)),t}and(e){if(e.length===0)return new Ve;let t=this.intervals,s=e.intervals,r,i=t.length,o=s.length,a=0,c=0;for(;a<i&&c<o;){let l=t[a],u=s[c];l.startsBeforeDisjoint(u)?a++:u.startsBeforeDisjoint(l)?c++:l.properlyContains(u)?(r||(r=new Ve),r.addInterval(l.intersection(u)),c++):u.properlyContains(l)?(r||(r=new Ve),r.addInterval(l.intersection(u)),a++):l.disjoint(u)||(r||(r=new Ve),r.addInterval(l.intersection(u)),l.startsAfterNonDisjoint(u)?c++:u.startsAfterNonDisjoint(l)&&a++)}return r||new Ve}subtract(e){if(this.length===0)return new Ve;let t=new Ve(this);if(e.length===0)return t;let s=0,r=0;for(;s<t.intervals.length&&r<e.intervals.length;){let i=t.intervals[s],o=e.intervals[r];if(o.stop<i.start){r++;continue}if(o.start>i.stop){s++;continue}let a,c;o.start>i.start&&(a=new Y(i.start,o.start-1)),o.stop<i.stop&&(c=new Y(o.stop+1,i.stop)),a?c?(t.intervals[s]=a,t.intervals.splice(s+1,0,c),s++,r++):(t.intervals[s]=a,s++):c?(t.intervals[s]=c,r++):t.intervals.splice(s,1)}return t}contains(e){let t=this.intervals.length,s=0,r=t-1;for(;s<=r;){let i=Math.floor((s+r)/2),o=this.intervals[i];if(o.stop<e)s=i+1;else if(o.start>e)r=i-1;else return!0}return!1}removeRange(e){if(this.cachedHashCode=void 0,e.start===e.stop)this.removeOne(e.start);else if(this.intervals!==null){let t=0;for(let s of this.intervals){if(e.stop<=s.start)return;if(e.start>s.start&&e.stop<s.stop){this.intervals[t]=new Y(s.start,e.start);let r=new Y(e.stop,s.stop);this.intervals.splice(t,0,r);return}else e.start<=s.start&&e.stop>=s.stop?(this.intervals.splice(t,1),t=t-1):e.start<s.stop?this.intervals[t]=new Y(s.start,e.start):e.stop<s.stop&&(this.intervals[t]=new Y(e.stop,s.stop));t+=1}}}removeOne(e){this.cachedHashCode=void 0;for(let t=0;t<this.intervals.length;t++){let s=this.intervals[t];if(e<s.start)return;if(e===s.start&&e===s.stop){this.intervals.splice(t,1);return}else if(e===s.start){this.intervals[t]=new Y(s.start+1,s.stop);return}else if(e===s.stop){this.intervals[t]=new Y(s.start,s.stop-1);return}else if(e<s.stop){let r=new Y(s.start,e-1);this.intervals[t]=new Y(e+1,s.stop),this.intervals.splice(t,0,r);return}}}hashCode(){if(this.cachedHashCode===void 0){let e=C.initialize();for(let t of this.intervals)e=C.update(e,t.start),e=C.update(e,t.stop);this.cachedHashCode=C.finish(e,this.intervals.length*2)}return this.cachedHashCode}equals(e){if(this===e)return!0;if(this.intervals.length!==e.intervals.length)return!1;for(let t=0;t<this.intervals.length;t++)if(!this.intervals[t].equals(e.intervals[t]))return!1;return!0}toString(e){if(this.intervals.length===0)return"{}";let t="";this.length>1&&(t+="{");for(let s=0;s<this.intervals.length;++s){let r=this.intervals[s],i=r.start,o=r.stop;i===o?i===x.EOF?t+="<EOF>":e?t+="'"+String.fromCodePoint(i)+"'":t+=i:e?t+="'"+String.fromCodePoint(i)+"'..'"+String.fromCodePoint(o)+"'":t+=i+".."+o,s<this.intervals.length-1&&(t+=", ")}return this.length>1&&(t+="}"),t}toStringWithVocabulary(e){if(this.intervals.length===0)return"{}";let t="";this.length>1&&(t+="{");for(let s=0;s<this.intervals.length;++s){let r=this.intervals[s],i=r.start,o=r.stop;if(i===o)i===x.EOF?t+="<EOF>":t+=this.elementName(e,i);else for(let a=i;a<=o;++a)a>i&&(t+=", "),t+=this.elementName(e,a);s<this.intervals.length-1&&(t+=", ")}return this.length>1&&(t+="}"),t}toStringWithRuleNames(e){if(this.intervals.length===0)return"{}";let t="";this.length>1&&(t+="{");let s=yt.fromTokenNames(e);for(let r=0;r<this.intervals.length;++r){let i=this.intervals[r],o=i.start,a=i.stop;if(o===a)o===x.EOF?t+="<EOF>":t+=this.elementName(s,o);else for(let c=o;c<=a;++c)c>o&&(t+=", "),t+=this.elementName(s,c);r<this.intervals.length-1&&(t+=", ")}return this.length>1&&(t+="}"),t}toArray(){let e=[];for(let t of this.intervals)for(let s=t.start;s<=t.stop;s++)e.push(s);return e}get length(){let e=0;for(let t of this.intervals)e+=t.length;return e}elementName(e,t){return t===x.EOF?"<EOF>":t===x.EPSILON?"<EPSILON>":e.getDisplayName(t)}};var Kg=y(n=>n===null?"null":n,"valueToString"),er=y(n=>Array.isArray(n)?"["+n.map(Kg).join(", ")+"]":"null","arrayToString"),Io=y((n,e)=>{if(n===e)return!0;if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++){let s=n[t],r=e[t];if(s!==r&&(!s||!s.equals(r)))return!1}return!0},"equalArrays"),Yg=y((n,e)=>{if(n===e)return!0;if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0},"equalNumberArrays"),Jg=y((n,e=!1)=>(n=n.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r"),e&&(n=n.replace(/ /g,"\xB7")),n),"escapeWhitespace"),J=class rs{static{y(this,"SemanticContext")}cachedHashCode;static andContext(e,t){if(e===null||e===rs.NONE)return t;if(t===null||t===rs.NONE)return e;let s=new Xg(e,t);return s.operands.length===1?s.operands[0]:s}static orContext(e,t){if(e===null)return t;if(t===null)return e;if(e===rs.NONE||t===rs.NONE)return rs.NONE;let s=new Qg(e,t);return s.operands.length===1?s.operands[0]:s}static filterPrecedencePredicates(e){let t=[];for(let s of e)s instanceof rs.PrecedencePredicate&&t.push(s);return t}evalPrecedence(e,t){return this}},Xg=class Ao extends J{static{y(this,"AND")}operands;constructor(e,t){super();let s=new tt;e instanceof Ao?e.operands.forEach(i=>{s.add(i)}):s.add(e),t instanceof Ao?t.operands.forEach(i=>{s.add(i)}):s.add(t);let r=J.filterPrecedencePredicates(s);if(r.length>0){let i=null;r.forEach(o=>{(i===null||o.precedence<i.precedence)&&(i=o)}),i&&s.add(i)}this.operands=s.toArray()}equals(e){return this===e?!0:e instanceof Ao?Io(this.operands,e.operands):!1}hashCode(){if(this.cachedHashCode===void 0){let e=C.initialize();for(let t of this.operands)e=C.updateFromComparable(e,t);e=C.update(e,3813686060),this.cachedHashCode=C.finish(e,this.operands.length+1)}return this.cachedHashCode}evaluate(e,t){for(let s of this.operands)if(!s.evaluate(e,t))return!1;return!0}evalPrecedence(e,t){let s=!1,r=[];for(let o of this.operands){let a=o.evalPrecedence(e,t);if(s||=a!==o,a===null)return null;a!==J.NONE&&r.push(a)}if(!s)return this;if(r.length===0)return J.NONE;let i=null;return r.forEach(o=>{i=i===null?o:J.andContext(i,o)}),i}toString(){let e=this.operands.map(t=>t.toString());return(e.length>3?e.slice(3):e).join("&&")}},Qg=class vo extends J{static{y(this,"OR")}operands;constructor(e,t){super();let s=new tt;e instanceof vo?e.operands.forEach(i=>{s.add(i)}):s.add(e),t instanceof vo?t.operands.forEach(i=>{s.add(i)}):s.add(t);let r=J.filterPrecedencePredicates(s);if(r.length>0){let i=r.sort((a,c)=>a.compareTo(c)),o=i[i.length-1];s.add(o)}this.operands=s.toArray()}equals(e){return this===e?!0:e instanceof vo?Io(this.operands,e.operands):!1}hashCode(){if(this.cachedHashCode===void 0){let e=C.initialize();for(let t of this.operands)e=C.updateFromComparable(e,t);e=C.update(e,3383313031),this.cachedHashCode=C.finish(e,this.operands.length+1)}return this.cachedHashCode}evaluate(e,t){for(let s of this.operands)if(s.evaluate(e,t))return!0;return!1}evalPrecedence(e,t){let s=!1,r=[];for(let o of this.operands){let a=o.evalPrecedence(e,t);if(s||=a!==o,a===J.NONE)return J.NONE;a!==null&&r.push(a)}if(!s)return this;if(r.length===0)return null;let i=null;return r.forEach(o=>{i=i===null?o:J.orContext(i,o)}),i}toString(){let e=this.operands.map(t=>t.toString());return(e.length>3?e.slice(3):e).join("||")}};(n=>{class e extends n{static{y(this,"Predicate")}ruleIndex;predIndex;isCtxDependent;constructor(r,i,o){super(),this.ruleIndex=r??-1,this.predIndex=i??-1,this.isCtxDependent=o??!1}evaluate(r,i){let o=this.isCtxDependent?i:null;return r.sempred(o,this.ruleIndex,this.predIndex)}hashCode(){if(this.cachedHashCode===void 0){let r=C.initialize();r=C.update(r,this.ruleIndex),r=C.update(r,this.predIndex),r=C.update(r,this.isCtxDependent?1:0),r=C.finish(r,3),this.cachedHashCode=r}return this.cachedHashCode}equals(r){return this===r?!0:this.ruleIndex===r.ruleIndex&&this.predIndex===r.predIndex&&this.isCtxDependent===r.isCtxDependent}toString(){return"{"+this.ruleIndex+":"+this.predIndex+"}?"}}n.Predicate=e;class t extends n{static{y(this,"PrecedencePredicate")}precedence;constructor(r){super(),this.precedence=r??0}evaluate(r,i){return r.precpred(i,this.precedence)}evalPrecedence(r,i){return r.precpred(i??null,this.precedence)?n.NONE:null}compareTo(r){return this.precedence-r.precedence}hashCode(){return 31+this.precedence}equals(r){return this===r?!0:this.precedence===r.precedence}toString(){return"{"+this.precedence+">=prec}?"}}n.PrecedencePredicate=t,n.NONE=new e})(J||(J={}));var ge=class Hr{static{y(this,"ATNConfig")}state;alt;reachesIntoOuterContext=!1;precedenceFilterSuppressed=!1;get semanticContext(){return this.#t}cachedHashCode;#e=null;#t;constructor(e,t,s,r){this.state=t,this.alt=e.alt,this.context=s,this.#t=r??J.NONE,this.reachesIntoOuterContext=e.reachesIntoOuterContext,e.precedenceFilterSuppressed!==void 0&&(this.precedenceFilterSuppressed=e.precedenceFilterSuppressed)}static duplicate(e,t){return new Hr(e,e.state,e.context,t??e.semanticContext)}static createWithContext(e,t,s,r){return new Hr({alt:t},e,s,r)}static createWithConfig(e,t,s){return new Hr(t,e,s??t.context,t.semanticContext)}static createWithSemanticContext(e,t,s){return new Hr(t,e??t.state,t.context,s)}hashCode(){if(this.cachedHashCode===void 0){let e=C.initialize(7);e=C.update(e,this.state.stateNumber),e=C.update(e,this.alt),e=C.updateFromComparable(e,this.#e),e=C.updateFromComparable(e,this.semanticContext),e=C.finish(e,4),this.cachedHashCode=e}return this.cachedHashCode}get context(){return this.#e}set context(e){this.#e=e,this.cachedHashCode=void 0}equals(e){return this===e?!0:this.state.stateNumber===e.state.stateNumber&&this.alt===e.alt&&(this.context===null?e.context===null:this.context.equals(e.context))&&this.semanticContext.equals(e.semanticContext)&&this.precedenceFilterSuppressed===e.precedenceFilterSuppressed}toString(e,t=!0){let s="";return t&&(s=","+this.alt),"("+this.state+s+(this.context!==null?",["+this.context.toString()+"]":"")+(this.semanticContext!==J.NONE?","+this.semanticContext.toString():"")+(this.reachesIntoOuterContext?",up="+this.reachesIntoOuterContext:"")+")"}},L=class sf{static{y(this,"ATNState")}static INVALID_STATE_NUMBER=-1;static INVALID_TYPE=0;static BASIC=1;static RULE_START=2;static BLOCK_START=3;static PLUS_BLOCK_START=4;static STAR_BLOCK_START=5;static TOKEN_START=6;static RULE_STOP=7;static BLOCK_END=8;static STAR_LOOP_BACK=9;static STAR_LOOP_ENTRY=10;static PLUS_LOOP_BACK=11;static LOOP_END=12;static stateType=sf.INVALID_STATE_NUMBER;stateNumber=0;ruleIndex=0;epsilonOnlyTransitions=!1;nextTokenWithinRule;transitions=[];hashCode(){return this.stateNumber}equals(e){return this.stateNumber===e.stateNumber}toString(){return`${this.stateNumber}`}addTransitionAtIndex(e,t){this.transitions.length===0?this.epsilonOnlyTransitions=t.isEpsilon:this.epsilonOnlyTransitions!==t.isEpsilon&&(this.epsilonOnlyTransitions=!1),this.transitions.splice(e,0,t)}addTransition(e){this.transitions.length===0?this.epsilonOnlyTransitions=e.isEpsilon:this.epsilonOnlyTransitions!==e.isEpsilon&&(this.epsilonOnlyTransitions=!1),this.transitions.push(e)}setTransition(e,t){this.transitions.splice(e,1,t)}removeTransition(e){return this.transitions.splice(e,1)[0]}},ve=class rf{static{y(this,"PredictionContext")}static EMPTY_RETURN_STATE=2147483647;static traceATNSimulator=!1;cachedHashCode;constructor(e){this.cachedHashCode=e}static calculateEmptyHashCode(){let e=C.initialize(31);return e=C.finish(e,0),e}static calculateHashCodeSingle(e,t){let s=C.initialize(31);return s=C.updateFromComparable(s,e),s=C.update(s,t),s=C.finish(s,2),s}static calculateHashCodeList(e,t){let s=C.initialize(31);for(let r of e)s=C.updateFromComparable(s,r);for(let r of t)s=C.update(s,r);return s=C.finish(s,2*e.length),s}isEmpty(){return!1}hasEmptyPath(){return this.getReturnState(this.length-1)===rf.EMPTY_RETURN_STATE}hashCode(){return this.cachedHashCode}toString(e){return""}},tr=class of extends ve{static{y(this,"SingletonPredictionContext")}parent;returnState;constructor(e,t){super(e?ve.calculateHashCodeSingle(e,t):ve.calculateEmptyHashCode()),this.parent=e??null,this.returnState=t}getParent(e){return this.parent}getReturnState(e){return this.returnState}equals(e){return this===e?!0:!(e instanceof of)||this.hashCode()!==e.hashCode()||this.returnState!==e.returnState?!1:this.parent==null?e.parent==null:this.parent.equals(e.parent)}toString(){let e=this.parent===null?"":this.parent.toString();return e.length===0?this.returnState===ve.EMPTY_RETURN_STATE?"$":""+this.returnState:""+this.returnState+" "+e}get length(){return 1}},ye=class af extends tr{static{y(this,"EmptyPredictionContext")}static instance=new af;constructor(){super(void 0,ve.EMPTY_RETURN_STATE)}isEmpty(){return!0}getParent(){return null}getReturnState(){return this.returnState}equals(e){return this===e}toString(){return"$"}},N=class{static{y(this,"Transition")}static INVALID=0;static EPSILON=1;static RANGE=2;static RULE=3;static PREDICATE=4;static ATOM=5;static ACTION=6;static SET=7;static NOT_SET=8;static WILDCARD=9;static PRECEDENCE=10;target;constructor(n){this.target=n}get isEpsilon(){return!1}get label(){return null}toString(){return""}},kc=class extends N{static{y(this,"SetTransition")}set;constructor(n,e){super(n),e?this.set=e:this.set=mt.of(x.INVALID_TYPE,x.INVALID_TYPE)}get transitionType(){return N.SET}get label(){return this.set}matches(n,e,t){return this.set.contains(n)}toString(){return this.set.toString()}},Rc=class extends kc{static{y(this,"NotSetTransition")}get transitionType(){return N.NOT_SET}matches(n,e,t){return n>=e&&n<=t&&!super.matches(n,e,t)}toString(){return"~"+super.toString()}},e0=class{static{y(this,"MapKeyEqualityComparator")}keyComparator;constructor(n){this.keyComparator=n}hashCode(n){return this.keyComparator.hashCode(n.key)}equals(n,e){return this.keyComparator.equals(n.key,e.key)}},sn=class cf{static{y(this,"HashMap")}backingStore;constructor(e){e instanceof cf?this.backingStore=new tt(e.backingStore):(e=e??tf.instance,this.backingStore=new tt(new e0(e)))}clear(){this.backingStore.clear()}containsKey(e){return this.backingStore.contains({key:e})}get(e){let t=this.backingStore.get({key:e});if(t)return t.value}get isEmpty(){return this.backingStore.isEmpty}set(e,t){let s=this.backingStore.get({key:e,value:t}),r;return s?(r=s.value,s.value=t):this.backingStore.add({key:e,value:t}),r}setIfAbsent(e,t){let s=this.backingStore.get({key:e,value:t}),r;return s?r=s.value:this.backingStore.add({key:e,value:t}),r}keys(){return this.backingStore.toArray().map(e=>e.key)}values(){return this.backingStore.toArray().map(e=>e.value)}get size(){return this.backingStore.size}hashCode(){return this.backingStore.hashCode()}equals(e){return this.backingStore.equals(e.backingStore)}},gt=class{static{y(this,"TerminalNode")}parent=null;symbol;constructor(n){this.symbol=n}getChild(n){return null}getSymbol(){return this.symbol}getPayload(){return this.symbol}getSourceInterval(){if(this.symbol===null)return Y.INVALID_INTERVAL;let n=this.symbol.tokenIndex;return new Y(n,n)}getChildCount(){return 0}accept(n){return n.visitTerminal(this)}getText(){return this.symbol?.text??""}toString(){return this.symbol?.type===x.EOF?"<EOF>":this.symbol?.text??""}toStringTree(){return this.toString()}},Qr=class extends gt{static{y(this,"ErrorNode")}accept(n){return n.visitErrorNode(this)}},To=class Xs{static{y(this,"CommonToken")}static EMPTY_SOURCE=[null,null];source;tokenIndex;start;stop;type;line;column;channel;#e;constructor(e){this.type=e.type,this.source=e.source,this.tokenIndex=e.tokenIndex??-1,this.line=e.line??0,this.column=e.column??-1,this.channel=e.channel??x.DEFAULT_CHANNEL,this.start=e.start??0,this.stop=e.stop??0,this.#e=e.text,e.line===void 0&&e.source[0]!==null&&(this.line=e.source[0].line),e.column===void 0&&e.source[0]!==null&&(this.column=e.source[0].column)}static fromToken(e){let t=[e.tokenSource,e.inputStream];return new Xs({type:e.type,line:e.line,tokenIndex:e.tokenIndex,column:e.column,channel:e.channel,start:e.start,stop:e.stop,text:e.text,source:t})}static fromType(e,t){return new Xs({type:e,text:t,source:Xs.EMPTY_SOURCE})}static fromSource(e,t,s,r,i){return new Xs({type:t,channel:s,start:r,stop:i,source:e})}get tokenSource(){return this.source[0]}get inputStream(){return this.source[1]}set inputStream(e){this.source[1]=e}clone(){return new Xs({source:this.source,type:this.type,channel:this.channel,start:this.start,stop:this.stop,tokenIndex:this.tokenIndex,line:this.line,column:this.column,text:this.#e})}toString(e){let t="";this.channel>0&&(t=",channel="+this.channel);let s=this.text;s?(s=s.replace(/\n/g,"\\n"),s=s.replace(/\r/g,"\\r"),s=s.replace(/\t/g,"\\t")):s="<no text>";let r=String(this.type);return e&&(r=e.vocabulary.getDisplayName(this.type)??"<unknown>"),"[@"+this.tokenIndex+","+this.start+":"+this.stop+"='"+s+"',<"+r+">"+t+","+this.line+":"+this.column+"]"}get text(){if(this.#e!==void 0)return this.#e;let e=this.inputStream;if(!e)return;let t=e.size;return this.start<t&&this.stop<t?e.getTextFromRange(this.start,this.stop):"<EOF>"}set text(e){this.#e=e}setText(e){this.#e=e}setType(e){this.type=e}setLine(e){this.line=e}setCharPositionInLine(e){this.column=e}setChannel(e){this.channel=e}setTokenIndex(e){this.tokenIndex=e}},En=class en{static{y(this,"Trees")}static toStringTree(e,t,s){t=t??null,s&&(t=s.ruleNames);let r=en.getNodeText(e,t);r=Jg(r,!1);let i=e.getChildCount();if(i===0)return r;let o="("+r+" ";i>0&&(r=en.toStringTree(e.getChild(0),t),o=o.concat(r));for(let a=1;a<i;a++)r=en.toStringTree(e.getChild(a),t),o=o.concat(" "+r);return o=o.concat(")"),o}static getNodeText(e,t,s){if(t=t??null,s&&(t=s.ruleNames),t!==null)if(e instanceof K){let o=e.ruleContext.getAltNumber();return o!==0?t[e.ruleIndex]+":"+o:t[e.ruleIndex]}else{if(e instanceof Qr)return e.toString();if(e instanceof gt)return e.symbol.text}let r=e.getPayload();return zg(r)?r.text:String(e.getPayload())}static getChildren(e){let t=[];for(let s=0;s<e.getChildCount();s++)t.push(e.getChild(s));return t}static getAncestors(e){if(e.parent===null)return[];let t=[],s=e.parent;for(;s!==null;)t=[s].concat(t),s=s.parent;return t}static isAncestorOf(e,t){if(e===null||t===null||e.parent===null)return!1;let s=t.parent;for(;s!==null;){if(e===s)return!0;s=s.parent}return!1}static findAllTokenNodes(e,t){return en.findAllNodes(e,t,!0)}static findAllRuleNodes(e,t){return en.findAllNodes(e,t,!1)}static findAllNodes(e,t,s){let r=[];return en.doFindAllNodes(e,t,s,r),r}static descendants(e){let t=[e];for(let s=0;s<e.getChildCount();s++)t=t.concat(en.descendants(e.getChild(s)));return t}static getRootOfSubtreeEnclosingRegion(e,t,s){let r=e.getChildCount();for(let i=0;i<r;i++){let o=e.getChild(i),a=this.getRootOfSubtreeEnclosingRegion(o,t,s);if(a!==null)return a}return e instanceof K&&t>=e.start.tokenIndex&&(e.stop===null||s<=e.stop.tokenIndex)?e:null}static stripChildrenOutOfRange(e,t,s,r){if(e!==null)for(let i=0;i<e.getChildCount();i++){let o=e.getChild(i),a=o.getSourceInterval();if(e instanceof K&&(a.stop<s||a.start>r)&&this.isAncestorOf(o,t)){let c=To.fromType(x.INVALID_TYPE,"...");e.children[i]=new gt(c)}}}static doFindAllNodes(e,t,s,r){s&&e instanceof gt?e.symbol?.type===t&&r.push(e):!s&&e instanceof K&&e.ruleIndex===t&&r.push(e);for(let i=0;i<e.getChildCount();i++)en.doFindAllNodes(e.getChild(i),t,s,r)}},K=class lf{static{y(this,"ParserRuleContext")}static empty=new lf(null);start=null;stop=null;children=[];invokingState;parent;constructor(e,t=-1){this.parent=e,this.invokingState=t}copyFrom(e){this.parent=e.parent,this.invokingState=e.invokingState,this.children.slice(0,this.children.length),this.start=e.start,this.stop=e.stop,e.children&&e.children.forEach(t=>{t instanceof Qr&&(this.children.push(t),t.parent=this)})}enterRule(e){}exitRule(e){}addChild(e){return this.children.push(e),e}removeLastChild(){this.children.pop()}addTokenNode(e){let t=new gt(e);return this.children.push(t),t.parent=this,t}addErrorNode(e){return e.parent=this,this.children.push(e),e}getChild(e,t){if(e<0||e>=this.children.length)return null;if(!t)return this.children[e];for(let s of this.children)if(s instanceof t){if(e===0)return s;e-=1}return null}getToken(e,t){if(t<0||t>=this.children.length)return null;for(let s of this.children)if("symbol"in s&&s.symbol?.type===e){if(t===0)return s;t-=1}return null}getTokens(e){let t=[];for(let s of this.children)"symbol"in s&&s.symbol?.type===e&&t.push(s);return t}getRuleContext(e,t){return this.getChild(e,t)}getRuleContexts(e){let t=[];for(let s of this.children)s instanceof e&&t.push(s);return t}getChildCount(){return this.children.length}getSourceInterval(){return this.start===null?Y.INVALID_INTERVAL:this.stop===null||this.stop.tokenIndex<this.start.tokenIndex?new Y(this.start.tokenIndex,this.start.tokenIndex-1):new Y(this.start.tokenIndex,this.stop.tokenIndex)}depth(){let e=0,t=this;for(;t!==null;)t=t.parent,e+=1;return e}isEmpty(){return this.invokingState===-1}get ruleContext(){return this}get ruleIndex(){return-1}getPayload(){return this}getText(){return this.children.length===0?"":this.children.map(e=>e.getText()).join("")}getAltNumber(){return Z.INVALID_ALT_NUMBER}setAltNumber(e){}accept(e){return e.visitChildren(this)}toStringTree(...e){return e.length<2?En.toStringTree(this,null,e[0]):En.toStringTree(this,e[0],e[1])}toString(e,t){e=e??null,t=t??null;let s=this,r="[";for(;s!==null&&s!==t;){if(e===null)s.isEmpty()||(r+=s.invokingState);else{let i=s.ruleIndex,o=i>=0&&i<e.length?e[i]:""+i;r+=o}s.parent!==null&&(e!==null||!s.parent.isEmpty())&&(r+=" "),s=s.parent}return r+="]",r}},Cn=class uf extends ve{static{y(this,"ArrayPredictionContext")}parents=[];returnStates=[];constructor(e,t){return super(ve.calculateHashCodeList(e,t)),this.parents=e,this.returnStates=t,this}isEmpty(){return this.returnStates[0]===ve.EMPTY_RETURN_STATE}get length(){return this.returnStates.length}getParent(e){return this.parents[e]}getReturnState(e){return this.returnStates[e]}equals(e){return this===e?!0:!(e instanceof uf)||this.hashCode()!==e.hashCode()?!1:Yg(this.returnStates,e.returnStates)&&Io(this.parents,e.parents)}toString(){if(this.isEmpty())return"[]";let e=[];for(let t=0;t<this.returnStates.length;t++){if(this.returnStates[t]===ve.EMPTY_RETURN_STATE){e.push("$");continue}e.push(this.returnStates[t].toString()),this.parents[t]?e.push(this.parents[t].toString()):e.push("null")}return`[${e.join(", ")}]`}},ls=y((n,e)=>e===ve.EMPTY_RETURN_STATE&&n===null?ye.instance:new tr(n,e),"createSingletonPredictionContext"),_c=y((n,e)=>{if(e||(e=K.empty),!e.parent||e===K.empty)return ye.instance;let t=_c(n,e.parent),r=n.states[e.invokingState].transitions[0];return ls(t,r.followState.stateNumber)},"predictionContextFromRuleContext"),df=y((n,e,t)=>{if(n.isEmpty())return n;let s=t.get(n);if(s)return s;if(s=e.get(n),s)return t.set(n,s),s;let r=!1,i=[];for(let a=0;a<i.length;a++){let c=df(n.getParent(a),e,t);if(r||c!==n.getParent(a)){if(!r){i=[];for(let l=0;l<n.length;l++)i[l]=n.getParent(l);r=!0}i[a]=c}}if(!r)return e.add(n),t.set(n,n),n;let o;return i.length===0?o=ye.instance:i.length===1?o=ls(i[0]??void 0,n.getReturnState(0)):o=new Cn(i,n.returnStates),e.add(o),t.set(o,o),t.set(n,o),o},"getCachedPredictionContext"),Nc=y((n,e,t,s)=>{if(n===e||n.equals(e))return n;if(n instanceof tr&&e instanceof tr)return s0(n,e,t,s);if(t){if(n instanceof ye)return n;if(e instanceof ye)return e}return n instanceof tr&&(n=new Cn([n.parent],[n.returnState])),e instanceof tr&&(e=new Cn([e.parent],[e.returnState])),t0(n,e,t,s)},"merge"),t0=y((n,e,t,s)=>{if(s){let u=s.get(n,e);if(u||(u=s.get(e,n),u))return u}let r=0,i=0,o=0,a=new Array(n.returnStates.length+e.returnStates.length).fill(0),c=new Array(n.returnStates.length+e.returnStates.length).fill(null);for(;r<n.returnStates.length&&i<e.returnStates.length;){let u=n.parents[r],d=e.parents[i];if(n.returnStates[r]===e.returnStates[i]){let h=n.returnStates[r];h===ve.EMPTY_RETURN_STATE&&u===null&&d===null||u!==null&&d!==null&&u===d?(c[o]=u,a[o]=h):(c[o]=Nc(u,d,t,s),a[o]=h),r+=1,i+=1}else n.returnStates[r]<e.returnStates[i]?(c[o]=u,a[o]=n.returnStates[r],r+=1):(c[o]=d,a[o]=e.returnStates[i],i+=1);o+=1}if(r<n.returnStates.length)for(let u=r;u<n.returnStates.length;u++)c[o]=n.parents[u],a[o]=n.returnStates[u],o+=1;else for(let u=i;u<e.returnStates.length;u++)c[o]=e.parents[u],a[o]=e.returnStates[u],o+=1;if(o<c.length){if(o===1){let u=ls(c[0]??void 0,a[0]);return s!==null&&s.set(n,e,u),u}c=c.slice(0,o),a=a.slice(0,o)}let l=new Cn(c,a);return l.equals(n)?(s!==null&&s.set(n,e,n),ve.traceATNSimulator&&console.log("mergeArrays a="+n+",b="+e+" -> a"),n):l.equals(e)?(s!==null&&s.set(n,e,e),e):(n0(c),s!==null&&s.set(n,e,l),ve.traceATNSimulator&&console.log("mergeArrays a="+n+",b="+e+" -> "+l),l)},"mergeArrays"),n0=y(n=>{let e=new sn(cs.instance);for(let t of n)t&&(e.containsKey(t)||e.set(t,t));for(let t=0;t<n.length;t++)n[t]&&(n[t]=e.get(n[t])??null)},"combineCommonParents"),s0=y((n,e,t,s)=>{if(s!==null){let i=s.get(n,e);if(i!==null||(i=s.get(e,n),i!==null))return i}let r=r0(n,e,t);if(r!==null)return s!==null&&s.set(n,e,r),r;if(n.returnState===e.returnState){let i=Nc(n.parent,e.parent,t,s);if(i===n.parent)return n;if(i===e.parent)return e;let o=ls(i,n.returnState);return s!==null&&s.set(n,e,o),o}else{let i=null;if((n===e||n.parent!==null&&n.parent.equals(e.parent))&&(i=n.parent),i!==null){let l=[n.returnState,e.returnState];n.returnState>e.returnState&&(l[0]=e.returnState,l[1]=n.returnState);let u=[i,i],d=new Cn(u,l);return s!==null&&s.set(n,e,d),d}let o=[n.returnState,e.returnState],a=[n.parent,e.parent];n.returnState>e.returnState&&(o[0]=e.returnState,o[1]=n.returnState,a=[e.parent,n.parent]);let c=new Cn(a,o);return s!==null&&s.set(n,e,c),c}},"mergeSingletons"),r0=y((n,e,t)=>{if(t){if(n===ye.instance||e===ye.instance)return ye.instance}else{if(n===ye.instance&&e===ye.instance)return ye.instance;if(n===ye.instance){let s=[e.returnState,ve.EMPTY_RETURN_STATE],r=[e.parent,null];return new Cn(r,s)}if(e===ye.instance){let s=[n.returnState,ve.EMPTY_RETURN_STATE],r=[n.parent,null];return new Cn(r,s)}}return null},"mergeRoot"),i0=class Ac{constructor(e){this.atn=e}static{y(this,"LL1Analyzer")}static hitPredicate=x.INVALID_TYPE;getDecisionLookahead(e){let t=e.transitions.length,s=new Array(t);for(let r=0;r<t;r++){let i=new mt,o=new tt;this.doLook(e.transitions[r].target,void 0,ye.instance,i,o,new Lt,!1,!1),i.length>0&&!i.contains(Ac.hitPredicate)&&(s[r]=i)}return s}look(e,t,s){let r=new mt,i=s?_c(this.atn,s):null;return this.doLook(e,t,i,r,new tt,new Lt,!0,!0),r}doLook(e,t,s,r,i,o,a,c){let l=ge.createWithContext(e,0,s);if(!i.get(l)){if(i.add(l),e===t)if(s){if(s.isEmpty()&&c){r.addOne(x.EOF);return}}else{r.addOne(x.EPSILON);return}if(e.constructor.stateType===L.RULE_STOP){if(s){if(s.isEmpty()&&c){r.addOne(x.EOF);return}}else{r.addOne(x.EPSILON);return}if(s!==ye.instance){let u=o.get(e.ruleIndex);try{o.clear(e.ruleIndex);for(let d=0;d<s.length;d++){let h=this.atn.states[s.getReturnState(d)];this.doLook(h,t,s.getParent(d),r,i,o,a,c)}}finally{u&&o.set(e.ruleIndex)}return}}for(let u of e.transitions)switch(u.transitionType){case N.RULE:{if(o.get(u.target.ruleIndex))continue;let d=ls(s??void 0,u.followState.stateNumber);try{o.set(u.target.ruleIndex),this.doLook(u.target,t,d,r,i,o,a,c)}finally{o.clear(u.target.ruleIndex)}break}case N.PREDICATE:case N.PRECEDENCE:{a?this.doLook(u.target,t,s,r,i,o,a,c):r.addOne(Ac.hitPredicate);break}case N.WILDCARD:{r.addRange(x.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType);break}default:{if(u.isEpsilon)this.doLook(u.target,t,s,r,i,o,a,c);else{let d=u.label;d&&(u instanceof Rc&&(d=d.complement(x.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType)),r.addSet(d))}break}}}}},Z=class{static{y(this,"ATN")}static INVALID_ALT_NUMBER=0;static LEXER=0;static PARSER=1;grammarType;maxTokenType;states=[];decisionToState=[];ruleToStartState=[];ruleToStopState=[];modeNameToStartState=new Map;ruleToTokenType=[];lexerActions=[];modeToStartState=[];analyzer;constructor(n,e){this.grammarType=n,this.maxTokenType=e,this.analyzer=new i0(this)}nextTokens(n,e){if(!e&&n.nextTokenWithinRule)return n.nextTokenWithinRule;let t=this.analyzer.look(n,void 0,e);return e||(n.nextTokenWithinRule=t),t}addState(n){n&&(n.stateNumber=this.states.length),this.states.push(n)}removeState(n){this.states[n.stateNumber]=null}defineDecisionState(n){return this.decisionToState.push(n),n.decision=this.decisionToState.length-1,n.decision}getDecisionState(n){return this.decisionToState.length===0?null:this.decisionToState[n]}getNumberOfDecisions(){return this.decisionToState.length}getExpectedTokens(n,e){if(n<0||n>=this.states.length)throw new Error("Invalid state number.");let t=this.states[n],s=this.nextTokens(t);if(!s.contains(x.EPSILON))return s;let r=e,i=new mt;for(i.addSet(s),i.removeOne(x.EPSILON);r!==null&&r.invokingState>=0&&s.contains(x.EPSILON);){let a=this.states[r.invokingState].transitions[0];s=this.nextTokens(a.followState),i.addSet(s),i.removeOne(x.EPSILON),r=r.parent}return s.contains(x.EPSILON)&&i.addOne(x.EOF),i}},Bd=class ff{static{y(this,"KeyTypeEqualityComparer")}static instance=new ff;hashCode(e){let t=7;return t=31*t+e.state.stateNumber,t=31*t+e.alt,t=31*t+e.semanticContext.hashCode(),t}equals(e,t){return e===t?!0:e.state.stateNumber===t.state.stateNumber&&e.alt===t.alt&&e.semanticContext.equals(t.semanticContext)}},nn=class{static{y(this,"ATNConfigSet")}configLookup=new tt(Bd.instance);configs=[];uniqueAlt=0;hasSemanticContext=!1;dipsIntoOuterContext=!1;fullCtx=!1;readOnly=!1;conflictingAlts=null;firstStopState;#e=-1;constructor(n){if(n!==void 0)if(typeof n=="boolean")this.fullCtx=n??!0;else{let e=n;this.addAll(e.configs),this.uniqueAlt=e.uniqueAlt,this.conflictingAlts=e.conflictingAlts,this.hasSemanticContext=e.hasSemanticContext,this.dipsIntoOuterContext=e.dipsIntoOuterContext}}[Symbol.iterator](){return this.configs[Symbol.iterator]()}add(n,e=null){if(this.readOnly)throw new Error("This set is readonly");!this.firstStopState&&n.state.constructor.stateType===L.RULE_STOP&&(this.firstStopState=n),this.hasSemanticContext||=n.semanticContext!==J.NONE,this.dipsIntoOuterContext||=n.reachesIntoOuterContext;let t=this.configLookup.getOrAdd(n);if(t===n){this.#e=-1,this.configs.push(n);return}let s=!this.fullCtx,r=Nc(t.context,n.context,s,e);t.reachesIntoOuterContext||=n.reachesIntoOuterContext,t.precedenceFilterSuppressed||=n.precedenceFilterSuppressed,t.context=r}get elements(){return this.configs}getAlts(){let n=new Lt;for(let e of this.configs)n.set(e.alt);return n}getPredicates(){let n=[];for(let e of this.configs)e.semanticContext!==J.NONE&&n.push(e.semanticContext);return n}getStates(){let n=new tt;for(let e of this.configs)n.add(e.state);return n}optimizeConfigs(n){if(this.readOnly)throw new Error("This set is readonly");if(this.configLookup.size!==0)for(let e of this.configs)e.context=n.getCachedContext(e.context)}addAll(n){for(let e of n)this.add(e);return!1}equals(n){return!!(this===n||this.fullCtx===n.fullCtx&&this.uniqueAlt===n.uniqueAlt&&this.conflictingAlts===n.conflictingAlts&&this.hasSemanticContext===n.hasSemanticContext&&this.dipsIntoOuterContext===n.dipsIntoOuterContext&&Io(this.configs,n.configs))}hashCode(){return this.#e===-1&&(this.#e=this.computeHashCode()),this.#e}get length(){return this.configs.length}isEmpty(){return this.configs.length===0}contains(n){if(this.configLookup===null)throw new Error("This method is not implemented for readonly sets.");return this.configLookup.contains(n)}containsFast(n){if(this.configLookup===null)throw new Error("This method is not implemented for readonly sets.");return this.configLookup.contains(n)}clear(){if(this.readOnly)throw new Error("This set is readonly");this.configs=[],this.#e=-1,this.configLookup=new tt(Bd.instance)}setReadonly(n){this.readOnly=n,n&&(this.configLookup=null)}toString(){return er(this.configs)+(this.hasSemanticContext?",hasSemanticContext="+this.hasSemanticContext:"")+(this.uniqueAlt!==Z.INVALID_ALT_NUMBER?",uniqueAlt="+this.uniqueAlt:"")+(this.conflictingAlts!==null?",conflictingAlts="+this.conflictingAlts:"")+(this.dipsIntoOuterContext?",dipsIntoOuterContext":"")}computeHashCode(){let n=C.initialize();return this.configs.forEach(e=>{n=C.update(n,e.hashCode())}),n=C.finish(n,this.configs.length),n}},qd=class extends L{static{y(this,"BasicState")}static stateType=L.BASIC},us=class extends L{static{y(this,"DecisionState")}decision=-1;nonGreedy=!1},as=class extends us{static{y(this,"BlockStartState")}endState},gc=class extends L{static{y(this,"BlockEndState")}static stateType=L.BLOCK_END;startState},Ys=class extends L{static{y(this,"LoopEndState")}static stateType=L.LOOP_END;loopBackState},vc=class extends L{static{y(this,"RuleStartState")}static stateType=L.RULE_START;stopState;isLeftRecursiveRule=!1},pt=class extends L{static{y(this,"RuleStopState")}static stateType=L.RULE_STOP},o0=class extends us{static{y(this,"TokensStartState")}static stateType=L.TOKEN_START},zd=class extends us{static{y(this,"PlusLoopbackState")}static stateType=L.PLUS_LOOP_BACK},yc=class extends L{static{y(this,"StarLoopbackState")}static stateType=L.STAR_LOOP_BACK},vn=class extends us{static{y(this,"StarLoopEntryState")}static stateType=L.STAR_LOOP_ENTRY;loopBackState;precedenceRuleDecision=!1},xc=class extends as{static{y(this,"PlusBlockStartState")}static stateType=L.PLUS_BLOCK_START;loopBackState},Sc=class extends as{static{y(this,"StarBlockStartState")}static stateType=L.STAR_BLOCK_START},Wd=class extends as{static{y(this,"BasicBlockStartState")}static stateType=L.BLOCK_START},Jr=class extends N{static{y(this,"AtomTransition")}labelValue;#e;constructor(n,e){super(n),this.labelValue=e,this.#e=mt.of(e,e)}get label(){return this.#e}get transitionType(){return N.ATOM}matches(n){return this.labelValue===n}toString(){return this.labelValue.toString()}},Ec=class extends N{static{y(this,"RuleTransition")}ruleIndex;precedence;followState;constructor(n,e,t,s){super(n),this.ruleIndex=e,this.precedence=t,this.followState=s}get isEpsilon(){return!0}get transitionType(){return N.RULE}matches(n,e,t){return!1}},Cc=class extends N{static{y(this,"RangeTransition")}start;stop;#e=new mt;constructor(n,e,t){super(n),this.start=e,this.stop=t,this.#e.addRange(e,t)}get label(){return this.#e}get transitionType(){return N.RANGE}matches(n,e,t){return n>=this.start&&n<=this.stop}toString(){return"'"+String.fromCharCode(this.start)+"'..'"+String.fromCharCode(this.stop)+"'"}},hf=class extends N{static{y(this,"ActionTransition")}ruleIndex;actionIndex;isCtxDependent;constructor(n,e,t,s){super(n),this.ruleIndex=e,this.actionIndex=t??-1,this.isCtxDependent=s??!1}get isEpsilon(){return!0}get transitionType(){return N.ACTION}matches(n,e,t){return!1}toString(){return"action_"+this.ruleIndex+":"+this.actionIndex}},Wr=class extends N{static{y(this,"EpsilonTransition")}#e;constructor(n,e=-1){super(n),this.#e=e}get outermostPrecedenceReturn(){return this.#e}get isEpsilon(){return!0}get transitionType(){return N.EPSILON}matches(){return!1}toString(){return"epsilon"}},a0=class extends N{static{y(this,"WildcardTransition")}get transitionType(){return N.WILDCARD}matches(n,e,t){return n>=e&&n<=t}toString(){return"."}},pf=class extends N{static{y(this,"AbstractPredicateTransition")}constructor(n){super(n)}},mf=class extends pf{static{y(this,"PredicateTransition")}ruleIndex;predIndex;isCtxDependent;constructor(n,e,t,s){super(n),this.ruleIndex=e,this.predIndex=t,this.isCtxDependent=s}get isEpsilon(){return!0}matches(n,e,t){return!1}get transitionType(){return N.PREDICATE}getPredicate(){return new J.Predicate(this.ruleIndex,this.predIndex,this.isCtxDependent)}toString(){return"pred_"+this.ruleIndex+":"+this.predIndex}},c0=class extends pf{static{y(this,"PrecedencePredicateTransition")}precedence;constructor(n,e){super(n),this.precedence=e}get isEpsilon(){return!0}matches(n,e,t){return!1}getPredicate(){return new J.PrecedencePredicate(this.precedence)}get transitionType(){return N.PRECEDENCE}toString(){return this.precedence+" >= _p"}},X={CHANNEL:0,CUSTOM:1,MODE:2,MORE:3,POP_MODE:4,PUSH_MODE:5,SKIP:6,TYPE:7},l0=class gf{static{y(this,"LexerSkipAction")}static instance=new gf;actionType;isPositionDependent=!1;constructor(){this.actionType=X.SKIP}equals(e){return e===this}hashCode(){return X.SKIP}execute(e){e.skip()}toString(){return"skip"}},u0=class yf{static{y(this,"LexerChannelAction")}channel;actionType;isPositionDependent=!1;cachedHashCode;constructor(e){this.actionType=X.CHANNEL,this.channel=e}execute(e){e.channel=this.channel}hashCode(){if(this.cachedHashCode===void 0){let e=C.initialize();e=C.update(e,this.actionType),e=C.update(e,this.channel),this.cachedHashCode=C.finish(e,2)}return this.cachedHashCode}equals(e){return this===e?!0:e instanceof yf?this.channel===e.channel:!1}toString(){return"channel("+this.channel+")"}},d0=class xf{static{y(this,"LexerCustomAction")}ruleIndex;actionIndex;actionType;isPositionDependent=!0;cachedHashCode;constructor(e,t){this.actionType=X.CUSTOM,this.ruleIndex=e,this.actionIndex=t}execute(e){e.action(null,this.ruleIndex,this.actionIndex)}hashCode(){if(this.cachedHashCode===void 0){let e=C.initialize();e=C.update(e,this.actionType),e=C.update(e,this.ruleIndex),e=C.update(e,this.actionIndex),this.cachedHashCode=C.finish(e,3)}return this.cachedHashCode}equals(e){return this===e?!0:e instanceof xf?this.ruleIndex===e.ruleIndex&&this.actionIndex===e.actionIndex:!1}},f0=class Sf{static{y(this,"LexerMoreAction")}static instance=new Sf;actionType;isPositionDependent=!1;constructor(){this.actionType=X.MORE}equals(e){return e===this}hashCode(){return X.MORE}execute(e){e.more()}toString(){return"more"}},h0=class bf{static{y(this,"LexerTypeAction")}type;actionType;isPositionDependent=!1;cachedHashCode;constructor(e){this.actionType=X.TYPE,this.type=e}execute(e){e.type=this.type}hashCode(){if(this.cachedHashCode===void 0){let e=C.initialize();e=C.update(e,this.actionType),e=C.update(e,this.type),this.cachedHashCode=C.finish(e,2)}return this.cachedHashCode}equals(e){return this===e?!0:e instanceof bf?this.type===e.type:!1}toString(){return"type("+this.type+")"}},p0=class Af{static{y(this,"LexerPushModeAction")}mode;actionType;isPositionDependent=!1;cachedHashCode;constructor(e){this.actionType=X.PUSH_MODE,this.mode=e}execute(e){e.pushMode(this.mode)}hashCode(){if(this.cachedHashCode===void 0){let e=C.initialize();e=C.update(e,this.actionType),e=C.update(e,this.mode),this.cachedHashCode=C.finish(e,2)}return this.cachedHashCode}equals(e){return this===e?!0:e instanceof Af?this.mode===e.mode:!1}toString(){return"pushMode("+this.mode+")"}},m0=class vf{static{y(this,"LexerPopModeAction")}static instance=new vf;actionType;isPositionDependent=!1;constructor(){this.actionType=X.POP_MODE}equals(e){return e===this}hashCode(){return X.POP_MODE}execute(e){e.popMode()}toString(){return"popMode"}},g0=class Ef{static{y(this,"LexerModeAction")}mode;actionType;isPositionDependent=!1;cachedHashCode;constructor(e){this.actionType=X.MODE,this.mode=e}execute(e){e.mode=this.mode}hashCode(){if(this.cachedHashCode===void 0){let e=C.initialize();e=C.update(e,this.actionType),e=C.update(e,this.mode),this.cachedHashCode=C.finish(e,2)}return this.cachedHashCode}equals(e){return this===e?!0:e instanceof Ef?this.mode===e.mode:!1}toString(){return"mode("+this.mode+")"}},Tn=class Gr{static{y(this,"ATNDeserializer")}static SERIALIZED_VERSION=4;static stateTypeMapper=new Map([[L.INVALID_TYPE,void 0],[L.BASIC,qd],[L.RULE_START,vc],[L.BLOCK_START,Wd],[L.PLUS_BLOCK_START,xc],[L.STAR_BLOCK_START,Sc],[L.TOKEN_START,o0],[L.RULE_STOP,pt],[L.BLOCK_END,gc],[L.STAR_LOOP_BACK,yc],[L.STAR_LOOP_ENTRY,vn],[L.PLUS_LOOP_BACK,zd],[L.LOOP_END,Ys]]);static lexerActionFactoryMapper=new Map([[X.CHANNEL,e=>new u0(e)],[X.CUSTOM,(e,t)=>new d0(e,t)],[X.MODE,e=>new g0(e)],[X.MORE,()=>f0.instance],[X.POP_MODE,()=>m0.instance],[X.PUSH_MODE,e=>new p0(e)],[X.SKIP,()=>l0.instance],[X.TYPE,e=>new h0(e)]]);data=[];pos=0;deserializationOptions;actionFactories;constructor(e){e||(e={readOnly:!1,verifyATN:!0,generateRuleBypassTransitions:!1}),this.deserializationOptions=e}deserialize(e){this.data=e,this.checkVersion();let t=this.readATN();this.readStates(t),this.readRules(t),this.readModes(t);let s=[];return this.readSets(t,s),this.readEdges(t,s),this.readDecisions(t),this.readLexerActions(t),this.markPrecedenceDecisions(t),this.verifyATN(t),this.deserializationOptions.generateRuleBypassTransitions&&t.grammarType===Z.PARSER&&(this.generateRuleBypassTransitions(t),this.verifyATN(t)),t}checkVersion(){let e=this.data[this.pos++];if(e!==Gr.SERIALIZED_VERSION)throw new Error("Could not deserialize ATN with version "+e+" (expected "+Gr.SERIALIZED_VERSION+").")}readATN(){let e=this.data[this.pos++],t=this.data[this.pos++];return new Z(e,t)}readStates(e){let t,s,r=[],i=[],o=this.data[this.pos++];for(let l=0;l<o;l++){let u=this.data[this.pos++];if(u===L.INVALID_TYPE){e.addState(null);continue}let d=this.data[this.pos++],h=this.stateFactory(u,d);if(u===L.LOOP_END){let p=this.data[this.pos++];r.push([h,p])}else if(h instanceof as){let p=this.data[this.pos++];i.push([h,p])}e.addState(h)}for(t=0;t<r.length;t++){let l=r[t];l[0].loopBackState=e.states[l[1]]??void 0}for(t=0;t<i.length;t++){let l=i[t];l[0].endState=e.states[l[1]]}let a=this.data[this.pos++];for(t=0;t<a;t++)s=this.data[this.pos++],e.states[s].nonGreedy=!0;let c=this.data[this.pos++];for(t=0;t<c;t++)s=this.data[this.pos++],e.states[s].isLeftRecursiveRule=!0}readRules(e){let t,s=this.data[this.pos++];for(e.grammarType===Z.LEXER&&(e.ruleToTokenType=new Array(s),e.ruleToTokenType.fill(0)),e.ruleToStartState=new Array(s),e.ruleToStartState.fill(null),t=0;t<s;t++){let r=this.data[this.pos++];if(e.ruleToStartState[t]=e.states[r],e.grammarType===Z.LEXER){let i=this.data[this.pos++];e.ruleToTokenType[t]=i}}for(e.ruleToStopState=new Array(s),e.ruleToStopState.fill(null),t=0;t<e.states.length;t++){let r=e.states[t];r instanceof pt&&(e.ruleToStopState[r.ruleIndex]=r,e.ruleToStartState[r.ruleIndex].stopState=r)}}readModes(e){let t=this.data[this.pos++];for(let s=0;s<t;s++){let r=this.data[this.pos++];e.modeToStartState.push(e.states[r])}}readSets(e,t){let s=this.data[this.pos++];for(let r=0;r<s;r++){let i=new mt;t.push(i);let o=this.data[this.pos++];this.data[this.pos++]!==0&&i.addOne(-1);for(let c=0;c<o;c++){let l=this.data[this.pos++],u=this.data[this.pos++];i.addRange(l,u)}}}readEdges(e,t){let s,r,i,o,a,c=this.data[this.pos++];for(s=0;s<c;s++){let l=this.data[this.pos++],u=this.data[this.pos++],d=this.data[this.pos++],h=this.data[this.pos++],p=this.data[this.pos++],m=this.data[this.pos++];o=this.edgeFactory(e,d,u,h,p,m,t),e.states[l].addTransition(o)}for(s=0;s<e.states.length;s++)for(i=e.states[s],r=0;r<i.transitions.length;r++){let l=i.transitions[r];if(!(l instanceof Ec))continue;let u=-1;e.ruleToStartState[l.target.ruleIndex].isLeftRecursiveRule&&l.precedence===0&&(u=l.target.ruleIndex),o=new Wr(l.followState,u),e.ruleToStopState[l.target.ruleIndex].addTransition(o)}for(s=0;s<e.states.length;s++){if(i=e.states[s],i instanceof as){if(!i.endState)throw new Error("IllegalState");if(i.endState.startState)throw new Error("IllegalState");i.endState.startState=i}if(i instanceof zd)for(r=0;r<i.transitions.length;r++)a=i.transitions[r].target,a instanceof xc&&(a.loopBackState=i);else if(i instanceof yc)for(r=0;r<i.transitions.length;r++)a=i.transitions[r].target,a instanceof vn&&(a.loopBackState=i)}}readDecisions(e){let t=this.data[this.pos++];for(let s=0;s<t;s++){let r=this.data[this.pos++],i=e.states[r];e.decisionToState.push(i),i.decision=s}}readLexerActions(e){if(e.grammarType===Z.LEXER){let t=this.data[this.pos++];e.lexerActions=[];for(let s=0;s<t;s++){let r=this.data[this.pos++],i=this.data[this.pos++],o=this.data[this.pos++];e.lexerActions.push(this.lexerActionFactory(r,i,o))}}}generateRuleBypassTransitions(e){let t,s=e.ruleToStartState.length;for(t=0;t<s;t++)e.ruleToTokenType[t]=e.maxTokenType+t+1;for(t=0;t<s;t++)this.generateRuleBypassTransition(e,t)}generateRuleBypassTransition(e,t){let s,r,i=new Wd;i.ruleIndex=t,e.addState(i);let o=new gc;o.ruleIndex=t,e.addState(o),i.endState=o,e.defineDecisionState(i),o.startState=i;let a=null,c=null;if(e.ruleToStartState[t].isLeftRecursiveRule){for(c=null,s=0;s<e.states.length;s++)if(r=e.states[s],this.stateIsEndStateFor(r,t)){c=r,a=r.loopBackState.transitions[0];break}if(a===null)throw new Error("Couldn't identify final state of the precedence rule prefix section.")}else c=e.ruleToStopState[t];for(s=0;s<e.states.length;s++){r=e.states[s];for(let d of r.transitions)d!==a&&d.target===c&&(d.target=o)}let l=e.ruleToStartState[t];for(;l.transitions.length>0;){let d=l.removeTransition(l.transitions.length-1);i.addTransition(d)}e.ruleToStartState[t].addTransition(new Wr(i)),c&&o.addTransition(new Wr(c));let u=new qd;e.addState(u),u.addTransition(new Jr(o,e.ruleToTokenType[t])),i.addTransition(new Wr(u))}stateIsEndStateFor(e,t){if(e.ruleIndex!==t||!(e instanceof vn))return null;let s=e.transitions[e.transitions.length-1].target;return s instanceof Ys&&s.epsilonOnlyTransitions&&s.transitions[0].target instanceof pt?e:null}markPrecedenceDecisions(e){for(let t of e.states)if(t instanceof vn&&e.ruleToStartState[t.ruleIndex].isLeftRecursiveRule){let s=t.transitions[t.transitions.length-1].target;s instanceof Ys&&s.epsilonOnlyTransitions&&s.transitions[0].target instanceof pt&&(t.precedenceRuleDecision=!0)}}verifyATN(e){if(this.deserializationOptions.verifyATN){for(let t of e.states)if(t!==null)if(this.checkCondition(t.epsilonOnlyTransitions||t.transitions.length<=1),t instanceof xc)this.checkCondition(t.loopBackState!==null);else if(t instanceof vn)if(this.checkCondition(t.loopBackState!==null),this.checkCondition(t.transitions.length===2),t.transitions[0].target instanceof Sc)this.checkCondition(t.transitions[1].target instanceof Ys),this.checkCondition(!t.nonGreedy);else if(t.transitions[0].target instanceof Ys)this.checkCondition(t.transitions[1].target instanceof Sc),this.checkCondition(t.nonGreedy);else throw new Error("IllegalState");else t instanceof yc?(this.checkCondition(t.transitions.length===1),this.checkCondition(t.transitions[0].target instanceof vn)):t instanceof Ys?this.checkCondition(t.loopBackState!==null):t instanceof vc?this.checkCondition(t.stopState!==null):t instanceof as?this.checkCondition(t.endState!==null):t instanceof gc?this.checkCondition(t.startState!==null):t instanceof us?this.checkCondition(t.transitions.length<=1||t.decision>=0):this.checkCondition(t.transitions.length<=1||t instanceof pt)}}checkCondition(e,t){if(!e)throw t==null&&(t="IllegalState"),t}edgeFactory(e,t,s,r,i,o,a){let c=e.states[s];switch(t){case N.EPSILON:return new Wr(c);case N.RANGE:return o!==0?new Cc(c,x.EOF,i):new Cc(c,r,i);case N.RULE:return new Ec(e.states[r],i,o,c);case N.PREDICATE:return new mf(c,r,i,o!==0);case N.PRECEDENCE:return new c0(c,r);case N.ATOM:return o!==0?new Jr(c,x.EOF):new Jr(c,r);case N.ACTION:return new hf(c,r,i,o!==0);case N.SET:return new kc(c,a[r]);case N.NOT_SET:return new Rc(c,a[r]);case N.WILDCARD:return new a0(c);default:throw new Error("The specified transition type: "+t+" is not valid.")}}stateFactory(e,t){let s=Gr.stateTypeMapper.get(e);if(!s)throw new Error("The specified state type "+e+" is not valid.");let r=new s;return r.ruleIndex=t,r}lexerActionFactory(e,t,s){let r=Gr.lexerActionFactoryMapper.get(e);if(!r)throw new Error("The specified lexer action type "+e+" is not valid.");return r(t,s)}},y0=class Cf extends sn{static{y(this,"OrderedHashMap")}#e=[];clear(){super.clear(),this.#e=[]}get(e){return super.get(e)}set(e,t){let s=super.set(e,t);return s===void 0&&this.#e.push(e),s}setIfAbsent(e,t){let s=super.setIfAbsent(e,t);return s===void 0&&this.#e.push(e),s}values(){return{[Symbol.iterator]:()=>{let e=0;return{next:y(()=>e<this.#e.length?{done:!1,value:super.get(this.#e[e++])}:{done:!0,value:void 0},"next")}}}}keys(){return this.#e[Symbol.iterator]()}equals(e){return e instanceof Cf?super.equals(e):!1}},xA=class Tc{static{y(this,"ATNSerializer")}atn;data=[];sets=new y0(cs.instance);nonGreedyStates=[];precedenceStates=[];constructor(e){this.atn=e}static getSerialized(e){return new Tc(e).serialize()}static serializeSets(e,t){e.push(t.length);for(let s of t){let r=s.contains(x.EOF),i=[...s];r&&i[0].stop===x.EOF?e.push(i.length-1):e.push(i.length),e.push(r?1:0);for(let o of i){if(o.start===x.EOF){if(o.stop===x.EOF)continue;e.push(0)}else e.push(o.start);e.push(o.stop)}}}serialize(){this.addPreamble();let e=this.addEdges();this.addNonGreedyStates(),this.addPrecedenceStates(),this.addRuleStatesAndLexerTokenTypes(),this.addModeStartStates();let t=this.addSets();return this.addEdges(e,t),this.addDecisionStartStates(),this.addLexerActions(),this.data}addPreamble(){this.data.push(Tn.SERIALIZED_VERSION),this.data.push(this.atn.grammarType),this.data.push(this.atn.maxTokenType)}addLexerActions(){if(this.atn.grammarType===Z.LEXER){this.data.push(this.atn.lexerActions.length);for(let e of this.atn.lexerActions)switch(this.data.push(e.actionType),e.actionType){case X.CHANNEL:{let t=e.channel;this.data.push(t),this.data.push(0);break}case X.CUSTOM:{let t=e.ruleIndex,s=e.actionIndex;this.data.push(t),this.data.push(s);break}case X.MODE:{let t=e.mode;this.data.push(t),this.data.push(0);break}case X.MORE:{this.data.push(0),this.data.push(0);break}case X.POP_MODE:{this.data.push(0),this.data.push(0);break}case X.PUSH_MODE:{let t=e.mode;this.data.push(t),this.data.push(0);break}case X.SKIP:{this.data.push(0),this.data.push(0);break}case X.TYPE:{let t=e.type;this.data.push(t),this.data.push(0);break}default:throw new Error(`The specified lexer action type ${e.actionType} is not valid.`)}}}addDecisionStartStates(){this.data.push(this.atn.decisionToState.length);for(let e of this.atn.decisionToState)this.data.push(e.stateNumber)}addEdges(...e){switch(e.length){case 0:{let t=0;this.data.push(this.atn.states.length);for(let s of this.atn.states){if(s===null){this.data.push(L.INVALID_TYPE);continue}let r=s.constructor.stateType;s instanceof us&&s.nonGreedy&&this.nonGreedyStates.push(s.stateNumber),s instanceof vc&&s.isLeftRecursiveRule&&this.precedenceStates.push(s.stateNumber),this.data.push(r),this.data.push(s.ruleIndex),s.constructor.stateType===L.LOOP_END?this.data.push(s.loopBackState.stateNumber):s instanceof as&&this.data.push(s.endState.stateNumber),s.constructor.stateType!==L.RULE_STOP&&(t+=s.transitions.length);for(let i of s.transitions){let o=i.transitionType;if(o===N.SET||o===N.NOT_SET){let a=i;this.sets.set(a.set,!0)}}}return t}case 2:{let[t,s]=e;this.data.push(t);for(let r of this.atn.states)if(r!==null&&r.constructor.stateType!==L.RULE_STOP)for(let i of r.transitions){if(this.atn.states[i.target.stateNumber]===null)throw new Error("Cannot serialize a transition to a removed state.");let o=r.stateNumber,a=i.target.stateNumber,c=i.transitionType,l=0,u=0,d=0;switch(c){case N.RULE:{a=i.followState.stateNumber,l=i.target.stateNumber,u=i.ruleIndex,d=i.precedence;break}case N.PRECEDENCE:{l=i.precedence;break}case N.PREDICATE:{let h=i;l=h.ruleIndex,u=h.predIndex,d=h.isCtxDependent?1:0;break}case N.RANGE:{l=i.start,u=i.stop,l===x.EOF&&(l=0,d=1);break}case N.ATOM:{l=i.labelValue,l===x.EOF&&(l=0,d=1);break}case N.ACTION:{let h=i;l=h.ruleIndex,u=h.actionIndex,d=h.isCtxDependent?1:0;break}case N.SET:{l=s.get(i.set);break}case N.NOT_SET:{l=s.get(i.set);break}case N.WILDCARD:break;default:}this.data.push(o),this.data.push(a),this.data.push(c),this.data.push(l),this.data.push(u),this.data.push(d)}break}default:throw new Error("Invalid number of arguments")}}addSets(){Tc.serializeSets(this.data,[...this.sets.keys()]);let e=new sn,t=0;for(let s of this.sets.keys())e.set(s,t++);return e}addModeStartStates(){let e=this.atn.modeToStartState.length;if(this.data.push(e),e>0)for(let t of this.atn.modeToStartState)this.data.push(t.stateNumber)}addRuleStatesAndLexerTokenTypes(){let e=this.atn.ruleToStartState.length;this.data.push(e);for(let t=0;t<e;t++){let s=this.atn.ruleToStartState[t];this.data.push(s.stateNumber),this.atn.grammarType===Z.LEXER&&this.data.push(this.atn.ruleToTokenType[t])}}addPrecedenceStates(){this.data.push(this.precedenceStates.length);for(let e of this.precedenceStates)this.data.push(e)}addNonGreedyStates(){this.data.push(this.nonGreedyStates.length);for(let e of this.nonGreedyStates)this.data.push(e)}},nr=class wc{static{y(this,"DFAState")}stateNumber=-1;configs;edges=[];isAcceptState=!1;prediction=-1;lexerActionExecutor=null;requiresFullContext=!1;predicates=null;constructor(e){e&&(this.configs=e)}static fromState(e){let t=new wc;return t.stateNumber=e,t}static fromConfigs(e){return new wc(e)}static hashCode(e){return e.configs.hashCode()}static equals(e,t){return e.configs.equals(t.configs)}getAltSet(){let e=new Set;for(let t of this.configs)e.add(t.alt);return e.size===0?null:e}toString(){let e="";return e+=this.stateNumber,e+=":",e+=this.configs?this.configs.toString():"",this.isAcceptState&&(e+="=>",this.predicates?e+=er(this.predicates):e+=this.prediction),e.toString()}},Dt=class{static{y(this,"ATNSimulator")}static ERROR=nr.fromState(2147483647);atn;sharedContextCache;constructor(n,e){return this.atn=n,this.sharedContextCache=e,this}getCachedContext(n){if(!this.sharedContextCache)return n;let e=new sn(cs.instance);return df(n,this.sharedContextCache,e)}},SA=class Tf{static{y(this,"CodePointTransitions")}static createWithCodePoint(e,t){return Tf.createWithCodePointRange(e,t,t)}static createWithCodePointRange(e,t,s){return t===s?new Jr(e,t):new Cc(e,t,s)}},x0=class{static{y(this,"DecisionInfo")}decision=0;invocations=0;timeInPrediction=0;sllTotalLook=0;sllMinLook=0;sllMaxLook=0;sllMaxLookEvent;llTotalLook=0;llMinLook=0;llMaxLook=0;llMaxLookEvent;contextSensitivities;errors;ambiguities;predicateEvals;sllATNTransitions=0;sllDFATransitions=0;llFallback=0;llATNTransitions=0;llDFATransitions=0;constructor(n){this.decision=n,this.contextSensitivities=[],this.errors=[],this.ambiguities=[],this.predicateEvals=[]}toString(){return"{decision="+this.decision+", contextSensitivities="+this.contextSensitivities.length+", errors="+this.errors.length+", ambiguities="+this.ambiguities.length+", sllLookahead="+this.sllTotalLook+", sllATNTransitions="+this.sllATNTransitions+", sllDFATransitions="+this.sllDFATransitions+", llFallback="+this.llFallback+", llLookahead="+this.llTotalLook+", llATNTransitions="+this.llATNTransitions+"}"}},Ot=class Kr extends ge{static{y(this,"LexerATNConfig")}lexerActionExecutor;passedThroughNonGreedyDecision;constructor(e,t,s,r){return super(e,t,s??e.context,s?J.NONE:e.semanticContext),this.lexerActionExecutor=s?r:e.lexerActionExecutor??null,this.passedThroughNonGreedyDecision=Kr.checkNonGreedyDecision(e,this.state),this}static createWithExecutor(e,t,s){return new Kr(e,t,e.context,s)}static createWithConfig(e,t,s){return new Kr(t,e,s??null,t.lexerActionExecutor)}static createWithContext(e,t,s){return new Kr({alt:t},e,s,null)}static checkNonGreedyDecision(e,t){return e.passedThroughNonGreedyDecision||"nonGreedy"in t&&t.nonGreedy}hashCode(){if(this.cachedHashCode===void 0){let e=C.initialize(7);e=C.update(e,this.state.stateNumber),e=C.update(e,this.alt),e=C.updateFromComparable(e,this.context),e=C.updateFromComparable(e,this.semanticContext),e=C.update(e,this.passedThroughNonGreedyDecision?1:0),e=C.updateFromComparable(e,this.lexerActionExecutor),e=C.finish(e,6),this.cachedHashCode=e}return this.cachedHashCode}equals(e){return this===e?!0:this.passedThroughNonGreedyDecision===e.passedThroughNonGreedyDecision&&(this.lexerActionExecutor&&e.lexerActionExecutor?this.lexerActionExecutor.equals(e.lexerActionExecutor):!e.lexerActionExecutor)&&super.equals(e)}},ir=class{static{y(this,"BaseErrorListener")}syntaxError(n,e,t,s,r,i){}reportAmbiguity(n,e,t,s,r,i,o){}reportAttemptingFullContext(n,e,t,s,r,i){}reportContextSensitivity(n,e,t,s,r,i){}},S0=class wf extends ir{static{y(this,"ConsoleErrorListener")}static instance=new wf;syntaxError(e,t,s,r,i,o){console.error("line "+s+":"+r+" "+i)}},b0=class extends ir{constructor(n){return super(),this.delegates=n,this}static{y(this,"ProxyErrorListener")}syntaxError(n,e,t,s,r,i){this.delegates.forEach(o=>{o.syntaxError(n,e,t,s,r,i)})}reportAmbiguity(n,e,t,s,r,i,o){this.delegates.forEach(a=>{a.reportAmbiguity(n,e,t,s,r,i,o)})}reportAttemptingFullContext(n,e,t,s,r,i){this.delegates.forEach(o=>{o.reportAttemptingFullContext(n,e,t,s,r,i)})}reportContextSensitivity(n,e,t,s,r,i){this.delegates.forEach(o=>{o.reportContextSensitivity(n,e,t,s,r,i)})}},If=class Yr{static{y(this,"Recognizer")}static EOF=-1;static tokenTypeMapCache=new Map;static ruleIndexMapCache=new Map;interpreter;listeners=[S0.instance];stateNumber=-1;checkVersion(e){let t="4.13.1";t!==e&&console.error("ANTLR runtime and generated code versions disagree: "+t+"!="+e)}addErrorListener(e){this.listeners.push(e)}removeErrorListeners(){this.listeners=[]}removeErrorListener(e){for(let t=0;t<this.listeners.length;t++)if(this.listeners[t]===e){this.listeners.splice(t,1);return}}getErrorListeners(){return this.listeners}getTokenTypeMap(){let e=this.vocabulary,t=Yr.tokenTypeMapCache.get(e);if(!t){t=new Map;for(let s=0;s<=this.atn.maxTokenType;s++){let r=e.getLiteralName(s);r&&t.set(r,s);let i=e.getSymbolicName(s);i&&t.set(i,s)}t.set("EOF",x.EOF),Yr.tokenTypeMapCache.set(e,t)}return t}getRuleIndexMap(){let e=this.ruleNames,t=Yr.ruleIndexMapCache.get(e);return t||(t=new Map,e.forEach((s,r)=>t.set(s,r)),Yr.ruleIndexMapCache.set(e,t)),t}getTokenType(e){let t=this.getTokenTypeMap().get(e);return t||x.INVALID_TYPE}getErrorHeader(e){let t=e.offendingToken?.line,s=e.offendingToken?.column;return"line "+t+":"+s}get errorListenerDispatch(){return new b0(this.listeners)}sempred(e,t,s){return!0}precpred(e,t){return!0}action(e,t,s){}get atn(){return this.interpreter.atn}get state(){return this.stateNumber}set state(e){this.stateNumber=e}getParseInfo(){}},kf=class Rf{static{y(this,"CommonTokenFactory")}static DEFAULT=new Rf;copyText=!1;constructor(e){this.copyText=e??!1}create(e,t,s,r,i,o,a,c){let l=To.fromSource(e,t,r,i,o);return l.line=a,l.column=c,s?l.text=s:this.copyText&&e[1]!==null&&(l.text=e[1].getTextFromRange(i,o)),l}},ie=class _f extends Error{static{y(this,"RecognitionException")}ctx;offendingToken=null;offendingState=-1;recognizer;input;constructor(e){super(e.message),Error.captureStackTrace&&Error.captureStackTrace(this,_f),this.message=e.message,this.recognizer=e.recognizer,this.input=e.input,this.ctx=e.ctx,this.recognizer!==null&&(this.offendingState=this.recognizer.state)}getExpectedTokens(){return this.recognizer!==null&&this.ctx!==null?this.recognizer.atn.getExpectedTokens(this.offendingState,this.ctx):null}toString(){return this.message}},wo=class extends ie{static{y(this,"LexerNoViableAltException")}startIndex;deadEndConfigs;constructor(n,e,t,s){super({message:"",recognizer:n,input:e,ctx:null}),this.startIndex=t,this.deadEndConfigs=s}toString(){let n="";return this.input&&this.startIndex>=0&&this.startIndex<this.input.size&&(n=this.input.getTextFromRange(this.startIndex,this.startIndex)),`LexerNoViableAltException(${n})`}},nt=class An extends If{static{y(this,"Lexer")}static DEFAULT_MODE=0;static MORE=-2;static SKIP=-3;static DEFAULT_TOKEN_CHANNEL=x.DEFAULT_CHANNEL;static HIDDEN=x.HIDDEN_CHANNEL;options={minDFAEdge:0,maxDFAEdge:256,minCodePoint:0,maxCodePoint:1114111};tokenStartCharIndex=-1;channel=0;type=0;mode=An.DEFAULT_MODE;currentTokenColumn=0;currentTokenStartLine=0;input;token=null;hitEOF=!1;factory;#e=[];#t;constructor(e,t){super(),this.options={...this.options,...t},this.input=e,this.factory=kf.DEFAULT}reset(e=!0){e&&this.input.seek(0),this.token=null,this.type=x.INVALID_TYPE,this.channel=x.DEFAULT_CHANNEL,this.tokenStartCharIndex=-1,this.currentTokenColumn=-1,this.currentTokenStartLine=-1,this.#t=void 0,this.hitEOF=!1,this.mode=An.DEFAULT_MODE,this.#e=[],this.interpreter.reset()}nextToken(){if(this.input===null)throw new Error("nextToken requires a non-null input stream.");let e=this.input.mark();try{for(;;){if(this.hitEOF)return this.emitEOF(),this.token;this.token=null,this.channel=x.DEFAULT_CHANNEL,this.tokenStartCharIndex=this.input.index,this.currentTokenColumn=this.interpreter.column,this.currentTokenStartLine=this.interpreter.line,this.#t=void 0;let t=!1;for(;;){this.type=x.INVALID_TYPE;let s=An.SKIP;try{s=this.interpreter.match(this.input,this.mode)}catch(r){if(r instanceof wo)this.notifyListeners(r),this.recover(r);else throw r}if(this.input.LA(1)===x.EOF&&(this.hitEOF=!0),this.type===x.INVALID_TYPE&&(this.type=s),this.type===An.SKIP){t=!0;break}if(this.type!==An.MORE)break}if(!t)return this.token===null&&this.emit(),this.token}}finally{this.input.release(e)}}skip(){this.type=An.SKIP}more(){this.type=An.MORE}pushMode(e){sr.debug&&console.log("pushMode "+e),this.#e.push(this.mode),this.mode=e}popMode(){if(this.#e.length===0)throw new Error("Empty Stack");return sr.debug&&console.log("popMode back to "+this.#e.slice(0,-1)),this.mode=this.#e.pop(),this.mode}get modeStack(){return this.#e}emitToken(e){this.token=e}emit(){let e=this.factory.create([this,this.input],this.type,this.#t,this.channel,this.tokenStartCharIndex,this.getCharIndex()-1,this.currentTokenStartLine,this.currentTokenColumn);return this.emitToken(e),e}emitEOF(){let e=this.factory.create([this,this.input],x.EOF,void 0,x.DEFAULT_CHANNEL,this.input.index,this.input.index-1,this.line,this.column);return this.emitToken(e),e}getCharIndex(){return this.input.index}getAllTokens(){let e=[],t=this.nextToken();for(;t.type!==x.EOF;)e.push(t),t=this.nextToken();return e}notifyListeners(e){let t=this.tokenStartCharIndex,s=this.input.index,r=this.input.getTextFromRange(t,s),i="token recognition error at: '"+this.getErrorDisplay(r)+"'";this.errorListenerDispatch.syntaxError(this,null,this.currentTokenStartLine,this.currentTokenColumn,i,e)}getErrorDisplay(e){return e}getErrorDisplayForChar(e){return e.charCodeAt(0)===x.EOF?"<EOF>":e===`
25
+ `?"\\n":e===" "?"\\t":e==="\r"?"\\r":e}getCharErrorDisplay(e){return"'"+this.getErrorDisplayForChar(e)+"'"}recover(e){this.input.LA(1)!==x.EOF&&(e instanceof wo?this.interpreter.consume(this.input):this.input.consume())}get inputStream(){return this.input}set inputStream(e){this.reset(!1),this.input=e}set tokenFactory(e){this.factory=e}get tokenFactory(){return this.factory}get sourceName(){return this.input.getSourceName()}get line(){return this.interpreter.line}set line(e){this.interpreter.line=e}get column(){return this.interpreter.column}set column(e){this.interpreter.column=e}get text(){return this.#t?this.#t:this.interpreter.getText(this.input)}set text(e){this.#t=e}},Nf=class{static{y(this,"DFASerializer")}dfa;vocabulary;constructor(n,e){this.dfa=n,this.vocabulary=e}toString(){if(!this.dfa.s0)return"";let n="",e=this.dfa.getStates();for(let t of e){let s=0;s=t.edges.length;for(let r=0;r<s;r++){let i=t.edges[r];if(i&&i.stateNumber!==2147483647){n+=this.getStateString(t);let o=this.getEdgeLabel(r);n+="-",n+=o,n+="->",n+=this.getStateString(i),n+=`
26
+ `}}}return n}getEdgeLabel(n){return`${this.vocabulary.getDisplayName(n-1)}`}getStateString(n){let e=n.stateNumber,t=(n.isAcceptState?":":"")+"s"+e+(n.requiresFullContext?"^":"");return n.isAcceptState?n.predicates!==null?`${t}=>${n.predicates.toString()}`:`${t}=>${n.prediction}`:`${t}`}},A0=class extends Nf{static{y(this,"LexerDFASerializer")}constructor(n){super(n,yt.EMPTY_VOCABULARY)}getEdgeLabel=y(n=>"'"+String.fromCharCode(n)+"'","getEdgeLabel")},rn=class{static{y(this,"DFA")}s0;decision;atnStartState;isPrecedenceDfa;states=new Map;constructor(n,e){this.atnStartState=n,this.decision=e??0;let t=!1;n instanceof vn&&n.precedenceRuleDecision&&(t=!0,this.s0=nr.fromState(-1)),this.isPrecedenceDfa=t}[Symbol.iterator]=()=>this.states.values()[Symbol.iterator]();getPrecedenceStartState=y(n=>{if(!this.isPrecedenceDfa)throw new Error("Only precedence DFAs may contain a precedence start state.");if(!(!this.s0||!this.s0.edges||n<0||n>=this.s0.edges.length))return this.s0.edges[n]},"getPrecedenceStartState");setPrecedenceStartState=y((n,e)=>{if(!this.isPrecedenceDfa)throw new Error("Only precedence DFAs may contain a precedence start state.");n<0||!this.s0||(this.s0.edges[n]=e)},"setPrecedenceStartState");getStates(){let n=[...this.states.values()];return n.sort((e,t)=>e.stateNumber-t.stateNumber),n}getState(n){return this.states.get(n.configs.hashCode())??null}getStateForConfigs(n){return this.states.get(n.hashCode())??null}addState(n){let e=n.configs.hashCode();this.states.has(e)||(this.states.set(e,n),n.stateNumber=this.states.size-1)}toString(n){return n?this.s0?new Nf(this,n).toString()??"":"":this.toString(yt.EMPTY_VOCABULARY)}toLexerString(){return this.s0?new A0(this).toString()??"":""}get length(){return this.states.size}},bc=class Of{static{y(this,"LexerIndexedCustomAction")}offset;action;actionType;isPositionDependent=!0;cachedHashCode;constructor(e,t){this.actionType=t.actionType,this.offset=e,this.action=t}execute(e){this.action.execute(e)}hashCode(){if(this.cachedHashCode===void 0){let e=C.initialize();e=C.update(e,this.offset),e=C.updateFromComparable(e,this.action),this.cachedHashCode=C.finish(e,2)}return this.cachedHashCode}equals(e){return this===e?!0:e instanceof Of?this.offset===e.offset&&this.action===e.action:!1}},v0=class Eo{static{y(this,"LexerActionExecutor")}lexerActions;actionType;isPositionDependent=!1;cachedHashCode;constructor(e){return this.actionType=-1,this.lexerActions=e??[],this}static append(e,t){if(e===null)return new Eo([t]);let s=e.lexerActions.concat([t]);return new Eo(s)}fixOffsetBeforeMatch(e){let t=null;for(let s=0;s<this.lexerActions.length;s++)this.lexerActions[s].isPositionDependent&&!(this.lexerActions[s]instanceof bc)&&(t===null&&(t=this.lexerActions.concat([])),t[s]=new bc(e,this.lexerActions[s]));return t===null?this:new Eo(t)}execute(e,t,s){if(t===void 0||s===void 0)return;let r=!1,i=t.index;try{for(let o of this.lexerActions){let a=o;if(o instanceof bc){let c=o.offset;t.seek(s+c),a=o.action,r=s+c!==i}else o.isPositionDependent&&(t.seek(i),r=!1);a.execute(e)}}finally{r&&t.seek(i)}}hashCode(){if(this.cachedHashCode===void 0){let e=C.initialize(7);for(let t of this.lexerActions)e=C.update(e,t.hashCode());this.cachedHashCode=C.finish(e,this.lexerActions.length)}return this.cachedHashCode}equals(e){return this===e?!0:this.cachedHashCode!==e.cachedHashCode||this.lexerActions.length!==e.lexerActions.length?!1:this.lexerActions.every((t,s)=>t.equals(e.lexerActions[s]))}},E0=class Pf extends tt{static{y(this,"OrderedHashSet")}elements=[];getOrAdd(e){let t=this.size,s=super.getOrAdd(e);return this.size>t&&this.elements.push(e),s}equals(e){return e instanceof Pf?super.equals(e):!1}clear(){super.clear(),this.elements=[]}*[Symbol.iterator](){yield*this.elements}toArray(){return this.elements.slice(0)}},Zd=class extends nn{static{y(this,"OrderedATNConfigSet")}constructor(){super(),this.configLookup=new E0}},sr=class et extends Dt{static{y(this,"LexerATNSimulator")}static debug=!1;decisionToDFA;recognizer=null;startIndex=-1;line=1;column=0;mode=nt.DEFAULT_MODE;prevAccept;options;lexerATNConfigFactory;constructor(e,t,s,r){super(t,r),this.decisionToDFA=s,this.recognizer=e,e?this.options=e.options:this.options={minDFAEdge:0,maxDFAEdge:256,minCodePoint:0,maxCodePoint:1114111}}match(e,t){this.mode=t;let s=e.mark();try{this.startIndex=e.index,this.prevAccept=void 0;let r=this.decisionToDFA[t];return r.s0?this.execATN(e,r.s0):this.matchATN(e)}finally{e.release(s)}}reset(){this.prevAccept=void 0,this.startIndex=-1,this.line=1,this.column=0,this.mode=nt.DEFAULT_MODE}clearDFA(){for(let e=0;e<this.decisionToDFA.length;e++)this.decisionToDFA[e]=new rn(this.atn.getDecisionState(e),e)}getDFA(e){return this.decisionToDFA[e]}getText(e){return e.getTextFromRange(this.startIndex,e.index-1)}consume(e){e.LA(1)===10?(this.line+=1,this.column=0):this.column+=1,e.consume()}getTokenName(e){return e===x.EOF?"EOF":"'"+String.fromCharCode(e)+"'"}matchATN(e){let t=this.atn.modeToStartState[this.mode];et.debug&&console.log("matchATN mode "+this.mode+" start: "+t);let s=this.mode,r=this.computeStartState(e,t),i=r.hasSemanticContext;r.hasSemanticContext=!1;let o=this.addDFAState(r);i||(this.decisionToDFA[this.mode].s0=o);let a=this.execATN(e,o);return et.debug&&console.log("DFA after matchATN: "+this.decisionToDFA[s].toLexerString()),a}execATN(e,t){et.debug&&console.log("start state closure="+t.configs),t.isAcceptState&&this.captureSimState(e,t);let s=e.LA(1);for(;;){et.debug&&console.log("execATN loop starting closure: "+t.configs);let r=this.getExistingTargetState(t,s);if(r||(r=this.computeTargetState(e,t,s)),r===Dt.ERROR||(s!==x.EOF&&this.consume(e),r.isAcceptState&&(this.captureSimState(e,r),s===x.EOF)))break;s=e.LA(1),t=r}return this.failOrAccept(e,t.configs,s)}getExistingTargetState(e,t){if(t>=this.options.minDFAEdge&&t<=this.options.maxDFAEdge){let s=e.edges[t-this.options.minDFAEdge];return et.debug&&s&&console.log("reuse state "+e.stateNumber+" edge to "+s.stateNumber),s}}computeTargetState(e,t,s){let r=new Zd;return this.getReachableConfigSet(e,t.configs,r,s),r.length===0?(r.hasSemanticContext||this.addDFAEdge(t,s,Dt.ERROR),Dt.ERROR):this.addDFAEdge(t,s,null,r)}failOrAccept(e,t,s){if(this.prevAccept?.dfaState){let{dfaState:r,index:i,line:o,column:a}=this.prevAccept;return this.accept(e,r.lexerActionExecutor,this.startIndex,i,o,a),r.prediction}if(s===x.EOF&&e.index===this.startIndex)return x.EOF;throw new wo(this.recognizer,e,this.startIndex,t)}getReachableConfigSet(e,t,s,r){let i=Z.INVALID_ALT_NUMBER;for(let o of t){let a=o.alt===i;if(!(a&&o.passedThroughNonGreedyDecision)){et.debug&&console.log(`testing %s at %s
27
+ `,this.getTokenName(r),o.toString(this.recognizer,!0));for(let c of o.state.transitions){let l=this.getReachableTarget(c,r);if(l){let u=o.lexerActionExecutor;u&&(u=u.fixOffsetBeforeMatch(e.index-this.startIndex));let d=r===x.EOF,h=Ot.createWithExecutor(o,l,u);this.closure(e,h,s,a,!0,d)&&(i=o.alt)}}}}}accept(e,t,s,r,i,o){et.debug&&console.log(`ACTION %s
28
+ `,t),e.seek(r),this.line=i,this.column=o,t&&this.recognizer&&t.execute(this.recognizer,e,s)}getReachableTarget(e,t){if(e.matches(t,this.options.minCodePoint,this.options.maxCodePoint))return e.target}computeStartState(e,t){let s=ye.instance,r=new Zd;for(let i=0;i<t.transitions.length;i++){let o=t.transitions[i].target,a=Ot.createWithContext(o,i+1,s);this.closure(e,a,r,!1,!1,!1)}return r}closure(e,t,s,r,i,o){let a=null;if(et.debug&&console.log("closure("+t.toString(this.recognizer,!0)+")"),t.state.constructor.stateType===L.RULE_STOP){if(et.debug&&(this.recognizer!==null?console.log(`closure at %s rule stop %s
29
+ `,this.recognizer.ruleNames[t.state.ruleIndex],t):console.log(`closure at rule stop %s
30
+ `,t)),!t.context||t.context.hasEmptyPath()){if(!t.context||t.context.isEmpty())return s.add(t),!0;s.add(Ot.createWithConfig(t.state,t,ye.instance)),r=!0}if(t.context&&!t.context.isEmpty()){for(let c=0;c<t.context.length;c++)if(t.context.getReturnState(c)!==ve.EMPTY_RETURN_STATE){let l=t.context.getParent(c),u=this.atn.states[t.context.getReturnState(c)];a=Ot.createWithConfig(u,t,l),r=this.closure(e,a,s,r,i,o)}}return r}t.state.epsilonOnlyTransitions||(!r||!t.passedThroughNonGreedyDecision)&&s.add(t);for(let c of t.state.transitions)a=this.getEpsilonTarget(e,t,c,s,i,o),a&&(r=this.closure(e,a,s,r,i,o));return r}getEpsilonTarget(e,t,s,r,i,o){this.lexerATNConfigFactory||this.setupATNFactoryLookup();let a=this.lexerATNConfigFactory[s.transitionType];return a?a(e,t,s,r,i,o):null}setupATNFactoryLookup(){this.lexerATNConfigFactory=[],this.lexerATNConfigFactory[N.RULE]=(t,s,r)=>{let i=ls(s.context??void 0,r.followState.stateNumber);return Ot.createWithConfig(r.target,s,i)},this.lexerATNConfigFactory[N.PRECEDENCE]=()=>{throw new Error("Precedence predicates are not supported in lexers.")},this.lexerATNConfigFactory[N.PREDICATE]=(t,s,r,i,o)=>{let a=r;return et.debug&&console.log("EVAL rule "+a.ruleIndex+":"+a.predIndex),i.hasSemanticContext=!0,this.evaluatePredicate(t,a.ruleIndex,a.predIndex,o)?Ot.createWithConfig(r.target,s):null},this.lexerATNConfigFactory[N.ACTION]=(t,s,r)=>{if(s.context===null||s.context.hasEmptyPath()){let i=v0.append(s.lexerActionExecutor,this.atn.lexerActions[r.actionIndex]);return Ot.createWithExecutor(s,r.target,i)}else return Ot.createWithConfig(r.target,s)},this.lexerATNConfigFactory[N.EPSILON]=(t,s,r)=>Ot.createWithConfig(r.target,s);let e=y((t,s,r,i,o,a)=>a&&r.matches(x.EOF,this.options.minCodePoint,this.options.maxCodePoint)?Ot.createWithConfig(r.target,s):null,"simple");this.lexerATNConfigFactory[N.ATOM]=e,this.lexerATNConfigFactory[N.RANGE]=e,this.lexerATNConfigFactory[N.SET]=e}evaluatePredicate(e,t,s,r){if(!this.recognizer)return!0;if(!r)return this.recognizer.sempred(null,t,s);let i=this.column,o=this.line,a=e.index,c=e.mark();try{return this.consume(e),this.recognizer.sempred(null,t,s)}finally{this.column=i,this.line=o,e.seek(a),e.release(c)}}captureSimState(e,t){this.prevAccept={index:e.index,line:this.line,column:this.column,dfaState:t}}addDFAEdge(e,t,s,r){if(!s&&r){let i=r.hasSemanticContext;if(r.hasSemanticContext=!1,s=this.addDFAState(r),i)return s}return t<this.options.minDFAEdge||t>this.options.maxDFAEdge||(et.debug&&console.log("EDGE "+e+" -> "+s+" upon "+t),e.edges[t-this.options.minDFAEdge]=s),s}addDFAState(e){let t=this.decisionToDFA[this.mode],s=t.getStateForConfigs(e);if(s)return s;let r=nr.fromConfigs(e),i=e.firstStopState;return i&&(r.isAcceptState=!0,r.lexerActionExecutor=i.lexerActionExecutor,r.prediction=this.atn.ruleToTokenType[i.state.ruleIndex]),e.setReadonly(!0),t.addState(r),r}},C0=class{static{y(this,"ParseInfo")}atnSimulator;constructor(n){this.atnSimulator=n}getDecisionInfo(){return this.atnSimulator.getDecisionInfo()}getLLDecisions(){let n=this.atnSimulator.getDecisionInfo(),e=new Array;for(let t=0;t<n.length;t++)n[t].llFallback>0&&e.push(t);return e}getTotalTimeInPrediction(){let n=this.atnSimulator.getDecisionInfo(),e=0;for(let t of n)e+=t.timeInPrediction;return e}getTotalSLLLookaheadOps(){let n=this.atnSimulator.getDecisionInfo(),e=0;for(let t of n)e+=t.sllTotalLook;return e}getTotalLLLookaheadOps(){let n=this.atnSimulator.getDecisionInfo(),e=0;for(let t of n)e+=t.llTotalLook;return e}getTotalSLLATNLookaheadOps(){let n=this.atnSimulator.getDecisionInfo(),e=0;for(let t of n)e+=t.sllATNTransitions;return e}getTotalLLATNLookaheadOps(){let n=this.atnSimulator.getDecisionInfo(),e=0;for(let t of n)e+=t.llATNTransitions;return e}getTotalATNLookaheadOps(){let n=this.atnSimulator.getDecisionInfo(),e=0;for(let t of n)e+=t.sllATNTransitions,e+=t.llATNTransitions;return e}getDFASize(n){if(n===void 0){let e=0,t=this.atnSimulator.decisionToDFA;for(let s=0;s<t.length;s++)e+=this.getDFASize(s);return e}else return this.atnSimulator.decisionToDFA[n].length}},ds=class extends ie{static{y(this,"NoViableAltException")}deadEndConfigs=null;startToken;constructor(n,e=null,t=null,s=null,r=null,i=null){i=i??n.context,s=s??n.getCurrentToken(),t=t??n.getCurrentToken(),e=e??n.inputStream,super({message:"",recognizer:n,input:e,ctx:i}),this.deadEndConfigs=r,this.startToken=t,this.offendingToken=s}},Hd=class{static{y(this,"DoubleDict")}cacheMap;constructor(){this.cacheMap=new sn}get(n,e){let t=this.cacheMap.get(n)??null;return t===null?null:t.get(e)??null}set(n,e,t){let s=this.cacheMap.get(n);s||(s=new sn,this.cacheMap.set(n,s)),s.set(e,t)}},T0=class Df{static{y(this,"SubsetEqualityComparer")}static instance=new Df;hashCode(e){let t=C.initialize(7);return t=C.update(t,e.state.stateNumber),t=C.updateFromComparable(t,e.context),t=C.finish(t,2),t}equals(e,t){return e.state.stateNumber===t.state.stateNumber&&(e.context?.equals(t.context)??!0)}},Te=class tn{static{y(this,"PredictionMode")}static SLL=0;static LL=1;static LL_EXACT_AMBIG_DETECTION=2;static hasSLLConflictTerminatingPrediction(e,t){if(tn.allConfigsInRuleStopStates(t))return!0;if(e===tn.SLL&&t.hasSemanticContext){let r=new nn;for(let i of t)i=ge.duplicate(i,J.NONE),r.add(i);t=r}let s=tn.getConflictingAltSubsets(t);return tn.hasConflictingAltSet(s)&&!tn.hasStateAssociatedWithOneAlt(t)}static hasConfigInRuleStopState(e){for(let t of e)if(t.state instanceof pt)return!0;return!1}static allConfigsInRuleStopStates(e){for(let t of e)if(!(t.state instanceof pt))return!1;return!0}static resolvesToJustOneViableAlt(e){return tn.getSingleViableAlt(e)}static allSubsetsConflict(e){return!tn.hasNonConflictingAltSet(e)}static hasNonConflictingAltSet(e){for(let t of e)if(t.length===1)return!0;return!1}static hasConflictingAltSet(e){for(let t of e)if(t.length>1)return!0;return!1}static allSubsetsEqual(e){let t=null;for(let s of e)if(t===null)t=s;else if(s!==t)return!1;return!0}static getUniqueAlt(e){let t=tn.getAlts(e);return t.length===1?t.nextSetBit(0):Z.INVALID_ALT_NUMBER}static getAlts(e){let t=new Lt;return e.forEach(s=>{t.or(s)}),t}static getConflictingAltSubsets(e){let t=new sn(T0.instance);for(let s of e){let r=t.get(s);r||(r=new Lt,t.set(s,r)),r.set(s.alt)}return Array.from(t.values())}static getStateToAltMap(e){let t=new sn(cs.instance);for(let s of e){let r=t.get(s.state);r||(r=new Lt,t.set(s.state,r)),r.set(s.alt)}return t}static hasStateAssociatedWithOneAlt(e){let t={};for(let s of e){let r=s.state.stateNumber;t[r]||(t[r]=0),t[r]++}return Object.values(t).some(s=>s===1)}static getSingleViableAlt(e){let t=null;for(let s of e){let r=s.nextSetBit(0);if(t===null)t=r;else if(t!==r)return Z.INVALID_ALT_NUMBER}return t??0}},ti=class F extends Dt{static{y(this,"ParserATNSimulator")}static traceATNSimulator=!1;static debug;static debugAdd=!1;static debugClosure=!1;static dfaDebug=!1;static retryDebug=!1;predictionMode;decisionToDFA;parser;mergeCache=new Hd;predictionState;constructor(e,t,s,r){super(t,r),this.parser=e,this.decisionToDFA=s}static getUniqueAlt(e){let t=Z.INVALID_ALT_NUMBER;for(let s of e)if(t===Z.INVALID_ALT_NUMBER)t=s.alt;else if(s.alt!==t)return Z.INVALID_ALT_NUMBER;return t}reset(){}clearDFA(){for(let e=0;e<this.decisionToDFA.length;e++)this.decisionToDFA[e]=new rn(this.atn.getDecisionState(e),e)}adaptivePredict(e,t,s){(F.debug||F.traceATNSimulator)&&console.log("adaptivePredict decision "+t+" exec LA(1)=="+this.getLookaheadName(e)+" line "+e.LT(1).line+":"+e.LT(1).column);let r=this.decisionToDFA[t];this.predictionState={input:e,startIndex:e.index,outerContext:s??void 0,dfa:r};let i=e.mark(),o=e.index;try{let a;if(r.isPrecedenceDfa?a=r.getPrecedenceStartState(this.parser.getPrecedence()):a=r.s0,!a){s||(s=K.empty),F.debug&&console.log("predictATN decision "+r.decision+" exec LA(1)=="+this.getLookaheadName(e)+", outerContext="+s.toString(this.parser.ruleNames));let u=this.computeStartState(r.atnStartState,K.empty,!1);r.isPrecedenceDfa?(u=this.applyPrecedenceFilter(u),a=this.addDFAState(r,nr.fromConfigs(u)),r.setPrecedenceStartState(this.parser.getPrecedence(),a)):(a=this.addDFAState(r,nr.fromConfigs(u)),r.s0=a)}let c=this.execATN(r,a,e,o,s);return F.debug&&console.log("DFA after predictATN: "+r.toString(this.parser.vocabulary)),c}finally{this.predictionState.dfa=void 0,this.mergeCache=new Hd,e.seek(o),e.release(i)}}execATN(e,t,s,r,i){(F.debug||F.traceATNSimulator)&&console.log("execATN decision "+e.decision+", DFA state "+t+", LA(1)=="+this.getLookaheadName(s)+" line "+s.LT(1).line+":"+s.LT(1).column);let o,a=t,c=s.LA(1);for(;;){let l=this.getExistingTargetState(a,c);if(l||(l=this.computeTargetState(e,a,c)),l===Dt.ERROR){let u=this.noViableAlt(s,i,a.configs,r);if(s.seek(r),o=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(a.configs,i),o!==Z.INVALID_ALT_NUMBER)return o;throw u}if(l.requiresFullContext&&this.predictionMode!==Te.SLL){let u=null;if(l.predicates!==null){F.debug&&console.log("DFA state has preds in DFA sim LL failover");let p=s.index;if(p!==r&&s.seek(r),u=this.evalSemanticContext(l.predicates,i,!0),u.length===1)return F.debug&&console.log("Full LL avoided"),u.nextSetBit(0);p!==r&&s.seek(p)}F.dfaDebug&&console.log("ctx sensitive state "+i+" in "+l);let h=this.computeStartState(e.atnStartState,i,!0);return this.reportAttemptingFullContext(e,u,l.configs,r,s.index),o=this.execATNWithFullContext(e,l,h,s,r,i),o}if(l.isAcceptState){if(l.predicates===null)return l.prediction;let u=s.index;s.seek(r);let d=this.evalSemanticContext(l.predicates,i,!0);if(d.length===0)throw this.noViableAlt(s,i,l.configs,r);return d.length===1||this.reportAmbiguity(e,l,r,u,!1,d,l.configs),d.nextSetBit(0)}a=l,c!==x.EOF&&(s.consume(),c=s.LA(1))}}getExistingTargetState(e,t){return e.edges[t+1]}computeTargetState(e,t,s){let r=this.computeReachSet(t.configs,s,!1);if(r===null)return this.addDFAEdge(e,t,s,Dt.ERROR),Dt.ERROR;let i=nr.fromConfigs(r),o=F.getUniqueAlt(r);if(F.debug){let a=Te.getConflictingAltSubsets(r);console.log("SLL altSubSets="+er(a)+", configs="+r+", predict="+o+", allSubsetsConflict="+Te.allSubsetsConflict(a)+", conflictingAlts="+this.getConflictingAlts(r))}return o!==Z.INVALID_ALT_NUMBER?(i.isAcceptState=!0,i.configs.uniqueAlt=o,i.prediction=o):Te.hasSLLConflictTerminatingPrediction(this.predictionMode,r)&&(i.configs.conflictingAlts=this.getConflictingAlts(r),i.requiresFullContext=!0,i.isAcceptState=!0,i.prediction=i.configs.conflictingAlts.nextSetBit(0)),i.isAcceptState&&i.configs.hasSemanticContext&&(this.predicateDFAState(i,this.atn.getDecisionState(e.decision)),i.predicates!==null&&(i.prediction=Z.INVALID_ALT_NUMBER)),i=this.addDFAEdge(e,t,s,i),i}getRuleName(e){return this.parser!==null&&e>=0?this.parser.ruleNames[e]:"<rule "+e+">"}getTokenName(e){if(e===x.EOF)return"EOF";let s=(this.parser?.vocabulary??yt.EMPTY_VOCABULARY).getDisplayName(e);return s===e.toString()?s:s+"<"+e+">"}getLookaheadName(e){return this.getTokenName(e.LA(1))}dumpDeadEndConfigs(e){console.log("dead end configs: ");let t=e.deadEndConfigs;for(let s of t){let r="no edges";if(s.state.transitions.length>0){let i=s.state.transitions[0];i instanceof Jr?r="Atom "+this.getTokenName(i.labelValue):i instanceof kc&&(r=(i instanceof Rc?"~":"")+"Set "+i.label)}console.error(s.toString(this.parser,!0)+":"+r)}}predicateDFAState(e,t){let s=t.transitions.length,r=this.getConflictingAltsOrUniqueAlt(e.configs),i=this.getPredsForAmbigAlts(r,e.configs,s);i!==null?(e.predicates=this.getPredicatePredictions(r,i),e.prediction=Z.INVALID_ALT_NUMBER):e.prediction=r.nextSetBit(0)}execATNWithFullContext(e,t,s,r,i,o){(F.debug||F.traceATNSimulator)&&console.log("execATNWithFullContext "+s);let a=!0,c=!1,l,u=s;r.seek(i);let d=r.LA(1),h=-1;for(;;){if(l=this.computeReachSet(u,d,a),l===null){let m=this.noViableAlt(r,o,u,i);r.seek(i);let g=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(u,o);if(g!==Z.INVALID_ALT_NUMBER)return g;throw m}let p=Te.getConflictingAltSubsets(l);if(F.debug&&console.log("LL altSubSets="+p+", predict="+Te.getUniqueAlt(p)+", resolvesToJustOneViableAlt="+Te.resolvesToJustOneViableAlt(p)),l.uniqueAlt=F.getUniqueAlt(l),l.uniqueAlt!==Z.INVALID_ALT_NUMBER){h=l.uniqueAlt;break}else if(this.predictionMode!==Te.LL_EXACT_AMBIG_DETECTION){if(h=Te.resolvesToJustOneViableAlt(p),h!==Z.INVALID_ALT_NUMBER)break}else if(Te.allSubsetsConflict(p)&&Te.allSubsetsEqual(p)){c=!0,h=Te.getSingleViableAlt(p);break}u=l,d!==x.EOF&&(r.consume(),d=r.LA(1))}return l.uniqueAlt!==Z.INVALID_ALT_NUMBER?(this.reportContextSensitivity(e,h,l,i,r.index),h):(this.reportAmbiguity(e,t,i,r.index,c,l.getAlts(),l),h)}computeReachSet(e,t,s){F.debug&&console.log("in computeReachSet, starting closure: "+e);let r=new nn(s),i=null;for(let a of e){if(F.debug&&console.log("testing "+this.getTokenName(t)+" at "+a),a.state instanceof pt){(s||t===x.EOF)&&(i===null&&(i=[]),i.push(a));continue}for(let c of a.state.transitions){let l=this.getReachableTarget(c,t);if(l!==null){let u=ge.createWithConfig(l,a);r.add(u,this.mergeCache),F.debugAdd&&console.log("added "+u+" to intermediate")}}}let o=null;if(i===null&&t!==x.EOF&&(r.length===1||F.getUniqueAlt(r)!==Z.INVALID_ALT_NUMBER)&&(o=r),o===null){o=new nn(s);let a=new tt,c=t===x.EOF;for(let l of r)this.closure(l,o,a,!1,s,c)}if(t===x.EOF&&(o=this.removeAllConfigsNotInRuleStopState(o,o===r)),i!==null&&(!s||!Te.hasConfigInRuleStopState(o)))for(let a of i)o.add(a,this.mergeCache);return F.traceATNSimulator&&console.log("computeReachSet "+e+" -> "+o),o.length===0?null:o}removeAllConfigsNotInRuleStopState(e,t){if(Te.allConfigsInRuleStopStates(e))return e;let s=new nn(e.fullCtx);for(let r of e){if(r.state instanceof pt){s.add(r,this.mergeCache);continue}if(t&&r.state.epsilonOnlyTransitions&&this.atn.nextTokens(r.state).contains(x.EPSILON)){let o=this.atn.ruleToStopState[r.state.ruleIndex];s.add(ge.createWithConfig(o,r),this.mergeCache)}}return s}computeStartState(e,t,s){let r=_c(this.atn,t),i=new nn(s);F.traceATNSimulator&&console.log("computeStartState from ATN state "+e+" initialContext="+r.toString(this.parser));for(let o=0;o<e.transitions.length;o++){let a=e.transitions[o].target,c=ge.createWithContext(a,o+1,r),l=new tt;this.closure(c,i,l,!0,s,!1)}return i}applyPrecedenceFilter(e){let t=[],s=new nn(e.fullCtx);for(let r of e){if(r.alt!==1)continue;let i=r.semanticContext.evalPrecedence(this.parser,this.predictionState.outerContext);i!==null&&(t[r.state.stateNumber]=r.context,i!==r.semanticContext?s.add(ge.duplicate(r,i),this.mergeCache):s.add(r,this.mergeCache))}for(let r of e)if(r.alt!==1){if(!r.precedenceFilterSuppressed){let i=t[r.state.stateNumber]||null;if(i!==null&&i.equals(r.context))continue}s.add(r,this.mergeCache)}return s}getReachableTarget(e,t){return e.matches(t,0,this.atn.maxTokenType)?e.target:null}getPredsForAmbigAlts(e,t,s){let r=[];for(let o of t)e.get(o.alt)&&(r[o.alt]=J.orContext(r[o.alt]??null,o.semanticContext));let i=0;for(let o=1;o<s+1;o++){let a=r[o]??null;a===null?r[o]=J.NONE:a!==J.NONE&&(i+=1)}return i===0&&(r=null),F.debug&&console.log("getPredsForAmbigAlts result "+er(r)),r}getPredicatePredictions(e,t){let s=[],r=!1;for(let i=1;i<t.length;i++){let o=t[i];e.get(i)&&s.push({pred:o,alt:i}),o!==J.NONE&&(r=!0)}return r?s:null}getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(e,t){let s=this.splitAccordingToSemanticValidity(e,t),r=s[0],i=s[1],o=this.getAltThatFinishedDecisionEntryRule(r);return o!==Z.INVALID_ALT_NUMBER||i.length>0&&(o=this.getAltThatFinishedDecisionEntryRule(i),o!==Z.INVALID_ALT_NUMBER)?o:Z.INVALID_ALT_NUMBER}getAltThatFinishedDecisionEntryRule(e){let t=[];for(let s of e)(s.reachesIntoOuterContext||s.state instanceof pt&&s.context.hasEmptyPath())&&t.indexOf(s.alt)<0&&t.push(s.alt);return t.length===0?Z.INVALID_ALT_NUMBER:Math.min(...t)}splitAccordingToSemanticValidity(e,t){let s=new nn(e.fullCtx),r=new nn(e.fullCtx);for(let i of e)i.semanticContext!==J.NONE?i.semanticContext.evaluate(this.parser,t)?s.add(i):r.add(i):s.add(i);return[s,r]}evalSemanticContext(e,t,s){let r=new Lt;for(let i of e){if(i.pred===J.NONE){if(r.set(i.alt),!s)break;continue}let o=i.pred.evaluate(this.parser,t);if((F.debug||F.dfaDebug)&&console.log("eval pred "+i+"="+o),o&&(r.set(i.alt),!s))break}return r}closure(e,t,s,r,i,o){this.closureCheckingStopState(e,t,s,r,i,0,o)}closureCheckingStopState(e,t,s,r,i,o,a){if((F.traceATNSimulator||F.debugClosure)&&console.log("closure("+e.toString(this.parser,!0)+")"),e.state instanceof pt)if(e.context&&!e.context.isEmpty()){for(let c=0;c<e.context.length;c++){if(e.context.getReturnState(c)===ve.EMPTY_RETURN_STATE){if(i){t.add(ge.createWithConfig(e.state,e,ye.instance),this.mergeCache);continue}else F.debug&&console.log("FALLING off rule "+this.getRuleName(e.state.ruleIndex)),this.closure_(e,t,s,r,i,o,a);continue}let l=this.atn.states[e.context.getReturnState(c)],u=e.context.getParent(c),d=ge.createWithContext(l,e.alt,u,e.semanticContext);d.reachesIntoOuterContext=e.reachesIntoOuterContext,this.closureCheckingStopState(d,t,s,r,i,o-1,a)}return}else if(i){t.add(e,this.mergeCache);return}else F.debug&&console.log("FALLING off rule "+this.getRuleName(e.state.ruleIndex));this.closure_(e,t,s,r,i,o,a)}closure_(e,t,s,r,i,o,a){let c=e.state;c.epsilonOnlyTransitions||t.add(e,this.mergeCache);for(let l=0;l<c.transitions.length;l++){if(l===0&&this.canDropLoopEntryEdgeInLeftRecursiveRule(e))continue;let u=c.transitions[l],d=r&&!(u instanceof hf),h=this.getEpsilonTarget(e,u,d,o===0,i,a);if(h){let p=o;if(e.state.constructor.stateType===L.RULE_STOP){if(this.predictionState.dfa&&this.predictionState?.dfa.isPrecedenceDfa&&u.outermostPrecedenceReturn===this.predictionState?.dfa.atnStartState?.ruleIndex&&(h.precedenceFilterSuppressed=!0),h.reachesIntoOuterContext=!0,s.getOrAdd(h)!==h)continue;t.dipsIntoOuterContext=!0,p-=1,F.debug&&console.log("dips into outer ctx: "+h)}else{if(!u.isEpsilon&&s.getOrAdd(h)!==h)continue;u instanceof Ec&&p>=0&&(p+=1)}this.closureCheckingStopState(h,t,s,d,i,p,a)}}}canDropLoopEntryEdgeInLeftRecursiveRule(e){let t=e.state;if(t.constructor.stateType!==L.STAR_LOOP_ENTRY||!e.context||!t.precedenceRuleDecision||e.context.isEmpty()||e.context.hasEmptyPath())return!1;let s=e.context.length;for(let a=0;a<s;a++)if(this.atn.states[e.context.getReturnState(a)].ruleIndex!==t.ruleIndex)return!1;let i=t.transitions[0].target.endState.stateNumber,o=this.atn.states[i];for(let a=0;a<s;a++){let c=e.context.getReturnState(a),l=this.atn.states[c];if(l.transitions.length!==1||!l.transitions[0].isEpsilon)return!1;let u=l.transitions[0].target;if(!(l.constructor.stateType===L.BLOCK_END&&u===t)&&l!==o&&u!==o&&!(u.constructor.stateType===L.BLOCK_END&&u.transitions.length===1&&u.transitions[0].isEpsilon&&u.transitions[0].target===t))return!1}return!0}getEpsilonTarget(e,t,s,r,i,o){switch(t.transitionType){case N.RULE:return this.ruleTransition(e,t);case N.PRECEDENCE:return this.precedenceTransition(e,t,s,r,i);case N.PREDICATE:return this.predTransition(e,t,s,r,i);case N.ACTION:{if(F.debug){let a=t,c=a.actionIndex===-1?65535:a.actionIndex;console.log("ACTION edge "+a.ruleIndex+":"+c)}return ge.createWithConfig(t.target,e)}case N.EPSILON:return ge.createWithConfig(t.target,e);case N.ATOM:case N.RANGE:case N.SET:return o&&t.matches(x.EOF,0,1)?ge.createWithConfig(t.target,e):null;default:return null}}precedenceTransition(e,t,s,r,i){F.debug&&(console.log("PRED (collectPredicates="+s+") "+t.precedence+">=_p, ctx dependent=true"),this.parser!==null&&console.log("context surrounding pred is "+er(this.parser.getRuleInvocationStack())));let o=null;if(s&&r)if(i&&this.predictionState?.input){let a=this.predictionState.input.index;this.predictionState.input.seek(this.predictionState.startIndex);let c=t.getPredicate().evaluate(this.parser,this.predictionState.outerContext);this.predictionState.input.seek(a),c&&(o=ge.createWithConfig(t.target,e))}else{let a=J.andContext(e.semanticContext,t.getPredicate());o=ge.createWithSemanticContext(t.target,e,a)}else o=ge.createWithConfig(t.target,e);return F.debug&&console.log("config from pred transition="+o),o}predTransition(e,t,s,r,i){F.debug&&(console.log("PRED (collectPredicates="+s+") "+t.ruleIndex+":"+t.predIndex+", ctx dependent="+t.isCtxDependent),this.parser!==null&&console.log("context surrounding pred is "+er(this.parser.getRuleInvocationStack())));let o=null;if(s&&(t.isCtxDependent&&r||!t.isCtxDependent))if(i&&this.predictionState?.input){let a=this.predictionState.input.index;this.predictionState.input.seek(this.predictionState.startIndex);let c=t.getPredicate().evaluate(this.parser,this.predictionState.outerContext);this.predictionState.input.seek(a),c&&(o=ge.createWithConfig(t.target,e))}else{let a=J.andContext(e.semanticContext,t.getPredicate());o=ge.createWithSemanticContext(t.target,e,a)}else o=ge.createWithConfig(t.target,e);return F.debug&&console.log("config from pred transition="+o),o}ruleTransition(e,t){F.debug&&console.log("CALL rule "+this.getRuleName(t.target.ruleIndex)+", ctx="+e.context);let s=t.followState,r=ls(e.context??void 0,s.stateNumber);return ge.createWithConfig(t.target,e,r)}getConflictingAlts(e){let t=Te.getConflictingAltSubsets(e);return Te.getAlts(t)}getConflictingAltsOrUniqueAlt(e){let t;return e.uniqueAlt!==Z.INVALID_ALT_NUMBER?(t=new Lt,t.set(e.uniqueAlt)):t=e.conflictingAlts,t}noViableAlt(e,t,s,r){return new ds(this.parser,e,e.get(r),e.LT(1),s,t)}addDFAEdge(e,t,s,r){return F.debug&&console.log("EDGE "+t+" -> "+r+" upon "+this.getTokenName(s)),r=this.addDFAState(e,r),s<-1||s>this.atn.maxTokenType||(F.debug&&console.log(`DFA=
31
+ `+e.toString(this.parser!=null?this.parser.vocabulary:yt.EMPTY_VOCABULARY)),t.edges[s+1]=r),r}addDFAState(e,t){if(t===Dt.ERROR)return t;let s=e.getState(t);return s!==null?s:(t.configs.readOnly||(t.configs.optimizeConfigs(this),t.configs.setReadonly(!0)),F.traceATNSimulator&&console.log("addDFAState new "+t),e.addState(t),t)}reportAttemptingFullContext(e,t,s,r,i){if(F.debug||F.retryDebug){let o=new Y(r,i+1);console.log("reportAttemptingFullContext decision="+e.decision+":"+s+", input="+this.parser.tokenStream.getTextFromInterval(o))}this.parser.errorListenerDispatch.reportAttemptingFullContext(this.parser,e,r,i,t,s)}reportContextSensitivity(e,t,s,r,i){if(F.debug||F.retryDebug){let o=new Y(r,i+1);console.log("reportContextSensitivity decision="+e.decision+":"+s+", input="+this.parser.tokenStream.getTextFromInterval(o))}this.parser.errorListenerDispatch.reportContextSensitivity(this.parser,e,r,i,t,s)}reportAmbiguity(e,t,s,r,i,o,a){if(F.debug||F.retryDebug){let c=new Y(s,r+1);console.log("reportAmbiguity "+o+":"+a+", input="+this.parser.tokenStream.getTextFromInterval(c))}this.parser.errorListenerDispatch.reportAmbiguity(this.parser,e,s,r,i,o,a)}},fs=class{static{y(this,"PredictionContextCache")}cache=new sn(cs.instance);add(n){if(n===ye.instance)return n;let e=this.cache.get(n);return e||(this.cache.set(n,n),n)}get(n){return this.cache.get(n)}get length(){return this.cache.size}},So=class extends ti{static{y(this,"ProfilingATNSimulator")}decisions;numDecisions=0;currentDecision=0;currentState;conflictingAltResolvedBySLL;sllStopIndex=0;llStopIndex=0;constructor(n){let e=n.interpreter.sharedContextCache;if(super(n,n.interpreter.atn,n.interpreter.decisionToDFA,e),e){this.numDecisions=this.atn.decisionToState.length,this.decisions=new Array(this.numDecisions);for(let t=0;t<this.numDecisions;t++)this.decisions[t]=new x0(t)}}adaptivePredict(n,e,t){try{this.sllStopIndex=-1,this.llStopIndex=-1,this.currentDecision=e;let s=performance.now(),r=super.adaptivePredict(n,e,t),i=performance.now();this.decisions[e].timeInPrediction+=i-s,this.decisions[e].invocations++;let o=this.sllStopIndex-this.predictionState.startIndex+1;if(this.decisions[e].sllTotalLook+=o,this.decisions[e].sllMinLook=this.decisions[e].sllMinLook===0?o:Math.min(this.decisions[e].sllMinLook,o),o>this.decisions[e].sllMaxLook&&(this.decisions[e].sllMaxLook=o,this.decisions[e].sllMaxLookEvent={decision:e,configs:null,predictedAlt:r,input:n,startIndex:this.predictionState.startIndex,stopIndex:this.sllStopIndex,fullCtx:!1}),this.llStopIndex>=0){let a=this.llStopIndex-this.predictionState.startIndex+1;this.decisions[e].llTotalLook+=a,this.decisions[e].llMinLook=this.decisions[e].llMinLook===0?a:Math.min(this.decisions[e].llMinLook,a),a>this.decisions[e].llMaxLook&&(this.decisions[e].llMaxLook=a,this.decisions[e].llMaxLookEvent={decision:e,configs:null,predictedAlt:r,input:n,startIndex:this.predictionState.startIndex,stopIndex:this.llStopIndex,fullCtx:!0})}return r}finally{this.currentDecision=-1}}getExistingTargetState(n,e){this.sllStopIndex=this.predictionState.input.index;let t=super.getExistingTargetState(n,e);return t!==void 0&&(this.decisions[this.currentDecision].sllDFATransitions++,t===Dt.ERROR&&this.decisions[this.currentDecision].errors.push({decision:this.currentDecision,configs:n.configs,input:this.predictionState.input,startIndex:this.predictionState.startIndex,stopIndex:this.sllStopIndex,fullCtx:!1})),this.currentState=t,t}computeTargetState(n,e,t){let s=super.computeTargetState(n,e,t);return this.currentState=s,s}computeReachSet(n,e,t){t&&this.predictionState?.input&&(this.llStopIndex=this.predictionState.input.index);let s=super.computeReachSet(n,e,t);return this.predictionState?.input&&(t?(this.decisions[this.currentDecision].llATNTransitions++,s===null&&this.decisions[this.currentDecision].errors.push({decision:this.currentDecision,configs:n,input:this.predictionState.input,startIndex:this.predictionState.startIndex,stopIndex:this.sllStopIndex,fullCtx:!0})):(this.decisions[this.currentDecision].sllATNTransitions++,s===null&&this.decisions[this.currentDecision].errors.push({decision:this.currentDecision,configs:n,input:this.predictionState.input,startIndex:this.predictionState.startIndex,stopIndex:this.sllStopIndex,fullCtx:!1}))),s}reportAttemptingFullContext(n,e,t,s,r){e!==null?this.conflictingAltResolvedBySLL=e.nextSetBit(0):this.conflictingAltResolvedBySLL=t.getAlts().nextSetBit(0),this.decisions[this.currentDecision].llFallback++,e&&super.reportAttemptingFullContext(n,e,t,s,r)}reportContextSensitivity(n,e,t,s,r){e!==this.conflictingAltResolvedBySLL&&this.predictionState.input&&this.decisions[this.currentDecision].contextSensitivities.push({decision:this.currentDecision,configs:t,input:this.predictionState.input,startIndex:s,stopIndex:r,fullCtx:!0}),super.reportContextSensitivity(n,e,t,s,r)}reportAmbiguity(n,e,t,s,r,i,o){let a;i?a=i.nextSetBit(0):a=o.getAlts().nextSetBit(0),this.predictionState?.input&&(o.fullCtx&&a!==this.conflictingAltResolvedBySLL&&this.decisions[this.currentDecision].contextSensitivities.push({decision:this.currentDecision,configs:o,input:this.predictionState.input,startIndex:t,stopIndex:s,fullCtx:!0}),this.decisions[this.currentDecision].ambiguities.push({ambigAlts:i,decision:this.currentDecision,configs:o,input:this.predictionState.input,startIndex:t,stopIndex:s,fullCtx:o.fullCtx})),super.reportAmbiguity(n,e,t,s,r,i,o)}getDecisionInfo(){return this.decisions}getCurrentState(){return this.currentState}},Gd;(n=>{n.toString=y(e=>`(${e.pred}, ${e.alt})`,"toString")})(Gd||(Gd={}));var Ic=class extends Error{static{y(this,"ParseCancellationException")}constructor(n){super(),this.cause=n}},bA=class{static{y(this,"InterpreterDataReader")}static parseInterpreterData(n){let e=[],t=[],s=[],r=[],i=[],o=n.split(`
32
+ `),a=0,c=o[a++];if(c!=="token literal names:")throw new Error("Unexpected data entry");do{if(c=o[a++],c.length===0)break;r.push(c==="null"?null:c)}while(!0);if(c=o[a++],c!=="token symbolic names:")throw new Error("Unexpected data entry");do{if(c=o[a++],c.length===0)break;i.push(c==="null"?null:c)}while(!0);if(c=o[a++],c!=="rule names:")throw new Error("Unexpected data entry");do{if(c=o[a++],c.length===0)break;e.push(c)}while(!0);if(c=o[a++],c==="channel names:"){do{if(c=o[a++],c.length===0)break;t.push(c)}while(!0);if(c=o[a++],c!=="mode names:")throw new Error("Unexpected data entry");do{if(c=o[a++],c.length===0)break;s.push(c)}while(!0)}if(c=o[a++],c!=="atn:")throw new Error("Unexpected data entry");c=o[a++];let l=c.split(","),u,d=[];for(let p=0;p<l.length;++p){let m=l[p];m.startsWith("[")?u=Number(m.substring(1).trim()):m.endsWith("]")?u=Number(m.substring(0,m.length-1).trim()):u=Number(m.trim()),d[p]=u}return{atn:new Tn().deserialize(d),vocabulary:new yt(r,i,[]),ruleNames:e,channels:t.length>0?t:void 0,modes:s.length>0?s:void 0}}},Lf=class{static{y(this,"AbstractParseTreeVisitor")}visit(n){return n.accept(this)}visitChildren(n){let e=this.defaultResult(),t=n.getChildCount();for(let s=0;s<t&&this.shouldVisitNextChild(n,e);s++){let r=n.getChild(s);if(r){let i=r.accept(this);e=this.aggregateResult(e,i)}}return e}visitTerminal(n){return this.defaultResult()}visitErrorNode(n){return this.defaultResult()}defaultResult(){return null}shouldVisitNextChild(n,e){return!0}aggregateResult(n,e){return e}},AA=class $f{static{y(this,"ParseTreeWalker")}static DEFAULT=new $f;walk(e,t){if(t instanceof Qr)e.visitErrorNode(t);else if(t instanceof gt)e.visitTerminal(t);else{let r=t;this.enterRule(e,r);for(let i=0;i<t.getChildCount();i++)this.walk(e,t.getChild(i));this.exitRule(e,r)}}enterRule(e,t){let s=t.ruleContext;e.enterEveryRule(s),s.enterRule(e)}exitRule(e,t){let s=t.ruleContext;s.exitRule(e),e.exitEveryRule(s)}},rr;(n=>{n.fromString=y(e=>new w0(e),"fromString")})(rr||(rr={}));var w0=class{static{y(this,"CharStreamImpl")}name="";index=0;data;constructor(n){let e=[];for(let t of n)e.push(t.codePointAt(0));this.data=new Uint32Array(e)}reset(){this.index=0}consume(){if(this.index>=this.data.length)throw new Error("cannot consume EOF");this.index+=1}LA(n){if(n===0)return 0;n<0&&(n+=1);let e=this.index+n-1;return e<0||e>=this.data.length?x.EOF:this.data[e]}mark(){return-1}release(n){}seek(n){if(n<=this.index){this.index=n;return}this.index=Math.min(n,this.data.length)}getTextFromRange(n,e){return e=e??this.data.length-1,e>=this.data.length&&(e=this.data.length-1),n>=this.data.length?"":this.stringFromRange(n,e+1)}getTextFromInterval(n){let e=n.start,t=n.stop;return t>=this.data.length&&(t=this.data.length-1),e>=this.data.length?"":this.stringFromRange(e,t+1)}toString(){return this.stringFromRange(0)}get size(){return this.data.length}getSourceName(){return this.name?this.name:Co.UNKNOWN_SOURCE_NAME}stringFromRange(n,e){let t=this.data.slice(n,e),s="";return t.forEach(r=>{s+=String.fromCodePoint(r)}),s}},Mf=y(n=>n.setText!==void 0,"isWritableToken"),I0=class{static{y(this,"BufferedTokenStream")}tokenSource;tokens=[];p=-1;fetchedEOF=!1;constructor(n){this.tokenSource=n}mark(){return 0}release(n){}reset(){this.seek(0)}seek(n){this.lazyInit(),this.p=this.adjustSeekIndex(n)}get size(){return this.tokens.length}get index(){return this.p}get(n){return this.lazyInit(),this.tokens[n]}consume(){let n=!1;if(this.p>=0?this.fetchedEOF?n=this.p<this.tokens.length-1:n=this.p<this.tokens.length:n=!1,!n&&this.LA(1)===x.EOF)throw new Error("cannot consume EOF");this.sync(this.p+1)&&(this.p=this.adjustSeekIndex(this.p+1))}sync(n){let e=n-this.tokens.length+1;return e>0?this.fetch(e)>=e:!0}fetch(n){if(this.fetchedEOF)return 0;for(let e=0;e<n;e++){let t=this.tokenSource.nextToken();if(Mf(t)&&(t.tokenIndex=this.tokens.length),this.tokens.push(t),t.type===x.EOF)return this.fetchedEOF=!0,e+1}return n}getTokens(n,e,t){if(this.lazyInit(),n===void 0&&e===void 0)return this.tokens;if(n??=0,e===void 0&&(e=this.tokens.length-1),n<0||e>=this.tokens.length||e<0||n>=this.tokens.length)throw new RangeError("start "+n+" or stop "+e+" not in 0.."+(this.tokens.length-1));if(n>e)return[];if(t===void 0)return this.tokens.slice(n,e+1);let s=[];e>=this.tokens.length&&(e=this.tokens.length-1);for(let r=n;r<e;r++){let i=this.tokens[r];if(i.type===x.EOF){s.push(i);break}t.has(i.type)&&s.push(i)}return s}LA(n){return this.LT(n)?.type??x.INVALID_TYPE}LB(n){return this.p-n<0?null:this.tokens[this.p-n]}LT(n){if(this.lazyInit(),n===0)return null;if(n<0)return this.LB(-n);let e=this.p+n-1;return this.sync(e),e>=this.tokens.length?this.tokens[this.tokens.length-1]:this.tokens[e]}adjustSeekIndex(n){return n}lazyInit(){this.p===-1&&this.setup()}setup(){this.sync(0),this.p=this.adjustSeekIndex(0)}setTokenSource(n){this.tokenSource=n,this.tokens=[],this.p=-1,this.fetchedEOF=!1}nextTokenOnChannel(n,e){if(this.sync(n),n>=this.tokens.length)return-1;let t=this.tokens[n];for(;t.channel!==e;){if(t.type===x.EOF)return-1;n+=1,this.sync(n),t=this.tokens[n]}return n}previousTokenOnChannel(n,e){if(n>=this.tokens.length)return this.tokens.length-1;for(;n>=0;){let t=this.tokens[n];if(t.type===x.EOF||t.channel===e)return n;--n}return n}getHiddenTokensToRight(n,e){if(e===void 0&&(e=-1),this.lazyInit(),n<0||n>=this.tokens.length)throw new Error(`${n} not in 0..${this.tokens.length-1}`);let t=this.nextTokenOnChannel(n+1,nt.DEFAULT_TOKEN_CHANNEL),s=n+1,r=t===-1?this.tokens.length-1:t;return this.filterForChannel(s,r,e)}getHiddenTokensToLeft(n,e){if(e===void 0&&(e=-1),this.lazyInit(),n<0||n>=this.tokens.length)throw new Error(`${n} not in 0..${this.tokens.length-1}`);let t=this.previousTokenOnChannel(n-1,nt.DEFAULT_TOKEN_CHANNEL);if(t===n-1)return;let s=t+1,r=n-1;return this.filterForChannel(s,r,e)}filterForChannel(n,e,t){let s=[];for(let r=n;r<e+1;r++){let i=this.tokens[r];t===-1?i.channel!==nt.DEFAULT_TOKEN_CHANNEL&&s.push(i):i.channel===t&&s.push(i)}if(s.length!==0)return s}getSourceName(){return this.tokenSource.sourceName}getText(){return this.getTextFromInterval(Y.of(0,this.size-1))}getTextFromInterval(n){let e=n.start,t=n.stop;if(e<0||t<0)return"";this.sync(t),t>=this.tokens.length&&(t=this.tokens.length-1);let s="";for(let r=e;r<=t;++r){let i=this.tokens[r];if(i.type===x.EOF)break;s+=i.text}return s}getTextFromContext(n){return this.getTextFromInterval(n.getSourceInterval())}getTextFromRange(n,e){return n!==null&&e!==null?this.getTextFromInterval(Y.of(n.tokenIndex,e.tokenIndex)):""}fill(){for(this.lazyInit();this.fetch(1e3)===1e3;);}setLine(n){this.tokenSource.line=n}setColumn(n){this.tokenSource.column=n}},ko=class extends I0{static{y(this,"CommonTokenStream")}channel=x.DEFAULT_CHANNEL;constructor(n,e){super(n),this.channel=e??x.DEFAULT_CHANNEL}adjustSeekIndex(n){return this.nextTokenOnChannel(n,this.channel)}LB(n){if(n===0||this.index-n<0)return null;let e=this.index,t=1;for(;t<=n;)e=this.previousTokenOnChannel(e-1,this.channel),t+=1;return e<0?null:this.tokens[e]}LT(n){if(this.lazyInit(),n===0)return null;if(n<0)return this.LB(-n);let e=this.index,t=1;for(;t<n;)this.sync(e+1)&&(e=this.nextTokenOnChannel(e+1,this.channel)),t+=1;return this.tokens[e]}getNumberOfOnChannelTokens(){let n=0;this.fill();for(let e of this.tokens)if(e.channel===this.channel&&(n+=1),e.type===x.EOF)break;return n}},ft=class me extends nt{static{y(this,"XPathLexer")}static TOKEN_REF=1;static RULE_REF=2;static ANYWHERE=3;static ROOT=4;static WILDCARD=5;static BANG=6;static ID=7;static STRING=8;static channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"];static literalNames=[null,null,null,"'//'","'/'","'*'","'!'"];static symbolicNames=[null,"TOKEN_REF","RULE_REF","ANYWHERE","ROOT","WILDCARD","BANG","ID","STRING"];static modeNames=["DEFAULT_MODE"];static ruleNames=["ANYWHERE","ROOT","WILDCARD","BANG","ID","NameChar","NameStartChar","STRING"];constructor(e){super(e),this.interpreter=new sr(this,me._ATN,me.decisionsToDFA,new fs)}get grammarFileName(){return"XPathLexer.g4"}get literalNames(){return me.literalNames}get symbolicNames(){return me.symbolicNames}get ruleNames(){return me.ruleNames}get serializedATN(){return me._serializedATN}get channelNames(){return me.channelNames}get modeNames(){return me.modeNames}action(e,t,s){t===4&&this.ID_action(e,s)}ID_action(e,t){if(t===0){let s=this.text;s.charAt(0)===s.charAt(0).toUpperCase()?this.type=me.TOKEN_REF:this.type=me.RULE_REF}}static _serializedATN=[4,0,8,48,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,1,0,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,5,4,29,8,4,10,4,12,4,32,9,4,1,4,1,4,1,5,1,5,1,6,1,6,1,7,1,7,5,7,42,8,7,10,7,12,7,45,9,7,1,7,1,7,1,43,0,8,1,3,3,4,5,5,7,6,9,7,11,0,13,0,15,8,1,0,2,784,0,0,8,14,27,48,57,65,90,95,95,97,122,127,159,170,170,173,173,181,181,186,186,192,214,216,246,248,705,710,721,736,740,748,748,750,750,768,884,886,887,890,893,895,895,902,902,904,906,908,908,910,929,931,1013,1015,1153,1155,1159,1162,1327,1329,1366,1369,1369,1376,1416,1425,1469,1471,1471,1473,1474,1476,1477,1479,1479,1488,1514,1519,1522,1536,1541,1552,1562,1564,1564,1568,1641,1646,1747,1749,1757,1759,1768,1770,1788,1791,1791,1807,1866,1869,1969,1984,2037,2042,2042,2045,2045,2048,2093,2112,2139,2144,2154,2160,2183,2185,2190,2192,2193,2200,2403,2406,2415,2417,2435,2437,2444,2447,2448,2451,2472,2474,2480,2482,2482,2486,2489,2492,2500,2503,2504,2507,2510,2519,2519,2524,2525,2527,2531,2534,2545,2556,2556,2558,2558,2561,2563,2565,2570,2575,2576,2579,2600,2602,2608,2610,2611,2613,2614,2616,2617,2620,2620,2622,2626,2631,2632,2635,2637,2641,2641,2649,2652,2654,2654,2662,2677,2689,2691,2693,2701,2703,2705,2707,2728,2730,2736,2738,2739,2741,2745,2748,2757,2759,2761,2763,2765,2768,2768,2784,2787,2790,2799,2809,2815,2817,2819,2821,2828,2831,2832,2835,2856,2858,2864,2866,2867,2869,2873,2876,2884,2887,2888,2891,2893,2901,2903,2908,2909,2911,2915,2918,2927,2929,2929,2946,2947,2949,2954,2958,2960,2962,2965,2969,2970,2972,2972,2974,2975,2979,2980,2984,2986,2990,3001,3006,3010,3014,3016,3018,3021,3024,3024,3031,3031,3046,3055,3072,3084,3086,3088,3090,3112,3114,3129,3132,3140,3142,3144,3146,3149,3157,3158,3160,3162,3165,3165,3168,3171,3174,3183,3200,3203,3205,3212,3214,3216,3218,3240,3242,3251,3253,3257,3260,3268,3270,3272,3274,3277,3285,3286,3293,3294,3296,3299,3302,3311,3313,3315,3328,3340,3342,3344,3346,3396,3398,3400,3402,3406,3412,3415,3423,3427,3430,3439,3450,3455,3457,3459,3461,3478,3482,3505,3507,3515,3517,3517,3520,3526,3530,3530,3535,3540,3542,3542,3544,3551,3558,3567,3570,3571,3585,3642,3648,3662,3664,3673,3713,3714,3716,3716,3718,3722,3724,3747,3749,3749,3751,3773,3776,3780,3782,3782,3784,3790,3792,3801,3804,3807,3840,3840,3864,3865,3872,3881,3893,3893,3895,3895,3897,3897,3902,3911,3913,3948,3953,3972,3974,3991,3993,4028,4038,4038,4096,4169,4176,4253,4256,4293,4295,4295,4301,4301,4304,4346,4348,4680,4682,4685,4688,4694,4696,4696,4698,4701,4704,4744,4746,4749,4752,4784,4786,4789,4792,4798,4800,4800,4802,4805,4808,4822,4824,4880,4882,4885,4888,4954,4957,4959,4992,5007,5024,5109,5112,5117,5121,5740,5743,5759,5761,5786,5792,5866,5870,5880,5888,5909,5919,5940,5952,5971,5984,5996,5998,6e3,6002,6003,6016,6099,6103,6103,6108,6109,6112,6121,6155,6169,6176,6264,6272,6314,6320,6389,6400,6430,6432,6443,6448,6459,6470,6509,6512,6516,6528,6571,6576,6601,6608,6617,6656,6683,6688,6750,6752,6780,6783,6793,6800,6809,6823,6823,6832,6845,6847,6862,6912,6988,6992,7001,7019,7027,7040,7155,7168,7223,7232,7241,7245,7293,7296,7304,7312,7354,7357,7359,7376,7378,7380,7418,7424,7957,7960,7965,7968,8005,8008,8013,8016,8023,8025,8025,8027,8027,8029,8029,8031,8061,8064,8116,8118,8124,8126,8126,8130,8132,8134,8140,8144,8147,8150,8155,8160,8172,8178,8180,8182,8188,8203,8207,8234,8238,8255,8256,8276,8276,8288,8292,8294,8303,8305,8305,8319,8319,8336,8348,8400,8412,8417,8417,8421,8432,8450,8450,8455,8455,8458,8467,8469,8469,8473,8477,8484,8484,8486,8486,8488,8488,8490,8493,8495,8505,8508,8511,8517,8521,8526,8526,8544,8584,11264,11492,11499,11507,11520,11557,11559,11559,11565,11565,11568,11623,11631,11631,11647,11670,11680,11686,11688,11694,11696,11702,11704,11710,11712,11718,11720,11726,11728,11734,11736,11742,11744,11775,11823,11823,12293,12295,12321,12335,12337,12341,12344,12348,12353,12438,12441,12442,12445,12447,12449,12538,12540,12543,12549,12591,12593,12686,12704,12735,12784,12799,13312,19903,19968,42124,42192,42237,42240,42508,42512,42539,42560,42607,42612,42621,42623,42737,42775,42783,42786,42888,42891,42954,42960,42961,42963,42963,42965,42969,42994,43047,43052,43052,43072,43123,43136,43205,43216,43225,43232,43255,43259,43259,43261,43309,43312,43347,43360,43388,43392,43456,43471,43481,43488,43518,43520,43574,43584,43597,43600,43609,43616,43638,43642,43714,43739,43741,43744,43759,43762,43766,43777,43782,43785,43790,43793,43798,43808,43814,43816,43822,43824,43866,43868,43881,43888,44010,44012,44013,44016,44025,44032,55203,55216,55238,55243,55291,63744,64109,64112,64217,64256,64262,64275,64279,64285,64296,64298,64310,64312,64316,64318,64318,64320,64321,64323,64324,64326,64433,64467,64829,64848,64911,64914,64967,65008,65019,65024,65039,65056,65071,65075,65076,65101,65103,65136,65140,65142,65276,65279,65279,65296,65305,65313,65338,65343,65343,65345,65370,65382,65470,65474,65479,65482,65487,65490,65495,65498,65500,65529,65531,65536,65547,65549,65574,65576,65594,65596,65597,65599,65613,65616,65629,65664,65786,65856,65908,66045,66045,66176,66204,66208,66256,66272,66272,66304,66335,66349,66378,66384,66426,66432,66461,66464,66499,66504,66511,66513,66517,66560,66717,66720,66729,66736,66771,66776,66811,66816,66855,66864,66915,66928,66938,66940,66954,66956,66962,66964,66965,66967,66977,66979,66993,66995,67001,67003,67004,67072,67382,67392,67413,67424,67431,67456,67461,67463,67504,67506,67514,67584,67589,67592,67592,67594,67637,67639,67640,67644,67644,67647,67669,67680,67702,67712,67742,67808,67826,67828,67829,67840,67861,67872,67897,67968,68023,68030,68031,68096,68099,68101,68102,68108,68115,68117,68119,68121,68149,68152,68154,68159,68159,68192,68220,68224,68252,68288,68295,68297,68326,68352,68405,68416,68437,68448,68466,68480,68497,68608,68680,68736,68786,68800,68850,68864,68903,68912,68921,69248,69289,69291,69292,69296,69297,69373,69404,69415,69415,69424,69456,69488,69509,69552,69572,69600,69622,69632,69702,69734,69749,69759,69818,69821,69821,69826,69826,69837,69837,69840,69864,69872,69881,69888,69940,69942,69951,69956,69959,69968,70003,70006,70006,70016,70084,70089,70092,70094,70106,70108,70108,70144,70161,70163,70199,70206,70209,70272,70278,70280,70280,70282,70285,70287,70301,70303,70312,70320,70378,70384,70393,70400,70403,70405,70412,70415,70416,70419,70440,70442,70448,70450,70451,70453,70457,70459,70468,70471,70472,70475,70477,70480,70480,70487,70487,70493,70499,70502,70508,70512,70516,70656,70730,70736,70745,70750,70753,70784,70853,70855,70855,70864,70873,71040,71093,71096,71104,71128,71133,71168,71232,71236,71236,71248,71257,71296,71352,71360,71369,71424,71450,71453,71467,71472,71481,71488,71494,71680,71738,71840,71913,71935,71942,71945,71945,71948,71955,71957,71958,71960,71989,71991,71992,71995,72003,72016,72025,72096,72103,72106,72151,72154,72161,72163,72164,72192,72254,72263,72263,72272,72345,72349,72349,72368,72440,72704,72712,72714,72758,72760,72768,72784,72793,72818,72847,72850,72871,72873,72886,72960,72966,72968,72969,72971,73014,73018,73018,73020,73021,73023,73031,73040,73049,73056,73061,73063,73064,73066,73102,73104,73105,73107,73112,73120,73129,73440,73462,73472,73488,73490,73530,73534,73538,73552,73561,73648,73648,73728,74649,74752,74862,74880,75075,77712,77808,77824,78933,82944,83526,92160,92728,92736,92766,92768,92777,92784,92862,92864,92873,92880,92909,92912,92916,92928,92982,92992,92995,93008,93017,93027,93047,93053,93071,93760,93823,93952,94026,94031,94087,94095,94111,94176,94177,94179,94180,94192,94193,94208,100343,100352,101589,101632,101640,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,113664,113770,113776,113788,113792,113800,113808,113817,113821,113822,113824,113827,118528,118573,118576,118598,119141,119145,119149,119170,119173,119179,119210,119213,119362,119364,119808,119892,119894,119964,119966,119967,119970,119970,119973,119974,119977,119980,119982,119993,119995,119995,119997,120003,120005,120069,120071,120074,120077,120084,120086,120092,120094,120121,120123,120126,120128,120132,120134,120134,120138,120144,120146,120485,120488,120512,120514,120538,120540,120570,120572,120596,120598,120628,120630,120654,120656,120686,120688,120712,120714,120744,120746,120770,120772,120779,120782,120831,121344,121398,121403,121452,121461,121461,121476,121476,121499,121503,121505,121519,122624,122654,122661,122666,122880,122886,122888,122904,122907,122913,122915,122916,122918,122922,122928,122989,123023,123023,123136,123180,123184,123197,123200,123209,123214,123214,123536,123566,123584,123641,124112,124153,124896,124902,124904,124907,124909,124910,124912,124926,124928,125124,125136,125142,125184,125259,125264,125273,126464,126467,126469,126495,126497,126498,126500,126500,126503,126503,126505,126514,126516,126519,126521,126521,126523,126523,126530,126530,126535,126535,126537,126537,126539,126539,126541,126543,126545,126546,126548,126548,126551,126551,126553,126553,126555,126555,126557,126557,126559,126559,126561,126562,126564,126564,126567,126570,126572,126578,126580,126583,126585,126588,126590,126590,126592,126601,126603,126619,126625,126627,126629,126633,126635,126651,130032,130041,131072,173791,173824,177977,177984,178205,178208,183969,183984,191456,194560,195101,196608,201546,201552,205743,917505,917505,917536,917631,917760,917999,662,0,65,90,97,122,170,170,181,181,186,186,192,214,216,246,248,705,710,721,736,740,748,748,750,750,880,884,886,887,890,893,895,895,902,902,904,906,908,908,910,929,931,1013,1015,1153,1162,1327,1329,1366,1369,1369,1376,1416,1488,1514,1519,1522,1568,1610,1646,1647,1649,1747,1749,1749,1765,1766,1774,1775,1786,1788,1791,1791,1808,1808,1810,1839,1869,1957,1969,1969,1994,2026,2036,2037,2042,2042,2048,2069,2074,2074,2084,2084,2088,2088,2112,2136,2144,2154,2160,2183,2185,2190,2208,2249,2308,2361,2365,2365,2384,2384,2392,2401,2417,2432,2437,2444,2447,2448,2451,2472,2474,2480,2482,2482,2486,2489,2493,2493,2510,2510,2524,2525,2527,2529,2544,2545,2556,2556,2565,2570,2575,2576,2579,2600,2602,2608,2610,2611,2613,2614,2616,2617,2649,2652,2654,2654,2674,2676,2693,2701,2703,2705,2707,2728,2730,2736,2738,2739,2741,2745,2749,2749,2768,2768,2784,2785,2809,2809,2821,2828,2831,2832,2835,2856,2858,2864,2866,2867,2869,2873,2877,2877,2908,2909,2911,2913,2929,2929,2947,2947,2949,2954,2958,2960,2962,2965,2969,2970,2972,2972,2974,2975,2979,2980,2984,2986,2990,3001,3024,3024,3077,3084,3086,3088,3090,3112,3114,3129,3133,3133,3160,3162,3165,3165,3168,3169,3200,3200,3205,3212,3214,3216,3218,3240,3242,3251,3253,3257,3261,3261,3293,3294,3296,3297,3313,3314,3332,3340,3342,3344,3346,3386,3389,3389,3406,3406,3412,3414,3423,3425,3450,3455,3461,3478,3482,3505,3507,3515,3517,3517,3520,3526,3585,3632,3634,3635,3648,3654,3713,3714,3716,3716,3718,3722,3724,3747,3749,3749,3751,3760,3762,3763,3773,3773,3776,3780,3782,3782,3804,3807,3840,3840,3904,3911,3913,3948,3976,3980,4096,4138,4159,4159,4176,4181,4186,4189,4193,4193,4197,4198,4206,4208,4213,4225,4238,4238,4256,4293,4295,4295,4301,4301,4304,4346,4348,4680,4682,4685,4688,4694,4696,4696,4698,4701,4704,4744,4746,4749,4752,4784,4786,4789,4792,4798,4800,4800,4802,4805,4808,4822,4824,4880,4882,4885,4888,4954,4992,5007,5024,5109,5112,5117,5121,5740,5743,5759,5761,5786,5792,5866,5870,5880,5888,5905,5919,5937,5952,5969,5984,5996,5998,6e3,6016,6067,6103,6103,6108,6108,6176,6264,6272,6276,6279,6312,6314,6314,6320,6389,6400,6430,6480,6509,6512,6516,6528,6571,6576,6601,6656,6678,6688,6740,6823,6823,6917,6963,6981,6988,7043,7072,7086,7087,7098,7141,7168,7203,7245,7247,7258,7293,7296,7304,7312,7354,7357,7359,7401,7404,7406,7411,7413,7414,7418,7418,7424,7615,7680,7957,7960,7965,7968,8005,8008,8013,8016,8023,8025,8025,8027,8027,8029,8029,8031,8061,8064,8116,8118,8124,8126,8126,8130,8132,8134,8140,8144,8147,8150,8155,8160,8172,8178,8180,8182,8188,8305,8305,8319,8319,8336,8348,8450,8450,8455,8455,8458,8467,8469,8469,8473,8477,8484,8484,8486,8486,8488,8488,8490,8493,8495,8505,8508,8511,8517,8521,8526,8526,8544,8584,11264,11492,11499,11502,11506,11507,11520,11557,11559,11559,11565,11565,11568,11623,11631,11631,11648,11670,11680,11686,11688,11694,11696,11702,11704,11710,11712,11718,11720,11726,11728,11734,11736,11742,11823,11823,12293,12295,12321,12329,12337,12341,12344,12348,12353,12438,12445,12447,12449,12538,12540,12543,12549,12591,12593,12686,12704,12735,12784,12799,13312,19903,19968,42124,42192,42237,42240,42508,42512,42527,42538,42539,42560,42606,42623,42653,42656,42735,42775,42783,42786,42888,42891,42954,42960,42961,42963,42963,42965,42969,42994,43009,43011,43013,43015,43018,43020,43042,43072,43123,43138,43187,43250,43255,43259,43259,43261,43262,43274,43301,43312,43334,43360,43388,43396,43442,43471,43471,43488,43492,43494,43503,43514,43518,43520,43560,43584,43586,43588,43595,43616,43638,43642,43642,43646,43695,43697,43697,43701,43702,43705,43709,43712,43712,43714,43714,43739,43741,43744,43754,43762,43764,43777,43782,43785,43790,43793,43798,43808,43814,43816,43822,43824,43866,43868,43881,43888,44002,44032,55203,55216,55238,55243,55291,63744,64109,64112,64217,64256,64262,64275,64279,64285,64285,64287,64296,64298,64310,64312,64316,64318,64318,64320,64321,64323,64324,64326,64433,64467,64829,64848,64911,64914,64967,65008,65019,65136,65140,65142,65276,65313,65338,65345,65370,65382,65470,65474,65479,65482,65487,65490,65495,65498,65500,65536,65547,65549,65574,65576,65594,65596,65597,65599,65613,65616,65629,65664,65786,65856,65908,66176,66204,66208,66256,66304,66335,66349,66378,66384,66421,66432,66461,66464,66499,66504,66511,66513,66517,66560,66717,66736,66771,66776,66811,66816,66855,66864,66915,66928,66938,66940,66954,66956,66962,66964,66965,66967,66977,66979,66993,66995,67001,67003,67004,67072,67382,67392,67413,67424,67431,67456,67461,67463,67504,67506,67514,67584,67589,67592,67592,67594,67637,67639,67640,67644,67644,67647,67669,67680,67702,67712,67742,67808,67826,67828,67829,67840,67861,67872,67897,67968,68023,68030,68031,68096,68096,68112,68115,68117,68119,68121,68149,68192,68220,68224,68252,68288,68295,68297,68324,68352,68405,68416,68437,68448,68466,68480,68497,68608,68680,68736,68786,68800,68850,68864,68899,69248,69289,69296,69297,69376,69404,69415,69415,69424,69445,69488,69505,69552,69572,69600,69622,69635,69687,69745,69746,69749,69749,69763,69807,69840,69864,69891,69926,69956,69956,69959,69959,69968,70002,70006,70006,70019,70066,70081,70084,70106,70106,70108,70108,70144,70161,70163,70187,70207,70208,70272,70278,70280,70280,70282,70285,70287,70301,70303,70312,70320,70366,70405,70412,70415,70416,70419,70440,70442,70448,70450,70451,70453,70457,70461,70461,70480,70480,70493,70497,70656,70708,70727,70730,70751,70753,70784,70831,70852,70853,70855,70855,71040,71086,71128,71131,71168,71215,71236,71236,71296,71338,71352,71352,71424,71450,71488,71494,71680,71723,71840,71903,71935,71942,71945,71945,71948,71955,71957,71958,71960,71983,71999,71999,72001,72001,72096,72103,72106,72144,72161,72161,72163,72163,72192,72192,72203,72242,72250,72250,72272,72272,72284,72329,72349,72349,72368,72440,72704,72712,72714,72750,72768,72768,72818,72847,72960,72966,72968,72969,72971,73008,73030,73030,73056,73061,73063,73064,73066,73097,73112,73112,73440,73458,73474,73474,73476,73488,73490,73523,73648,73648,73728,74649,74752,74862,74880,75075,77712,77808,77824,78895,78913,78918,82944,83526,92160,92728,92736,92766,92784,92862,92880,92909,92928,92975,92992,92995,93027,93047,93053,93071,93760,93823,93952,94026,94032,94032,94099,94111,94176,94177,94179,94179,94208,100343,100352,101589,101632,101640,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,113664,113770,113776,113788,113792,113800,113808,113817,119808,119892,119894,119964,119966,119967,119970,119970,119973,119974,119977,119980,119982,119993,119995,119995,119997,120003,120005,120069,120071,120074,120077,120084,120086,120092,120094,120121,120123,120126,120128,120132,120134,120134,120138,120144,120146,120485,120488,120512,120514,120538,120540,120570,120572,120596,120598,120628,120630,120654,120656,120686,120688,120712,120714,120744,120746,120770,120772,120779,122624,122654,122661,122666,122928,122989,123136,123180,123191,123197,123214,123214,123536,123565,123584,123627,124112,124139,124896,124902,124904,124907,124909,124910,124912,124926,124928,125124,125184,125251,125259,125259,126464,126467,126469,126495,126497,126498,126500,126500,126503,126503,126505,126514,126516,126519,126521,126521,126523,126523,126530,126530,126535,126535,126537,126537,126539,126539,126541,126543,126545,126546,126548,126548,126551,126551,126553,126553,126555,126555,126557,126557,126559,126559,126561,126562,126564,126564,126567,126570,126572,126578,126580,126583,126585,126588,126590,126590,126592,126601,126603,126619,126625,126627,126629,126633,126635,126651,131072,173791,173824,177977,177984,178205,178208,183969,183984,191456,194560,195101,196608,201546,201552,205743,47,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,15,1,0,0,0,1,17,1,0,0,0,3,20,1,0,0,0,5,22,1,0,0,0,7,24,1,0,0,0,9,26,1,0,0,0,11,35,1,0,0,0,13,37,1,0,0,0,15,39,1,0,0,0,17,18,5,47,0,0,18,19,5,47,0,0,19,2,1,0,0,0,20,21,5,47,0,0,21,4,1,0,0,0,22,23,5,42,0,0,23,6,1,0,0,0,24,25,5,33,0,0,25,8,1,0,0,0,26,30,3,13,6,0,27,29,3,11,5,0,28,27,1,0,0,0,29,32,1,0,0,0,30,28,1,0,0,0,30,31,1,0,0,0,31,33,1,0,0,0,32,30,1,0,0,0,33,34,6,4,0,0,34,10,1,0,0,0,35,36,7,0,0,0,36,12,1,0,0,0,37,38,7,1,0,0,38,14,1,0,0,0,39,43,5,39,0,0,40,42,9,0,0,0,41,40,1,0,0,0,42,45,1,0,0,0,43,44,1,0,0,0,43,41,1,0,0,0,44,46,1,0,0,0,45,43,1,0,0,0,46,47,5,39,0,0,47,16,1,0,0,0,3,0,30,43,1,1,4,0];static __ATN;static get _ATN(){return me.__ATN||(me.__ATN=new Tn().deserialize(me._serializedATN)),me.__ATN}static vocabulary=new yt(me.literalNames,me.symbolicNames,[]);get vocabulary(){return me.vocabulary}static decisionsToDFA=me._ATN.decisionToState.map((e,t)=>new rn(e,t))},k0=class extends ir{static{y(this,"XPathLexerErrorListener")}syntaxError(n,e,t,s,r,i){}},or=class{static{y(this,"XPathElement")}invert;nodeName;constructor(n){this.nodeName=n,this.invert=!1}toString(){return"XPathElement["+(this.invert?"!":"")+this.nodeName+"]"}},R0=class extends or{static{y(this,"XPathRuleAnywhereElement")}ruleIndex;constructor(n,e){super(n),this.ruleIndex=e}evaluate(n){return En.findAllRuleNodes(n,this.ruleIndex)}toString(){return"XPathRuleAnywhereElement["+(this.invert?"!":"")+this.nodeName+"]"}},_0=class extends or{static{y(this,"XPathRuleElement")}ruleIndex;constructor(n,e){super(n),this.ruleIndex=e}evaluate(n){let e=[];for(let t of En.getChildren(n))t instanceof K&&(t.ruleIndex===this.ruleIndex&&!this.invert||t.ruleIndex!==this.ruleIndex&&this.invert)&&e.push(t);return e}toString(){return"XPathRuleElement["+(this.invert?"!":"")+this.nodeName+"]"}},N0=class extends or{static{y(this,"XPathTokenAnywhereElement")}tokenType;constructor(n,e){super(n),this.tokenType=e}evaluate(n){return En.findAllTokenNodes(n,this.tokenType)}toString(){return"XPathTokenAnywhereElement["+(this.invert?"!":"")+this.nodeName+"]"}},O0=class extends or{static{y(this,"XPathTokenElement")}tokenType;constructor(n,e){super(n),this.tokenType=e}evaluate(n){let e=[];for(let t of En.getChildren(n))t instanceof gt&&t.symbol&&(t.symbol.type===this.tokenType&&!this.invert||t.symbol.type!==this.tokenType&&this.invert)&&e.push(t);return e}toString(){return"XPathTokenElement["+(this.invert?"!":"")+this.nodeName+"]"}},P0=class extends or{static{y(this,"XPathWildcardAnywhereElement")}constructor(){super(Oc.WILDCARD)}evaluate(n){return this.invert?[]:En.descendants(n)}toString(){return"XPathWildcardAnywhereElement["+(this.invert?"!":"")+this.nodeName+"]"}},D0=class extends or{static{y(this,"XPathWildcardElement")}constructor(){super(Oc.WILDCARD)}evaluate(n){let e=[];if(this.invert)return e;for(let t of En.getChildren(n))e.push(t);return e}toString(){return"XPathWildcardElement["+(this.invert?"!":"")+this.nodeName+"]"}},Oc=class Ff{static{y(this,"XPath")}static WILDCARD="*";static NOT="!";path;elements;parser;constructor(e,t){this.parser=e,this.path=t,this.elements=this.split(t)}static findAll(e,t,s){return new Ff(s,t).evaluate(e)}split(e){let t=new ft(rr.fromString(e));t.recover=c=>{throw c},t.removeErrorListeners(),t.addErrorListener(new k0);let s=new ko(t);try{s.fill()}catch(c){if(c instanceof wo){let u="Invalid tokens or characters at index "+t.column+" in path '"+e+"' -- "+c.message;throw new RangeError(u)}throw c}let r=s.getTokens(),i=[],o=r.length,a=0;e:for(;a<o;){let c=r[a],l;switch(c.type){case ft.ROOT:case ft.ANYWHERE:let u=c.type===ft.ANYWHERE;a++,l=r[a];let d=l.type===ft.BANG;d&&(a++,l=r[a]);let h=this.getXPathElement(l,u);h.invert=d,i.push(h),a++;break;case ft.TOKEN_REF:case ft.RULE_REF:case ft.WILDCARD:i.push(this.getXPathElement(c,!1)),++a;break;case x.EOF:break e;default:throw new Error("Unknown path element "+c)}}return i}evaluate(e){let t=new K(null);t.addChild(e);let s=new Set([t]),r=0;for(;r<this.elements.length;){let i=new Set;for(let o of s)o.getChildCount()>0&&this.elements[r].evaluate(o).forEach(c=>{i.add(c)},i);r++,s=i}return s}getXPathElement(e,t){if(e.type===x.EOF)throw new Error("Missing path element at end of path");let s=e.text;if(s==null)throw new Error("Expected wordToken to have text content.");let r=this.parser.getTokenType(s),i=this.parser.getRuleIndex(s);switch(e.type){case ft.WILDCARD:return t?new P0:new D0;case ft.TOKEN_REF:case ft.STRING:if(r===x.INVALID_TYPE)throw new Error(s+" at index "+e.start+" isn't a valid token name");return t?new N0(s,r):new O0(s,r);default:if(i===-1)throw new Error(s+" at index "+e.start+" isn't a valid rule name");return t?new R0(s,i):new _0(s,i)}}},jf=class{static{y(this,"Chunk")}},L0=class{static{y(this,"ParseTreeMatch")}tree;pattern;labels;mismatchedNode;constructor(n,e,t,s){this.tree=n,this.pattern=e,this.labels=t,this.mismatchedNode=s}get(n){let e=this.labels.get(n);return!e||e.length===0?null:e[e.length-1]}getAll(n){return this.labels.get(n)??[]}getLabels(){return this.labels}getMismatchedNode(){return this.mismatchedNode}succeeded(){return!this.mismatchedNode}getPattern(){return this.pattern}getTree(){return this.tree}toString(){return`Match ${this.succeeded()?"succeeded":"failed"}; found ${this.getLabels().size} labels`}},$0=class{static{y(this,"ParseTreePattern")}patternRuleIndex;pattern;patternTree;matcher;constructor(n,e,t,s){this.matcher=n,this.patternRuleIndex=t,this.pattern=e,this.patternTree=s}match(n){return this.matcher.match(n,this)}matches(n){return this.matcher.match(n,this).succeeded()}findAll(n,e){let t=Oc.findAll(n,e,this.matcher.getParser()),s=new Array;for(let r of t){let i=this.match(r);i.succeeded()&&s.push(i)}return s}getMatcher(){return this.matcher}getPattern(){return this.pattern}getPatternRuleIndex(){return this.patternRuleIndex}getPatternTree(){return this.patternTree}},Xr=class extends ie{static{y(this,"InputMismatchException")}constructor(n){super({message:"",recognizer:n,input:n.inputStream,ctx:n.context}),this.offendingToken=n.getCurrentToken()}},ei=class extends ie{static{y(this,"FailedPredicateException")}ruleIndex=0;predicateIndex=0;predicate;constructor(n,e,t=null){super({message:M0(e??"no predicate",t??null),recognizer:n,input:n.inputStream,ctx:n.context});let r=n.atn.states[n.state].transitions[0];r instanceof mf?(this.ruleIndex=r.ruleIndex,this.predicateIndex=r.predIndex):(this.ruleIndex=0,this.predicateIndex=0),this.predicate=e,this.offendingToken=n.getCurrentToken()}},M0=y((n,e)=>e!==null?e:"failed predicate: {"+n+"}?","formatMessage"),Vf=class{static{y(this,"DefaultErrorStrategy")}errorRecoveryMode=!1;lastErrorIndex=-1;lastErrorStates=new mt;nextTokensContext=null;nextTokenState=0;reset(n){this.endErrorCondition(n)}beginErrorCondition(n){this.errorRecoveryMode=!0}inErrorRecoveryMode(n){return this.errorRecoveryMode}endErrorCondition(n){this.errorRecoveryMode=!1,this.lastErrorStates=new mt,this.lastErrorIndex=-1}reportMatch(n){this.endErrorCondition(n)}reportError(n,e){this.inErrorRecoveryMode(n)||(this.beginErrorCondition(n),e instanceof ds?this.reportNoViableAlternative(n,e):e instanceof Xr?this.reportInputMismatch(n,e):e instanceof ei?this.reportFailedPredicate(n,e):n.notifyErrorListeners(e.message,e.offendingToken,e))}recover(n,e){this.lastErrorIndex===n.inputStream?.index&&this.lastErrorStates.contains(n.state)&&n.consume(),this.lastErrorIndex=n.inputStream?.index??0,this.lastErrorStates.addOne(n.state);let t=this.getErrorRecoverySet(n);this.consumeUntil(n,t)}sync(n){if(this.inErrorRecoveryMode(n))return;let e=n.atn.states[n.state],t=n.tokenStream.LA(1),s=n.atn.nextTokens(e);if(s.contains(t)){this.nextTokensContext=null,this.nextTokenState=L.INVALID_STATE_NUMBER;return}if(s.contains(x.EPSILON)){this.nextTokensContext===null&&(this.nextTokensContext=n.context,this.nextTokenState=n.state);return}switch(e.constructor.stateType){case L.BLOCK_START:case L.STAR_BLOCK_START:case L.PLUS_BLOCK_START:case L.STAR_LOOP_ENTRY:{if(this.singleTokenDeletion(n)!==null)return;throw new Xr(n)}case L.PLUS_LOOP_BACK:case L.STAR_LOOP_BACK:{this.reportUnwantedToken(n);let r=new mt;r.addSet(n.getExpectedTokens());let i=r.addSet(this.getErrorRecoverySet(n));this.consumeUntil(n,i);break}default:}}reportNoViableAlternative(n,e){if(e.message.length>0){n.notifyErrorListeners(e.message,e.offendingToken,e);return}let t=n.tokenStream,s;t!==null&&e.startToken?e.startToken.type===x.EOF?s="<EOF>":s=t.getTextFromRange(e.startToken,e.offendingToken):s="<unknown input>";let r="no viable alternative at input "+this.escapeWSAndQuote(s);n.notifyErrorListeners(r,e.offendingToken,e)}reportInputMismatch(n,e){if(e.message.length>0){n.notifyErrorListeners(e.message,e.offendingToken,e);return}let t="mismatched input "+this.getTokenErrorDisplay(e.offendingToken)+" expecting "+e.getExpectedTokens().toStringWithVocabulary(n.vocabulary);n.notifyErrorListeners(t,e.offendingToken,e)}reportFailedPredicate(n,e){let s="rule "+n.ruleNames[n.context.ruleIndex]+" "+e.message;n.notifyErrorListeners(s,e.offendingToken,e)}reportUnwantedToken(n){if(this.inErrorRecoveryMode(n))return;this.beginErrorCondition(n);let e=n.getCurrentToken(),t=this.getTokenErrorDisplay(e),s=this.getExpectedTokens(n),r="extraneous input "+t+" expecting "+s.toStringWithVocabulary(n.vocabulary);n.notifyErrorListeners(r,e,null)}reportMissingToken(n){if(this.inErrorRecoveryMode(n))return;this.beginErrorCondition(n);let e=n.getCurrentToken(),s="missing "+this.getExpectedTokens(n).toStringWithVocabulary(n.vocabulary)+" at "+this.getTokenErrorDisplay(e);n.notifyErrorListeners(s,e,null)}recoverInline(n){let e=this.singleTokenDeletion(n);if(e)return n.consume(),e;if(this.singleTokenInsertion(n))return this.getMissingSymbol(n);throw new Xr(n)}singleTokenInsertion(n){let e=n.tokenStream?.LA(1)??-1,t=n.atn,r=t.states[n.state].transitions[0].target;return t.nextTokens(r,n.context??void 0).contains(e)?(this.reportMissingToken(n),!0):!1}singleTokenDeletion(n){let e=n.tokenStream?.LA(2)??-1;if(this.getExpectedTokens(n).contains(e)){this.reportUnwantedToken(n),n.consume();let s=n.getCurrentToken();return this.reportMatch(n),s}return null}getMissingSymbol(n){let e=n.getCurrentToken(),t=this.getExpectedTokens(n),s=x.INVALID_TYPE;t.length!==0&&(s=t.minElement);let r;s===x.EOF?r="<missing EOF>":r="<missing "+n.vocabulary.getDisplayName(s)+">";let i=e,o=n.tokenStream?.LT(-1);return i.type===x.EOF&&o!==null&&(i=o),n.getTokenFactory().create(i.source,s,r,x.DEFAULT_CHANNEL,-1,-1,i.line,i.column)}getExpectedTokens(n){return n.getExpectedTokens()}getTokenErrorDisplay(n){if(n===null)return"<no token>";let e=n.text;return e||(n.type===x.EOF?e="<EOF>":e="<"+n.type+">"),this.escapeWSAndQuote(e)}escapeWSAndQuote(n){return n=n.replace(/\n/g,"\\n"),n=n.replace(/\r/g,"\\r"),n=n.replace(/\t/g,"\\t"),"'"+n+"'"}getErrorRecoverySet(n){let e=n.atn,t=n.context,s=new mt;for(;t!==null&&t.invokingState>=0;){let i=e.states[t.invokingState].transitions[0],o=e.nextTokens(i.followState);s.addSet(o),t=t.parent}return s.removeOne(x.EPSILON),s}consumeUntil(n,e){let t=n.tokenStream?.LA(1)??-1;for(;t!==x.EOF&&!e.contains(t);)n.consume(),t=n.tokenStream?.LA(1)??-1}},F0=class extends Vf{static{y(this,"BailErrorStrategy")}recover(n,e){throw new Ic(e)}recoverInline(n){let e=new Xr(n);throw new Ic(e)}sync(n){}},j0=class{static{y(this,"ListTokenSource")}sourceName;tokenFactory=kf.DEFAULT;tokens=[];i=0;eofToken=null;constructor(n,e){this.tokens=n,this.sourceName=e??""}get column(){if(this.i<this.tokens.length)return this.tokens[this.i].column;if(this.eofToken!==null)return this.eofToken.column;if(this.tokens.length>0){let n=this.tokens[this.tokens.length-1],e=n.text;if(e){let t=e.lastIndexOf(`
33
+ `);if(t>=0)return e.length-t-1}return n.column+n.stop-n.start+1}return 0}nextToken(){if(this.i>=this.tokens.length){if(this.eofToken===null){let e=-1;if(this.tokens.length>0){let s=this.tokens[this.tokens.length-1].stop;s!==-1&&(e=s+1)}let t=Math.max(-1,e-1);this.eofToken=this.tokenFactory.create([this,this.inputStream],x.EOF,"EOF",x.DEFAULT_CHANNEL,e,t,this.line,this.column)}return this.eofToken}let n=this.tokens[this.i];return this.i===this.tokens.length-1&&n.type===x.EOF&&(this.eofToken=n),this.i++,n}get line(){if(this.i<this.tokens.length)return this.tokens[this.i].line;if(this.eofToken!==null)return this.eofToken.line;if(this.tokens.length>0){let n=this.tokens[this.tokens.length-1],e=n.line,t=n.text;if(t)for(let s of t)s===`
34
+ `&&e++;return e}return 1}get inputStream(){return this.i<this.tokens.length?this.tokens[this.i].inputStream:this.eofToken!==null?this.eofToken.inputStream:this.tokens.length>0?this.tokens[this.tokens.length-1].inputStream:null}getSourceName(){if(this.sourceName!==null)return this.sourceName;let n=this.inputStream;return n!==null?n.getSourceName():"List"}},V0=class extends K{static{y(this,"InterpreterRuleContext")}#e;constructor(n,e,t){super(e,t),this.#e=n}get ruleIndex(){return this.#e}},U0=class{static{y(this,"TraceListener")}parser;constructor(n){this.parser=n}enterEveryRule(n){console.log("enter "+this.parser.ruleNames[n.ruleIndex]+", LT(1)="+this.parser.inputStream?.LT(1)?.text)}visitTerminal(n){console.log("consume "+n.getSymbol()+" rule "+this.parser.ruleNames[this.parser.context.ruleIndex])}exitEveryRule(n){console.log("exit "+this.parser.ruleNames[n.ruleIndex]+", LT(1)="+this.parser.inputStream?.LT(1)?.text)}visitErrorNode(n){}},Pc=class extends If{static{y(this,"Parser")}printer=null;buildParseTrees=!0;errorHandler=new Vf;context=null;precedenceStack=[];parseListeners=null;syntaxErrors=0;matchedEOF=!1;tracer=null;bypassAltsAtnCache=null;#e;constructor(n){super(),this.precedenceStack.push(0),this.syntaxErrors=0,this.#e=n}reset(n=!0){n&&this.inputStream.seek(0),this.errorHandler.reset(this),this.context=null,this.syntaxErrors=0,this.matchedEOF=!1,this.setTrace(!1),this.precedenceStack=[],this.precedenceStack.push(0),this.interpreter&&this.interpreter.reset()}match(n){let e=this.getCurrentToken();return e.type===n?(n===x.EOF&&(this.matchedEOF=!0),this.errorHandler.reportMatch(this),this.consume()):(e=this.errorHandler.recoverInline(this),this.buildParseTrees&&e.tokenIndex===-1&&this.context.addErrorNode(this.createErrorNode(this.context,e))),e}matchWildcard(){let n=this.getCurrentToken();return n.type>0?(this.errorHandler.reportMatch(this),this.consume()):(n=this.errorHandler.recoverInline(this),this.buildParseTrees&&n.tokenIndex===-1&&this.context.addErrorNode(this.createErrorNode(this.context,n))),n}getParseListeners(){return this.parseListeners??[]}addParseListener(n){if(n===null)throw new Error("listener");this.parseListeners===null&&(this.parseListeners=[]),this.parseListeners.push(n)}removeParseListener(n){if(this.parseListeners!==null&&n!==null){let e=this.parseListeners.indexOf(n);e>=0&&this.parseListeners.splice(e,1),this.parseListeners.length===0&&(this.parseListeners=null)}}removeParseListeners(){this.parseListeners=null}triggerEnterRuleEvent(){if(this.parseListeners!==null){let n=this.context;this.parseListeners.forEach(e=>{e.enterEveryRule(n),n.enterRule(e)})}}triggerExitRuleEvent(){if(this.parseListeners!==null){let n=this.context;this.parseListeners.slice(0).reverse().forEach(e=>{n.exitRule(e),e.exitEveryRule(n)})}}getTokenFactory(){return this.inputStream.tokenSource.tokenFactory}setTokenFactory(n){this.inputStream.tokenSource.tokenFactory=n}compileParseTreePattern(n,e,t){if(!t&&this.tokenStream!==null){let r=this.tokenStream.tokenSource;r instanceof nt&&(t=r)}if(!t)throw new Error("Parser can't discover a lexer to use");return new W0(t,this).compile(n,e)}getATNWithBypassAlts(){let n=this.serializedATN;if(n===null)throw new Error("The current parser does not support an ATN with bypass alternatives.");if(this.bypassAltsAtnCache!==null)return this.bypassAltsAtnCache;let e={readOnly:!1,verifyATN:!0,generateRuleBypassTransitions:!0};return this.bypassAltsAtnCache=new Tn(e).deserialize(n),this.bypassAltsAtnCache}get numberOfSyntaxErrors(){return this.syntaxErrors}get inputStream(){return this.#e}set inputStream(n){this.tokenStream=n}get tokenStream(){return this.#e}set tokenStream(n){this.reset(!1),this.#e=n}getCurrentToken(){return this.inputStream.LT(1)}notifyErrorListeners(n,e,t){e=e??null,t=t??null,e===null&&(e=this.getCurrentToken()),this.syntaxErrors+=1;let s=e.line,r=e.column;this.errorListenerDispatch.syntaxError(this,e,s,r,n,t)}consume(){let n=this.getCurrentToken();n.type!==x.EOF&&this.tokenStream.consume();let e=this.parseListeners!==null&&this.parseListeners.length>0;if(this.buildParseTrees||e){let t;this.errorHandler.inErrorRecoveryMode(this)?t=this.context.addErrorNode(this.createErrorNode(this.context,n)):t=this.context.addTokenNode(n),e&&this.parseListeners.forEach(s=>{t instanceof Qr?s.visitErrorNode(t):s.visitTerminal(t)})}return n}addContextToParseTree(){this.context?.parent&&this.context.parent.addChild(this.context)}enterRule(n,e,t){this.state=e,this.context=n,this.context.start=this.inputStream.LT(1),this.buildParseTrees&&this.addContextToParseTree(),this.triggerEnterRuleEvent()}exitRule(){this.matchedEOF?this.context.stop=this.inputStream.LT(1):this.context.stop=this.inputStream.LT(-1),this.triggerExitRuleEvent(),this.state=this.context.invokingState,this.context=this.context.parent}enterOuterAlt(n,e){n.setAltNumber(e),this.buildParseTrees&&this.context!==n&&this.context?.parent&&(this.context.parent.removeLastChild(),this.context.parent.addChild(n)),this.context=n}getPrecedence(){return this.precedenceStack.length===0?-1:this.precedenceStack[this.precedenceStack.length-1]}enterRecursionRule(n,e,t,s){this.state=e,this.precedenceStack.push(s),this.context=n,this.context.start=this.inputStream.LT(1),this.triggerEnterRuleEvent()}pushNewRecursionContext(n,e,t){let s=this.context;s.parent=n,s.invokingState=e,s.stop=this.inputStream.LT(-1),this.context=n,this.context.start=s.start,this.buildParseTrees&&this.context.addChild(s),this.triggerEnterRuleEvent()}unrollRecursionContexts(n){this.precedenceStack.pop(),this.context.stop=this.inputStream.LT(-1);let e=this.context,t=this.getParseListeners();if(t!==null&&t.length>0)for(;this.context!==n;)this.triggerExitRuleEvent(),this.context=this.context.parent;else this.context=n;e.parent=n,this.buildParseTrees&&n!==null&&n.addChild(e)}getInvokingContext(n){let e=this.context;for(;e!==null;){if(e.ruleIndex===n)return e;e=e.parent}return null}precpred(n,e){return e>=this.precedenceStack[this.precedenceStack.length-1]}isExpectedToken(n){let e=this.interpreter.atn,t=this.context,s=e.states[this.state],r=e.nextTokens(s);if(r.contains(n))return!0;if(!r.contains(x.EPSILON))return!1;for(;t!==null&&t.invokingState>=0&&r.contains(x.EPSILON);){let o=e.states[t.invokingState].transitions[0];if(r=e.nextTokens(o.followState),r.contains(n))return!0;t=t.parent}return!!(r.contains(x.EPSILON)&&n===x.EOF)}getExpectedTokens(){return this.interpreter.atn.getExpectedTokens(this.state,this.context)}getExpectedTokensWithinCurrentRule(){let n=this.interpreter.atn,e=n.states[this.state];return n.nextTokens(e)}getRuleIndex(n){return this.getRuleIndexMap().get(n)??-1}getRuleInvocationStack(n){n=n??null,n===null&&(n=this.context);let e=[];for(;n!==null;){let t=n.ruleIndex;t<0?e.push("n/a"):e.push(this.ruleNames[t]),n=n.parent}return e}getDFAStrings(){return this.interpreter.decisionToDFA.toString()}dumpDFA(){let n=!1;for(let e of this.interpreter.decisionToDFA)e.length>0&&(n&&console.log(),this.printer&&(this.printer.println("Decision "+e.decision+":"),this.printer.print(e.toString(this.vocabulary))),n=!0)}getSourceName(){return this.inputStream.getSourceName()}getParseInfo(){let n=this.interpreter;if(n instanceof So)return new C0(n)}setProfile(n){let e=this.interpreter,t=e.predictionMode;if(n)e instanceof So||(this.interpreter=new So(this));else if(e instanceof So){let s=e.sharedContextCache;if(s){let r=new ti(this,this.atn,e.decisionToDFA,s);this.interpreter=r}}this.interpreter.predictionMode=t}setTrace(n){n?(this.tracer!==null&&this.removeParseListener(this.tracer),this.tracer=new U0(this),this.addParseListener(this.tracer)):(this.removeParseListener(this.tracer),this.tracer=null)}createTerminalNode(n,e){return new gt(e)}createErrorNode(n,e){return new Qr(e)}},B0=class extends Pc{static{y(this,"ParserInterpreter")}rootContext;overrideDecisionRoot=null;parentContextStack=[];overrideDecisionAlt=-1;overrideDecisionReached=!1;decisionToDFA;sharedContextCache=new fs;pushRecursionContextStates;#e=-1;#t=-1;#s;#n;#r;#i;constructor(n,e,t,s,r){super(r),this.#s=n,this.#n=s,this.#r=t.slice(0),this.#i=e,this.pushRecursionContextStates=new Lt;for(let i of s.states)i instanceof vn&&i.precedenceRuleDecision&&this.pushRecursionContextStates.set(i.stateNumber);this.decisionToDFA=s.decisionToState.map((i,o)=>new rn(i,o)),this.interpreter=new ti(this,s,this.decisionToDFA,this.sharedContextCache)}reset(){super.reset(),this.overrideDecisionReached=!1,this.overrideDecisionRoot=null}get atn(){return this.#n}get vocabulary(){return this.#i}get ruleNames(){return this.#r}get grammarFileName(){return this.#s}get atnState(){return this.#n.states[this.state]}parse(n){let e=this.#n.ruleToStartState[n];for(this.rootContext=this.createInterpreterRuleContext(null,L.INVALID_STATE_NUMBER,n),e.isLeftRecursiveRule?this.enterRecursionRule(this.rootContext,e.stateNumber,n,0):this.enterRule(this.rootContext,e.stateNumber,n);;){let t=this.atnState;switch(t.constructor.stateType){case L.RULE_STOP:{if(this.context?.isEmpty())if(e.isLeftRecursiveRule){let s=this.context,r=this.parentContextStack.pop();return this.unrollRecursionContexts(r[0]),s}else return this.exitRule(),this.rootContext;this.visitRuleStopState(t);break}default:{try{this.visitState(t)}catch(s){if(s instanceof ie)this.state=this.#n.ruleToStopState[t.ruleIndex].stateNumber,this.errorHandler.reportError(this,s),this.recover(s);else throw s}break}}}}addDecisionOverride(n,e,t){this.#e=n,this.#t=e,this.overrideDecisionAlt=t}get overrideDecision(){return this.#e}get overrideDecisionInputIndex(){return this.#t}enterRecursionRule(n,e,t,s){this.parentContextStack.push([this.context,n.invokingState]),super.enterRecursionRule(n,e,t,s)}get serializedATN(){throw new Error("The ParserInterpreter does not support the serializedATN property.")}visitState(n){let e=1;n instanceof us&&(e=this.visitDecisionState(n));let t=n.transitions[e-1];switch(t.transitionType){case N.EPSILON:if(this.pushRecursionContextStates.get(n.stateNumber)&&t.target.constructor.stateType!==L.LOOP_END){let c=this.parentContextStack[this.parentContextStack.length-1],l=this.createInterpreterRuleContext(c[0],c[1],this.context.ruleIndex);this.pushNewRecursionContext(l,this.#n.ruleToStartState[n.ruleIndex].stateNumber,this.context.ruleIndex)}break;case N.ATOM:this.match(t.label.minElement);break;case N.RANGE:case N.SET:case N.NOT_SET:t.matches(this.inputStream.LA(1),x.MIN_USER_TOKEN_TYPE,65535)||this.recoverInline(),this.matchWildcard();break;case N.WILDCARD:this.matchWildcard();break;case N.RULE:let s=t.target,r=s.ruleIndex,i=this.createInterpreterRuleContext(this.context,n.stateNumber,r);s.isLeftRecursiveRule?this.enterRecursionRule(i,s.stateNumber,r,t.precedence):this.enterRule(i,t.target.stateNumber,r);break;case N.PREDICATE:let o=t;if(!this.sempred(this.context,o.ruleIndex,o.predIndex))throw new ei(this);break;case N.ACTION:let a=t;this.action(this.context,a.ruleIndex,a.actionIndex);break;case N.PRECEDENCE:if(!this.precpred(this.context,t.precedence)){let c=t.precedence;throw new ei(this,`precpred(_ctx, ${c})`)}break;default:throw new Error("UnsupportedOperationException: Unrecognized ATN transition type.")}this.state=t.target.stateNumber}visitDecisionState(n){let e=1;if(n.transitions.length>1){this.errorHandler.sync(this);let t=n.decision;t===this.#e&&this.inputStream.index===this.#t&&!this.overrideDecisionReached?(e=this.overrideDecisionAlt,this.overrideDecisionReached=!0):e=this.interpreter.adaptivePredict(this.inputStream,t,this.context)}return e}createInterpreterRuleContext(n,e,t){return new V0(t,n,e)}visitRuleStopState(n){if(this.#n.ruleToStartState[n.ruleIndex].isLeftRecursiveRule){let[s,r]=this.parentContextStack.pop();this.unrollRecursionContexts(s),this.state=r}else this.exitRule();let t=this.#n.states[this.state].transitions[0];this.state=t.followState.stateNumber}recover(n){let e=this.inputStream.index;if(this.errorHandler.recover(this,n),this.inputStream.index===e){let t=n.offendingToken;if(!t)throw new Error("Expected exception to have an offending token");let s=t.tokenSource,r=s?.inputStream??null,i=[s,r];if(n instanceof Xr){let o=n.getExpectedTokens();if(!o)throw new Error("Expected the exception to provide expected tokens");let a=x.INVALID_TYPE;o.length!==0&&(a=o.minElement);let c=this.getTokenFactory().create(i,a,t.text,x.DEFAULT_CHANNEL,-1,-1,t.line,t.column);this.context.addErrorNode(this.createErrorNode(this.context,c))}else{let o=this.getTokenFactory().create(i,x.INVALID_TYPE,t.text,x.DEFAULT_CHANNEL,-1,-1,t.line,t.column);this.context.addErrorNode(this.createErrorNode(this.context,o))}}}recoverInline(){return this.errorHandler.recoverInline(this)}},Kd=class extends Map{static{y(this,"MultiMap")}map(n,e){let t=this.get(n);t||(t=new Array,this.set(n,t)),t.push(e)}getPairs(){let n=new Array;for(let e of this.keys()){let t=this.get(e)??[];for(let s of t)n.push([e,s])}return n}toString(){let n=[];return this.forEach((e,t)=>{n.push(`${t}=[${e.join(", ")}]`)}),`{${n.join(", ")}}`}},q0=class extends Error{static{y(this,"CannotInvokeStartRuleError")}constructor(n){super(),this.cause=n}},Yd=class{static{y(this,"RuleTagToken")}label;ruleName;bypassTokenType;constructor(n,e,t){this.ruleName=n,this.bypassTokenType=e,this.label=t}get channel(){return x.DEFAULT_CHANNEL}get text(){return this.label!==void 0?"<"+this.label+":"+this.ruleName+">":"<"+this.ruleName+">"}get type(){return this.bypassTokenType}get line(){return 0}get column(){return-1}get tokenIndex(){return-1}get start(){return-1}get stop(){return-1}get tokenSource(){return null}get inputStream(){return null}toString(){return this.ruleName+":"+this.bypassTokenType}},z0=class extends Error{static{y(this,"StartRuleDoesNotConsumeFullPatternError")}},Jd=class extends jf{static{y(this,"TagChunk")}tag;label;constructor(...n){let e,t;if(n.length===1?t=n[0]:(e=n[0],t=n[1]),super(),!t)throw new Error("tag cannot be null or empty");this.label=e,this.tag=t}toString(){return this.label!==void 0?this.label+":"+this.tag:this.tag}},Js=class extends jf{static{y(this,"TextChunk")}text;constructor(n){super(),this.text=n}toString(){return"'"+this.text+"'"}},Xd=class extends To{static{y(this,"TokenTagToken")}tokenName;label;constructor(n,e,t){super({type:e,source:To.EMPTY_SOURCE}),this.tokenName=n,this.label=t}get text(){return this.label!==void 0?"<"+this.label+":"+this.tokenName+">":"<"+this.tokenName+">"}toString(){return this.tokenName+":"+this.type}},W0=class{static{y(this,"ParseTreePatternMatcher")}start="<";stop=">";escape="\\";lexer;parser;constructor(n,e){this.lexer=n,this.parser=e}setDelimiters(n,e,t){if(n===null||n.length===0)throw new Error("start cannot be null or empty");if(e===null||e.length===0)throw new Error("stop cannot be null or empty");this.start=n,this.stop=e,this.escape=t}matches(...n){switch(n.length){case 2:{let[e,t]=n,s=new Kd;return this.matchImpl(e,t.getPatternTree(),s)===null}case 3:{let[e,t,s]=n,r=this.compile(t,s);return this.matches(e,r)}default:throw new Error("Invalid number of arguments")}}match(...n){switch(n.length){case 2:{let[e,t]=n,s=new Kd,r=this.matchImpl(e,t.getPatternTree(),s);return new L0(e,t,s,r)}case 3:{let[e,t,s]=n,r=this.compile(t,s);return this.match(e,r)}default:throw new Error("Invalid number of arguments")}}compile(n,e){let t=this.tokenize(n),s=new j0(t),r=new ko(s),i=new B0(this.parser.grammarFileName,this.parser.vocabulary,this.parser.ruleNames,this.parser.getATNWithBypassAlts(),r);i.removeErrorListeners();let o=null;try{i.errorHandler=new F0,o=i.parse(e)}catch(a){throw a instanceof Ic?a.cause:a instanceof ie?a:a instanceof Error?new q0(a):a}if(r.LA(1)!==x.EOF)throw new z0;return new $0(this,n,e,o)}getLexer(){return this.lexer}getParser(){return this.parser}tokenize(n){let e=this.split(n),t=new Array;for(let s of e)if(s instanceof Jd){let r=s,i=r.tag[0];if(i===i.toUpperCase()){let o=this.parser.getTokenType(r.tag);if(o===x.INVALID_TYPE)throw new Error("Unknown token "+r.tag+" in pattern: "+n);let a=new Xd(r.tag,o,r.label);t.push(a)}else if(i===i.toLowerCase()){let o=this.parser.getRuleIndex(r.tag);if(o===-1)throw new Error("Unknown rule "+r.tag+" in pattern: "+n);let a=this.parser.getATNWithBypassAlts().ruleToTokenType[o];t.push(new Yd(r.tag,a,r.label))}else throw new Error("invalid tag: "+r.tag+" in pattern: "+n)}else{let r=s,i=rr.fromString(r.text);this.lexer.inputStream=i;let o=this.lexer.nextToken();for(;o.type!==x.EOF;)t.push(o),o=this.lexer.nextToken()}return t}split(n){let e=0,t=n.length,s=new Array,r=new Array,i=new Array;for(;e<t;)e===n.indexOf(this.escape+this.start,e)?e+=this.escape.length+this.start.length:e===n.indexOf(this.escape+this.stop,e)?e+=this.escape.length+this.stop.length:e===n.indexOf(this.start,e)?(r.push(e),e+=this.start.length):e===n.indexOf(this.stop,e)?(i.push(e),e+=this.stop.length):e++;if(r.length>i.length)throw new Error("unterminated tag in pattern: "+n);if(r.length<i.length)throw new Error("missing start tag in pattern: "+n);let o=r.length;for(let a=0;a<o;a++)if(r[a]>=i[a])throw new Error("tag delimiters out of order in pattern: "+n);if(o===0){let a=n.substring(0,t);s.push(new Js(a))}if(o>0&&r[0]>0){let a=n.substring(0,r[0]);s.push(new Js(a))}for(let a=0;a<o;a++){let c=n.substring(r[a]+this.start.length,i[a]),l=c,u,d=c.indexOf(":");if(d>=0&&(u=c.substring(0,d),l=c.substring(d+1,c.length)),s.push(new Jd(u,l)),a+1<o){let h=n.substring(i[a]+this.stop.length,r[a+1]);s.push(new Js(h))}}if(o>0){let a=i[o-1]+this.stop.length;if(a<t){let c=n.substring(a,t);s.push(new Js(c))}}for(let a=0;a<s.length;a++){let c=s[a];if(c instanceof Js){let l=c,u=l.text.replaceAll(this.escape,"");u.length<l.text.length&&(s[a]=new Js(u))}}return s}matchImpl(n,e,t){if(n instanceof gt&&e instanceof gt){let s=n,r=e,i;if(s.getSymbol().type===r.getSymbol().type)if(r.getSymbol()instanceof Xd){let o=r.getSymbol();t.map(o.tokenName,n),o.label!==void 0&&t.map(o.label,n)}else s.getText()===r.getText()||i||(i=s);else i||(i=s);return i}if(n instanceof K&&e instanceof K){let s,r=this.getRuleTagToken(e);if(r)return n.ruleIndex===e.ruleIndex?(t.map(r.ruleName,n),r.label&&t.map(r.label,n)):s||(s=n),s;if(n.getChildCount()!==e.getChildCount())return s||(s=n),s;let i=n.getChildCount();for(let o=0;o<i;o++){let a=this.matchImpl(n.getChild(o),e.getChild(o),t);if(a)return a}return s}return n}getRuleTagToken(n){if(n instanceof K&&n.getChildCount()===1&&n.getChild(0)instanceof gt){let e=n.getChild(0);if(e.getSymbol()instanceof Yd)return e.getSymbol()}}},vA=class extends ir{static{y(this,"DiagnosticErrorListener")}exactOnly;constructor(n){super(),this.exactOnly=n??!0}reportAmbiguity=y((n,e,t,s,r,i,o)=>{if(this.exactOnly&&!r)return;let a=this.getDecisionDescription(n,e),c=this.getConflictingAlts(i,o),l=n.tokenStream?.getTextFromInterval(Y.of(t,s)),u=`reportAmbiguity d=${a}: ambigAlts=${c}, input='${l}'`;n.notifyErrorListeners(u,null,null)},"reportAmbiguity");reportAttemptingFullContext=y((n,e,t,s,r,i)=>{let o=this.getDecisionDescription(n,e),a=n.tokenStream?.getTextFromInterval(Y.of(t,s)),c=`reportAttemptingFullContext d=${o}, input='${a}'`;n.notifyErrorListeners(c,null,null)},"reportAttemptingFullContext");reportContextSensitivity=y((n,e,t,s,r,i)=>{let o=this.getDecisionDescription(n,e),a=n.tokenStream?.getTextFromInterval(Y.of(t,s)),c=`reportContextSensitivity d=${o}, input='${a}'`;n.notifyErrorListeners(c,null,null)},"reportContextSensitivity");getDecisionDescription=y((n,e)=>{let t=e.decision,s=e.atnStartState.ruleIndex,r=n.ruleNames;if(s<0||s>=r.length)return t.toString();let i=r[s];return i.length===0?t.toString():`${t} (${i})`},"getDecisionDescription");getConflictingAlts=y((n,e)=>{if(n)return n;let t=new Lt;for(let s=0;s<e.configs.length;s++)t.set(e.configs[s].alt);return t},"getConflictingAlts")},EA=class extends nt{static{y(this,"LexerInterpreter")}decisionToDFA;sharedContextCache=new fs;#e;#t;#s;#n;#r;#i;constructor(n,e,t,s,r,i,o){if(super(o),i.grammarType!==Z.LEXER)throw new Error("IllegalArgumentException: The ATN must be a lexer ATN.");this.#e=n,this.#t=i,this.#s=t.slice(0),this.#n=s.slice(0),this.#r=r.slice(0),this.#i=e,this.decisionToDFA=i.decisionToState.map((a,c)=>new rn(a,c)),this.interpreter=new sr(this,i,this.decisionToDFA,this.sharedContextCache)}get atn(){return this.#t}get grammarFileName(){return this.#e}get ruleNames(){return this.#s}get channelNames(){return this.#n}get modeNames(){return this.#r}get vocabulary(){return this.#i}get serializedATN(){throw new Error("The LexerInterpreter does not support the serializedATN property.")}},CA=class is{static{y(this,"RuntimeMetaData")}static VERSION="4.13.1";static getRuntimeVersion(){return is.VERSION}static checkVersion(e,t){let s=is.VERSION,r=!1,i=!1;r=s!==e&&is.getMajorMinorVersion(s)!==is.getMajorMinorVersion(e),i=s!==t&&is.getMajorMinorVersion(s)!==is.getMajorMinorVersion(t),r&&console.error(`ANTLR Tool version ${e} used for code generation does not match the current runtime version ${s}`),i&&console.error(`ANTLR Runtime version ${t} used for parser compilation does not match the current runtime version ${s}`)}static getMajorMinorVersion(e){let t=e.indexOf("."),s=t>=0?e.indexOf(".",t+1):-1,r=e.indexOf("-"),i=e.length;return s>=0&&(i=Math.min(i,s)),r>=0&&(i=Math.min(i,r)),e.substring(0,i)}},TA=class os{static{y(this,"TokenStreamRewriter")}static DEFAULT_PROGRAM_NAME="default";static PROGRAM_INIT_SIZE=100;static MIN_TOKEN_INDEX=0;tokens;programs=new Map;lastRewriteTokenIndexes;constructor(e){this.tokens=e}getTokenStream(){return this.tokens}insertAfter(e,t,s=os.DEFAULT_PROGRAM_NAME){let r;typeof e=="number"?r=e:r=e.tokenIndex;let i=this.getProgram(s),o=new Qd(this.tokens,r,i.length,t);i.push(o)}insertBefore(e,t,s=os.DEFAULT_PROGRAM_NAME){let r;typeof e=="number"?r=e:r=e.tokenIndex;let i=this.getProgram(s),o=new Qs(this.tokens,r,i.length,t);i.push(o)}replaceSingle(e,t,s=os.DEFAULT_PROGRAM_NAME){this.replace(e,e,t,s)}replace(e,t,s,r=os.DEFAULT_PROGRAM_NAME){if(typeof e!="number"&&(e=e.tokenIndex),typeof t!="number"&&(t=t.tokenIndex),e>t||e<0||t<0||t>=this.tokens.size)throw new RangeError(`replace: range invalid: ${e}..${t}(size=${this.tokens.size})`);let i=this.getProgram(r),o=new bo(this.tokens,e,t,i.length,s);i.push(o)}delete(e,t,s=os.DEFAULT_PROGRAM_NAME){t==null&&(t=e),this.replace(e,t,null,s)}getProgram(e){let t=this.programs.get(e);return t==null&&(t=this.initializeProgram(e)),t}initializeProgram(e){let t=[];return this.programs.set(e,t),t}getText(e,t=os.DEFAULT_PROGRAM_NAME){let s;e instanceof Y?s=e:s=new Y(0,this.tokens.size-1),typeof e=="string"&&(t=e);let r=this.programs.get(t),i=s.start,o=s.stop;if(o>this.tokens.size-1&&(o=this.tokens.size-1),i<0&&(i=0),r==null||r.length===0)return this.tokens.getTextFromInterval(new Y(i,o));let a=[],c=this.reduceToSingleOperationPerIndex(r),l=i;for(;l<=o&&l<this.tokens.size;){let u=c.get(l);c.delete(l);let d=this.tokens.get(l);u==null?(d.type!==x.EOF&&a.push(String(d.text)),l++):l=u.execute(a)}if(o===this.tokens.size-1)for(let u of c.values())u&&u.index>=this.tokens.size-1&&a.push(String(u.text));return a.join("")}reduceToSingleOperationPerIndex(e){for(let s=0;s<e.length;s++){let r=e[s];if(r==null||!(r instanceof bo))continue;let i=r,o=this.getKindOfOps(e,Qs,s);for(let c of o)c.index===i.index?(e[c.instructionIndex]=null,i.text=String(c.text)+(i.text!=null?i.text.toString():"")):c.index>i.index&&c.index<=i.lastIndex&&(e[c.instructionIndex]=null);let a=this.getKindOfOps(e,bo,s);for(let c of a){if(c.index>=i.index&&c.lastIndex<=i.lastIndex){e[c.instructionIndex]=null;continue}let l=c.lastIndex<i.index||c.index>i.lastIndex;if(c.text==null&&i.text==null&&!l)e[c.instructionIndex]=null,i.index=Math.min(c.index,i.index),i.lastIndex=Math.max(c.lastIndex,i.lastIndex);else if(!l)throw new Error(`replace op boundaries of ${i} overlap with previous ${c}`)}}for(let s=0;s<e.length;s++){let r=e[s];if(r==null||!(r instanceof Qs))continue;let i=r,o=this.getKindOfOps(e,Qs,s);for(let c of o)c.index===i.index&&(c instanceof Qd?(i.text=this.catOpText(c.text,i.text),e[c.instructionIndex]=null):c instanceof Qs&&(i.text=this.catOpText(i.text,c.text),e[c.instructionIndex]=null));let a=this.getKindOfOps(e,bo,s);for(let c of a){if(i.index===c.index){c.text=this.catOpText(i.text,c.text),e[s]=null;continue}if(i.index>=c.index&&i.index<=c.lastIndex)throw new Error(`insert op ${i} within boundaries of previous ${c}`)}}let t=new Map;for(let s of e)if(s!=null){if(t.get(s.index)!=null)throw new Error("should only be one op per index");t.set(s.index,s)}return t}catOpText(e,t){let s="",r="";return e!=null&&(s=e.toString()),t!=null&&(r=t.toString()),s+r}getKindOfOps(e,t,s){return e.slice(0,s).filter(r=>r&&r instanceof t)}},Uf=class{static{y(this,"RewriteOperation")}instructionIndex;index;text;tokens;constructor(n,e,t,s){this.tokens=n,this.instructionIndex=t,this.index=e,this.text=s===void 0?"":s}execute(n){return this.index}toString(){return"<RewriteOperation@"+this.tokens.get(this.index)+':"'+this.text+'">'}},Qs=class extends Uf{static{y(this,"InsertBeforeOp")}constructor(n,e,t,s){super(n,e,t,s)}execute(n){return this.text&&n.push(this.text.toString()),this.tokens.get(this.index).type!==x.EOF&&n.push(String(this.tokens.get(this.index).text)),this.index+1}toString(){return"<InsertBeforeOp@"+this.tokens.get(this.index)+':"'+this.text+'">'}},Qd=class extends Qs{static{y(this,"InsertAfterOp")}constructor(n,e,t,s){super(n,e+1,t,s)}toString(){return"<InsertAfterOp@"+this.tokens.get(this.index)+':"'+this.text+'">'}},bo=class extends Uf{static{y(this,"ReplaceOp")}lastIndex;constructor(n,e,t,s,r){super(n,e,s,r),this.lastIndex=t}execute(n){return this.text&&n.push(this.text.toString()),this.lastIndex+1}toString(){return this.text==null?"<DeleteOp@"+this.tokens.get(this.index)+".."+this.tokens.get(this.lastIndex)+">":"<ReplaceOp@"+this.tokens.get(this.index)+".."+this.tokens.get(this.lastIndex)+':"'+this.text+'">'}},wA=class{static{y(this,"UnbufferedTokenStream")}tokenSource;tokens;n;p=0;numMarkers=0;lastToken;lastTokenBufferStart;currentTokenIndex=0;constructor(n,e){this.tokenSource=n,e=e??256,this.tokens=new Array(e),this.n=0,this.fill(1)}get(n){let e=this.getBufferStartIndex();if(n<e||n>=e+this.n)throw new Error("get("+n+") outside buffer: "+e+".."+(e+this.n));return this.tokens[n-e]}LT(n){if(n===-1)return this.lastToken;this.sync(n);let e=this.p+n-1;if(e<0)throw new Error("LT("+n+") gives negative index");return e>=this.n?this.tokens[this.n-1]:this.tokens[e]}LA(n){return this.LT(n).type}getText(){return""}getTextFromContext(n){return this.getTextFromInterval(n.getSourceInterval())}getTextFromInterval(n){let e=this.getBufferStartIndex(),t=e+this.tokens.length-1,s=n.start,r=n.stop;if(s<e||r>t)throw new Error("interval "+n+" not in token buffer window: "+e+".."+t);let i=s-e,o=r-e,a="";for(let c=i;c<=o;c++){let l=this.tokens[c];a+=l.text}return a}getTextFromRange(n,e){return this.getTextFromInterval(Y.of(n.tokenIndex,e.tokenIndex))}consume(){if(this.LA(1)===x.EOF)throw new Error("cannot consume EOF");this.lastToken=this.tokens[this.p],this.p===this.n-1&&this.numMarkers===0&&(this.n=0,this.p=-1,this.lastTokenBufferStart=this.lastToken),this.p++,this.currentTokenIndex++,this.sync(1)}mark(){this.numMarkers===0&&(this.lastTokenBufferStart=this.lastToken);let n=-this.numMarkers-1;return this.numMarkers++,n}release(n){let e=-this.numMarkers;if(n!==e)throw new Error("release() called with an invalid marker.");this.numMarkers--,this.numMarkers===0&&(this.p>0&&(this.tokens.copyWithin(0,this.p,this.n),this.n=this.n-this.p,this.p=0),this.lastTokenBufferStart=this.lastToken)}get index(){return this.currentTokenIndex}seek(n){if(n===this.currentTokenIndex)return;n>this.currentTokenIndex&&(this.sync(n-this.currentTokenIndex),n=Math.min(n,this.getBufferStartIndex()+this.n-1));let e=this.getBufferStartIndex(),t=n-e;if(t<0)throw new Error("cannot seek to negative index "+n);if(t>=this.n)throw new Error("seek to index outside buffer: "+n+" not in "+e+".."+(e+this.n));this.p=t,this.currentTokenIndex=n,this.p===0?this.lastToken=this.lastTokenBufferStart:this.lastToken=this.tokens[this.p-1]}get size(){throw new Error("Unbuffered stream cannot know its size")}getSourceName(){return this.tokenSource.sourceName}setLine(n){this.tokenSource.line=n}setColumn(n){this.tokenSource.column=n}sync(n){let e=this.p+n-1-this.n+1;e>0&&this.fill(e)}fill(n){for(let e=0;e<n;e++){if(this.n>0&&this.tokens[this.n-1].type===x.EOF)return e;let t=this.tokenSource.nextToken();this.add(t)}return n}add(n){this.n>=this.tokens.length&&(this.tokens.length=this.tokens.length*2),Mf(n)&&n.setTokenIndex(this.getBufferStartIndex()+this.n),this.tokens[this.n++]=n}getBufferStartIndex(){return this.currentTokenIndex-this.p}};var B=class n extends nt{constructor(e){super(e),this.interpreter=new sr(this,n._ATN,n.decisionsToDFA,new fs)}get grammarFileName(){return"Express.g4"}get literalNames(){return n.literalNames}get symbolicNames(){return n.symbolicNames}get ruleNames(){return n.ruleNames}get serializedATN(){return n._serializedATN}get channelNames(){return n.channelNames}get modeNames(){return n.modeNames}static get _ATN(){return n.__ATN||(n.__ATN=new Tn().deserialize(n._serializedATN)),n.__ATN}get vocabulary(){return n.vocabulary}};B.T__0=1;B.T__1=2;B.T__2=3;B.T__3=4;B.T__4=5;B.T__5=6;B.T__6=7;B.T__7=8;B.T__8=9;B.T__9=10;B.T__10=11;B.RAW_TRIPLE_STRING=12;B.TRIPLE_STRING=13;B.RAW_STRING=14;B.STANDARD_STRING=15;B.PATH=16;B.CHECK=17;B.NUMBER=18;B.BOOLEAN=19;B.IDENTIFIER=20;B.COMMENT=21;B.BLOCK_COMMENT=22;B.SEMICOLON=23;B.WS=24;B.channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"];B.literalNames=[null,"'='","'['","','","']'","'{'","'}'","':'","'('","')'","'_'","'null'",null,null,null,null,null,null,null,null,null,null,null,"';'"];B.symbolicNames=[null,null,null,null,null,null,null,null,null,null,null,null,"RAW_TRIPLE_STRING","TRIPLE_STRING","RAW_STRING","STANDARD_STRING","PATH","CHECK","NUMBER","BOOLEAN","IDENTIFIER","COMMENT","BLOCK_COMMENT","SEMICOLON","WS"];B.modeNames=["DEFAULT_MODE"];B.ruleNames=["T__0","T__1","T__2","T__3","T__4","T__5","T__6","T__7","T__8","T__9","T__10","RAW_TRIPLE_STRING","TRIPLE_STRING","RAW_STRING","STANDARD_STRING","PATH","CHECK","NUMBER","BOOLEAN","IDENTIFIER","COMMENT","BLOCK_COMMENT","SEMICOLON","WS"];B._serializedATN=[4,0,24,233,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,1,5,1,5,1,6,1,6,1,7,1,7,1,8,1,8,1,9,1,9,1,10,1,10,1,10,1,10,1,10,1,11,1,11,1,11,1,11,1,11,1,11,5,11,81,8,11,10,11,12,11,84,9,11,1,11,1,11,1,11,1,11,1,12,1,12,1,12,1,12,1,12,1,12,1,12,5,12,97,8,12,10,12,12,12,100,9,12,1,12,1,12,1,12,1,12,1,13,1,13,1,13,5,13,109,8,13,10,13,12,13,112,9,13,1,13,1,13,1,14,1,14,1,14,1,14,5,14,120,8,14,10,14,12,14,123,9,14,1,14,1,14,1,15,1,15,5,15,129,8,15,10,15,12,15,132,9,15,1,16,1,16,1,16,5,16,137,8,16,10,16,12,16,140,9,16,1,17,3,17,143,8,17,1,17,4,17,146,8,17,11,17,12,17,147,1,17,1,17,5,17,152,8,17,10,17,12,17,155,9,17,3,17,157,8,17,1,17,1,17,4,17,161,8,17,11,17,12,17,162,3,17,165,8,17,1,17,1,17,3,17,169,8,17,1,17,4,17,172,8,17,11,17,12,17,173,3,17,176,8,17,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,3,18,187,8,18,1,19,1,19,5,19,191,8,19,10,19,12,19,194,9,19,1,20,1,20,1,20,3,20,199,8,20,1,20,5,20,202,8,20,10,20,12,20,205,9,20,1,20,1,20,1,21,1,21,1,21,1,21,5,21,213,8,21,10,21,12,21,216,9,21,1,21,1,21,1,21,1,21,1,21,1,22,1,22,1,22,1,22,1,23,4,23,228,8,23,11,23,12,23,229,1,23,1,23,4,82,98,121,214,0,24,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,27,14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,24,1,0,11,2,0,82,82,114,114,1,0,92,92,3,0,10,10,13,13,34,34,4,0,47,57,65,90,95,95,97,122,685,0,65,90,95,95,97,122,170,170,181,181,186,186,192,214,216,246,248,705,710,721,736,740,748,748,750,750,880,884,886,887,891,893,895,895,902,902,904,906,908,908,910,929,931,1013,1015,1153,1162,1327,1329,1366,1369,1369,1376,1416,1488,1514,1519,1522,1568,1610,1646,1647,1649,1747,1749,1749,1765,1766,1774,1775,1786,1788,1791,1791,1808,1808,1810,1839,1869,1957,1969,1969,1994,2026,2036,2037,2042,2042,2048,2069,2074,2074,2084,2084,2088,2088,2112,2136,2144,2154,2160,2183,2185,2190,2208,2249,2308,2361,2365,2365,2384,2384,2392,2401,2417,2432,2437,2444,2447,2448,2451,2472,2474,2480,2482,2482,2486,2489,2493,2493,2510,2510,2524,2525,2527,2529,2544,2545,2556,2556,2565,2570,2575,2576,2579,2600,2602,2608,2610,2611,2613,2614,2616,2617,2649,2652,2654,2654,2674,2676,2693,2701,2703,2705,2707,2728,2730,2736,2738,2739,2741,2745,2749,2749,2768,2768,2784,2785,2809,2809,2821,2828,2831,2832,2835,2856,2858,2864,2866,2867,2869,2873,2877,2877,2908,2909,2911,2913,2929,2929,2947,2947,2949,2954,2958,2960,2962,2965,2969,2970,2972,2972,2974,2975,2979,2980,2984,2986,2990,3001,3024,3024,3077,3084,3086,3088,3090,3112,3114,3129,3133,3133,3160,3162,3165,3165,3168,3169,3200,3200,3205,3212,3214,3216,3218,3240,3242,3251,3253,3257,3261,3261,3293,3294,3296,3297,3313,3314,3332,3340,3342,3344,3346,3386,3389,3389,3406,3406,3412,3414,3423,3425,3450,3455,3461,3478,3482,3505,3507,3515,3517,3517,3520,3526,3585,3632,3634,3634,3648,3654,3713,3714,3716,3716,3718,3722,3724,3747,3749,3749,3751,3760,3762,3762,3773,3773,3776,3780,3782,3782,3804,3807,3840,3840,3904,3911,3913,3948,3976,3980,4096,4138,4159,4159,4176,4181,4186,4189,4193,4193,4197,4198,4206,4208,4213,4225,4238,4238,4256,4293,4295,4295,4301,4301,4304,4346,4348,4680,4682,4685,4688,4694,4696,4696,4698,4701,4704,4744,4746,4749,4752,4784,4786,4789,4792,4798,4800,4800,4802,4805,4808,4822,4824,4880,4882,4885,4888,4954,4992,5007,5024,5109,5112,5117,5121,5740,5743,5759,5761,5786,5792,5866,5870,5880,5888,5905,5919,5937,5952,5969,5984,5996,5998,6e3,6016,6067,6103,6103,6108,6108,6176,6264,6272,6312,6314,6314,6320,6389,6400,6430,6480,6509,6512,6516,6528,6571,6576,6601,6656,6678,6688,6740,6823,6823,6917,6963,6981,6988,7043,7072,7086,7087,7098,7141,7168,7203,7245,7247,7258,7293,7296,7306,7312,7354,7357,7359,7401,7404,7406,7411,7413,7414,7418,7418,7424,7615,7680,7957,7960,7965,7968,8005,8008,8013,8016,8023,8025,8025,8027,8027,8029,8029,8031,8061,8064,8116,8118,8124,8126,8126,8130,8132,8134,8140,8144,8147,8150,8155,8160,8172,8178,8180,8182,8188,8305,8305,8319,8319,8336,8348,8450,8450,8455,8455,8458,8467,8469,8469,8472,8477,8484,8484,8486,8486,8488,8488,8490,8505,8508,8511,8517,8521,8526,8526,8544,8584,11264,11492,11499,11502,11506,11507,11520,11557,11559,11559,11565,11565,11568,11623,11631,11631,11648,11670,11680,11686,11688,11694,11696,11702,11704,11710,11712,11718,11720,11726,11728,11734,11736,11742,12293,12295,12321,12329,12337,12341,12344,12348,12353,12438,12445,12447,12449,12538,12540,12543,12549,12591,12593,12686,12704,12735,12784,12799,13312,19903,19968,42124,42192,42237,42240,42508,42512,42527,42538,42539,42560,42606,42623,42653,42656,42735,42775,42783,42786,42888,42891,42957,42960,42961,42963,42963,42965,42972,42994,43009,43011,43013,43015,43018,43020,43042,43072,43123,43138,43187,43250,43255,43259,43259,43261,43262,43274,43301,43312,43334,43360,43388,43396,43442,43471,43471,43488,43492,43494,43503,43514,43518,43520,43560,43584,43586,43588,43595,43616,43638,43642,43642,43646,43695,43697,43697,43701,43702,43705,43709,43712,43712,43714,43714,43739,43741,43744,43754,43762,43764,43777,43782,43785,43790,43793,43798,43808,43814,43816,43822,43824,43866,43868,43881,43888,44002,44032,55203,55216,55238,55243,55291,63744,64109,64112,64217,64256,64262,64275,64279,64285,64285,64287,64296,64298,64310,64312,64316,64318,64318,64320,64321,64323,64324,64326,64433,64467,64605,64612,64829,64848,64911,64914,64967,65008,65017,65137,65137,65139,65139,65143,65143,65145,65145,65147,65147,65149,65149,65151,65276,65313,65338,65345,65370,65382,65437,65440,65470,65474,65479,65482,65487,65490,65495,65498,65500,65536,65547,65549,65574,65576,65594,65596,65597,65599,65613,65616,65629,65664,65786,65856,65908,66176,66204,66208,66256,66304,66335,66349,66378,66384,66421,66432,66461,66464,66499,66504,66511,66513,66517,66560,66717,66736,66771,66776,66811,66816,66855,66864,66915,66928,66938,66940,66954,66956,66962,66964,66965,66967,66977,66979,66993,66995,67001,67003,67004,67008,67059,67072,67382,67392,67413,67424,67431,67456,67461,67463,67504,67506,67514,67584,67589,67592,67592,67594,67637,67639,67640,67644,67644,67647,67669,67680,67702,67712,67742,67808,67826,67828,67829,67840,67861,67872,67897,67968,68023,68030,68031,68096,68096,68112,68115,68117,68119,68121,68149,68192,68220,68224,68252,68288,68295,68297,68324,68352,68405,68416,68437,68448,68466,68480,68497,68608,68680,68736,68786,68800,68850,68864,68899,68938,68965,68975,68997,69248,69289,69296,69297,69314,69316,69376,69404,69415,69415,69424,69445,69488,69505,69552,69572,69600,69622,69635,69687,69745,69746,69749,69749,69763,69807,69840,69864,69891,69926,69956,69956,69959,69959,69968,70002,70006,70006,70019,70066,70081,70084,70106,70106,70108,70108,70144,70161,70163,70187,70207,70208,70272,70278,70280,70280,70282,70285,70287,70301,70303,70312,70320,70366,70405,70412,70415,70416,70419,70440,70442,70448,70450,70451,70453,70457,70461,70461,70480,70480,70493,70497,70528,70537,70539,70539,70542,70542,70544,70581,70583,70583,70609,70609,70611,70611,70656,70708,70727,70730,70751,70753,70784,70831,70852,70853,70855,70855,71040,71086,71128,71131,71168,71215,71236,71236,71296,71338,71352,71352,71424,71450,71488,71494,71680,71723,71840,71903,71935,71942,71945,71945,71948,71955,71957,71958,71960,71983,71999,71999,72001,72001,72096,72103,72106,72144,72161,72161,72163,72163,72192,72192,72203,72242,72250,72250,72272,72272,72284,72329,72349,72349,72368,72440,72640,72672,72704,72712,72714,72750,72768,72768,72818,72847,72960,72966,72968,72969,72971,73008,73030,73030,73056,73061,73063,73064,73066,73097,73112,73112,73440,73458,73474,73474,73476,73488,73490,73523,73648,73648,73728,74649,74752,74862,74880,75075,77712,77808,77824,78895,78913,78918,78944,82938,82944,83526,90368,90397,92160,92728,92736,92766,92784,92862,92880,92909,92928,92975,92992,92995,93027,93047,93053,93071,93504,93548,93760,93823,93952,94026,94032,94032,94099,94111,94176,94177,94179,94179,94208,100343,100352,101589,101631,101640,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,113664,113770,113776,113788,113792,113800,113808,113817,119808,119892,119894,119964,119966,119967,119970,119970,119973,119974,119977,119980,119982,119993,119995,119995,119997,120003,120005,120069,120071,120074,120077,120084,120086,120092,120094,120121,120123,120126,120128,120132,120134,120134,120138,120144,120146,120485,120488,120512,120514,120538,120540,120570,120572,120596,120598,120628,120630,120654,120656,120686,120688,120712,120714,120744,120746,120770,120772,120779,122624,122654,122661,122666,122928,122989,123136,123180,123191,123197,123214,123214,123536,123565,123584,123627,124112,124139,124368,124397,124400,124400,124896,124902,124904,124907,124909,124910,124912,124926,124928,125124,125184,125251,125259,125259,126464,126467,126469,126495,126497,126498,126500,126500,126503,126503,126505,126514,126516,126519,126521,126521,126523,126523,126530,126530,126535,126535,126537,126537,126539,126539,126541,126543,126545,126546,126548,126548,126551,126551,126553,126553,126555,126555,126557,126557,126559,126559,126561,126562,126564,126564,126567,126570,126572,126578,126580,126583,126585,126588,126590,126590,126592,126601,126603,126619,126625,126627,126629,126633,126635,126651,131072,173791,173824,177977,177984,178205,178208,183969,183984,191456,191472,192093,194560,195101,196608,201546,201552,205743,800,0,48,57,65,90,95,95,97,122,170,170,181,181,183,183,186,186,192,214,216,246,248,705,710,721,736,740,748,748,750,750,768,884,886,887,891,893,895,895,902,906,908,908,910,929,931,1013,1015,1153,1155,1159,1162,1327,1329,1366,1369,1369,1376,1416,1425,1469,1471,1471,1473,1474,1476,1477,1479,1479,1488,1514,1519,1522,1552,1562,1568,1641,1646,1747,1749,1756,1759,1768,1770,1788,1791,1791,1808,1866,1869,1969,1984,2037,2042,2042,2045,2045,2048,2093,2112,2139,2144,2154,2160,2183,2185,2190,2199,2273,2275,2403,2406,2415,2417,2435,2437,2444,2447,2448,2451,2472,2474,2480,2482,2482,2486,2489,2492,2500,2503,2504,2507,2510,2519,2519,2524,2525,2527,2531,2534,2545,2556,2556,2558,2558,2561,2563,2565,2570,2575,2576,2579,2600,2602,2608,2610,2611,2613,2614,2616,2617,2620,2620,2622,2626,2631,2632,2635,2637,2641,2641,2649,2652,2654,2654,2662,2677,2689,2691,2693,2701,2703,2705,2707,2728,2730,2736,2738,2739,2741,2745,2748,2757,2759,2761,2763,2765,2768,2768,2784,2787,2790,2799,2809,2815,2817,2819,2821,2828,2831,2832,2835,2856,2858,2864,2866,2867,2869,2873,2876,2884,2887,2888,2891,2893,2901,2903,2908,2909,2911,2915,2918,2927,2929,2929,2946,2947,2949,2954,2958,2960,2962,2965,2969,2970,2972,2972,2974,2975,2979,2980,2984,2986,2990,3001,3006,3010,3014,3016,3018,3021,3024,3024,3031,3031,3046,3055,3072,3084,3086,3088,3090,3112,3114,3129,3132,3140,3142,3144,3146,3149,3157,3158,3160,3162,3165,3165,3168,3171,3174,3183,3200,3203,3205,3212,3214,3216,3218,3240,3242,3251,3253,3257,3260,3268,3270,3272,3274,3277,3285,3286,3293,3294,3296,3299,3302,3311,3313,3315,3328,3340,3342,3344,3346,3396,3398,3400,3402,3406,3412,3415,3423,3427,3430,3439,3450,3455,3457,3459,3461,3478,3482,3505,3507,3515,3517,3517,3520,3526,3530,3530,3535,3540,3542,3542,3544,3551,3558,3567,3570,3571,3585,3642,3648,3662,3664,3673,3713,3714,3716,3716,3718,3722,3724,3747,3749,3749,3751,3773,3776,3780,3782,3782,3784,3790,3792,3801,3804,3807,3840,3840,3864,3865,3872,3881,3893,3893,3895,3895,3897,3897,3902,3911,3913,3948,3953,3972,3974,3991,3993,4028,4038,4038,4096,4169,4176,4253,4256,4293,4295,4295,4301,4301,4304,4346,4348,4680,4682,4685,4688,4694,4696,4696,4698,4701,4704,4744,4746,4749,4752,4784,4786,4789,4792,4798,4800,4800,4802,4805,4808,4822,4824,4880,4882,4885,4888,4954,4957,4959,4969,4977,4992,5007,5024,5109,5112,5117,5121,5740,5743,5759,5761,5786,5792,5866,5870,5880,5888,5909,5919,5940,5952,5971,5984,5996,5998,6e3,6002,6003,6016,6099,6103,6103,6108,6109,6112,6121,6155,6157,6159,6169,6176,6264,6272,6314,6320,6389,6400,6430,6432,6443,6448,6459,6470,6509,6512,6516,6528,6571,6576,6601,6608,6618,6656,6683,6688,6750,6752,6780,6783,6793,6800,6809,6823,6823,6832,6845,6847,6862,6912,6988,6992,7001,7019,7027,7040,7155,7168,7223,7232,7241,7245,7293,7296,7306,7312,7354,7357,7359,7376,7378,7380,7418,7424,7957,7960,7965,7968,8005,8008,8013,8016,8023,8025,8025,8027,8027,8029,8029,8031,8061,8064,8116,8118,8124,8126,8126,8130,8132,8134,8140,8144,8147,8150,8155,8160,8172,8178,8180,8182,8188,8204,8205,8255,8256,8276,8276,8305,8305,8319,8319,8336,8348,8400,8412,8417,8417,8421,8432,8450,8450,8455,8455,8458,8467,8469,8469,8472,8477,8484,8484,8486,8486,8488,8488,8490,8505,8508,8511,8517,8521,8526,8526,8544,8584,11264,11492,11499,11507,11520,11557,11559,11559,11565,11565,11568,11623,11631,11631,11647,11670,11680,11686,11688,11694,11696,11702,11704,11710,11712,11718,11720,11726,11728,11734,11736,11742,11744,11775,12293,12295,12321,12335,12337,12341,12344,12348,12353,12438,12441,12442,12445,12447,12449,12543,12549,12591,12593,12686,12704,12735,12784,12799,13312,19903,19968,42124,42192,42237,42240,42508,42512,42539,42560,42607,42612,42621,42623,42737,42775,42783,42786,42888,42891,42957,42960,42961,42963,42963,42965,42972,42994,43047,43052,43052,43072,43123,43136,43205,43216,43225,43232,43255,43259,43259,43261,43309,43312,43347,43360,43388,43392,43456,43471,43481,43488,43518,43520,43574,43584,43597,43600,43609,43616,43638,43642,43714,43739,43741,43744,43759,43762,43766,43777,43782,43785,43790,43793,43798,43808,43814,43816,43822,43824,43866,43868,43881,43888,44010,44012,44013,44016,44025,44032,55203,55216,55238,55243,55291,63744,64109,64112,64217,64256,64262,64275,64279,64285,64296,64298,64310,64312,64316,64318,64318,64320,64321,64323,64324,64326,64433,64467,64605,64612,64829,64848,64911,64914,64967,65008,65017,65024,65039,65056,65071,65075,65076,65101,65103,65137,65137,65139,65139,65143,65143,65145,65145,65147,65147,65149,65149,65151,65276,65296,65305,65313,65338,65343,65343,65345,65370,65381,65470,65474,65479,65482,65487,65490,65495,65498,65500,65536,65547,65549,65574,65576,65594,65596,65597,65599,65613,65616,65629,65664,65786,65856,65908,66045,66045,66176,66204,66208,66256,66272,66272,66304,66335,66349,66378,66384,66426,66432,66461,66464,66499,66504,66511,66513,66517,66560,66717,66720,66729,66736,66771,66776,66811,66816,66855,66864,66915,66928,66938,66940,66954,66956,66962,66964,66965,66967,66977,66979,66993,66995,67001,67003,67004,67008,67059,67072,67382,67392,67413,67424,67431,67456,67461,67463,67504,67506,67514,67584,67589,67592,67592,67594,67637,67639,67640,67644,67644,67647,67669,67680,67702,67712,67742,67808,67826,67828,67829,67840,67861,67872,67897,67968,68023,68030,68031,68096,68099,68101,68102,68108,68115,68117,68119,68121,68149,68152,68154,68159,68159,68192,68220,68224,68252,68288,68295,68297,68326,68352,68405,68416,68437,68448,68466,68480,68497,68608,68680,68736,68786,68800,68850,68864,68903,68912,68921,68928,68965,68969,68973,68975,68997,69248,69289,69291,69292,69296,69297,69314,69316,69372,69404,69415,69415,69424,69456,69488,69509,69552,69572,69600,69622,69632,69702,69734,69749,69759,69818,69826,69826,69840,69864,69872,69881,69888,69940,69942,69951,69956,69959,69968,70003,70006,70006,70016,70084,70089,70092,70094,70106,70108,70108,70144,70161,70163,70199,70206,70209,70272,70278,70280,70280,70282,70285,70287,70301,70303,70312,70320,70378,70384,70393,70400,70403,70405,70412,70415,70416,70419,70440,70442,70448,70450,70451,70453,70457,70459,70468,70471,70472,70475,70477,70480,70480,70487,70487,70493,70499,70502,70508,70512,70516,70528,70537,70539,70539,70542,70542,70544,70581,70583,70592,70594,70594,70597,70597,70599,70602,70604,70611,70625,70626,70656,70730,70736,70745,70750,70753,70784,70853,70855,70855,70864,70873,71040,71093,71096,71104,71128,71133,71168,71232,71236,71236,71248,71257,71296,71352,71360,71369,71376,71395,71424,71450,71453,71467,71472,71481,71488,71494,71680,71738,71840,71913,71935,71942,71945,71945,71948,71955,71957,71958,71960,71989,71991,71992,71995,72003,72016,72025,72096,72103,72106,72151,72154,72161,72163,72164,72192,72254,72263,72263,72272,72345,72349,72349,72368,72440,72640,72672,72688,72697,72704,72712,72714,72758,72760,72768,72784,72793,72818,72847,72850,72871,72873,72886,72960,72966,72968,72969,72971,73014,73018,73018,73020,73021,73023,73031,73040,73049,73056,73061,73063,73064,73066,73102,73104,73105,73107,73112,73120,73129,73440,73462,73472,73488,73490,73530,73534,73538,73552,73562,73648,73648,73728,74649,74752,74862,74880,75075,77712,77808,77824,78895,78912,78933,78944,82938,82944,83526,90368,90425,92160,92728,92736,92766,92768,92777,92784,92862,92864,92873,92880,92909,92912,92916,92928,92982,92992,92995,93008,93017,93027,93047,93053,93071,93504,93548,93552,93561,93760,93823,93952,94026,94031,94087,94095,94111,94176,94177,94179,94180,94192,94193,94208,100343,100352,101589,101631,101640,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,113664,113770,113776,113788,113792,113800,113808,113817,113821,113822,118e3,118009,118528,118573,118576,118598,119141,119145,119149,119154,119163,119170,119173,119179,119210,119213,119362,119364,119808,119892,119894,119964,119966,119967,119970,119970,119973,119974,119977,119980,119982,119993,119995,119995,119997,120003,120005,120069,120071,120074,120077,120084,120086,120092,120094,120121,120123,120126,120128,120132,120134,120134,120138,120144,120146,120485,120488,120512,120514,120538,120540,120570,120572,120596,120598,120628,120630,120654,120656,120686,120688,120712,120714,120744,120746,120770,120772,120779,120782,120831,121344,121398,121403,121452,121461,121461,121476,121476,121499,121503,121505,121519,122624,122654,122661,122666,122880,122886,122888,122904,122907,122913,122915,122916,122918,122922,122928,122989,123023,123023,123136,123180,123184,123197,123200,123209,123214,123214,123536,123566,123584,123641,124112,124153,124368,124410,124896,124902,124904,124907,124909,124910,124912,124926,124928,125124,125136,125142,125184,125259,125264,125273,126464,126467,126469,126495,126497,126498,126500,126500,126503,126503,126505,126514,126516,126519,126521,126521,126523,126523,126530,126530,126535,126535,126537,126537,126539,126539,126541,126543,126545,126546,126548,126548,126551,126551,126553,126553,126555,126555,126557,126557,126559,126559,126561,126562,126564,126564,126567,126570,126572,126578,126580,126583,126585,126588,126590,126590,126592,126601,126603,126619,126625,126627,126629,126633,126635,126651,130032,130041,131072,173791,173824,177977,177984,178205,178208,183969,183984,191456,191472,192093,194560,195101,196608,201546,201552,205743,917760,917999,2,0,43,43,45,45,1,0,48,57,2,0,69,69,101,101,2,0,10,10,13,13,3,0,9,10,13,13,32,32,255,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,47,1,0,0,0,1,49,1,0,0,0,3,51,1,0,0,0,5,53,1,0,0,0,7,55,1,0,0,0,9,57,1,0,0,0,11,59,1,0,0,0,13,61,1,0,0,0,15,63,1,0,0,0,17,65,1,0,0,0,19,67,1,0,0,0,21,69,1,0,0,0,23,74,1,0,0,0,25,89,1,0,0,0,27,105,1,0,0,0,29,115,1,0,0,0,31,126,1,0,0,0,33,133,1,0,0,0,35,142,1,0,0,0,37,186,1,0,0,0,39,188,1,0,0,0,41,198,1,0,0,0,43,208,1,0,0,0,45,222,1,0,0,0,47,227,1,0,0,0,49,50,5,61,0,0,50,2,1,0,0,0,51,52,5,91,0,0,52,4,1,0,0,0,53,54,5,44,0,0,54,6,1,0,0,0,55,56,5,93,0,0,56,8,1,0,0,0,57,58,5,123,0,0,58,10,1,0,0,0,59,60,5,125,0,0,60,12,1,0,0,0,61,62,5,58,0,0,62,14,1,0,0,0,63,64,5,40,0,0,64,16,1,0,0,0,65,66,5,41,0,0,66,18,1,0,0,0,67,68,5,95,0,0,68,20,1,0,0,0,69,70,5,110,0,0,70,71,5,117,0,0,71,72,5,108,0,0,72,73,5,108,0,0,73,22,1,0,0,0,74,75,7,0,0,0,75,76,5,34,0,0,76,77,5,34,0,0,77,78,5,34,0,0,78,82,1,0,0,0,79,81,9,0,0,0,80,79,1,0,0,0,81,84,1,0,0,0,82,83,1,0,0,0,82,80,1,0,0,0,83,85,1,0,0,0,84,82,1,0,0,0,85,86,5,34,0,0,86,87,5,34,0,0,87,88,5,34,0,0,88,24,1,0,0,0,89,90,5,34,0,0,90,91,5,34,0,0,91,92,5,34,0,0,92,98,1,0,0,0,93,94,5,92,0,0,94,97,9,0,0,0,95,97,8,1,0,0,96,93,1,0,0,0,96,95,1,0,0,0,97,100,1,0,0,0,98,99,1,0,0,0,98,96,1,0,0,0,99,101,1,0,0,0,100,98,1,0,0,0,101,102,5,34,0,0,102,103,5,34,0,0,103,104,5,34,0,0,104,26,1,0,0,0,105,106,7,0,0,0,106,110,5,34,0,0,107,109,8,2,0,0,108,107,1,0,0,0,109,112,1,0,0,0,110,108,1,0,0,0,110,111,1,0,0,0,111,113,1,0,0,0,112,110,1,0,0,0,113,114,5,34,0,0,114,28,1,0,0,0,115,121,5,34,0,0,116,117,5,92,0,0,117,120,9,0,0,0,118,120,8,1,0,0,119,116,1,0,0,0,119,118,1,0,0,0,120,123,1,0,0,0,121,122,1,0,0,0,121,119,1,0,0,0,122,124,1,0,0,0,123,121,1,0,0,0,124,125,5,34,0,0,125,30,1,0,0,0,126,130,5,36,0,0,127,129,7,3,0,0,128,127,1,0,0,0,129,132,1,0,0,0,130,128,1,0,0,0,130,131,1,0,0,0,131,32,1,0,0,0,132,130,1,0,0,0,133,134,5,63,0,0,134,138,7,4,0,0,135,137,7,5,0,0,136,135,1,0,0,0,137,140,1,0,0,0,138,136,1,0,0,0,138,139,1,0,0,0,139,34,1,0,0,0,140,138,1,0,0,0,141,143,7,6,0,0,142,141,1,0,0,0,142,143,1,0,0,0,143,164,1,0,0,0,144,146,7,7,0,0,145,144,1,0,0,0,146,147,1,0,0,0,147,145,1,0,0,0,147,148,1,0,0,0,148,156,1,0,0,0,149,153,5,46,0,0,150,152,7,7,0,0,151,150,1,0,0,0,152,155,1,0,0,0,153,151,1,0,0,0,153,154,1,0,0,0,154,157,1,0,0,0,155,153,1,0,0,0,156,149,1,0,0,0,156,157,1,0,0,0,157,165,1,0,0,0,158,160,5,46,0,0,159,161,7,7,0,0,160,159,1,0,0,0,161,162,1,0,0,0,162,160,1,0,0,0,162,163,1,0,0,0,163,165,1,0,0,0,164,145,1,0,0,0,164,158,1,0,0,0,165,175,1,0,0,0,166,168,7,8,0,0,167,169,7,6,0,0,168,167,1,0,0,0,168,169,1,0,0,0,169,171,1,0,0,0,170,172,7,7,0,0,171,170,1,0,0,0,172,173,1,0,0,0,173,171,1,0,0,0,173,174,1,0,0,0,174,176,1,0,0,0,175,166,1,0,0,0,175,176,1,0,0,0,176,36,1,0,0,0,177,178,5,116,0,0,178,179,5,114,0,0,179,180,5,117,0,0,180,187,5,101,0,0,181,182,5,102,0,0,182,183,5,97,0,0,183,184,5,108,0,0,184,185,5,115,0,0,185,187,5,101,0,0,186,177,1,0,0,0,186,181,1,0,0,0,187,38,1,0,0,0,188,192,7,4,0,0,189,191,7,5,0,0,190,189,1,0,0,0,191,194,1,0,0,0,192,190,1,0,0,0,192,193,1,0,0,0,193,40,1,0,0,0,194,192,1,0,0,0,195,199,5,35,0,0,196,197,5,47,0,0,197,199,5,47,0,0,198,195,1,0,0,0,198,196,1,0,0,0,199,203,1,0,0,0,200,202,8,9,0,0,201,200,1,0,0,0,202,205,1,0,0,0,203,201,1,0,0,0,203,204,1,0,0,0,204,206,1,0,0,0,205,203,1,0,0,0,206,207,6,20,0,0,207,42,1,0,0,0,208,209,5,47,0,0,209,210,5,42,0,0,210,214,1,0,0,0,211,213,9,0,0,0,212,211,1,0,0,0,213,216,1,0,0,0,214,215,1,0,0,0,214,212,1,0,0,0,215,217,1,0,0,0,216,214,1,0,0,0,217,218,5,42,0,0,218,219,5,47,0,0,219,220,1,0,0,0,220,221,6,21,0,0,221,44,1,0,0,0,222,223,5,59,0,0,223,224,1,0,0,0,224,225,6,22,0,0,225,46,1,0,0,0,226,228,7,10,0,0,227,226,1,0,0,0,228,229,1,0,0,0,229,227,1,0,0,0,229,230,1,0,0,0,230,231,1,0,0,0,231,232,6,23,0,0,232,48,1,0,0,0,24,0,82,96,98,110,119,121,130,138,142,147,153,156,162,164,168,173,175,186,192,198,203,214,229,1,6,0,0];B.vocabulary=new yt(B.literalNames,B.symbolicNames,[]);B.decisionsToDFA=B._ATN.decisionToState.map((n,e)=>new rn(n,e));var T=class n extends Pc{get grammarFileName(){return"Express.g4"}get literalNames(){return n.literalNames}get symbolicNames(){return n.symbolicNames}get ruleNames(){return n.ruleNames}get serializedATN(){return n._serializedATN}createFailedPredicateException(e,t){return new ei(this,e,t)}constructor(e){super(e),this.interpreter=new ti(this,n._ATN,n.decisionsToDFA,new fs)}program(){let e=new Dc(this.context,this.state);this.enterRule(e,0,n.RULE_program);let t;try{this.enterOuterAlt(e,1);{for(this.state=35,this.errorHandler.sync(this),t=this.tokenStream.LA(1);(t&-32)===0&&(1<<t&2096164)!==0;)this.state=32,this.statement(),this.state=37,this.errorHandler.sync(this),t=this.tokenStream.LA(1);this.state=38,this.match(n.EOF)}}catch(s){if(s instanceof ie)this.errorHandler.reportError(this,s),this.errorHandler.recover(this,s);else throw s}finally{this.exitRule()}return e}statement(){let e=new ni(this.context,this.state);this.enterRule(e,2,n.RULE_statement);try{switch(this.state=42,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,1,this.context)){case 1:this.enterOuterAlt(e,1),this.state=40,this.assignment();break;case 2:this.enterOuterAlt(e,2),this.state=41,this.expression();break}}catch(t){if(t instanceof ie)this.errorHandler.reportError(this,t),this.errorHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}assignment(){let e=new Ro(this.context,this.state);this.enterRule(e,4,n.RULE_assignment);try{this.enterOuterAlt(e,1);{switch(this.state=46,this.errorHandler.sync(this),this.tokenStream.LA(1)){case n.IDENTIFIER:this.state=44,this.identifier();break;case n.PATH:this.state=45,this.path();break;default:throw new ds(this)}this.state=48,this.match(n.T__0),this.state=49,this.expression()}}catch(t){if(t instanceof ie)this.errorHandler.reportError(this,t),this.errorHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}expression(){let e=new st(this.context,this.state);this.enterRule(e,6,n.RULE_expression);try{switch(this.state=58,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,3,this.context)){case 1:this.enterOuterAlt(e,1),this.state=51,this.array();break;case 2:this.enterOuterAlt(e,2),this.state=52,this.map();break;case 3:this.enterOuterAlt(e,3),this.state=53,this.path();break;case 4:this.enterOuterAlt(e,4),this.state=54,this.check();break;case 5:this.enterOuterAlt(e,5),this.state=55,this.call();break;case 6:this.enterOuterAlt(e,6),this.state=56,this.variable();break;case 7:this.enterOuterAlt(e,7),this.state=57,this.literal();break}}catch(t){if(t instanceof ie)this.errorHandler.reportError(this,t),this.errorHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}array(){let e=new _o(this.context,this.state);this.enterRule(e,8,n.RULE_array);let t;try{let s;this.enterOuterAlt(e,1);{if(this.state=60,this.match(n.T__1),this.state=72,this.errorHandler.sync(this),t=this.tokenStream.LA(1),(t&-32)===0&&(1<<t&2096164)!==0){for(this.state=61,this.expression(),this.state=66,this.errorHandler.sync(this),s=this.interpreter.adaptivePredict(this.tokenStream,4,this.context);s!==2&&s!==Z.INVALID_ALT_NUMBER;)s===1&&(this.state=62,this.match(n.T__2),this.state=63,this.expression()),this.state=68,this.errorHandler.sync(this),s=this.interpreter.adaptivePredict(this.tokenStream,4,this.context);this.state=70,this.errorHandler.sync(this),t=this.tokenStream.LA(1),t===3&&(this.state=69,this.match(n.T__2))}this.state=74,this.match(n.T__3)}}catch(s){if(s instanceof ie)this.errorHandler.reportError(this,s),this.errorHandler.recover(this,s);else throw s}finally{this.exitRule()}return e}map(){let e=new No(this.context,this.state);this.enterRule(e,10,n.RULE_map);let t;try{let s;this.enterOuterAlt(e,1);{if(this.state=76,this.match(n.T__4),this.state=88,this.errorHandler.sync(this),t=this.tokenStream.LA(1),(t&-32)===0&&(1<<t&1110016)!==0){for(this.state=77,this.map_entry(),this.state=82,this.errorHandler.sync(this),s=this.interpreter.adaptivePredict(this.tokenStream,7,this.context);s!==2&&s!==Z.INVALID_ALT_NUMBER;)s===1&&(this.state=78,this.match(n.T__2),this.state=79,this.map_entry()),this.state=84,this.errorHandler.sync(this),s=this.interpreter.adaptivePredict(this.tokenStream,7,this.context);this.state=86,this.errorHandler.sync(this),t=this.tokenStream.LA(1),t===3&&(this.state=85,this.match(n.T__2))}this.state=90,this.match(n.T__5)}}catch(s){if(s instanceof ie)this.errorHandler.reportError(this,s),this.errorHandler.recover(this,s);else throw s}finally{this.exitRule()}return e}map_entry(){let e=new si(this.context,this.state);this.enterRule(e,12,n.RULE_map_entry);try{this.enterOuterAlt(e,1);{switch(this.state=94,this.errorHandler.sync(this),this.tokenStream.LA(1)){case n.IDENTIFIER:this.state=92,this.identifier();break;case n.RAW_TRIPLE_STRING:case n.TRIPLE_STRING:case n.RAW_STRING:case n.STANDARD_STRING:this.state=93,this.string_();break;default:throw new ds(this)}this.state=96,this.match(n.T__6),this.state=97,this.expression()}}catch(t){if(t instanceof ie)this.errorHandler.reportError(this,t),this.errorHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}path(){let e=new ri(this.context,this.state);this.enterRule(e,14,n.RULE_path);try{this.enterOuterAlt(e,1),this.state=99,this.match(n.PATH)}catch(t){if(t instanceof ie)this.errorHandler.reportError(this,t),this.errorHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}check(){let e=new Oo(this.context,this.state);this.enterRule(e,16,n.RULE_check);let t;try{let s;if(this.enterOuterAlt(e,1),this.state=101,this.match(n.CHECK),this.state=117,this.errorHandler.sync(this),t=this.tokenStream.LA(1),t===8){if(this.state=102,this.match(n.T__7),this.state=114,this.errorHandler.sync(this),t=this.tokenStream.LA(1),(t&-32)===0&&(1<<t&2096164)!==0){for(this.state=103,this.expression(),this.state=108,this.errorHandler.sync(this),s=this.interpreter.adaptivePredict(this.tokenStream,11,this.context);s!==2&&s!==Z.INVALID_ALT_NUMBER;)s===1&&(this.state=104,this.match(n.T__2),this.state=105,this.expression()),this.state=110,this.errorHandler.sync(this),s=this.interpreter.adaptivePredict(this.tokenStream,11,this.context);this.state=112,this.errorHandler.sync(this),t=this.tokenStream.LA(1),t===3&&(this.state=111,this.match(n.T__2))}this.state=116,this.match(n.T__8)}}catch(s){if(s instanceof ie)this.errorHandler.reportError(this,s),this.errorHandler.recover(this,s);else throw s}finally{this.exitRule()}return e}call(){let e=new Po(this.context,this.state);this.enterRule(e,18,n.RULE_call);let t;try{let s;this.enterOuterAlt(e,1);{if(this.state=119,this.identifier(),this.state=120,this.match(n.T__7),this.state=132,this.errorHandler.sync(this),t=this.tokenStream.LA(1),(t&-32)===0&&(1<<t&2096164)!==0){for(this.state=121,this.arg(),this.state=126,this.errorHandler.sync(this),s=this.interpreter.adaptivePredict(this.tokenStream,15,this.context);s!==2&&s!==Z.INVALID_ALT_NUMBER;)s===1&&(this.state=122,this.match(n.T__2),this.state=123,this.arg()),this.state=128,this.errorHandler.sync(this),s=this.interpreter.adaptivePredict(this.tokenStream,15,this.context);this.state=130,this.errorHandler.sync(this),t=this.tokenStream.LA(1),t===3&&(this.state=129,this.match(n.T__2))}this.state=134,this.match(n.T__8)}}catch(s){if(s instanceof ie)this.errorHandler.reportError(this,s),this.errorHandler.recover(this,s);else throw s}finally{this.exitRule()}return e}arg(){let e=new ii(this.context,this.state);this.enterRule(e,20,n.RULE_arg);try{switch(this.state=138,this.errorHandler.sync(this),this.interpreter.adaptivePredict(this.tokenStream,18,this.context)){case 1:this.enterOuterAlt(e,1),this.state=136,this.named_arg();break;case 2:this.enterOuterAlt(e,2),this.state=137,this.expression();break}}catch(t){if(t instanceof ie)this.errorHandler.reportError(this,t),this.errorHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}named_arg(){let e=new Do(this.context,this.state);this.enterRule(e,22,n.RULE_named_arg);try{this.enterOuterAlt(e,1),this.state=140,this.identifier(),this.state=141,this.match(n.T__0),this.state=142,this.expression()}catch(t){if(t instanceof ie)this.errorHandler.reportError(this,t),this.errorHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}variable(){let e=new Lo(this.context,this.state);this.enterRule(e,24,n.RULE_variable);try{switch(this.state=146,this.errorHandler.sync(this),this.tokenStream.LA(1)){case n.T__9:this.enterOuterAlt(e,1),this.state=144,this.match(n.T__9);break;case n.IDENTIFIER:this.enterOuterAlt(e,2),this.state=145,this.identifier();break;default:throw new ds(this)}}catch(t){if(t instanceof ie)this.errorHandler.reportError(this,t),this.errorHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}literal(){let e=new $o(this.context,this.state);this.enterRule(e,26,n.RULE_literal);try{switch(this.state=152,this.errorHandler.sync(this),this.tokenStream.LA(1)){case n.RAW_TRIPLE_STRING:case n.TRIPLE_STRING:case n.RAW_STRING:case n.STANDARD_STRING:this.enterOuterAlt(e,1),this.state=148,this.string_();break;case n.NUMBER:this.enterOuterAlt(e,2),this.state=149,this.match(n.NUMBER);break;case n.BOOLEAN:this.enterOuterAlt(e,3),this.state=150,this.match(n.BOOLEAN);break;case n.T__10:this.enterOuterAlt(e,4),this.state=151,this.match(n.T__10);break;default:throw new ds(this)}}catch(t){if(t instanceof ie)this.errorHandler.reportError(this,t),this.errorHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}identifier(){let e=new wn(this.context,this.state);this.enterRule(e,28,n.RULE_identifier);try{this.enterOuterAlt(e,1),this.state=154,this.match(n.IDENTIFIER)}catch(t){if(t instanceof ie)this.errorHandler.reportError(this,t),this.errorHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}string_(){let e=new oi(this.context,this.state);this.enterRule(e,30,n.RULE_string);let t;try{this.enterOuterAlt(e,1),this.state=156,t=this.tokenStream.LA(1),(t&-32)===0&&(1<<t&61440)!==0?(this.errorHandler.reportMatch(this),this.consume()):this.errorHandler.recoverInline(this)}catch(s){if(s instanceof ie)this.errorHandler.reportError(this,s),this.errorHandler.recover(this,s);else throw s}finally{this.exitRule()}return e}static get _ATN(){return n.__ATN||(n.__ATN=new Tn().deserialize(n._serializedATN)),n.__ATN}get vocabulary(){return n.vocabulary}};T.T__0=1;T.T__1=2;T.T__2=3;T.T__3=4;T.T__4=5;T.T__5=6;T.T__6=7;T.T__7=8;T.T__8=9;T.T__9=10;T.T__10=11;T.RAW_TRIPLE_STRING=12;T.TRIPLE_STRING=13;T.RAW_STRING=14;T.STANDARD_STRING=15;T.PATH=16;T.CHECK=17;T.NUMBER=18;T.BOOLEAN=19;T.IDENTIFIER=20;T.COMMENT=21;T.BLOCK_COMMENT=22;T.SEMICOLON=23;T.WS=24;T.RULE_program=0;T.RULE_statement=1;T.RULE_assignment=2;T.RULE_expression=3;T.RULE_array=4;T.RULE_map=5;T.RULE_map_entry=6;T.RULE_path=7;T.RULE_check=8;T.RULE_call=9;T.RULE_arg=10;T.RULE_named_arg=11;T.RULE_variable=12;T.RULE_literal=13;T.RULE_identifier=14;T.RULE_string=15;T.literalNames=[null,"'='","'['","','","']'","'{'","'}'","':'","'('","')'","'_'","'null'",null,null,null,null,null,null,null,null,null,null,null,"';'"];T.symbolicNames=[null,null,null,null,null,null,null,null,null,null,null,null,"RAW_TRIPLE_STRING","TRIPLE_STRING","RAW_STRING","STANDARD_STRING","PATH","CHECK","NUMBER","BOOLEAN","IDENTIFIER","COMMENT","BLOCK_COMMENT","SEMICOLON","WS"];T.ruleNames=["program","statement","assignment","expression","array","map","map_entry","path","check","call","arg","named_arg","variable","literal","identifier","string"];T._serializedATN=[4,1,24,159,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,1,0,5,0,34,8,0,10,0,12,0,37,9,0,1,0,1,0,1,1,1,1,3,1,43,8,1,1,2,1,2,3,2,47,8,2,1,2,1,2,1,2,1,3,1,3,1,3,1,3,1,3,1,3,1,3,3,3,59,8,3,1,4,1,4,1,4,1,4,5,4,65,8,4,10,4,12,4,68,9,4,1,4,3,4,71,8,4,3,4,73,8,4,1,4,1,4,1,5,1,5,1,5,1,5,5,5,81,8,5,10,5,12,5,84,9,5,1,5,3,5,87,8,5,3,5,89,8,5,1,5,1,5,1,6,1,6,3,6,95,8,6,1,6,1,6,1,6,1,7,1,7,1,8,1,8,1,8,1,8,1,8,5,8,107,8,8,10,8,12,8,110,9,8,1,8,3,8,113,8,8,3,8,115,8,8,1,8,3,8,118,8,8,1,9,1,9,1,9,1,9,1,9,5,9,125,8,9,10,9,12,9,128,9,9,1,9,3,9,131,8,9,3,9,133,8,9,1,9,1,9,1,10,1,10,3,10,139,8,10,1,11,1,11,1,11,1,11,1,12,1,12,3,12,147,8,12,1,13,1,13,1,13,1,13,3,13,153,8,13,1,14,1,14,1,15,1,15,1,15,0,0,16,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,0,1,1,0,12,15,170,0,35,1,0,0,0,2,42,1,0,0,0,4,46,1,0,0,0,6,58,1,0,0,0,8,60,1,0,0,0,10,76,1,0,0,0,12,94,1,0,0,0,14,99,1,0,0,0,16,101,1,0,0,0,18,119,1,0,0,0,20,138,1,0,0,0,22,140,1,0,0,0,24,146,1,0,0,0,26,152,1,0,0,0,28,154,1,0,0,0,30,156,1,0,0,0,32,34,3,2,1,0,33,32,1,0,0,0,34,37,1,0,0,0,35,33,1,0,0,0,35,36,1,0,0,0,36,38,1,0,0,0,37,35,1,0,0,0,38,39,5,0,0,1,39,1,1,0,0,0,40,43,3,4,2,0,41,43,3,6,3,0,42,40,1,0,0,0,42,41,1,0,0,0,43,3,1,0,0,0,44,47,3,28,14,0,45,47,3,14,7,0,46,44,1,0,0,0,46,45,1,0,0,0,47,48,1,0,0,0,48,49,5,1,0,0,49,50,3,6,3,0,50,5,1,0,0,0,51,59,3,8,4,0,52,59,3,10,5,0,53,59,3,14,7,0,54,59,3,16,8,0,55,59,3,18,9,0,56,59,3,24,12,0,57,59,3,26,13,0,58,51,1,0,0,0,58,52,1,0,0,0,58,53,1,0,0,0,58,54,1,0,0,0,58,55,1,0,0,0,58,56,1,0,0,0,58,57,1,0,0,0,59,7,1,0,0,0,60,72,5,2,0,0,61,66,3,6,3,0,62,63,5,3,0,0,63,65,3,6,3,0,64,62,1,0,0,0,65,68,1,0,0,0,66,64,1,0,0,0,66,67,1,0,0,0,67,70,1,0,0,0,68,66,1,0,0,0,69,71,5,3,0,0,70,69,1,0,0,0,70,71,1,0,0,0,71,73,1,0,0,0,72,61,1,0,0,0,72,73,1,0,0,0,73,74,1,0,0,0,74,75,5,4,0,0,75,9,1,0,0,0,76,88,5,5,0,0,77,82,3,12,6,0,78,79,5,3,0,0,79,81,3,12,6,0,80,78,1,0,0,0,81,84,1,0,0,0,82,80,1,0,0,0,82,83,1,0,0,0,83,86,1,0,0,0,84,82,1,0,0,0,85,87,5,3,0,0,86,85,1,0,0,0,86,87,1,0,0,0,87,89,1,0,0,0,88,77,1,0,0,0,88,89,1,0,0,0,89,90,1,0,0,0,90,91,5,6,0,0,91,11,1,0,0,0,92,95,3,28,14,0,93,95,3,30,15,0,94,92,1,0,0,0,94,93,1,0,0,0,95,96,1,0,0,0,96,97,5,7,0,0,97,98,3,6,3,0,98,13,1,0,0,0,99,100,5,16,0,0,100,15,1,0,0,0,101,117,5,17,0,0,102,114,5,8,0,0,103,108,3,6,3,0,104,105,5,3,0,0,105,107,3,6,3,0,106,104,1,0,0,0,107,110,1,0,0,0,108,106,1,0,0,0,108,109,1,0,0,0,109,112,1,0,0,0,110,108,1,0,0,0,111,113,5,3,0,0,112,111,1,0,0,0,112,113,1,0,0,0,113,115,1,0,0,0,114,103,1,0,0,0,114,115,1,0,0,0,115,116,1,0,0,0,116,118,5,9,0,0,117,102,1,0,0,0,117,118,1,0,0,0,118,17,1,0,0,0,119,120,3,28,14,0,120,132,5,8,0,0,121,126,3,20,10,0,122,123,5,3,0,0,123,125,3,20,10,0,124,122,1,0,0,0,125,128,1,0,0,0,126,124,1,0,0,0,126,127,1,0,0,0,127,130,1,0,0,0,128,126,1,0,0,0,129,131,5,3,0,0,130,129,1,0,0,0,130,131,1,0,0,0,131,133,1,0,0,0,132,121,1,0,0,0,132,133,1,0,0,0,133,134,1,0,0,0,134,135,5,9,0,0,135,19,1,0,0,0,136,139,3,22,11,0,137,139,3,6,3,0,138,136,1,0,0,0,138,137,1,0,0,0,139,21,1,0,0,0,140,141,3,28,14,0,141,142,5,1,0,0,142,143,3,6,3,0,143,23,1,0,0,0,144,147,5,10,0,0,145,147,3,28,14,0,146,144,1,0,0,0,146,145,1,0,0,0,147,25,1,0,0,0,148,153,3,30,15,0,149,153,5,18,0,0,150,153,5,19,0,0,151,153,5,11,0,0,152,148,1,0,0,0,152,149,1,0,0,0,152,150,1,0,0,0,152,151,1,0,0,0,153,27,1,0,0,0,154,155,5,20,0,0,155,29,1,0,0,0,156,157,7,0,0,0,157,31,1,0,0,0,21,35,42,46,58,66,70,72,82,86,88,94,108,112,114,117,126,130,132,138,146,152];T.vocabulary=new yt(T.literalNames,T.symbolicNames,[]);T.decisionsToDFA=T._ATN.decisionToState.map((n,e)=>new rn(n,e));var Dc=class extends K{constructor(e,t){super(e,t)}EOF(){return this.getToken(T.EOF,0)}statement(e){return e===void 0?this.getRuleContexts(ni):this.getRuleContext(e,ni)}get ruleIndex(){return T.RULE_program}accept(e){return e.visitProgram?e.visitProgram(this):e.visitChildren(this)}},ni=class extends K{constructor(e,t){super(e,t)}assignment(){return this.getRuleContext(0,Ro)}expression(){return this.getRuleContext(0,st)}get ruleIndex(){return T.RULE_statement}accept(e){return e.visitStatement?e.visitStatement(this):e.visitChildren(this)}},Ro=class extends K{constructor(e,t){super(e,t)}expression(){return this.getRuleContext(0,st)}identifier(){return this.getRuleContext(0,wn)}path(){return this.getRuleContext(0,ri)}get ruleIndex(){return T.RULE_assignment}accept(e){return e.visitAssignment?e.visitAssignment(this):e.visitChildren(this)}},st=class extends K{constructor(e,t){super(e,t)}array(){return this.getRuleContext(0,_o)}map(){return this.getRuleContext(0,No)}path(){return this.getRuleContext(0,ri)}check(){return this.getRuleContext(0,Oo)}call(){return this.getRuleContext(0,Po)}variable(){return this.getRuleContext(0,Lo)}literal(){return this.getRuleContext(0,$o)}get ruleIndex(){return T.RULE_expression}accept(e){return e.visitExpression?e.visitExpression(this):e.visitChildren(this)}},_o=class extends K{constructor(e,t){super(e,t)}expression(e){return e===void 0?this.getRuleContexts(st):this.getRuleContext(e,st)}get ruleIndex(){return T.RULE_array}accept(e){return e.visitArray?e.visitArray(this):e.visitChildren(this)}},No=class extends K{constructor(e,t){super(e,t)}map_entry(e){return e===void 0?this.getRuleContexts(si):this.getRuleContext(e,si)}get ruleIndex(){return T.RULE_map}accept(e){return e.visitMap?e.visitMap(this):e.visitChildren(this)}},si=class extends K{constructor(e,t){super(e,t)}expression(){return this.getRuleContext(0,st)}identifier(){return this.getRuleContext(0,wn)}string(){return this.getRuleContext(0,oi)}get ruleIndex(){return T.RULE_map_entry}accept(e){return e.visitMap_entry?e.visitMap_entry(this):e.visitChildren(this)}},ri=class extends K{constructor(e,t){super(e,t)}PATH(){return this.getToken(T.PATH,0)}get ruleIndex(){return T.RULE_path}accept(e){return e.visitPath?e.visitPath(this):e.visitChildren(this)}},Oo=class extends K{constructor(e,t){super(e,t)}CHECK(){return this.getToken(T.CHECK,0)}expression(e){return e===void 0?this.getRuleContexts(st):this.getRuleContext(e,st)}get ruleIndex(){return T.RULE_check}accept(e){return e.visitCheck?e.visitCheck(this):e.visitChildren(this)}},Po=class extends K{constructor(e,t){super(e,t)}identifier(){return this.getRuleContext(0,wn)}arg(e){return e===void 0?this.getRuleContexts(ii):this.getRuleContext(e,ii)}get ruleIndex(){return T.RULE_call}accept(e){return e.visitCall?e.visitCall(this):e.visitChildren(this)}},ii=class extends K{constructor(e,t){super(e,t)}named_arg(){return this.getRuleContext(0,Do)}expression(){return this.getRuleContext(0,st)}get ruleIndex(){return T.RULE_arg}accept(e){return e.visitArg?e.visitArg(this):e.visitChildren(this)}},Do=class extends K{constructor(e,t){super(e,t)}identifier(){return this.getRuleContext(0,wn)}expression(){return this.getRuleContext(0,st)}get ruleIndex(){return T.RULE_named_arg}accept(e){return e.visitNamed_arg?e.visitNamed_arg(this):e.visitChildren(this)}},Lo=class extends K{constructor(e,t){super(e,t)}identifier(){return this.getRuleContext(0,wn)}get ruleIndex(){return T.RULE_variable}accept(e){return e.visitVariable?e.visitVariable(this):e.visitChildren(this)}},$o=class extends K{constructor(e,t){super(e,t)}string(){return this.getRuleContext(0,oi)}NUMBER(){return this.getToken(T.NUMBER,0)}BOOLEAN(){return this.getToken(T.BOOLEAN,0)}get ruleIndex(){return T.RULE_literal}accept(e){return e.visitLiteral?e.visitLiteral(this):e.visitChildren(this)}},wn=class extends K{constructor(e,t){super(e,t)}IDENTIFIER(){return this.getToken(T.IDENTIFIER,0)}get ruleIndex(){return T.RULE_identifier}accept(e){return e.visitIdentifier?e.visitIdentifier(this):e.visitChildren(this)}},oi=class extends K{constructor(e,t){super(e,t)}RAW_TRIPLE_STRING(){return this.getToken(T.RAW_TRIPLE_STRING,0)}TRIPLE_STRING(){return this.getToken(T.TRIPLE_STRING,0)}RAW_STRING(){return this.getToken(T.RAW_STRING,0)}STANDARD_STRING(){return this.getToken(T.STANDARD_STRING,0)}get ruleIndex(){return T.RULE_string}accept(e){return e.visitString?e.visitString(this):e.visitChildren(this)}};var Mo=class extends Lf{};function G(n,e){return typeof n=="object"&&n!==null&&!Array.isArray(n)&&n.kind===e}function ar(n,e,t){Object.defineProperty(n,e,{value:t,enumerable:!0,writable:!0,configurable:!0})}function Z0(n){return typeof n=="object"&&n!==null&&n.type==="kw"&&typeof n.key=="string"}function H0(n){return typeof n=="object"&&n!==null&&n.type==="pos"}function G0(n){let e=Number(n);if(!Number.isFinite(e))throw new Je(`Number literal ${n} is out of range.`);return e}function qf(n){return n.replace(/\\([\s\S])/gu,(e,t)=>{switch(t){case"n":return`
35
+ `;case"r":return"\r";case"t":return" ";case"\\":return"\\";case'"':return'"';default:return e}})}var $c=class extends ir{constructor(){super(...arguments),this.errors=[]}syntaxError(e,t,s,r,i,o){let a=e instanceof nt;this.errors.push([s,r,i,a])}},Mc=class extends Mo{constructor(e){super(),this.visitProgram=t=>{let s=[];for(let r of t.statement()){if(this.firstErrorLine!==void 0&&r.start!==null&&r.start.line>=this.firstErrorLine)break;try{let i=this.visit(r);i!=null&&s.push(i)}catch{}}return s},this.visitStatement=t=>t.assignment()?this.visit(t.assignment()):t.expression()?["EXPR",this.visit(t.expression())]:null,this.visitAssignment=t=>{let s;t.identifier()?s=t.identifier().getText():s=t.path().getText();let r=this.visit(t.expression());return["ASSIGN",s,r]},this.visitExpression=t=>{let s=t.getChild(0);return s?this.visit(s):null},this.visitArray=t=>t.expression().map(s=>this.visit(s)),this.visitMap=t=>{let s={};for(let r of t.map_entry()){let[i,o]=this.visit(r);ar(s,i,o)}return{kind:"map",entries:s}},this.visitMap_entry=t=>{let s;t.identifier()?s=t.identifier().getText():s=this.visit(t.string());let r=this.visit(t.expression());return[s,r]},this.visitPath=t=>({kind:"path",path:t.PATH().getText().slice(1)}),this.visitCheck=t=>{let s=t.CHECK().getText().slice(1),r=[];for(let i of t.expression())r.push(this.visit(i));return{kind:"check",name:s,args:r}},this.visitArg=t=>{if(t.named_arg()){let[s,r]=this.visit(t.named_arg());return{type:"kw",key:s,value:r}}return{type:"pos",value:this.visit(t.expression())}},this.visitNamed_arg=t=>{let s=t.identifier().getText(),r=this.visit(t.expression());return[s,r]},this.visitCall=t=>{let s=t.identifier().getText(),r=[],i={};for(let o of t.arg()){let a=this.visit(o);Z0(a)?ar(i,a.key,a.value):H0(a)?r.push(a.value):r.push(a??null)}return{kind:"call",name:s,args:r,kwargs:i}},this.visitVariable=t=>t.identifier()?{kind:"variable",name:t.identifier().getText()}:{kind:"skipped"},this.visitLiteral=t=>t.string()?this.visit(t.string()):t.NUMBER()?G0(t.NUMBER().getText()):t.BOOLEAN()?t.BOOLEAN().getText()==="true":null,this.visitIdentifier=t=>t.IDENTIFIER().getText(),this.visitString=t=>{if(t.RAW_TRIPLE_STRING())return t.RAW_TRIPLE_STRING().getText().slice(4,-3);if(t.RAW_STRING())return t.RAW_STRING().getText().slice(2,-1);if(t.TRIPLE_STRING()){let s=t.TRIPLE_STRING().getText();return qf(s.slice(3,-3))}if(t.STANDARD_STRING()){let s=t.STANDARD_STRING().getText();return qf(s.slice(1,-1).replace(/^[\r\n]+|[\r\n]+$/g,""))}return t.getText()},this.firstErrorLine=e}},K0="a-zA-Z_",ai="a-zA-Z0-9_",Fo=`[${K0}][${ai}]*`,Y0=/([rR]"""[\s\S]*?"""|[rR]"[^\r\n"]*"|"""(?:\\[\s\S]|[^\\])*?"""|"(?:\\[\s\S]|[^\\])*?"|(?:#|\/\/)[^\r\n]*|\/\*[\s\S]*?\*\/)|--([^\r\n]*)/g,J0=new RegExp(`^[ \\t]*(${Fo})[ \\t]*=(?!=)`,"gm"),Lc=new RegExp(`^([ \\t]*${Fo})[ \\t]*(\\r?\\n)[ \\t]*([${ai}]+)(?=[ \\t]*=(?!=))`,"gm"),X0=new RegExp("(\\$["+ai+"/]*/)[ \\t]*(\\r?\\n)[ \\t]*(["+ai+"/]+)","g"),Q0=new RegExp(`^${Fo}$`),ey=/^[ \t]*=(?!=)/,ty=new RegExp(`([([,:=][ \\t]*\\r?\\n?[ \\t]*|[([,:=][ \\t]*)(${Fo})[ \\t]*(\\r?\\n)[ \\t]*([${ai}]+)(?=[ \\t]*[,)\\]}]|\\s*\\r?\\n)`,"g");function ny(n){let e=[],t=0;for(let l of n.matchAll(Y0)){let u=l.index??0;u>t&&e.push({isTok:!1,text:n.slice(t,u)}),l[1]!==void 0?e.push({isTok:!0,text:l[1]}):e.push({isTok:!0,text:`//${l[2]??""}`}),t=u+l[0].length}t<n.length&&e.push({isTok:!1,text:n.slice(t)});let s=0,r=[];for(let l of e){if(l.isTok){r.push([]);continue}let u=[];for(let d=0;d<l.text.length;d++){let h=l.text[d];u.push(s),h==="("||h==="["||h==="{"?s++:(h===")"||h==="]"||h==="}")&&s>0&&s--}r.push(u)}let i=new Set;for(let l=0;l<e.length;l++){let u=e[l];if(!u.isTok){let d=r[l];for(let h of u.text.matchAll(Lc)){let p=h.index??0;if(d[p]===0){let m=p+h[0].length-h[3].length;i.add(`${l}:${m}`)}}}}let o=new Set;for(let l=0;l<e.length;l++){let u=e[l];if(!u.isTok){let d=r[l];for(let h of u.text.matchAll(J0)){let m=(h.index??0)+h[0].indexOf(h[1]);d[m]===0&&!i.has(`${l}:${m}`)&&o.add(h[1])}}}let a=new Set(o);for(let l=0;l<e.length;l++){let u=e[l];if(!u.isTok){let d=r[l];for(let h of u.text.matchAll(Lc)){let p=h.index??0;if(d[p]===0){let m=h[1].trim(),g=h[3];!o.has(m)&&!o.has(g)&&a.add(m+g)}}}}let c=[];for(let l of e){if(l.isTok){c.push(l.text);continue}let u=l.text.replace(X0,(d,h,p,m,g,E)=>{let A=E.slice(g+d.length);return Q0.test(m)&&ey.test(A)?d:`${h}${m}${p}`});u=u.replace(Lc,(d,h,p,m)=>{let g=h.trim();return!o.has(g)&&!o.has(m)?`${h}${m}${p}`:d}),u=u.replace(ty,(d,h,p,m,g)=>{let E=p+g;return a.has(E)&&!a.has(p)&&!a.has(g)?`${h}${E}${m}`:d}),c.push(u)}return c.join("")}function zf(n){let e=rr.fromString(ny(n)),t=new B(e),s=new $c;t.removeErrorListeners(),t.addErrorListener(s);let r=new ko(t),i=new T(r);i.removeErrorListeners(),i.addErrorListener(s);let o=i.program(),a=s.errors.length>0?s.errors[0][0]:void 0,l=new Mc(a).visit(o)??[];return{errors:s.errors,statements:l}}var $t={CREATE:"createSurface",UPDATE_COMPONENTS:"updateComponents",DELETE:"deleteSurface",UPDATE_DATA:"updateDataModel",CALL_FUNC:"callFunction",SURFACE:"surface"},Kf=/^(?:0|[1-9][0-9]*)$/,Wf=1e4;function Yf(n){return n.startsWith("$/")?n.slice(2):n.startsWith("$")?n.slice(1):n}function Jf(n){return"/"+Yf(n)}function Xf(n,e){if(!Kf.test(n))throw new _(`Cannot use non-numeric segment '${n}' on an array in path '${e}'.`);let t=parseInt(n,10);if(t>Wf)throw new _(`Cannot set path '${e}': array index '${n}' exceeds maximum supported index (${Wf}).`);return t}function sy(n,e,t,s){let r=Kf.test(t);if(!Array.isArray(n)){let a=n[e];if(a==null){let c=r?[]:{};return n[e]=c,c}if(typeof a=="object")return a;throw new _(`Cannot set path '${s}': segment '${e}' is a primitive value.`)}let i=Xf(e,s);for(;n.length<=i;)n.push(null);let o=n[i];if(o==null){let a=r?[]:{};return n[i]=a,a}if(typeof o=="object")return o;throw new _(`Cannot set path '${s}': segment '${e}' is a primitive value.`)}var Zf=["userMessage","context"];function ry(n){let e=n?.schema?n.helper.resolveItemSchema(n.schema):void 0;return e&&n?{schema:e,helper:n.helper}:void 0}function iy(n,e){let t=n?.schema?n.helper.resolvePropertySchema(n.schema,e):void 0;return t&&n?{schema:t,helper:n.helper}:void 0}function Qf(n,e,t){let s=Yf(e);if(!s){if(!t||typeof t!="object"||Array.isArray(t))throw new _(`Cannot set root data model '${e}' to a non-map value.`);for(let c of Object.keys(n))delete n[c];Object.assign(n,t);return}let r=s.split("/"),i=n;for(let c=0;c<r.length-1;c++)i=sy(i,r[c],r[c+1],e);let o=r[r.length-1];if(!Array.isArray(i)){i[o]=t;return}let a=Xf(o,e);for(;i.length<=a;)i.push(null);i[a]=t}function Uc(n){return G(n,"check")?!0:Array.isArray(n)&&n.length>0?n.every(Uc):!1}function oy(n,e){let t=new Set,s=n;for(;G(s,"variable");){if(t.has(s.name)||!Object.hasOwn(e,s.name))return!1;t.add(s.name),s=e[s.name]}return G(s,"path")}function jo(n){let e=de(n);return e?e.split("-")[0].split("+")[0].split(".").map(s=>parseInt(s,10)||0):[0,0,0]}function ay(n,e){let t=jo(n),s=jo(e),r=Math.max(t.length,s.length);for(let i=0;i<r;i++){let o=t[i]??0,a=s[i]??0;if(o!==a)return o>a}return!0}function qc(n){return n instanceof _t?`${n.message} (line ${n.line})`:n instanceof Error?n.message:String(n)}function cy(n){return typeof n=="string"?n:JSON.stringify(n)}function ly(n){return G(n,"call")?`a call to ${n.name}(...)`:G(n,"check")?`a check (?${n.name})`:G(n,"variable")?`the variable ${n.name}`:G(n,"path")?`the data binding $${n.path}`:G(n,"map")?"a map literal":G(n,"skipped")?"'_'":Array.isArray(n)?"a list":n===null?"null":`the ${typeof n} ${JSON.stringify(n)}`}function uy(n){if(typeof n=="string"){if(n.includes("ChildList"))return"ChildList";if(n.includes("Child")||n.includes("ComponentId"))return"Child";if(n.includes("Action"))return"Action"}}function eh(n){if(!n||typeof n!="object")return;let e=n,t=uy(e.$ref);if(t)return t;for(let s of["oneOf","anyOf","allOf"]){let r=e[s];if(Array.isArray(r))for(let i of r){let o=eh(i);if(o)return o}}}function Fc(n,e,t){let s=eh(t);if(s)return s;if(!n.commonTypesLoaded){if(e==="child")return"Child";if(e==="children")return"ChildList"}}var jc=/<a2ui(?:\s[^>]*)?>/iy,Vc=/<\/a2ui\s*>/iy;function Bc(n,e){if(n[e]!=="<")return;if(jc.lastIndex=e,jc.exec(n))return{kind:"open",end:jc.lastIndex};if(Vc.lastIndex=e,Vc.exec(n))return{kind:"close",end:Vc.lastIndex}}function Hf(n,e){let t=n.length;if(n.startsWith("//",e)||n[e]==="#"||n.startsWith("--",e)){let s=n.indexOf(`
36
+ `,e),r=s<0?t:s,i=e+(n[e]==="#"?1:2);for(;i<r;){if(n[i]==="<"&&Bc(n,i)?.kind==="close")return i;i+=1}return r}if(n.startsWith("/*",e)){let s=n.indexOf("*/",e+2);return s<0?t:s+2}}function Gf(n,e){let t=n.length,s=!1,r=e;if((n[e]==="r"||n[e]==="R")&&e+1<t&&n[e+1]==='"'&&(e===0||!/[a-zA-Z0-9_]/.test(n[e-1])))s=!0,r=e+1;else if(n[e]!=='"')return;let i=n.startsWith('"""',r),o=r+(i?3:1);for(;o<t;){if(!s&&n[o]==="\\"){o+=2;continue}if(i&&n.startsWith('"""',o))return o+3;if(!i&&n[o]==='"')return o+1;o+=1}return t}function dy(n){let e=!1,t=0,s=n.length;for(;t<s;){let c=Gf(n,t);if(c!==void 0){t=c;continue}let l=Hf(n,t);if(l!==void 0){t=l;continue}if(Bc(n,t)?.kind==="open"){e=!0;break}t+=1}let r=[],i=!e,o=0,a=i?0:-1;for(;o<s;){let c=Gf(n,o);if(c!==void 0){o=c;continue}let l=Hf(n,o);if(l!==void 0){o=l;continue}let u=Bc(n,o);if(u){u.kind==="open"?(i&&a>=0&&r.push(n.slice(a,o)),i=!0,a=u.end):(i&&a>=0&&r.push(n.slice(a,o)),i=!1,a=-1),o=u.end;continue}o+=1}return i&&a>=0&&a<s&&r.push(n.slice(a)),r.join("")}var fy=new Set(["+","-","*","/","%","=","<",">","!","&","|",".",",",":"]);function hy(n,e){if(e<=0||e>=n.length)return!0;let t=n.slice(e).trimStart();return!t||t.startsWith("//")||t.startsWith("/*")||t.startsWith("--")?!0:!fy.has(t[0])}var In=class extends Error{constructor(e){super(`Pending variable '${e}'.`),this.varName=e,this.name="PendingVariableError"}},Vo=class{constructor(e,t=!1){this.extraComponents=[],this.generatedIds=new Set,this.inlineCounter=0,this.callCounter=0,this.activeBoundPaths=new Map,this.resolving=new Set,this.referencedVars=new Set,this.keys=e,this.allowPending=t}},Uo=class{constructor(e,t,s=!1,r=!1,i){this.rawSymbols={},this.dataPathAssignments={},this.surfaceId=e,this.sendDataModel=t,this.update=s,this.hasSurfaceDirective=r,this.rawExtensions=i}},Bo=class{constructor(e,t={}){this.hasEmitted=!1,this.supersededComponents=[],this.scopeStates=new Map,this.emittedUnits=new Set,this.cachedPrefix="",this.cachedStatements=[],this.compiler=e,this.surfaceId=t.surfaceId??"default_surface",this.version=t.version?Nt(e.catalogs,t.version):e.version}snapshot(){let e=new Map;for(let[t,s]of this.scopeStates.entries())e.set(t,{surfaceId:s.surfaceId,surfaceCreated:s.surfaceCreated,emittedComponents:new Map(s.emittedComponents),emittedDataPaths:new Map(s.emittedDataPaths),varIds:new Map(s.varIds),compiledCache:new Map(s.compiledCache),dataCache:new Map(s.dataCache)});return{hasEmitted:this.hasEmitted,supersededComponents:[...this.supersededComponents],scopeStates:e,emittedUnits:new Set(this.emittedUnits),cachedPrefix:this.cachedPrefix,cachedStatements:[...this.cachedStatements]}}restore(e){this.hasEmitted=e.hasEmitted,this.supersededComponents=e.supersededComponents,this.scopeStates=e.scopeStates,this.emittedUnits=e.emittedUnits,this.cachedPrefix=e.cachedPrefix,this.cachedStatements=e.cachedStatements}compileStep(e,t){this.supersededComponents=[];let s=jo(this.version),r=[s[0]??0,s[1]??0];if(this.compiler.catalogs.length>1&&r[0]<1)throw new R(`Several catalogs need A2UI v1.0 or later, where components and function calls carry their own catalogId, but got '${this.version}'.`);let i=r[0]>=1?{path:"@path",call:"@call"}:{path:"path",call:"call"},o=new Vo(i,!t.isFinal),a=this.parseIncrementalStatements(e,t.isFinal,t.cachePrefix??!0),c=this.compiler.buildUnits(a,this.surfaceId,r);if(c.length===0){if(t.isFinal)throw new Xt("root");return[]}let l=new Set(t.existingSurfaces),u=[];for(let d=0;d<c.length;d++)u.push(...this.compileUnit(d,c[d],o,r,t.isFinal,l));return u}parseIncrementalStatements(e,t,s){if(this.cachedPrefix&&e.startsWith(this.cachedPrefix)&&hy(e,this.cachedPrefix.length)){let i=e.slice(this.cachedPrefix.length),o=i.trim()?this.compiler.parseStatements(i,!0,!1):[],a=[...this.cachedStatements,...o];return s&&(this.cachedPrefix=e,this.cachedStatements=a),a}let r=this.compiler.parseStatements(e,!0,!1);return s&&(this.cachedPrefix=e,this.cachedStatements=r),r}compileUnit(e,t,s,r,i,o){if(t.kind==="delete")return o.delete(t.surfaceId),this.emittedUnits.has(e)?[]:(this.emittedUnits.add(e),this.hasEmitted=!0,[{version:this.version,[$t.DELETE]:{surfaceId:t.surfaceId}}]);if(t.kind==="call")return this.compileCallUnit(e,t.stmt,t.scope,s,r);let a=this.scopeStates.get(e);a?a.surfaceId=t.scope.surfaceId:(a={surfaceId:t.scope.surfaceId,surfaceCreated:!1,emittedComponents:new Map,emittedDataPaths:new Map,varIds:new Map,compiledCache:new Map,dataCache:new Map},this.scopeStates.set(e,a));let c=o.has(t.scope.surfaceId),l=this.compileScopeDelta(t.scope,a,s,r,i,c);return(c||a.surfaceCreated)&&o.add(t.scope.surfaceId),l}compileCallUnit(e,t,s,r,i){if(this.emittedUnits.has(e))return[];try{let o=this.compiler.compileStandaloneCall(t,s,r,this.version,i);return this.emittedUnits.add(e),this.hasEmitted=!0,[o]}catch(o){if(o instanceof In)return[];throw o}}compileScopeDelta(e,t,s,r,i,o){let a=this.compiler.collectComponentIds(e,r),{compiled:c,hasPending:l}=this.collectReadyComponents(e,t,a,s,r),u=this.collectReadyData(e,t,a,s,r),d=c.some(p=>p.id==="root");return!e.update&&!t.surfaceCreated&&(!o||d||e.rawExtensions!==void 0)?this.compileInitialCreate(e,t,c,u,i,a,s,r):this.compileIncrementalUpdates(e,t,c,u,i,l,o)}compileInitialCreate(e,t,s,r,i,o,a,c){if(!s.some(h=>h.id==="root")){if(!i)return[];if(e.rawExtensions!==void 0)throw new _("surface() extensions require a surface-creating scope with a root component.");if(r.size>0&&s.length===0)return this.compileIncrementalUpdates(e,t,s,r,!0,!1,!1);throw new Xt("root")}let u;try{u=this.compiler.compileSurfaceMetadata(e,o,a,c)}catch(h){if(h instanceof In&&!i)return[];throw h}let d={};for(let[h,p]of r.entries())Qf(d,h,p),t.emittedDataPaths.set(h,JSON.stringify(p));for(let h of s)t.emittedComponents.set(String(h.id),JSON.stringify(h));return t.surfaceCreated=!0,this.hasEmitted=!0,this.compiler.buildCreateMessages(e,s,d,this.version,u)}compileIncrementalUpdates(e,t,s,r,i,o,a=!1){let c=s.filter(d=>t.emittedComponents.get(String(d.id))!==JSON.stringify(d));for(let d of c)t.emittedComponents.set(String(d.id),JSON.stringify(d));let l=this.buildDataUpdates(e,t,r);if(i&&t.emittedComponents.size===0&&t.emittedDataPaths.size===0&&!o)throw new Xt("root");let u=[];if(c.length>0){if(!e.hasSurfaceDirective&&!t.surfaceCreated&&!a)throw new Xt("root");u.push({version:this.version,[$t.UPDATE_COMPONENTS]:{surfaceId:e.surfaceId,components:c}})}return u.push(...l),u.length>0&&(this.hasEmitted=!0),u}earlierScopeComponent(e,t,s){let r;for(let i of this.scopeStates.values()){if(i===e)break;i.surfaceId===t&&i.emittedComponents.has(s)&&(r=i.emittedComponents.get(s))}return r!==void 0?JSON.parse(r):void 0}collectReadyComponents(e,t,s,r,i){r.generatedIds.clear();let o=new Set(s.values()),a=[],c=[],l=[],u=!1;for(let[d,h]of Object.entries(e.rawSymbols)){let p=t.compiledCache.get(d);if(p&&p.ast===h){let E=!0;for(let[A,[I,D]]of p.deps.entries())if(e.rawSymbols[A]!==I||s.get(A)!==D){E=!1;break}if(E&&(p.inlineDelta===0||p.startInline===r.inlineCounter)&&p.generatedIds.every(A=>!r.generatedIds.has(A)&&!o.has(A)&&!Object.hasOwn(e.rawSymbols,A))){r.inlineCounter+=p.inlineDelta;for(let A of p.generatedIds)r.generatedIds.add(A);if(p.comps.length>0){let A=p.comps[0],I=String(A.id),D=t.varIds.get(d);D!==void 0&&D!==I&&l.push(D),t.varIds.set(d,I),a.push(A),c.push(...p.comps.slice(1))}continue}}let m=r.inlineCounter,g=new Set(r.generatedIds);r.referencedVars.clear();try{let E=this.compiler.compileAstNodeForSession(d,h,e.rawSymbols,s,r,i),A=new Map;for(let O of r.referencedVars)A.set(O,[e.rawSymbols[O],s.get(O)]);let I=[...r.generatedIds].filter(O=>!g.has(O)),D=r.inlineCounter-m;if(E){let O=String(E.id),te=t.varIds.get(d);te!==void 0&&te!==O&&l.push(te),t.varIds.set(d,O);let Q=[...r.extraComponents];r.extraComponents=[],t.compiledCache.set(d,{ast:h,comps:[E,...Q],deps:A,startInline:m,inlineDelta:D,generatedIds:I}),a.push(E),c.push(...Q)}else t.compiledCache.set(d,{ast:h,comps:[],deps:A,startInline:m,inlineDelta:D,generatedIds:I})}catch(E){if(E instanceof In){r.extraComponents=[],r.inlineCounter=m,r.generatedIds=g,u=!0;continue}throw E}}if(a.push(...c),l.length>0){let d=new Set(a.map(h=>String(h.id)));for(let h of l)if(!d.has(h)){t.emittedComponents.delete(h);let p=this.earlierScopeComponent(t,e.surfaceId,h);p!==void 0?a.push(p):this.supersededComponents.push([e.surfaceId,h])}}return{compiled:a,hasPending:u}}collectReadyData(e,t,s,r,i){let o=new Map;for(let[a,c]of Object.entries(e.dataPathAssignments)){let l=t.dataCache.get(a);if(l&&l.ast===c){let u=!0;for(let[d,[h,p]]of l.deps.entries())if(e.rawSymbols[d]!==h||s.get(d)!==p){u=!1;break}if(u){o.set(a,l.val);continue}}r.referencedVars.clear();try{let u=this.compiler.compileDataValue(e,c,s,r,i),d=new Map;for(let h of r.referencedVars)d.set(h,[e.rawSymbols[h],s.get(h)]);t.dataCache.set(a,{ast:c,val:u,deps:d}),o.set(a,u)}catch(u){if(u instanceof In)continue;throw u}}return o}buildDataUpdates(e,t,s){let r=[];for(let[i,o]of s.entries()){let a=JSON.stringify(o);if(t.emittedDataPaths.get(i)===a)continue;let c=Jf(i);if(c==="/"&&(!o||typeof o!="object"||Array.isArray(o)))throw new _("Cannot assign a non-map value to the root data path '$/'.");t.emittedDataPaths.set(i,a),r.push({version:this.version,[$t.UPDATE_DATA]:{surfaceId:e.surfaceId,path:c,value:o}})}return r}},cr=class{constructor(e,t){this.catalogs=bn(e),this.version=Nt(this.catalogs,t),this.helpers=Gs(this.catalogs,this.version)}definesComponent(e,t){return typeof t=="string"&&this.helpers.has(t)?this.helpers.get(t).components.has(e):Qt(this.helpers,"component",e).length>0}definesFunction(e,t){return t!==void 0?typeof t=="string"&&(this.helpers.get(t)?.functions.has(e)??!1):Qt(this.helpers,"function",e).length>0}resolveSymbol(e,t,s,r){let i=e==="component"?"Component":"Function";if(s!==void 0){if(r[0]<1)throw new _("catalogId on a component or function call is only supported in A2UI v1.0 or later.");if(typeof s!="string"||!s)throw new _(`catalogId on ${e} '${t}' must be a non-empty string.`);let c=this.helpers.get(s);if(!c)throw Ks(`${i} '${t}'`,s,this.catalogs);if(!(e==="component"?c.components:c.functions).has(t))throw zr(e,t,s,this.helpers);return{helper:c,catalogId:s}}let o=Qt(this.helpers,e,t);if(o.length>1){let c=o.map(l=>`'${l}'`).join(", ");throw new _(`${i} '${t}' is defined in several catalogs: ${c}. Name the catalog to use with a catalogId argument.`)}if(o.length===0)throw zr(e,t,void 0,this.helpers);let a=o[0];return{helper:this.helpers.get(a),catalogId:this.catalogs.length>1?a:void 0}}parseSurfaceCall(e,t){let s=e.args,r=e.kwargs;if(s.length===0)throw new _('surface() requires at least 1 argument: surface("surface_id").');if(s.length>2)throw new _("surface() takes at most 2 positional arguments: surface(id) or surface(id, catalogId).");let i=s[0];if(typeof i!="string")throw new _("The first argument to surface() must be a string literal.");let o="";if(s.length===2){if("catalogId"in r)throw new _("Duplicate catalogId in surface(): specified both positionally and as a keyword argument.");if(typeof s[1]!="string")throw new _("The second argument to surface() must be a catalog ID string.");o=s[1]}let a,c=!1,l;for(let[u,d]of Object.entries(r))if(u==="catalogId"){if(typeof d!="string")throw new _("The catalogId argument to surface() must be a string.");o=d}else if(u==="sendDataModel"){if(typeof d!="boolean")throw new _("The sendDataModel argument to surface() must be a boolean.");a=d}else if(u==="update"){if(typeof d!="boolean")throw new _("The update argument to surface() must be a boolean.");c=d}else if(u==="extensions"){if(t[0]<1)throw new _("extensions on surface() is only supported in A2UI v1.0 or later.");l=d}else throw new _(`Unknown keyword argument '${u}' in surface().`);if(c&&l!==void 0)throw new _("surface() with update=true does not accept extensions.");if(o){if(this.catalogs.length>1)throw new _(`surface() names catalog '${o}', but a surface names no catalog when several catalogs are active. Component and function names resolve across the active catalogs, or take catalogId="..." when shared.`);if(o!==this.catalogs[0].id)throw Ks(`Surface '${i}'`,o,this.catalogs)}return{surfaceId:i,catalogId:o,sendDataModel:a,update:c,rawExtensions:l}}resolveAstVar(e,t,s,r){let i=e;for(;G(i,"variable");){let o=i.name;if(s.referencedVars.add(o),r.has(o))throw new _(`Variable '${o}' refers to itself through its own value.`);if(!Object.hasOwn(t,o))throw s.allowPending?new In(o):new _(`Undefined variable '${o}'.`);r.add(o),i=t[o]}return i}checkExtensionsAst(e,t,s,r,i){let o=this.resolveAstVar(e,t,s,new Set(i));if(G(o,"map"))for(let a of Object.values(o.entries))this.checkExtensionsAst(a,t,s,r,i);else if(Array.isArray(o))for(let a of o)this.checkExtensionsAst(a,t,s,r,i);else if(G(o,"call")){let a=o.kwargs.catalogId;if(this.definesComponent(o.name,a))throw new _(`extensions on ${r} cannot contain component '${o.name}'.`);if(a===void 0&&(o.name==="Event"||o.name==="_template"||o.name==="surface"||o.name==="deleteSurface"))throw new _(`extensions on ${r} cannot contain '${o.name}()'.`);for(let c of o.args)this.checkExtensionsAst(c,t,s,r,i);for(let c of Object.values(o.kwargs))this.checkExtensionsAst(c,t,s,r,i)}}compileExtensionsMap(e,t,s,r,i,o){let a=this.resolveAstVar(e,t,r,new Set);if(!G(a,"map"))throw new _(`extensions on ${o} must be a map.`);this.checkExtensionsAst(a,t,r,o,new Set);let c=this._compileValue(e,t,s,r,i,!1);if(!c||typeof c!="object"||Array.isArray(c))throw new _(`extensions on ${o} must be a map.`);let l=c;for(let u of Object.keys(l))if(!fe(u))throw new _(`Extension key '${u}' on ${o} is not a valid UAX 31 identifier.`);return l}parseStatements(e,t,s=!0){let r=s?dy(e):e;try{let i=zf(r);if(t&&i.errors.length>0){let[o,a,c,l]=i.errors[0];throw new _t(`Syntax error at line ${o}:${a}: ${c}`,o,a,l)}return i.statements}catch(i){if(!t)return[];if(i instanceof _t&&i.isLexer)throw i;let o=qc(i),a=new Je(`Failed to parse expression: ${o}`);throw a.cause=i,a}}buildUnits(e,t,s){let r=[],i=null;for(let o of e){let[a,...c]=o;if(a==="EXPR")i=this.appendExprUnit(c[0],i,r,s);else if(a==="ASSIGN"){let[l,u]=c;i===null&&(i=new Uo(t),r.push({kind:"scope",scope:i})),this.assignToScope(i,l,u)}}return r}appendExprUnit(e,t,s,r){if(!G(e,"call"))return t;if(e.name==="surface"){let i=this.parseSurfaceCall(e,r),o=new Uo(i.surfaceId,i.sendDataModel,i.update,!0,i.rawExtensions);return s.push({kind:"scope",scope:o}),o}return e.name==="deleteSurface"?(s.push({kind:"delete",surfaceId:this.parseDeleteSurfaceId(e)}),t):(s.push({kind:"call",stmt:e,scope:t}),t)}assignToScope(e,t,s){t.startsWith("$")?(delete e.dataPathAssignments[t],e.dataPathAssignments[t]=s):ar(e.rawSymbols,t,s)}parseDeleteSurfaceId(e){let t=e.args,s=e.kwargs;if(t.length>0&&typeof t[0]=="string")return t[0];if(typeof s.surfaceId=="string")return s.surfaceId;throw new _("deleteSurface() requires the id of the surface to delete.")}compileStandaloneCall(e,t,s,r,i){if(i[0]===0&&i[1]<=9)throw new _("Standalone function calls are not supported in A2UI v0.9");s.callCounter+=1;let o=t?t.rawSymbols:{},[a,c]=this.compileFunctionCall(e,o,new Map,s,i,!1,!0),l={catalogId:a.catalogId??this.catalogs[0].id,...a};return{version:r,callRendererFunction:{functionCallId:c??`call_${s.callCounter}`,callFunction:l}}}collectComponentIds(e,t){let s=new Map,r=new Set;for(let[i,o]of Object.entries(e.rawSymbols)){if(!G(o,"call"))continue;let a=o.name,c=o.kwargs.id;if(c!==void 0){if(typeof c!="string"||c.length===0)throw new _(`id on component '${a}' must be a non-empty string.`);if(t[0]>=1&&!fe(c))throw new _(`Component id '${c}' on '${a}' is not a valid UAX 31 identifier.`)}if(this.definesComponent(a,o.kwargs.catalogId)){let l=c??i;if(r.has(l))throw new Br(l);r.add(l),s.set(i,l)}}return s}compileSurfaceMetadata(e,t,s,r){return e.rawExtensions===void 0?void 0:{extensions:this.compileExtensionsMap(e.rawExtensions,e.rawSymbols,t,s,r,`surface '${e.surfaceId}'`)}}buildCreateMessages(e,t,s,r,i){let o=e.surfaceId,a=jd(this.catalogs),c={surfaceId:o};if(a!==void 0&&(c.catalogId=a),e.sendDataModel!==void 0&&(c.sendDataModel=e.sendDataModel),ay(r,"v1.0"))return c.components=t,Object.keys(s).length>0&&(c.dataModel=s),i!==void 0&&(c.metadata=i),[{version:r,[$t.CREATE]:c}];let l=[{version:r,[$t.CREATE]:c},{version:r,[$t.UPDATE_COMPONENTS]:{surfaceId:o,components:t}}];return Object.keys(s).length>0&&l.push({version:r,[$t.UPDATE_DATA]:{surfaceId:o,path:"/",value:s}}),l}compileAstNodeForSession(e,t,s,r,i,o){return this._compileAstNode(e,t,s,r,i,o)}compileDataValue(e,t,s,r,i){return this._compileValue(t,e.rawSymbols,s,r,i,!1)}compile(e,t="default_surface",s=!0,r){let i=r?Nt(this.catalogs,r):this.version,o=jo(i),a=[o[0]??0,o[1]??0];if(this.catalogs.length>1&&a[0]<1)throw new R(`Several catalogs need A2UI v1.0 or later, where components and function calls carry their own catalogId, but got '${i}'.`);let c=a[0]>=1?{path:"@path",call:"@call"}:{path:"path",call:"call"},l=new Vo(c),u=this.parseStatements(e,s),d=this.buildUnits(u,t,a);if(d.length===0)throw new Xt("root");let h=[];for(let p of d)p.kind==="delete"?h.push({version:i,[$t.DELETE]:{surfaceId:p.surfaceId}}):p.kind==="call"?h.push(this.compileStandaloneCall(p.stmt,p.scope,l,i,a)):h.push(...this.compileScope(p.scope,l,i,a));return h}compileScope(e,t,s,r){t.generatedIds.clear();let i=this.collectComponentIds(e,r),o=[];for(let[u,d]of Object.entries(e.rawSymbols)){let h=this._compileAstNode(u,d,e.rawSymbols,i,t,r);h&&o.push(h)}o.push(...t.extraComponents),t.extraComponents=[];let a=o.some(u=>u.id==="root");if(e.update||!a){if(e.rawExtensions!==void 0)throw new _("surface() extensions require a surface-creating scope with a root component.");return this.compileUpdateScope(e,o,i,t,s,r)}let c={};for(let[u,d]of Object.entries(e.dataPathAssignments)){let h=this._compileValue(d,e.rawSymbols,i,t,r,!1);Qf(c,u,h)}let l=this.compileSurfaceMetadata(e,i,t,r);return this.buildCreateMessages(e,o,c,s,l)}compileUpdateScope(e,t,s,r,i,o){let a=[];for(let[c,l]of Object.entries(e.dataPathAssignments)){let u=Jf(c),d=this._compileValue(l,e.rawSymbols,s,r,o,!1);if(u==="/"&&(!d||typeof d!="object"||Array.isArray(d)))throw new _("Cannot assign a non-map value to the root data path '$/'.");a.push({version:i,[$t.UPDATE_DATA]:{surfaceId:e.surfaceId,path:u,value:d}})}if(t.length===0){if(a.length>0)return a;throw new Xt("root")}return[{version:i,[$t.UPDATE_COMPONENTS]:{surfaceId:e.surfaceId,components:t}},...a]}_compileAstNode(e,t,s,r,i,o){if(!G(t,"call"))return null;let a=t.name,c=t.args,l={...t.kwargs},u=l.catalogId;delete l.catalogId;let d=l.id;if(delete l.id,d!==void 0){if(typeof d!="string"||d.length===0)throw new _(`id on component '${a}' must be a non-empty string.`);if(o[0]>=1&&!fe(d))throw new _(`Component id '${d}' on '${a}' is not a valid UAX 31 identifier.`)}if(!this.definesComponent(a,u)&&(u===void 0&&(a==="Event"||a==="_template"||a==="surface"||a==="deleteSurface")||this.definesFunction(a,u)))return null;let{helper:h,catalogId:p}=this.resolveSymbol("component",a,u,o),m=d??r.get(e)??e,g=h.getComponentProperties(a),E=g.includes("extensions")?void 0:l.extensions;g.includes("extensions")||delete l.extensions;let A={id:m,component:a};if(p!==void 0&&(A.catalogId=p),E!==void 0){if(o[0]<1)throw new _(`extensions on component '${a}' is only supported in A2UI v1.0 or later.`);let j=this.compileExtensionsMap(E,s,r,i,o,`component '${a}'`);A.metadata={extensions:j}}let I=h.getCheckRuleProperty(a),D=I?g.filter(j=>j!==I):g,O=[],te=[],Q=0,Me=[];for(let j of c){if(Uc(j)){Array.isArray(j)?O.push(...j):O.push(j);continue}Me.push(j)}let Mt=h.getComponentRequired(a);for(let j=0;j<Me.length;j++){let ce=Me[j];if(Q>=D.length)throw new _(`${a} takes at most ${D.length} positional arguments (${D.join(", ")}), but component '${m}' passes ${Me.length}.`);if(typeof ce=="number"&&!h.acceptsNumber(h.getPropertySchema(a,D[Q]))){let Be=!1;if(j===Me.length-1){let gs=[];for(let jt=Q+1;jt<D.length;jt++){let we=D[jt];!(we in l)&&h.acceptsNumber(h.getPropertySchema(a,we))&&gs.push(jt)}if(gs.length===1){let jt=gs[0],we=!0;for(let _n=Q;_n<jt;_n++){let Vt=D[_n];if(Mt.includes(Vt)||!h.getPropertyEnum(a,Vt)?.length){we=!1;break}}we&&(Q=jt,Be=!0)}}if(!Be&&!Mt.includes(D[Q])&&h.commonTypesLoaded)throw new _(`Positional argument ${j+1} for component '${a}' is a number, which is not valid for optional property '${D[Q]}'.`)}te.push([D[Q],ce]),Q+=1}for(let[j,ce]of Object.entries(l)){if(Uc(ce)){Array.isArray(ce)?O.push(...ce):O.push(ce);continue}te.push([j,ce])}let Ft=new Set,ms=new Map;for(let[j,ce]of te){if(!g.includes(j))throw new po(a,j,g);if(Ft.has(j))throw new mo(a,j);if(Ft.add(j),G(ce,"skipped")){A[j]=null;continue}let Be=h.getPropertySchema(a,j),gs=Fc(h,j,Be),jt=qr(Be),we=this._compileValue(ce,s,r,i,o,jt,{parentId:m,property:j},gs==="Child",gs==="ChildList"&&Array.isArray(ce),{schema:Be,helper:h});Be&&!h.admitsPath(Be)&&this._checkDataBindings(a,j,ce,Be,h,s),Be&&!h.admitsPath(Be)&&Array.isArray(we)&&pc(Be)&&(we=we.map(Vt=>typeof Vt=="string"?{label:Vt,value:Vt}:Vt));let _n=h.getPropertyEnum(a,j);if(_n&&!(we&&typeof we=="object")&&!_n.includes(we)){let Vt=`[${_n.map(Eh=>`'${Eh}'`).join(", ")}]`;throw new _(`Value '${we}' is not a valid enum choice for property '${j}' of component '${a}'. Allowed values are: ${Vt}`)}A[j]=we,oy(ce,s)&&ms.set(j,we)}for(let j of Mt)if(!(j==="id"||j==="component")&&!Ft.has(j))throw new ho(a,j);if(i.activeBoundPaths=ms,O.length>0){if(!I)throw new _(`Component '${a}' does not accept checks.`,"Remove the check expressions, or use a component whose schema declares a list of CheckRule.");let j=[];for(let ce of O)G(ce,"check")&&j.push(this.compileCheckCall(ce,s,r,i,o,!1));j.length>0&&(A[I]=j)}i.activeBoundPaths=new Map;let Yc={};for(let[j,ce]of Object.entries(A))ce!=null&&(Yc[j]=ce);return Yc}compileCheckCall(e,t,s,r,i,o=!1){let a=e.name,c=e.args,l=[],u;for(let O of c){if(G(O,"map")&&Object.hasOwn(O.entries,"catalogId")){let te=Object.keys(O.entries).filter(Q=>Q!=="catalogId");if(te.length>0)throw new _(`Unsupported key(s) in check options for '?${a}': ${te.join(", ")}. Only 'catalogId' is allowed.`);if(u!==void 0&&u!==O.entries.catalogId)throw new _(`Check '?${a}' specifies conflicting catalogId values.`);u=O.entries.catalogId;continue}l.push(O)}let{helper:d}=this.resolveSymbol("function",a,u,i),h=d.getFunctionProperties(a),p=`${a.charAt(0).toUpperCase()+a.slice(1)} check failed`,m=[],g=!1;if(h.length>0){let O=h[0];if(!(l.length>0&&G(l[0],"path"))){let Q=r.activeBoundPaths.get(O);if(Q){let Me=String(Q[r.keys.path]??"");m.push({kind:"path",path:Me}),g=!0}}}let E=g?1:0;for(let O=0;O<l.length;O++){let te=l[O],Q=O+E;if(Q<h.length){let Me=h[Q],Mt=d.getFunctionPropertySchema(a,Me),Ft=!1;if(typeof te=="string"&&Mt){let ms=Mt.type;(ms==="integer"||ms==="number"||ms==="boolean")&&(Ft=!0)}if(Ft){p=te;break}m.push(te)}else typeof te=="string"&&(p=te)}let A={};u!==void 0&&(A.catalogId=u);let I={kind:"call",name:a,args:m,kwargs:A},[D]=this.compileFunctionCall(I,t,s,r,i,o,!1);return{condition:D,message:p}}compileFunctionCall(e,t,s,r,i,o=!1,a=!1){let c=e.name,l=e.args,u={...e.kwargs},d=u.catalogId;delete u.catalogId;let h;if(a&&"functionCallId"in u){let I=u.functionCallId;if(delete u.functionCallId,typeof I!="string"||!I)throw new _(`functionCallId on function '${c}' must be a non-empty string.`);h=I}let{helper:p,catalogId:m}=this.resolveSymbol("function",c,d,i),g=p.getFunctionProperties(c),E={};for(let I=0;I<l.length;I++){let D=l[I];if(I<g.length){if(G(D,"skipped"))continue;let O=this._compileValue(D,t,s,r,i,o);O!=null&&(E[g[I]]=O)}}for(let[I,D]of Object.entries(u)){if(!g.includes(I))throw new Vr(c,I,g);if(I in E)throw new Ur(c,I);if(G(D,"skipped"))continue;let O=this._compileValue(D,t,s,r,i,o);O!=null&&(E[I]=O)}let A={[p.keys.call]:c};return m!==void 0&&(A.catalogId=m),A.args=E,[A,h]}compileEventCall(e,t,s,r,i){let o=e.args,a=e.kwargs,c=g=>this._compileValue(g,t,s,r,i,!1);if(o.length>2)throw new _(`Event accepts at most 2 positional arguments (name, context), got ${o.length}.`);for(let g of Object.keys(a))if(!Zf.includes(g))throw new Vr("Event",g,[...Zf]);if(o.length===2&&Object.hasOwn(a,"context"))throw new Ur("Event","context");let u={name:o.length>0?c(o[0]):""};if(Object.hasOwn(a,"userMessage")){if(i[0]<1)throw new _(`Event userMessage requires protocol v1.0 or later; the target version ${i[0]}.${i[1]} has no userMessage field.`);let g=c(a.userMessage),E=g!==null&&typeof g=="object"&&!Array.isArray(g)&&(Object.hasOwn(g,r.keys.path)||Object.hasOwn(g,r.keys.call));if(typeof g!="string"&&!E)throw new _(`Event userMessage must be a string, a $path data binding or a function call, got ${ly(a.userMessage)}.`);u.userMessage=g}let d=o.length===2?o[1]:a.context;if(d===void 0)return{event:u};let h=c(d),p={},m=g=>{for(let[E,A]of Object.entries(g))ar(p,E,A)};if(h&&typeof h=="object")if(Array.isArray(h))for(let g of h)g&&typeof g=="object"&&!Array.isArray(g)&&m(g);else m(h);return u.context=p,{event:u}}_compileValue(e,t,s,r,i,o=!1,a,c=!1,l=!1,u){if(Array.isArray(e)){let d=ry(u),h=o||qr(d?.schema),p=d?Fc(d.helper,"",d.schema):void 0;return e.map((m,g)=>this._compileValue(m,t,s,r,i,h,a?{...a,index:g}:void 0,l||p==="Child",p==="ChildList"&&Array.isArray(m),d))}if(G(e,"map"))return this.compileMapLiteral(e.entries,t,s,r,i,o,u);if(G(e,"path"))return{[r.keys.path]:e.path};if(G(e,"variable"))return this.compileVariableRef(e.name,t,s,r,i,o,c,l,u);if(G(e,"skipped"))throw new _("'_' can only stand in for an argument.");if(G(e,"check")){let{condition:d}=this.compileCheckCall(e,t,s,r,i,o);return d}return G(e,"call")?this.compileCallValue(e,t,s,r,i,o,a):e}compileMapLiteral(e,t,s,r,i,o,a){let c={};for(let[l,u]of Object.entries(e)){let d=iy(a,l),h=o||qr(d?.schema),p=d?Fc(d.helper,l,d.schema):void 0;ar(c,l,this._compileValue(u,t,s,r,i,h,void 0,p==="Child",p==="ChildList"&&Array.isArray(u),d))}return c}compileVariableRef(e,t,s,r,i,o,a,c,l){if(r.referencedVars.add(e),s.has(e))return s.get(e);if(Object.hasOwn(t,e)){if(r.resolving.has(e))throw new _(`Variable '${e}' refers to itself through its own value.`);r.resolving.add(e);try{return this._compileValue(t[e],t,s,r,i,o,void 0,a,c,l)}finally{r.resolving.delete(e)}}if(!a)throw r.allowPending?new In(e):new _(`Variable '${e}' is not assigned in surface.`);return e}compileCallValue(e,t,s,r,i,o,a){let c=e.name,l=e.args,u=e.kwargs;if(c==="_template")return this.compileTemplateHelper(l,t,s,r,i,o);if(c==="Event")return this.compileEventCall(e,t,s,r,i);if(this.definesComponent(c,u.catalogId))return this.compileInlineComponent(e,t,s,r,i,a);let[d]=this.compileFunctionCall(e,t,s,r,i,!1,!1);return o?{functionCall:d}:d}compileTemplateHelper(e,t,s,r,i,o){if(e.length<2)throw new Je("_template helper requires exactly 2 arguments: path and templateComponent.");let a=this._compileValue(e[0],t,s,r,i,o);if(!a||typeof a!="object"||!(r.keys.path in a))throw new Je(`The first argument to _template must be a dynamic data binding path (prefixed by $), got: ${cy(e[0])}`);let c=this._compileValue(e[1],t,s,r,i,o,void 0,!0,!1);return{path:a[r.keys.path],componentId:c}}compileInlineComponent(e,t,s,r,i,o){r.inlineCounter+=1;let a=o?o.index!==void 0?`${o.parentId}_${o.property}_${o.index}`:`${o.parentId}_${o.property}`:`_inline_${r.inlineCounter}`,c=typeof e.kwargs.id=="string"&&e.kwargs.id?e.kwargs.id:a;if(Object.hasOwn(t,c)||Array.from(s.values()).includes(c)||r.generatedIds.has(c))throw new Br(c);r.generatedIds.add(c);let l=r.extraComponents.length,u=this._compileAstNode(a,e,t,s,r,i);return u?(r.extraComponents.splice(l,0,u),u.id):a}_checkDataBindings(e,t,s,r,i,o){let a=(c,l,u)=>{if(G(c,"path")){if(l&&!i.admitsPath(l))throw new yo(e,t);return}if(G(c,"variable")){!u.has(c.name)&&Object.hasOwn(o,c.name)&&a(o[c.name],l,new Set([...u,c.name]));return}if(Array.isArray(c)){let d=l?i.resolveItemSchema(l):void 0;for(let h of c)a(h,d,u);return}if(G(c,"map"))for(let[d,h]of Object.entries(c.entries)){let p=l?i.resolvePropertySchema(l,d):void 0;a(h,p,u)}};a(s,r,new Set)}};var py=new Set(["true","false","null","_"]),my=new RegExp("^\\p{XID_Continue}$","u");function lr(n){return fe(n)&&!py.has(n)}function gy(n){let e=Array.from(n,t=>my.test(t)?t:"_").join("");for(;!lr(e);)e=`_${e}`;return e}function th(n){let e=new Map,t=new Set;for(let s of n)lr(s)&&(e.set(s,s),t.add(s));for(let s of n){if(e.has(s))continue;let r=gy(s),i=r,o=2;for(;t.has(i);)i=`${r}_${o}`,o+=1;e.set(s,i),t.add(i)}return e}var kn=class{constructor(e){this.value=e}};function ee(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function zc(n,e,t){if(n==null)return{};let s=ee(n);if(!s)throw new _(`${e} has a non-object '${t}'`);return s}function yy(n){return!(n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof kn)&&Object.keys(n).length===0)}function xy(n){let e=[];function t(s,r){if(s instanceof kn){e.push([r,s]);return}if(s&&typeof s=="object"&&!Array.isArray(s)&&Object.keys(s).length>0)for(let[i,o]of Object.entries(s))t(o,`${r}/${i}`);else e.push([r,s])}return t(n,""),e}function Wc(n){if(!n||typeof n!="object")return!1;let e=n;if(typeof e.$ref=="string"){let t=dt(e.$ref);if(t==="ComponentId"||t==="Child"||t==="ChildList")return!0}for(let t of["oneOf","anyOf","allOf"]){let s=e[t];if(Array.isArray(s)){for(let r of s)if(Wc(r))return!0}}return e.type==="array"&&e.items?Wc(e.items):!1}function Sy(n){if(!Number.isFinite(n))throw new b(`The number ${n} has no Express notation.`);return Object.is(n,-0)?"-0.0":String(n)}function Ue(n){let e=n.includes(`
37
+ `)||n.includes("\r"),t=n.includes(" "),s=n.includes("\\");return e&&!n.endsWith('"')&&!n.includes('"""')?s&&!t?`r"""${n}"""`:`"""${n.replaceAll("\\","\\\\").replaceAll(" ","\\t")}"""`:s&&!e&&!t&&!n.includes('"')?`r"${n}"`:`"${n.replaceAll("\\","\\\\").replaceAll('"','\\"').replaceAll(`
38
+ `,"\\n").replaceAll("\r","\\r").replaceAll(" ","\\t")}"`}function nh(n,e){let t=e.get(n);if(t!==void 0)return t;if(lr(n)){let s=!1;for(let r of e.values())if(r===n){s=!0;break}if(!s)return n}return Ue(n)}var hs=class{constructor(e,t){this.catalogs=bn(e),mc(this.catalogs),this.protocolVersion=t,this.helpers=Gs(this.catalogs,t),this.soleCatalogId=this.catalogs.length===1?this.catalogs[0].id:void 0,this.isV1=Wt(this.protocolVersion,"1.0.0")>=0}resolveSymbol(e,t,s,r){let i=e==="component"?"Component":"Function",o=(typeof s=="string"&&s?s:void 0)??r;if(!o)throw new _(`${i} '${t}' has no catalogId and its surface has no catalogId.`);let a=this.helpers.get(o);if(!a)throw Ks(`${i} '${t}'`,o,this.catalogs);if(!(e==="component"?a.components:a.functions).has(t))throw zr(e,t,o,this.helpers);if(this.soleCatalogId!==void 0)return{helper:a};let l=Qt(this.helpers,e,t);return l.length===1&&l[0]===o?{helper:a}:{helper:a,catalogId:o}}coalesceSurfaceMessages(e){let t=[],s=new Map;for(let r of e){let i=ee(r);if(!i||Object.keys(i).length===0)continue;let o=ee(i.createSurface);if(o){let u=typeof o.surfaceId=="string"&&o.surfaceId?o.surfaceId:"default_surface",d={...i,createSurface:{...o}};s.set(u,t.length),t.push(d);continue}let a=ee(i.deleteSurface);if(a){let u=typeof a.surfaceId=="string"&&a.surfaceId?a.surfaceId:"default_surface";s.delete(u),t.push(i);continue}if(ee(i.callRendererFunction)||ee(i.callFunction)){s.clear(),t.push(i);continue}let c=ee(i.updateComponents);if(c){let u=typeof c.surfaceId=="string"&&c.surfaceId?c.surfaceId:"default_surface";if(s.has(u)){let d=t[s.get(u)].createSurface;if(!d.components){d.components=c.components;continue}s.delete(u)}t.push(i);continue}let l=ee(i.updateDataModel);if(l){let u=typeof l.surfaceId=="string"&&l.surfaceId?l.surfaceId:"default_surface";if(s.has(u)){let d=t[s.get(u)].createSurface,h=l.path===void 0||l.path===null||l.path===""||l.path==="/",p=ee(l.value);if(h&&p){d.dataModel={...p};continue}s.delete(u)}t.push(i);continue}t.push(i)}return t}formatSurfaceHeader(e,t={}){let s=[Ue(e)];return typeof t.sendDataModel=="boolean"&&s.push(`sendDataModel=${t.sendDataModel?"true":"false"}`),t.update&&s.push("update=true"),t.extensions!==void 0&&s.push(`extensions=${this.decompileValue(t.extensions,new Map,!1)}`),`surface(${s.join(", ")})`}wrap(e){let t="";for(let s of e)s.type==="text"?t+=s.text+`
39
+ `:s.type==="a2ui"&&(t+=`${zs}
40
+ ${s.a2uiRaw}
41
+ ${Ws}
42
+ `);return t.trimEnd()}decompile(e,t=!1){let s=this.coalesceSurfaceMessages(e),r=new Map,i=[],o=0;for(let a of s){let c=i.length===0,l=ee(a.deleteSurface);if(l){i.push(this.decompileDeleteSurface(l,r));continue}let u=ee(a.callRendererFunction),d=ee(u?u.callFunction:a.callFunction);if(d){o+=1;let g=u&&typeof u.functionCallId=="string"&&u.functionCallId?u.functionCallId:void 0;i.push(this.decompileCallFunction(d,g,o));continue}let h=ee(a.updateDataModel);if(h){let g=this.decompileUpdateDataModel(h,r,c);g&&i.push(g);continue}let p=ee(a.createSurface);if(p){let g=this.decompileCreateSurface(p,r,t,c);g&&i.push(g);continue}let m=ee(a.updateComponents);if(m){let g=this.decompileUpdateComponents(m,r,t,c);g&&i.push(g);continue}}return i.join(`
43
+ `)}resolveSurfaceContext(e,t){let s=t.get(e)??this.soleCatalogId,r=(s?this.helpers.get(s):void 0)??this.helpers.get(this.catalogs[0].id);return{surfaceCatalogId:s,helper:r}}checkComponentIds(e){if(!this.isV1)return;let t=e.filter(s=>!fe(s)).map(s=>({path:`components.${s}.id`,code:"invalid_identifier",message:`Component id '${s}' must be a valid UAX #31 identifier`}));if(t.length>0)throw new b(t[0].message,t)}collectVariableNames(e){let t=[];for(let s of e)typeof s.id=="string"&&t.push(s.id);return this.checkComponentIds(t),th(t)}formatDataModelLines(e,t,s,r,i){if(!t&&!yy(e))return[];let o=xy(e);return o.sort((a,c)=>a[0]<c[0]?-1:a[0]>c[0]?1:0),o.map(([a,c])=>{let l=t?`${t}${a}`:a,u=this.decompileValue(c,s,!1,r,i);return`$${l} = ${u}`})}decompileDeleteSurface(e,t){let s=typeof e.surfaceId=="string"?e.surfaceId:"";return t.delete(s||"default_surface"),`deleteSurface(${Ue(s)})`}decompileCallFunction(e,t,s){let r=t&&t!==`call_${s}`?[`functionCallId=${Ue(t)}`]:void 0;return this.formatFunctionCall(e,new Map,this.soleCatalogId,r)}decompileUpdateDataModel(e,t,s){let r=typeof e.surfaceId=="string"&&e.surfaceId?e.surfaceId:"default_surface",{surfaceCatalogId:i,helper:o}=this.resolveSurfaceContext(r,t),c=(typeof e.path=="string"&&e.path?e.path:"/").replace(/\/+$/,""),l=c?e.value??null:e.value??{},u=this.decompileValue(l,new Map,!1,o,i),d=c?`$${c}`:"$/",h=[];return s&&r==="default_surface"||h.push(this.formatSurfaceHeader(r)),h.push(`${d} = ${u}`),h.join(`
44
+ `)}decompileCreateSurface(e,t,s,r){let i=typeof e.surfaceId=="string"&&e.surfaceId?e.surfaceId:"default_surface";if(typeof e.catalogId=="string"&&e.catalogId){if(this.helpers.size>0&&!this.helpers.has(e.catalogId))throw Ks(`Surface '${i}'`,e.catalogId,this.catalogs);t.set(i,e.catalogId)}else t.delete(i);let{surfaceCatalogId:o,helper:a}=this.resolveSurfaceContext(i,t),c=typeof e.sendDataModel=="boolean"?e.sendDataModel:void 0,l=this.isV1?ee(e.metadata):void 0,u=l?ee(l.extensions):void 0,d=[];r&&i==="default_surface"&&c===void 0&&u===void 0||d.push(this.formatSurfaceHeader(i,{sendDataModel:c,extensions:u}));let h=Array.isArray(e.components)?e.components:[],p=this.collectVariableNames(h);ee(e.dataModel)&&d.push(...this.formatDataModelLines(e.dataModel,"",p,a,o));for(let m of h)d.push(this.formatComponent(m,p,o,s));return d.length>0?d.join(`
45
+ `):void 0}decompileUpdateComponents(e,t,s,r){let i=typeof e.surfaceId=="string"&&e.surfaceId?e.surfaceId:"default_surface",{surfaceCatalogId:o}=this.resolveSurfaceContext(i,t),a=Array.isArray(e.components)?e.components:[],c=a.some(d=>ee(d)?.id==="root"),l=[];(c||!(r&&i==="default_surface"))&&l.push(this.formatSurfaceHeader(i,{update:c?!0:void 0}));let u=this.collectVariableNames(a);for(let d of a)l.push(this.formatComponent(d,u,o,s));return l.length>0?l.join(`
46
+ `):void 0}trimTrailingPlaceholders(e){for(;e.length>0&&e[e.length-1]==="_";)e.pop()}formatCheckPropertyArg(e,t,s,r,i,o){if(!Array.isArray(t)||t.length===0)return o?void 0:"_";let a=[];for(let l of t){let u=ee(l);u&&a.push(this.formatCheckRule(u,s,r,i))}let c=a.length===1?a[0]:`[${a.join(", ")}]`;return o?`${e}=${c}`:c}formatRegularPropertyArg(e,t,s,r,i,o,a,c,l){if(s in e){let h=a.getPropertySchema(t,s),p=Wc(h),m=this.decompileValue(e[s],o,p,a,c);return l?`${s}=${m}`:m}if(l)return;let u=r.indexOf(s);return r.slice(u+1).some(h=>h!==i&&h in e)?"_":void 0}formatComponent(e,t,s,r){let i=typeof e.id=="string"?e.id:"",o=t.get(i)??i,a=typeof e.component=="string"?e.component:"",{helper:c,catalogId:l}=this.resolveSymbol("component",a,e.catalogId,s),u=c.getComponentProperties(a),d=c.getCheckRuleProperty(a),h=[],p=this.isV1?ee(e.metadata):void 0,m=p?ee(p.extensions):void 0;for(let g of u){if(g==="metadata"&&m!==void 0)continue;let E=d&&g===d?this.formatCheckPropertyArg(g,e[d],e,t,s,r):this.formatRegularPropertyArg(e,a,g,u,d,t,c,s,r);E!==void 0&&h.push(E)}return this.trimTrailingPlaceholders(h),l!==void 0&&h.push(`catalogId=${Ue(l)}`),o!==i&&h.push(`id=${Ue(i)}`),m!==void 0&&h.push(`extensions=${this.decompileValue(m,t,!1,c,s)}`),`${o} = ${a}(${h.join(", ")})`}formatCheckRule(e,t,s,r){let i="condition"in e&&ee(e.condition)!==void 0,o=i?e.condition:e,a=i&&typeof e.message=="string"?e.message:"",c=o["@call"]??o.call,l=typeof c=="string"&&c?c:"None",u=zc(o.args,`Check '${l}'`,"args"),d,h;l!=="None"&&({helper:d,catalogId:h}=this.resolveSymbol("function",l,o.catalogId,r));let p=d?d.getFunctionProperties(l):[],m=d??this.helpers.get(this.catalogs[0].id),g=ee(t.value),E=ee(u.value),A=g?g["@path"]??g.path:void 0,I=E?E["@path"]??E.path:void 0,D=0;p.length>0&&p[0]==="value"&&typeof A=="string"&&A===I&&(D=1);let O=[];for(let Q=D;Q<p.length;Q++){let Me=p[Q];Me in u?O.push(this.decompileValue(u[Me],s,!1,m,r)):O.push("_")}let te=l.length>0?l[0].toUpperCase()+l.slice(1).toLowerCase():l;return l!=="None"&&a&&a!==`${te} check failed`?O.push(Ue(a)):this.trimTrailingPlaceholders(O),h!==void 0&&O.push(`{catalogId: ${Ue(h)}}`),O.length>0?`?${l}(${O.join(", ")})`:`?${l}`}formatFunctionCall(e,t,s,r){let i=e["@call"]??e.call,o=typeof i=="string"?i:"",a=e.args,c=Array.isArray(a),l=c?{}:zc(a,`Function call '${o}'`,"args"),{helper:u,catalogId:d}=this.resolveSymbol("function",o,e.catalogId,s),h=u.getFunctionProperties(o),p=[];for(let m=0;m<h.length;m++){let g=h[m];if(c?m<a.length:g in l){let A=c?a[m]:l[g];p.push(this.decompileValue(A,t,!1,u,s))}else p.push("_")}return this.trimTrailingPlaceholders(p),d!==void 0&&p.push(`catalogId=${Ue(d)}`),r&&r.length>0&&p.push(...r),`${o}(${p.join(", ")})`}decompileValue(e,t,s=!1,r=this.helpers.get(this.catalogs[0].id),i=this.soleCatalogId){if(e instanceof kn)return e.value;if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="number")return Sy(e);if(typeof e=="string")return s?nh(e,t):Ue(e);if(Array.isArray(e))return`[${e.map(a=>this.decompileValue(a,t,s,r,i)).join(", ")}]`;if(typeof e=="object"){let o=e;if(typeof o.path=="string"&&"componentId"in o&&typeof o.componentId=="string"){let u=this.decompileValue({[r.keys.path]:o.path},t,!1,r,i),d=nh(o.componentId,t);return`_template(${u}, ${d})`}let a=o[r.keys.path];if(typeof a=="string"&&Object.keys(o).length===1){let u=a;return u.startsWith("/")?`$/${u.slice(1)}`:`$${u}`}if("event"in o&&o.event&&typeof o.event=="object"&&(this.isV1||o.event.userMessage===void 0)){let u=o.event,d=typeof u.name=="string"?u.name:"",h=zc(u.context,`Event '${d}'`,"context"),p=[];for(let[g,E]of Object.entries(h)){let A=lr(g)?g:Ue(g);p.push(`${A}: ${this.decompileValue(E,t,!1,r,i)}`)}let m=[Ue(d)];if(p.length>0&&m.push(`{${p.join(", ")}}`),u.userMessage!==void 0&&u.userMessage!==null){let g=this.decompileValue(u.userMessage,t,!1,r,i);m.push(`userMessage=${g}`)}return`Event(${m.join(", ")})`}if("functionCall"in o&&o.functionCall&&typeof o.functionCall=="object")return this.formatFunctionCall(o.functionCall,t,i);if(typeof o[r.keys.call]=="string")return this.formatFunctionCall(o,t,i);let l=[];for(let[u,d]of Object.entries(o)){let h=s||u==="child"||u==="componentId",p=lr(u)?u:Ue(u);l.push(`${p}: ${this.decompileValue(d,t,h,r,i)}`)}return`{${l.join(", ")}}`}return String(e)}};function by(n){let e=new Set(n),t=()=>{throw new TypeError("DEFAULT_EXPRESS_PROGRESSIVE_KEYS is read-only.")};return Object.defineProperty(e,"add",{value:t,writable:!1,configurable:!1}),Object.defineProperty(e,"delete",{value:t,writable:!1,configurable:!1}),Object.defineProperty(e,"clear",{value:t,writable:!1,configurable:!1}),Object.freeze(e)}var ci=by(["text"]),uh=zs,dh=Ws,Ay="<a2ui(?:\\s[^>]*)?>",vy="<\\/a2ui\\s*>",Ey=/<a2ui\s[^>]*$/iy,Cy=/<\/a2ui\s*$/iy,Ty=/^\s*(?:```[a-zA-Z0-9_-]*[ \t]*\r?\n|`+\s*)/,wy=/(?:\r?\n?[ \t]*```[a-zA-Z0-9_-]*|`+)\s*$/,Iy=/(?:\s*```[a-zA-Z0-9_-]*[ \t]*(?:\r?\n[ \t]*)?|(?:^|(?<=\s))`{1,2})$/,ky=/(?:```[a-zA-Z0-9_-]*[ \t]*(?:\r?\n[ \t]*)?|`+)$/,Ry=/(?:^|(?<=\s))`{1,2}$/,sh=/^\s*```[a-zA-Z0-9_-]*[ \t]*(?:\r?\n|$)/,_y=/^\s*(?:`{0,2}|```[a-zA-Z0-9_-]*[ \t]*\r?)$/,rh=/^(?:\s*```[a-zA-Z0-9_-]*[ \t]*(?:\r?\n|$)|`+)/,Ny=/^(?:`+|\s*`{0,2}|\s*```[a-zA-Z0-9_-]*[ \t]*\r?)$/,Oy=/\s*```[a-zA-Z0-9_-]*[ \t]*\r?\n?$/,ih=/[a-zA-Z_][a-zA-Z0-9_]*/y,Py=/^\s*\$([a-zA-Z0-9_/]*)\s*=(?!=)/;function Dy(n,e=0){let t=new RegExp(Ay,"gi");t.lastIndex=e;let s=t.exec(n);return s?{start:s.index,end:s.index+s[0].length}:void 0}function fh(n,e){let t=new RegExp(vy,"iy");t.lastIndex=e;let s=t.exec(n);return s?e+s[0].length:void 0}function hh(n,e,t){return n.length-e<t.length&&t.startsWith(n.slice(e).toLowerCase())}function ph(n,e,t){return n.lastIndex=t,n.test(e)}function Ly(n){let e=n.indexOf("<");for(;e>=0;){if(hh(n,e,uh)||ph(Ey,n,e))return e;e=n.indexOf("<",e+1)}return n.length}function $y(n){let e=ky.exec(n);return e?e.index:n.length}function My(n,e){let t=e,s=n.length;for(;t<s;){let[o,a]=Fy(n,t,s);if(o>t){if(!a)return{closeStart:void 0,readableEnd:s,resumePos:t};t=o;continue}if(n[t]==="<"){let c=mh(n,t);if(c!==void 0)return{closeStart:c[0],readableEnd:c[1],resumePos:t}}t+=1}let r=s>0?n[s-1]:"",i=r==="r"||r==="R"||r==="/"||r==="-"?s-1:s;return{closeStart:void 0,readableEnd:s,resumePos:i}}function Fy(n,e,t){if((n[e]==="r"||n[e]==="R")&&e+1<t&&n[e+1]==='"'&&(e===0||!/[a-zA-Z0-9_]/.test(n[e-1]))){let s=oh(n,e+1,t,!0);return s!==void 0?s===t&&s-(e+1)===2?[t,!1]:[s,!0]:[t,!1]}if(n[e]==='"'){let s=oh(n,e,t,!1);return s!==void 0?s===t&&s-e===2?[t,!1]:[s,!0]:[t,!1]}if(n.startsWith("/*",e)){let s=n.indexOf("*/",e+2);return s<0?[t,!1]:[s+2,!0]}if(n[e]==="#"||n.startsWith("//",e)||n.startsWith("--",e)){let s=n[e]==="#"?e+1:e+2;for(;s<t&&n[s]!==`
47
+ `&&n[s]!=="\r";){if(n[s]==="<"&&mh(n,s)!==void 0)return[s,!0];s+=1}return s<t?[s+1,!0]:[t,!1]}return[e,!0]}function mh(n,e){if(fh(n,e)!==void 0)return[e,e];if(hh(n,e,dh)||ph(Cy,n,e))return[void 0,e]}function oh(n,e,t,s){let r=n[e],i=r.repeat(3),a=n.startsWith(i,e)?i:r,c=e+a.length;for(;c<t;){if(!s&&n[c]==="\\"){if(c+1>=t)return;c+=2;continue}if(n.startsWith(a,c))return c+a.length;c+=1}}function ah(n,e){let t=n.slice(0,e),s=t.trimStart();return s.length>0&&s.length<=3&&"```".startsWith(s)||s.startsWith("```")&&!s.includes(`
48
+ `)?void 0:t.replace(Ty,"").replace(wy,"")}var Zc=class{constructor(){this.depth=0,this.hasToken=!1,this.sawEquals=!1,this.hasRhs=!1,this.rhsClosed=!1,this.lastComplete=0}resetStatement(e){this.hasToken=!1,this.sawEquals=!1,this.hasRhs=!1,this.rhsClosed=!1,this.lastComplete=e}};function ch(n,e=!1){if(e)return[n,""];let t=new Zc,s=0,r=n.length;for(;s<r;){let[i,o]=jy(n,s,r);if(i>s){o&&t.depth===0&&t.sawEquals&&(t.hasRhs=!0,t.rhsClosed=!0,t.lastComplete=i),s=i;continue}s=Vy(n,s,r,t)}return[n.slice(0,t.lastComplete),n.slice(t.lastComplete)]}function jy(n,e,t){if((n[e]==="r"||n[e]==="R")&&e+1<t&&n[e+1]==='"'){let s=Hc(n,e+1,t,!0);return s!==void 0?s===t&&s-(e+1)===2?[t,!1]:[s,!0]:[t,!1]}if(n[e]==='"'){let s=Hc(n,e,t,!1);return s!==void 0?s===t&&s-e===2?[t,!1]:[s,!0]:[t,!1]}if(n.startsWith("/*",e)){let s=n.indexOf("*/",e+2);return s>=0?[s+2,!1]:[t,!1]}if(n[e]==="#"||n.startsWith("//",e)||n.startsWith("--",e)){let s=n.indexOf(`
49
+ `,e);return s>=0?[s,!1]:[t,!1]}return[e,!1]}function Hc(n,e,t,s){let i=n.startsWith('"""',e)?'"""':'"',o=e+i.length;for(;o<t;){if(!s&&n[o]==="\\"){if(o+1>=t)return;o+=2;continue}if(n.startsWith(i,o))return o+i.length;o+=1}}function Vy(n,e,t,s){let r=n[e];return r==="("||r==="["||r==="{"?Uy(s):r===")"||r==="]"||r==="}"?By(e,s):s.depth===0&&(r===`
50
+ `||r===";")?qy(e,s):/\s/.test(r)||zy(n,e,t,s),e+1}function Uy(n){n.depth+=1,n.hasToken=!0,n.sawEquals&&(n.hasRhs=!0,n.rhsClosed=!1)}function By(n,e){e.depth<=0||(e.depth-=1,e.depth===0&&(e.sawEquals||e.hasToken)&&(e.hasRhs=!0,e.rhsClosed=!0,e.lastComplete=n+1))}function qy(n,e){e.rhsClosed||e.sawEquals&&e.hasRhs?e.resetStatement(n+1):e.hasToken||(e.lastComplete=n+1)}function zy(n,e,t,s){if(s.depth===0&&n[e]==="="&&(e+1>=t||n[e+1]!=="=")){s.sawEquals=!0,s.hasToken=!0;return}s.hasToken=!0,s.depth===0&&s.sawEquals&&(s.hasRhs=!0)}var Gc=class{constructor(){this.brackets=[],this.calls=[],this.lastIdent=void 0}};function Wy(n,e,t){if(t.size===0||!n.trim())return;let s=Zy(n);if(s===void 0)return;let r=n.slice(s.strStart);if(Xy(r)||!Jy(n,s.calls,e,t))return;let i=n;if(!s.isRaw&&Qy(i)&&(i=i.slice(0,-1)),s.delim==='"""'&&i.slice(s.strStart).endsWith('"')){if(s.isRaw)return;i=`${i.slice(0,-1)}\\"`}let o=[...s.brackets].reverse().map(a=>e2(a)).join("");return`${i}${s.delim}${o}`}function Zy(n){let e=0,t=n.length,s=new Gc;for(;e<t;){let r=Hy(n,e,t,s);if(r!==void 0){if(r.unclosed!==void 0)return r.unclosed;e=r.nextI;continue}let i=Gy(n,e);if(i!==void 0){if(i<0)return;e=i;continue}e=Ky(n,e,s)}}function Hy(n,e,t,s){let r=(n[e]==="r"||n[e]==="R")&&e+1<t&&n[e+1]==='"';if(!r&&n[e]!=='"')return;let i=r?e+1:e,o=n.startsWith('"""',i)?'"""':'"',a=Hc(n,i,t,r);return a===void 0?{nextI:t,unclosed:{strStart:i+o.length,delim:o,isRaw:r,brackets:s.brackets,calls:s.calls}}:{nextI:a}}function Gy(n,e){if(n.startsWith("/*",e)){let t=n.indexOf("*/",e+2);return t<0?-1:t+2}if(n[e]==="#"||n.startsWith("//",e)||n.startsWith("--",e)){let t=n.indexOf(`
51
+ `,e);return t<0?-1:t+1}}function Ky(n,e,t){ih.lastIndex=e;let s=ih.exec(n);return s?(t.lastIdent=s[0],t.calls.length>0&&t.brackets[t.brackets.length-1]==="("&&(t.calls[t.calls.length-1].lastIdent=t.lastIdent),e+s[0].length):(Yy(n[e],t),e+1)}function Yy(n,e){let t=e.calls.length>0&&e.brackets[e.brackets.length-1]==="(";if(n==="(")e.brackets.push("("),e.calls.push({name:e.lastIdent??"",argIndex:0}),e.lastIdent=void 0;else if(n==="["||n==="{")e.brackets.push(n),e.lastIdent=void 0;else if(n===")"||n==="]"||n==="}")e.brackets.pop()==="("&&e.calls.length>0&&e.calls.pop(),e.lastIdent=void 0;else if(n===","&&t){let s=e.calls[e.calls.length-1];s.argIndex+=1,s.kwargName=void 0,s.lastIdent=void 0}else if(n==="="&&t&&e.calls[e.calls.length-1].lastIdent){let s=e.calls[e.calls.length-1];s.kwargName=s.lastIdent}else/\s/.test(n)||(e.lastIdent=void 0)}function Jy(n,e,t,s){if(e.length===0){let i=Py.exec(n);if(!i)return!1;let o=i[1].replace(/\/+$/,"").split("/");return s.has(o[o.length-1])}let r=e[e.length-1];if(!r.name)return!1;for(let i of t.values())if(i.components.has(r.name)){if(r.kwargName!==void 0)return s.has(r.kwargName);let o=i.getCheckRuleProperty(r.name),a=i.getComponentProperties(r.name).filter(c=>c!=="checks"&&c!==o);if(r.argIndex<a.length)return s.has(a[r.argIndex])}return!1}function Xy(n){let e=n.trimStart().toLowerCase();return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")}function Qy(n){let e=0,t=n.length-1;for(;t>=0&&n[t]==="\\";)e+=1,t-=1;return e%2===1}function e2(n){return n==="["?"]":n==="{"?"}":")"}function t2(n){if(n instanceof _)return jr;let e=n.cause;return n instanceof Je||e instanceof _t?Fr:ut}function qo(n,e){if(n instanceof ut)return n;if(n instanceof Zs){let r=n.cause,i,o;n instanceof _t?(i=n.line,o=n.column):r instanceof _t&&(i=r.line,o=r.column);let a=n.helpMessage||"Please correct the syntax error in your Express DSL.",c=t2(n),l=qc(n),u=new c(l,{rawContent:e,line:i,column:o,helpMessage:a});return u.cause=n,u}if(n instanceof H)return n;let t=n instanceof Error?n.message:String(n),s=new ut(`Failed to compile A2UI block: ${t}`,{rawContent:e});return s.cause=n,s}var zo=class{constructor(e,{wrapped:t=!0,state:s,afterRejectedBlock:r="end",progressiveKeys:i}={}){this.parser=e,this.closed=!1,this.held="",this.text=new uo,this.afterBlock=!1,this.wrappedInInlineBackticks=!1,this.rejected=!1,this.block="",this.scanPos=0,this.lastCompiledPrefix="",this.touched=new Set,this.wrapped=t,this.state=s??new Ye(e.catalogs),this.continues=r==="continue",this.compiler=new cr(e.catalogs,e.version),this.progressiveKeys=i!==void 0?new Set(i):e.progressiveKeys,this.inBlock=!t,this.initialSurfaces=new Set(this.state.surfaceIds),this.session=this.newSession()}get isInBlock(){return!this.closed&&this.inBlock}newSession(){return new Bo(this.compiler,{surfaceId:this.parser.surfaceId,version:this.parser.version})}resetBlock(){this.block="",this.scanPos=0,this.rejected=!1,this.lastCompiledPrefix="",this.touched=new Set,this.initialSurfaces=new Set(this.state.surfaceIds),this.session=this.newSession()}feed(e){if(this.closed)throw new Error("The response stream is closed.");let t=[];try{this.read(e,t)}catch(s){throw this.fail(),qs(s,t.filter(lh))}return t}close(){return this.end()}end(){if(this.closed)return[];this.closed=!0;let e=[];try{if(!this.wrapped)return this.rejected||this.readBlock(e,()=>this.finishBlock(e,this.block.length)),e;if(this.inBlock)return this.rejected||this.readBlock(e,()=>{throw new Mr(`The response ended inside an ${uh} block, before its ${dh} tag.`)}),this.state.markChecked(this.touched),e}catch(t){throw this.fail(),qs(t,e.filter(lh))}if(this.held){let t=this.held;if(this.held="",this.afterBlock){let s=this.wrappedInInlineBackticks?rh:sh;t=t.replace(s,""),this.wrappedInInlineBackticks=!1}this.text.emit(e,t.replace(Oy,""))}return e}fail(){this.closed=!0,this.state.markChecked(this.touched)}readBlock(e,t){try{t()}catch(s){if(!this.continues||!(s instanceof H))throw s;e.push({type:"error",error:s}),this.state.markChecked(this.touched),this.rejected=!0}}read(e,t){if(!this.wrapped){this.block+=e,this.rejected||this.readBlock(t,()=>this.emitReady(t,this.block.length));return}let s=this.held+e;for(this.held="";s.length>0;){if(this.inBlock){s=this.consumeBlockText(t,s);continue}if(this.afterBlock){let r=this.wrappedInInlineBackticks?Ny:_y,i=this.wrappedInInlineBackticks?rh:sh;if(r.test(s)){this.held=s;return}this.afterBlock=!1,this.wrappedInInlineBackticks=!1,s=s.replace(i,"");continue}s=this.consumeOutsideText(t,s)}}consumeBlockText(e,t){this.block+=t;let{closeStart:s,readableEnd:r,resumePos:i}=My(this.block,this.scanPos);if(this.scanPos=i,s===void 0)return this.rejected||this.readBlock(e,()=>this.emitReady(e,r)),"";let o=fh(this.block,s),a=this.block.slice(o);return this.rejected||this.readBlock(e,()=>this.finishBlock(e,s)),this.inBlock=!1,this.afterBlock=!0,this.resetBlock(),a}consumeOutsideText(e,t){let s=Dy(t);if(s){let o=t.slice(0,s.start);return this.wrappedInInlineBackticks=Ry.test(o),this.text.emit(e,o.replace(Iy,"")),this.text.reset(),this.inBlock=!0,this.resetBlock(),t.slice(s.end)}let r=Ly(t),i=$y(t.slice(0,r));return this.text.emit(e,t.slice(0,i)),this.held=t.slice(i),""}emitReady(e,t){let s=ah(this.block,t);if(!s||!s.trim())return;let r,i;if(this.lastCompiledPrefix&&s.startsWith(this.lastCompiledPrefix)&&(this.lastCompiledPrefix.endsWith(`
52
+ `)||this.lastCompiledPrefix.endsWith(";"))){let[c,l]=ch(s.slice(this.lastCompiledPrefix.length),!1);r=`${this.lastCompiledPrefix}${c}`,i=l}else[r,i]=ch(s,!1);let o=[];if(r.trim()&&r!==this.lastCompiledPrefix){let c=this.session.snapshot(),l=new Set(this.touched);try{this.state.transaction(()=>{let u=this.compileStep(r,!1,!0);u.length>0&&(this.apply(u),o.push(...u))}),this.lastCompiledPrefix=r}catch(u){throw this.session.restore(c),this.touched=l,u}}let a=Wy(i,this.compiler.helpers,this.progressiveKeys);if(a!==void 0){let c=r.trim()?`${r}
53
+ ${a}`:a;o.push(...this.tryCompileAndApplyHealed(c))}o.length>0&&e.push({type:"a2ui",a2ui:n2(o)})}tryCompileAndApplyHealed(e){let t=this.session.snapshot(),s=new Set(this.touched);try{return this.state.transaction(()=>{let r=this.compileStep(e,!1,!1);return r.length>0&&this.apply(r),r})}catch(r){if(r instanceof H)return this.session.restore(t),this.touched=s,[];throw r}}finishBlock(e,t){let s=ah(this.block,t)??"",r=[];this.state.transaction(()=>{if(!this.session.hasEmitted&&this.initialSurfaces.size===0){try{r=this.parser.compile(s,!0)}catch(i){throw qo(i,s)}this.apply(r)}else r=this.compileStep(s,!0,!0),r.length>0&&this.apply(r);this.state.checkTopology(this.touched)}),r.length>0&&e.push({type:"a2ui",a2ui:r})}compileStep(e,t,s=!0){try{return this.session.compileStep(e,{isFinal:t,existingSurfaces:this.initialSurfaces,cachePrefix:s})}catch(r){throw qo(r,e)}}apply(e){for(let[s,r]of this.session.supersededComponents)this.state.dropProvisionalComponent(s,r);this.session.supersededComponents=[];let t=this.state.apply(e);for(let s of t)this.touched.add(s)}};function lh(n){return n.type!=="error"}function n2(n){let e=[];for(let t of n)e.length>0&&s2(e[e.length-1],t)||e.push(t);return e}function s2(n,e){let s=e.updateComponents;if(!s||!Array.isArray(s.components))return!1;let r=s.surfaceId,i=n;for(let o of["updateComponents","createSurface"]){let a=i[o];if(a&&a.surfaceId===r&&Array.isArray(a.components)){let c=[...a.components],l=new Map;c.forEach((u,d)=>l.set(u.id,d));for(let u of s.components){let d=l.get(u.id);d!==void 0?c[d]=u:(l.set(u.id,c.length),c.push(u))}return a.components=c,!0}}return!1}var Wo=class extends io{constructor(e,t="main",s,r={}){super(),this.catalogs=bn(e),this.version=Nt(this.catalogs,s),this.surfaceId=t,this.progressiveKeys=r.progressiveKeys!==void 0?new Set(r.progressiveKeys):ci,this.lexer=new lo(zs,Ws,new Set(['"']),new Set(["#","//","--"]),hc,!1,[["/*","*/"]]),this.decompiler=new hs(this.catalogs,this.version)}get supportsStreaming(){return!0}openStream({wrapped:e=!0,state:t,afterRejectedBlock:s="end"}={}){return new zo(this,{wrapped:e,state:t??new Ye(this.catalogs),afterRejectedBlock:s,progressiveKeys:this.progressiveKeys})}hasFormatContent(e,{complete:t=!1}={}){return this.lexer.tokenize(e).some(r=>r.type==="a2ui"&&(!t||r.isFinal))}unwrap(e){return this.lexer.tokenize(e)}compile(e,t=!0){let s=new cr(this.catalogs,this.version);try{return s.compile(e,this.surfaceId,t)}catch(r){throw qo(r,e)}}decompile(e){return this.decompiler.decompile(e)}wrap(e){return this.decompiler.wrap(e)}};var r2=`# A2UI Express DSL Output Contract
54
+
55
+ You must output the user interface using A2UI Express.
56
+
57
+ IMPORTANT: You MUST always surround the entire A2UI Express block with the literal sentinel tags \`<a2ui>\` and \`</a2ui>\` (always include both the opening and closing tags; do NOT wrap the tags in backticks or replace the opening tag with a markdown code fence such as \`\`\`a2ui).
58
+
59
+ The host compiler will compile your A2UI Express output into the correct JSON envelopes automatically.
60
+
61
+ ## Grammar Rules
62
+
63
+ 1. Component constructors can be assigned to variables or nested inline inside parent component arguments:
64
+ header = ComponentA(prop1="val1")
65
+ root = ComponentB([header, ComponentC("Click", action=Event("submit"))])
66
+
67
+ Keyword arguments (\`param=value\`) and positional arguments with \`_\` placeholders are supported.
68
+
69
+ Variable names MUST start with a letter or underscore, and only contain letters, digits, and underscores.
70
+
71
+ 2. The interface tree must have a single entry point assigned to the reserved variable 'root'.
72
+
73
+ 3. Primitives:
74
+ - Strings: Quoted with \`"\` or \`"""\`. Support for \`\\n\`, \`\\t\`, \`\\\\\`, and \`\\"\` escapes.
75
+ Raw Strings: Prefaced by \`r\` (e.g., \`r"..."\` or \`r"""..."""\`), with no escape processing.
76
+ - Numbers: write as integers or decimals, e.g., 42
77
+ - Booleans: write true or false
78
+ - Null values: write null
79
+ - Dates & Times: Values for date-time inputs (e.g. in DateTimeInput) must strictly use RFC 3339 format with a timezone offset (e.g. "2026-03-14T00:00:00Z").
80
+
81
+ 4. Lists: represent as arrays, e.g., [child1, child2].
82
+
83
+ 5. Maps: represent as key-value blocks, e.g., {title: "Overview", child: contentCol}. Map keys are always literal strings (dynamic variable resolution is not supported for keys).
84
+
85
+ 6. Data bindings: prefix absolute paths in the data model with '$', e.g., $/user/firstName.
86
+ Prefix relative list scopes with '$', e.g., $firstName.
87
+ A lone '$' represents an empty relative path which resolves to the root of the current context (e.g. inside a template, representing the entire item itself).
88
+
89
+ 7. Logic and validation: prefix client check rules with '?', e.g., ?required or ?regex("^[0-9]{5}$"). To specify a custom error message for validation failures, append it as an extra string argument, e.g. ?regex("^[0-9]{5}$", "Postal code must be 5 digits").
90
+
91
+ 8. Action events: represent server-side actions using the Event helper:
92
+ Event("save_deal", {rep: $/form/rep})
93
+
94
+ 9. Nested functions: call client functions directly using catalog signatures, for example myFunction("value").
95
+
96
+ 10. Data model population: Assign a value directly to an absolute data path (e.g. $/path/to/key = "value") to populate or initialize values inside the shared dataModel. The value can be a primitive, array, or map.
97
+
98
+ 11. Dynamic list templates: If a component expects a template child list, represent it using the _template helper:
99
+ _template($/path/to/list, itemTemplate)
100
+ And define the template component variable on another line, utilizing relative path references prefixed with $:
101
+ itemTemplate = Image($url)
102
+
103
+ 12. To delete a user interface surface, output the standalone \`deleteSurface(surfaceId)\` command (no variable assignment):
104
+ deleteSurface("dashboard-surface-1")
105
+
106
+ 13. Static properties: Arguments annotated with '(static)' in the signatures below MUST be defined as literal values or arrays inline. You CANNOT use a dynamic data binding path (prefixed by $) for these arguments.
107
+
108
+ 14. Required actions: Parameters named 'action' (or annotated in component signatures) are strictly required. You must pass a valid Event (e.g. Event("click")) or function call. If no specific action is described in the user request, you must provide a dummy click event like Event("click") instead of passing null or omitting the parameter.
109
+
110
+ 15. Surface targeting: Output \`surface(surfaceId)\` to specify or target a user interface surface:
111
+ surface("dashboard-surface-1")
112
+ root = ComponentA(...)`,i2="root = ComponentA(...)";function o2(n){for(let e of n)for(let t of e.components.keys()){let s=Object.hasOwn(e.componentRefMap,t)?e.componentRefMap[t]:void 0;if(s!==void 0&&s.singleRefs.size>0)return t}for(let e of n)for(let t of e.components.keys())return t}var a2=["createSurface","updateComponents","updateDataModel","deleteSurface","callFunction","callRendererFunction"];function gh(n){return!!n&&typeof n=="object"&&a2.some(e=>e in n)}function xh(n){if(!n||typeof n!="object")return;let e=n;if(Array.isArray(e.enum))return e.enum;for(let t of["oneOf","anyOf"]){let s=e[t];if(Array.isArray(s))for(let r of s){let i=xh(r);if(i)return i}}}function Zo(n,e){if(n instanceof kn||!n||typeof n!="object")return n;if(Array.isArray(n))return n.map(o=>Zo(o,e));let t=n,s={};for(let[o,a]of Object.entries(t))s[o]=Zo(a,e);let r=typeof s.component=="string",i=typeof s.call=="string"||typeof s["@call"]=="string";return(r||i)&&!s.catalogId&&(s.catalogId=e),s}function yh(n,e){if(!e)return n;let t=new Set;return n.map(s=>{if(!s||typeof s!="object")return s;let r={...s};if(r.createSurface&&typeof r.createSurface=="object"){let i=r.createSurface,o=typeof i.surfaceId=="string"&&i.surfaceId?i.surfaceId:"default_surface";t.add(o),i.catalogId||(r.createSurface={...i,catalogId:e})}else if(r.deleteSurface&&typeof r.deleteSurface=="object"){let i=r.deleteSurface,o=typeof i.surfaceId=="string"&&i.surfaceId?i.surfaceId:"default_surface";t.delete(o)}else if(r.updateComponents&&typeof r.updateComponents=="object"){let i=r.updateComponents,o=typeof i.surfaceId=="string"&&i.surfaceId?i.surfaceId:"default_surface";t.has(o)||(r.updateComponents=Zo(i,e))}else if(r.updateDataModel&&typeof r.updateDataModel=="object"){let i=r.updateDataModel,o=typeof i.surfaceId=="string"&&i.surfaceId?i.surfaceId:"default_surface";t.has(o)||(r.updateDataModel=Zo(i,e))}else if(r.callRendererFunction&&typeof r.callRendererFunction=="object"){let i=r.callRendererFunction;if(i.callFunction&&typeof i.callFunction=="object"){let o=i.callFunction;o.catalogId||(r.callRendererFunction={...i,callFunction:{...o,catalogId:e}})}}else if(r.callFunction&&typeof r.callFunction=="object"){let i=r.callFunction;i.catalogId||(r.callFunction={...i,catalogId:e})}return r})}var Ho=class extends oo{constructor(e,t,s,r){super(e),this.allowedMessages=s,this.version=Nt(this.catalogs,r),this.examples=t,this.helpers=Gs(this.catalogs,this.version)}getHelper(e){let t=this.helpers.get(e.id);if(!t){let s=pe(e.protocolVersion);t=new Hs(e,s),this.helpers.set(e.id,t)}return t}multiCatalogRules(){let e=[...this.helpers.keys()],t=e[e.length-1],r=["","## Multiple Catalogs","","Several component catalogs are active. Each is identified by its catalog ID, and the signatures below are grouped by catalog:",e.map(a=>`- \`${a}\``).join(`
113
+ `),"","16. A surface has no catalog of its own: do not name a catalog on a `surface` line. Each component and function call, including checks, actions, nested function calls and inline child components, is found by its name in whichever catalog defines it.","","17. When several catalogs define the same component or function name, you MUST say which one you mean: add a `catalogId` keyword argument to the component or function call, or a `{catalogId: ...}` argument to a check. Do not add `catalogId` to any other name:",` widget = ComponentName(..., catalogId="${t}")`,` action = functionName(..., catalogId="${t}")`,` ?checkName(..., {catalogId: "${t}"})`],i=[],o=[["component","Component"],["function","Function"]];for(let[a,c]of o){let l=new Set;for(let u of this.helpers.values()){let d=a==="component"?u.components:u.functions;for(let h of d.keys())l.add(h)}for(let u of[...l].sort()){let d=Qt(this.helpers,a,u);if(d.length>1){let h=d.map(p=>`\`${p}\``).join(", ");i.push(`- ${c} \`${u}\`: ${h}`)}}}return i.length>0&&r.push("","These names are defined in several catalogs and need a `catalogId`:",...i),r.join(`
114
+ `)}generateBaseRules(){let e=this.allowedMessages,t=r2,s=!0;if(e){e.includes("deleteSurface")||(t=t.replace(/\n\n12\. To delete a user interface surface, output the standalone `deleteSurface\(surfaceId\)` command \(no variable assignment\):\n {4}deleteSurface\("dashboard-surface-1"\)/,"")),e.includes("updateDataModel")||(t=t.replace(/\n\n10\. Data model population: Assign a value directly to an absolute data path \(e\.g\. \$\/path\/to\/key = "value"\) to populate or initialize values inside the shared dataModel\. The value can be a primitive, array, or map\./,""));let o=e.includes("createSurface")||e.includes("updateComponents"),a=e.includes("updateDataModel");s=o||a,o||(t=t.replace(/\n {4}root = ComponentA\(\.\.\.\)$/,""),a||(t=t.replace(/\n\n15\. Surface targeting: Output `surface\(surfaceId\)` to specify or target a user interface surface:\n {4}surface\("dashboard-surface-1"\)$/,"")))}let r=o2(this.catalogs);r!==void 0&&(t=t.replace(i2,`root = ${r}(...)`));let i=[t];return this.catalogs.length>1&&s&&i.push(this.multiCatalogRules()),i.join(`
115
+ `)}renderCatalogInstructions(e){let t=this.getHelper(e),s=this.generateComponentSignatures(t),r=this.generateFunctionSignatures(t),o=e.instructions||t.catalog.instructions||"";if(o){let l=/```json\s*\n([\s\S]*?)\n```/g;o=o.replace(l,(u,d)=>this.replaceJsonBlockInInstructions(u,d,e))}let a=o?`
116
+
117
+ ## Catalog Instructions
118
+
119
+ ${o}`:"",c="";return this.catalogs.length>1&&(c=`# Catalog: ${e.id}
120
+
121
+ `),c+`## Positional Component Signatures
122
+
123
+ Use these exact positional signatures to instantiate components. Do not output property keys:
124
+ `+s+`
125
+
126
+ ## Positional Function Signatures
127
+
128
+ Use these exact positional signatures to instantiate check rules or logic functions:
129
+ `+r+a}replaceJsonBlockInInstructions(e,t,s){try{let r=(c,l,u)=>typeof l=="number"&&u?.source&&u.source.includes(".")&&Number.isInteger(l)?new kn(`${l}.0`):l,i=JSON.parse(t.trim(),r),o=Array.isArray(i)?i:typeof i=="object"&&i!==null?[i]:[];return o.length===0||!o.every(gh)?e:`\`\`\`
130
+ ${this.decompileMessages(o,s)}
131
+ \`\`\``}catch{return e}}formatSignatureEntry(e,t,s,r){let i=`\u2022 ${e}(${t.join(", ")})`;if(s){let o=s.replaceAll(`
132
+ `,`
133
+ `);i+=`
134
+ - Description: ${o}`}return r.length>0&&(i+=`
135
+ `+r.join(`
136
+ `)),i}formatComponentArgLabel(e,t,s,r){let i=`${e}${t?"":"?"}`,o=s&&typeof s=="object"&&typeof s.$ref=="string"?s.$ref:void 0;return o&&dt(o)==="ComponentId"?i+=" (component ID)":r.admitsPath(s)||(i+=" (static)"),i}formatSubKeyLines(e){return Object.entries(e).map(([t,s])=>{let r=s&&typeof s=="object"&&typeof s.description=="string"?s.description:"";return` * ${t}${r?` - ${r}`:""}`}).join(`
137
+ `)}formatComponentPropertyDetail(e,t){if(!t||typeof t!="object")return;let s=typeof t.description=="string"?t.description:void 0,r=xh(t),i=[];s&&i.push(s),r&&i.push(`Must be one of: ${r.map(a=>`'${a}'`).join(", ")}`);let o=i.length>0?` - ${e}: ${i.join(" ")}`:void 0;if(t.type==="object"&&t.properties&&typeof t.properties=="object"){let a=this.formatSubKeyLines(t.properties);o=o?`${o}
138
+ Map keys:
139
+ ${a}`:` - ${e}: Map with keys:
140
+ ${a}`}else if(t.type==="array"&&t.items&&typeof t.items=="object"){let a=t.items;if(a.type==="object"&&a.properties&&typeof a.properties=="object"){let c=this.formatSubKeyLines(a.properties);o=o?`${o}
141
+ List of maps keys:
142
+ ${c}`:` - ${e}: List of maps with keys:
143
+ ${c}`}}return o}generateComponentSignatures(e){return Array.from(e.components.keys()).sort().map(s=>{let r=e.getComponentProperties(s),i=e.getComponentRequired(s),o=[],a=[];for(let c of r){let l=e.getPropertySchema(s,c);o.push(this.formatComponentArgLabel(c,i.includes(c),l,e));let u=this.formatComponentPropertyDetail(c,l);u&&a.push(u)}return this.formatSignatureEntry(s,o,e.getComponentDescription(s),a)}).join(`
144
+ `)}generateFunctionSignatures(e){return Array.from(e.functions.keys()).sort().map(s=>{let r=e.getFunctionProperties(s),i=e.getFunctionRequired(s),o=[],a=[];for(let c of r){o.push(`${c}${i.includes(c)?"":"?"}`);let l=e.getFunctionPropertySchema(s,c),u=l&&typeof l.description=="string"?l.description:void 0;u&&a.push(` - ${c}: ${u}`)}return this.formatSignatureEntry(s,o,e.getFunctionDescription(s),a)}).join(`
145
+ `)}transformExamples(e,t){let s=/```json\s*\n([\s\S]*?)\n```/g;return e.replace(s,(r,i)=>this.replaceJsonBlock(r,i,t))}replaceJsonBlock(e,t,s){try{let r=JSON.parse(t.trim()),i=Array.isArray(r)?r:typeof r=="object"&&r!==null?[r]:[];return i.length===0||!i.every(gh)?e:this.decompileMessages(i,s)}catch{return e}}decompileMessages(e,t){let s=new hs(this.catalogs,this.version),r=yh(e,t?.id);return s.wrap([{type:"a2ui",a2uiRaw:s.decompile(r),isFinal:!0}])}renderExamples(e){if(!this.examples||!this.examples[e.id])return"";let t=this.examples[e.id];if(typeof t=="string")return this.transformExamples(t,e);if(Array.isArray(t)&&t.length>0){if(Array.isArray(t[0])){let s=new hs(this.catalogs,this.version),r=[];for(let i of t){let o=s.decompile(yh(i,e.id));o&&r.push(s.wrap([{type:"a2ui",a2uiRaw:o,isFinal:!0}]))}return r.join(`
146
+
147
+ `)}return this.decompileMessages(t,e)}return""}};var Go=class{constructor(e,t={}){this.catalogs=bn(e),this.surfaceId=t.surfaceId??"main",this.version=Nt(this.catalogs,t.version),this.progressiveKeys=t.progressiveKeys!==void 0?new Set(t.progressiveKeys):ci,this.promptGenerator=new Ho(this.catalogs,t.examples,t.allowedMessages,this.version)}createParser(){return new Wo(this.catalogs,this.surfaceId,this.version,{progressiveKeys:this.progressiveKeys})}},Rn=class{constructor(e={}){this.options=e,this.progressiveKeys=e.progressiveKeys!==void 0?new Set(e.progressiveKeys):ci}createFormat(e,t){return new Go(e,{...this.options,examples:t,progressiveKeys:this.progressiveKeys})}};var Ko=class{constructor(e,t,s,r={}){this._examples=t,this._catalogs=[...e];let i=s||new Rn;this._format=i.createFormat([...this._catalogs],t),this.checkState(r.state),this._state=r.state}get catalogs(){return[...this._catalogs]}get examples(){return this._examples}get state(){return this._state}get promptSnippet(){return this._format.promptGenerator.generate()}get parser(){return this._parser??=this._format.createParser(),this._parser}createState(){return new Ye(this._catalogs)}parseResponse(e,t={}){return this.parser.parseResponse(e,{...t,state:this.resolveState(t)})}openStream(e={}){return this.parser.openStream({...e,state:this.resolveState(e)})}resolveState(e){return e.state===void 0?this._state:(this.checkState(e.state),e.state)}acceptsState(e){return Sh(e.catalogs)===Sh(this._catalogs)}checkState(e){if(!(e===void 0||this.acceptsState(e)))throw new R(`The renderer state holds catalogs [${bh(e.catalogs)}], but the processor's active catalogs are [${bh(this._catalogs)}].`)}};function Sh(n){return JSON.stringify(n.map(e=>[e.id,no(e.protocolVersion)]))}function bh(n){return n.map(e=>`${e.id} (${pe(e.protocolVersion)})`).join(", ")}var Yo=class{constructor(e,t,s){this.catalogs=e,this.examples=t,this.factory=s||new Rn}createProcessor(e,t,s={}){if(!e)throw new R("createProcessor requires renderer capabilities to negotiate against");let r=Md(this.catalogs,e);if(this.examples){for(let[o,a]of Object.entries(this.examples))if(typeof a!="string"){for(let c of a)if(typeof c!="object"||c===null||Array.isArray(c))throw new b(`Example '${o}' contains a message that is not an object`);try{Fd(r,a)}catch(c){throw c instanceof b?new b(`Example '${o}' is invalid for the negotiated catalogs: ${c.message}`,c.details):c}}}let i=t||this.factory;return new Ko(r,this.examples,i,s)}};import*as rt from"fs";import*as $e from"path";var c2=80;function Ah(n){let e=n,t=e?.id??e?.catalogId??e?.catalog_id,s=typeof t=="string"&&t.length>0?t:"basic";if(s.includes("/")||s.includes("\\")){s=s.replace(/\\/g,"/");let r=s.split("/").filter(i=>i.length>0&&!i.endsWith(".json"));if(r.length>0){let i=r[r.length-1];i.startsWith("v")&&r.length>1&&(i=r[r.length-2]),s=i}}return s.toLowerCase()}function Xo(n,e){return[...n??e.promptGenerator.catalogs]}function vh(n){return!(n.length===0||/^\s|\s$/.test(n)||/[\n\r\t]/.test(n)||/^[-?:,[\]{}#&*!|>'"%@`]/.test(n)||/^(true|false|null|yes|no|on|off|~)$/i.test(n)||/^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/.test(n)||n.includes(": ")||n.includes(" #"))}function l2(n,e,t){if(!vh(e))return`${n} ${JSON.stringify(e)}`;let s=`${n} `,r=n.length+1,i=" ".repeat(t+2),o=!1,a=0,c=0;for(;c<=e.length;){let l=c<e.length?e[c]:void 0;if(o){if(l!==" "){if(a+1===c&&r>c2)s+=`
148
+ ${i}`,r=i.length;else{let u=e.slice(a,c);s+=u,r+=u.length}a=c}}else if(l===void 0||l===" "){let u=e.slice(a,c);s+=u,r+=u.length,a=c}l!==void 0&&(o=l===" "),c+=1}return s}function Jo(n,e,t=0){let s=" ".repeat(t),r=`${s}${n}:`;if(typeof e=="string")return l2(r,e,t);if(typeof e=="number"||typeof e=="boolean")return`${r} ${String(e)}`;if(e==null)return`${r} null`;if(Array.isArray(e)){if(e.length===0)return`${r} []`;let i=e.map(o=>typeof o=="string"&&vh(o)?`${s}- ${o}`:`${s}- ${JSON.stringify(o)}`);return`${r}
149
+ ${i.join(`
150
+ `)}`}if(typeof e=="object"){let i=Object.entries(e);if(i.length===0)return`${r} {}`;let o=i.map(([a,c])=>Jo(a,c,t+2));return`${r}
151
+ ${o.join(`
152
+ `)}`}return`${r} ${JSON.stringify(e)}`}function Kc(n){let e=n.split(/[\\/]/);if(n===""||$e.posix.isAbsolute(n)||$e.win32.isAbsolute(n)||e.some(s=>s===""||s==="."||s===".."))throw new b(`Skill filename ${JSON.stringify(n)} must be a relative path without "." or ".." segments.`);return n}function u2(n,e,t){let s=n;for(;!rt.existsSync(s);){let i=$e.dirname(s);if(i===s)break;s=i}let r=rt.realpathSync(s);if(r!==e&&!r.startsWith(e+$e.sep))throw new b(`Skill filename ${JSON.stringify(t)} resolves through a symlink to ${JSON.stringify(r)}, outside the output directory.`)}var ps=class{constructor(e){this.name=e.name,this.description=e.description,this.content=e.content,this.metadata=e.metadata??{},this.filename=Kc(e.filename||`${e.name}/SKILL.md`)}toMarkdown(){let e=[Jo("name",this.name),Jo("description",this.description)];return Object.keys(this.metadata).length>0&&e.push(Jo("metadata",this.metadata)),`---
153
+ ${e.join(`
154
+ `).trim()}
155
+ ---
156
+
157
+ ${this.content.trim()}
158
+ `}},li=class{constructor(e){if(this.skills=new Map,e){let t=typeof e[Symbol.iterator]=="function"?e:Object.entries(e);for(let[s,r]of t)this.skills.set(Kc(s),r)}}add(e){this.skills.set(Kc(e.filename),e)}get(e){let t=this.skills.get(e);if(t!==void 0)return t;for(let s of this.skills.values())if(s.name===e)return s;if(e.length>=3){for(let s of this.skills.values())if(s.filename.includes(e))return s}}has(e){return this.skills.has(e)}toDict(){let e={};for(let[t,s]of this.skills.entries())e[t]=s.toMarkdown();return e}exportToDirectory(e){rt.mkdirSync(e,{recursive:!0});let t=rt.realpathSync(e),s=new Map;for(let i of this.skills.keys()){let o=$e.dirname(i);if(o===".")continue;let a=$e.join(e,o);u2($e.dirname(a),t,i),s.set(a,i)}for(let i of s.keys())rt.rmSync(i,{recursive:!0,force:!0});let r={};for(let[i,o]of this.skills.entries()){let a=$e.join(e,i);rt.mkdirSync($e.dirname(a),{recursive:!0});let c=o.toMarkdown();rt.writeFileSync(a,c,"utf-8"),r[i]=c}return r}get size(){return this.skills.size}keys(){return this.skills.keys()}values(){return this.skills.values()}entries(){return this.skills.entries()}[Symbol.iterator](){return this.entries()}};var ui=class{constructor(e){this.fmt=e}generateSkill(e={}){let t=e.name??"a2ui",s=Xo(e.catalogs,this.fmt),r=this.fmt.promptGenerator,i=r.generateBaseRules(),o=[],a=[];for(let d of s){let h=r.generateCatalogInstructions(d);h&&o.push(h);let p=r.generateExamples(d);p&&!a.includes(p)&&a.push(p)}let c=[];i&&c.push(i),o.length>0&&c.push(...o),a.length>0&&c.push(`### Examples:
159
+
160
+ `+a.join(`
161
+
162
+ `));let l=c.join(`
163
+
164
+ `)+`
165
+ `,u=e.description||"Generates interactive user interface components for user requests.";return new ps({name:t,description:u,content:l,filename:`${t}/SKILL.md`})}generateCatalogSkill(e={}){let t=e.catalog;if(t===void 0){let i=Xo(void 0,this.fmt);if(i.length===0)throw new R("No catalog provided or configured on the inference format to compile catalog skill.");t=i[0]}let r=e.includeExamples??!0?this.fmt.promptGenerator.generateExamples(t)??"":"";return this.buildCatalogSkill(t,r,e.name,e.description)}buildCatalogSkill(e,t,s,r){let i=Ah(e),o=s||`a2ui-${i}`,a=this.fmt.promptGenerator.generateCatalogInstructions(e)||"";t&&(a+=`
166
+
167
+ ### Examples:
168
+
169
+ ${t}`);let c=r||`UI component catalog signatures for ${i}. Use when building ${i} user interface components.`;return new ps({name:o,description:c,content:a.trim()+`
170
+ `,filename:`${o}/SKILL.md`})}generateCoreSkill(e={}){let t=e.name??"a2ui-core",s=this.fmt.promptGenerator.generateBaseRules()||"",r=e.description||"Core A2UI protocol instructions and syntax rules for UI generation.";return new ps({name:t,description:r,content:s.trim()+`
171
+ `,filename:`${t}/SKILL.md`})}generateSkillSet(e={}){let t=new li;t.add(this.generateCoreSkill({name:e.coreName??"a2ui-core"}));let s=Xo(e.catalogs,this.fmt),r=this.fmt.promptGenerator,i=new Set;for(let o of s){let a=r.generateExamples(o)??"";t.add(this.buildCatalogSkill(o,i.has(a)?"":a)),i.add(a)}return t}};export{H as A2uiError,Yo as A2uiGenerator,co as CatalogConfig,Rn as ExpressFormatFactory,ui as SkillGenerator};
172
+ /*! Bundled license information:
173
+
174
+ @a2ui/web_core/src/catalog/exclusive_union.js:
175
+ @a2ui/web_core/src/catalog/schema_serializer.js:
176
+ @a2ui/web_core/src/catalog/schema_generator.js:
177
+ (*
178
+ * @license
179
+ * Copyright 2024 Google LLC
180
+ *
181
+ * Licensed under the Apache License, Version 2.0 (the "License");
182
+ * you may not use this file except in compliance with the License.
183
+ * You may obtain a copy of the License at
184
+ *
185
+ * https://www.apache.org/licenses/LICENSE-2.0
186
+ *
187
+ * Unless required by applicable law or agreed to in writing, software
188
+ * distributed under the License is distributed on an "AS IS" BASIS,
189
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ * See the License for the specific language governing permissions and
191
+ * limitations under the License.
192
+ *)
193
+ */