@agentronics/sdk 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-BPDWJCPY.js → chunk-DYCRZCCT.js} +2 -2
- package/dist/chunk-DYCRZCCT.js.map +1 -0
- package/dist/chunk-JR5YRLTH.js +18 -0
- package/dist/chunk-JR5YRLTH.js.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -4
- package/dist/index.d.ts +21 -4
- package/dist/index.global.js +4 -4
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{init-only-C80qhujz.d.ts → init-only-CRvqRvNI.d.ts} +8 -1
- package/dist/{init-only-s9E9bVC0.d.cts → init-only-Cif87Qbc.d.cts} +8 -1
- package/dist/init-only.cjs +4 -4
- package/dist/init-only.cjs.map +1 -1
- package/dist/init-only.d.cts +2 -2
- package/dist/init-only.d.ts +2 -2
- package/dist/init-only.global.js +4 -4
- package/dist/init-only.global.js.map +1 -1
- package/dist/init-only.js +1 -1
- package/dist/lite.d.cts +2 -2
- package/dist/lite.d.ts +2 -2
- package/dist/lite.js +1 -1
- package/dist/{webmcp-BgKzHeQ3.d.cts → webmcp-C5uwNbnJ.d.cts} +2 -1
- package/dist/{webmcp-BgKzHeQ3.d.ts → webmcp-C5uwNbnJ.d.ts} +2 -1
- package/package.json +3 -3
- package/dist/chunk-3WPDIMJP.js +0 -18
- package/dist/chunk-3WPDIMJP.js.map +0 -1
- package/dist/chunk-BPDWJCPY.js.map +0 -1
package/dist/index.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Agentronics=(function(exports){'use strict';var Or=Object.defineProperty;var Pr=(t,e)=>{for(var n in e)Or(t,n,{get:e[n],enumerable:true});};var d={};Pr(d,{BRAND:()=>so,DIRTY:()=>fe,EMPTY_PATH:()=>Lr,INVALID:()=>k,NEVER:()=>zo,OK:()=>L,ParseStatus:()=>j,Schema:()=>I,ZodAny:()=>le,ZodArray:()=>se,ZodBigInt:()=>ye,ZodBoolean:()=>he,ZodBranded:()=>He,ZodCatch:()=>Ie,ZodDate:()=>ve,ZodDefault:()=>Ce,ZodDiscriminatedUnion:()=>rt,ZodEffects:()=>Z,ZodEnum:()=>Se,ZodError:()=>V,ZodFirstPartyTypeKind:()=>_,ZodFunction:()=>st,ZodIntersection:()=>ke,ZodIssueCode:()=>m,ZodLazy:()=>_e,ZodLiteral:()=>Te,ZodMap:()=>$e,ZodNaN:()=>Ve,ZodNativeEnum:()=>Ae,ZodNever:()=>J,ZodNull:()=>be,ZodNullable:()=>Q,ZodNumber:()=>ge,ZodObject:()=>B,ZodOptional:()=>F,ZodParsedType:()=>y,ZodPipeline:()=>Je,ZodPromise:()=>de,ZodReadonly:()=>Re,ZodRecord:()=>ot,ZodSchema:()=>I,ZodSet:()=>We,ZodString:()=>ce,ZodSymbol:()=>Ne,ZodTransformer:()=>Z,ZodTuple:()=>X,ZodType:()=>I,ZodUndefined:()=>xe,ZodUnion:()=>we,ZodUnknown:()=>oe,ZodVoid:()=>Le,addIssueToContext:()=>f,any:()=>go,array:()=>xo,bigint:()=>lo,boolean:()=>Un,coerce:()=>Go,custom:()=>Wn,date:()=>uo,datetimeRegex:()=>Ln,defaultErrorMap:()=>ne,discriminatedUnion:()=>_o,effect:()=>jo,enum:()=>Oo,function:()=>Ro,getErrorMap:()=>Pe,getParsedType:()=>Y,instanceof:()=>ao,intersection:()=>To,isAborted:()=>tt,isAsync:()=>De,isDirty:()=>nt,isValid:()=>ae,late:()=>io,lazy:()=>Mo,literal:()=>Eo,makeIssue:()=>Ze,map:()=>Co,nan:()=>co,nativeEnum:()=>Po,never:()=>ho,null:()=>fo,nullable:()=>Lo,number:()=>Bn,object:()=>bo,objectUtil:()=>Tt,oboolean:()=>Uo,onumber:()=>Bo,optional:()=>No,ostring:()=>Vo,pipeline:()=>Wo,preprocess:()=>$o,promise:()=>Do,quotelessJson:()=>Dr,record:()=>Ao,set:()=>Io,setErrorMap:()=>Nr,strictObject:()=>wo,string:()=>Vn,symbol:()=>po,transformer:()=>jo,tuple:()=>So,undefined:()=>mo,union:()=>ko,unknown:()=>yo,util:()=>R,void:()=>vo});var R;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function n(o){throw new Error}t.assertNever=n,t.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},t.find=(o,s)=>{for(let i of o)if(s(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s;})(R||(R={}));var Tt;(function(t){t.mergeShapes=(e,n)=>({...e,...n});})(Tt||(Tt={}));var y=R.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Y=t=>{switch(typeof t){case "undefined":return y.undefined;case "string":return y.string;case "number":return Number.isNaN(t)?y.nan:y.number;case "boolean":return y.boolean;case "function":return y.function;case "bigint":return y.bigint;case "symbol":return y.symbol;case "object":return Array.isArray(t)?y.array:t===null?y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?y.promise:typeof Map<"u"&&t instanceof Map?y.map:typeof Set<"u"&&t instanceof Set?y.set:typeof Date<"u"&&t instanceof Date?y.date:y.object;default:return y.unknown}};var m=R.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"]),Dr=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),V=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r];},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r];};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e;}format(e){let n=e||function(s){return s.message},r={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)r._errors.push(n(i));else {let a=r,l=0;for(;l<i.path.length;){let c=i.path[l];l===i.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(i))):a[c]=a[c]||{_errors:[]},a=a[c],l++;}}};return o(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,R.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];n[s]=n[s]||[],n[s].push(e(o));}else r.push(e(o));return {formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};V.create=t=>new V(t);var jr=(t,e)=>{let n;switch(t.code){case m.invalid_type:t.received===y.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case m.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,R.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:n=`Unrecognized key(s) in object: ${R.joinValues(t.keys,", ")}`;break;case m.invalid_union:n="Invalid input";break;case m.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${R.joinValues(t.options)}`;break;case m.invalid_enum_value:n=`Invalid enum value. Expected ${R.joinValues(t.options)}, received '${t.received}'`;break;case m.invalid_arguments:n="Invalid function arguments";break;case m.invalid_return_type:n="Invalid function return type";break;case m.invalid_date:n="Invalid date";break;case m.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:R.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case m.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case m.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case m.custom:n="Invalid input";break;case m.invalid_intersection_types:n="Intersection results could not be merged";break;case m.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case m.not_finite:n="Number must be finite";break;default:n=e.defaultError,R.assertNever(t);}return {message:n}},ne=jr;var On=ne;function Nr(t){On=t;}function Pe(){return On}var Ze=t=>{let{data:e,path:n,errorMaps:r,issueData:o}=t,s=[...n,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return {...o,path:s,message:o.message};let a="",l=r.filter(c=>!!c).slice().reverse();for(let c of l)a=c(i,{data:e,defaultError:a}).message;return {...o,path:s,message:a}},Lr=[];function f(t,e){let n=Pe(),r=Ze({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===ne?void 0:ne].filter(o=>!!o)});t.common.issues.push(r);}var j=class t{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(e,n){let r=[];for(let o of n){if(o.status==="aborted")return k;o.status==="dirty"&&e.dirty(),r.push(o.value);}return {status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let o of n){let s=await o.key,i=await o.value;r.push({key:s,value:i});}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let o of n){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return k;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(r[s.value]=i.value);}return {status:e.value,value:r}}},k=Object.freeze({status:"aborted"}),fe=t=>({status:"dirty",value:t}),L=t=>({status:"valid",value:t}),tt=t=>t.status==="aborted",nt=t=>t.status==="dirty",ae=t=>t.status==="valid",De=t=>typeof Promise<"u"&&t instanceof Promise;var w;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message;})(w||(w={}));var K=class{constructor(e,n,r,o){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=o;}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}},Pn=(t,e)=>{if(ae(e))return {success:true,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return {success:false,get error(){if(this._error)return this._error;let n=new V(t.common.issues);return this._error=n,this._error}}};function C(t){if(!t)return {};let{errorMap:e,invalid_type_error:n,required_error:r,description:o}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,a)=>{let{message:l}=t;return i.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:o}}var I=class{get description(){return this._def.description}_getType(e){return Y(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Y(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return {status:new j,ctx:{common:e.parent.common,data:e.data,parsedType:Y(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(De(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??false,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Y(e)},o=this._parseSync({data:e,path:r.path,parent:r});return Pn(r,o)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Y(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return ae(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=true),n.common={issues:[],async:true};}return this._parseAsync({data:e,path:[],parent:n}).then(r=>ae(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:true},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Y(e)},o=this._parse({data:e,path:r.path,parent:r}),s=await(De(o)?o:Promise.resolve(o));return Pn(r,s)}refine(e,n){let r=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,s)=>{let i=e(o),a=()=>s.addIssue({code:m.custom,...r(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?true:(a(),false)):i?true:(a(),false)})}refinement(e,n){return this._refinement((r,o)=>e(r)?true:(o.addIssue(typeof n=="function"?n(r,o):n),false))}_refinement(e){return new Z({schema:this,typeName:_.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:n=>this["~validate"](n)};}optional(){return F.create(this,this._def)}nullable(){return Q.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return se.create(this)}promise(){return de.create(this,this._def)}or(e){return we.create([this,e],this._def)}and(e){return ke.create(this,e,this._def)}transform(e){return new Z({...C(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Ce({...C(this._def),innerType:this,defaultValue:n,typeName:_.ZodDefault})}brand(){return new He({typeName:_.ZodBranded,type:this,...C(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Ie({...C(this._def),innerType:this,catchValue:n,typeName:_.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Je.create(this,e)}readonly(){return Re.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},$r=/^c[^\s-]{8,}$/i,Wr=/^[0-9a-z]+$/,Vr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Br=/^[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,Ur=/^[a-z0-9_-]{21}$/i,Gr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,zr=/^[-+]?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)?)??$/,Fr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Kr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",St,Zr=/^(?:(?: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])$/,Hr=/^(?:(?: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])$/,Jr=/^(([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]))$/,qr=/^(([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])$/,Yr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Xr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,jn="((\\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])))",Qr=new RegExp(`^${jn}$`);function Nn(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function eo(t){return new RegExp(`^${Nn(t)}$`)}function Ln(t){let e=`${jn}T${Nn(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function to(t,e){return !!((e==="v4"||!e)&&Zr.test(t)||(e==="v6"||!e)&&Jr.test(t))}function no(t,e){if(!Gr.test(t))return false;try{let[n]=t.split(".");if(!n)return !1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),o=JSON.parse(atob(r));return !(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return false}}function ro(t,e){return !!((e==="v4"||!e)&&Hr.test(t)||(e==="v6"||!e)&&qr.test(t))}var ce=class t extends I{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){let s=this._getOrReturnCtx(e);return f(s,{code:m.invalid_type,expected:y.string,received:s.parsedType}),k}let r=new j,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),f(o,{code:m.too_small,minimum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),f(o,{code:m.too_big,maximum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),r.dirty());else if(s.kind==="length"){let i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?f(o,{code:m.too_big,maximum:s.value,type:"string",inclusive:true,exact:true,message:s.message}):a&&f(o,{code:m.too_small,minimum:s.value,type:"string",inclusive:true,exact:true,message:s.message}),r.dirty());}else if(s.kind==="email")Fr.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"email",code:m.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")St||(St=new RegExp(Kr,"u")),St.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"emoji",code:m.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")Br.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"uuid",code:m.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")Ur.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"nanoid",code:m.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")$r.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"cuid",code:m.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")Wr.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"cuid2",code:m.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")Vr.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"ulid",code:m.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data);}catch{o=this._getOrReturnCtx(e,o),f(o,{validation:"url",code:m.invalid_string,message:s.message}),r.dirty();}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"regex",code:m.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),f(o,{code:m.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),f(o,{code:m.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),f(o,{code:m.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?Ln(s).test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{code:m.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?Qr.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{code:m.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?eo(s).test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{code:m.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?zr.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"duration",code:m.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?to(e.data,s.version)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"ip",code:m.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?no(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"jwt",code:m.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?ro(e.data,s.version)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"cidr",code:m.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?Yr.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"base64",code:m.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?Xr.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"base64url",code:m.invalid_string,message:s.message}),r.dirty()):R.assertNever(s);return {status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(o=>e.test(o),{validation:n,code:m.invalid_string,...w.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...w.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...w.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:false,local:false,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??false,local:e?.local??false,...w.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,...w.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...w.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...w.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...w.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...w.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...w.errToObj(n)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};ce.create=t=>new ce({checks:[],typeName:_.ZodString,coerce:t?.coerce??false,...C(t)});function oo(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,o=n>r?n:r,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}var ge=class t extends I{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)!==y.number){let s=this._getOrReturnCtx(e);return f(s,{code:m.invalid_type,expected:y.number,received:s.parsedType}),k}let r,o=new j;for(let s of this._def.checks)s.kind==="int"?R.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:m.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),o.dirty()):s.kind==="multipleOf"?oo(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:m.not_finite,message:s.message}),o.dirty()):R.assertNever(s);return {status:o.value,value:e.data}}gte(e,n){return this.setLimit("min",e,true,w.toString(n))}gt(e,n){return this.setLimit("min",e,false,w.toString(n))}lte(e,n){return this.setLimit("max",e,true,w.toString(n))}lt(e,n){return this.setLimit("max",e,false,w.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:w.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:false,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:false,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:true,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:true,message:w.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return !!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&R.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return true;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);}return Number.isFinite(n)&&Number.isFinite(e)}};ge.create=t=>new ge({checks:[],typeName:_.ZodNumber,coerce:t?.coerce||false,...C(t)});var ye=class t extends I{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)!==y.bigint)return this._getInvalidInput(e);let r,o=new j;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):R.assertNever(s);return {status:o.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return f(n,{code:m.invalid_type,expected:y.bigint,received:n.parsedType}),k}gte(e,n){return this.setLimit("min",e,true,w.toString(n))}gt(e,n){return this.setLimit("min",e,false,w.toString(n))}lte(e,n){return this.setLimit("max",e,true,w.toString(n))}lt(e,n){return this.setLimit("max",e,false,w.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:w.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:false,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:w.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};ye.create=t=>new ye({checks:[],typeName:_.ZodBigInt,coerce:t?.coerce??false,...C(t)});var he=class extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:y.boolean,received:r.parsedType}),k}return L(e.data)}};he.create=t=>new he({typeName:_.ZodBoolean,coerce:t?.coerce||false,...C(t)});var ve=class t extends I{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){let s=this._getOrReturnCtx(e);return f(s,{code:m.invalid_type,expected:y.date,received:s.parsedType}),k}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return f(s,{code:m.invalid_date}),k}let r=new j,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),f(o,{code:m.too_small,message:s.message,inclusive:true,exact:false,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),f(o,{code:m.too_big,message:s.message,inclusive:true,exact:false,maximum:s.value,type:"date"}),r.dirty()):R.assertNever(s);return {status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};ve.create=t=>new ve({checks:[],coerce:t?.coerce||false,typeName:_.ZodDate,...C(t)});var Ne=class extends I{_parse(e){if(this._getType(e)!==y.symbol){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:y.symbol,received:r.parsedType}),k}return L(e.data)}};Ne.create=t=>new Ne({typeName:_.ZodSymbol,...C(t)});var xe=class extends I{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:y.undefined,received:r.parsedType}),k}return L(e.data)}};xe.create=t=>new xe({typeName:_.ZodUndefined,...C(t)});var be=class extends I{_parse(e){if(this._getType(e)!==y.null){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:y.null,received:r.parsedType}),k}return L(e.data)}};be.create=t=>new be({typeName:_.ZodNull,...C(t)});var le=class extends I{constructor(){super(...arguments),this._any=true;}_parse(e){return L(e.data)}};le.create=t=>new le({typeName:_.ZodAny,...C(t)});var oe=class extends I{constructor(){super(...arguments),this._unknown=true;}_parse(e){return L(e.data)}};oe.create=t=>new oe({typeName:_.ZodUnknown,...C(t)});var J=class extends I{_parse(e){let n=this._getOrReturnCtx(e);return f(n,{code:m.invalid_type,expected:y.never,received:n.parsedType}),k}};J.create=t=>new J({typeName:_.ZodNever,...C(t)});var Le=class extends I{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:y.void,received:r.parsedType}),k}return L(e.data)}};Le.create=t=>new Le({typeName:_.ZodVoid,...C(t)});var se=class t extends I{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),o=this._def;if(n.parsedType!==y.array)return f(n,{code:m.invalid_type,expected:y.array,received:n.parsedType}),k;if(o.exactLength!==null){let i=n.data.length>o.exactLength.value,a=n.data.length<o.exactLength.value;(i||a)&&(f(n,{code:i?m.too_big:m.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:true,exact:true,message:o.exactLength.message}),r.dirty());}if(o.minLength!==null&&n.data.length<o.minLength.value&&(f(n,{code:m.too_small,minimum:o.minLength.value,type:"array",inclusive:true,exact:false,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&n.data.length>o.maxLength.value&&(f(n,{code:m.too_big,maximum:o.maxLength.value,type:"array",inclusive:true,exact:false,message:o.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((i,a)=>o.type._parseAsync(new K(n,i,n.path,a)))).then(i=>j.mergeArray(r,i));let s=[...n.data].map((i,a)=>o.type._parseSync(new K(n,i,n.path,a)));return j.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:w.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:w.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:w.toString(n)}})}nonempty(e){return this.min(1,e)}};se.create=(t,e)=>new se({type:t,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...C(e)});function je(t){if(t instanceof B){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=F.create(je(r));}return new B({...t._def,shape:()=>e})}else return t instanceof se?new se({...t._def,type:je(t.element)}):t instanceof F?F.create(je(t.unwrap())):t instanceof Q?Q.create(je(t.unwrap())):t instanceof X?X.create(t.items.map(e=>je(e))):t}var B=class t extends I{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(),n=R.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==y.object){let c=this._getOrReturnCtx(e);return f(c,{code:m.invalid_type,expected:y.object,received:c.parsedType}),k}let{status:r,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof J&&this._def.unknownKeys==="strip"))for(let c in o.data)i.includes(c)||a.push(c);let l=[];for(let c of i){let u=s[c],v=o.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new K(o,v,o.path,c)),alwaysSet:c in o.data});}if(this._def.catchall instanceof J){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of a)l.push({key:{status:"valid",value:u},value:{status:"valid",value:o.data[u]}});else if(c==="strict")a.length>0&&(f(o,{code:m.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let c=this._def.catchall;for(let u of a){let v=o.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new K(o,v,o.path,u)),alwaysSet:u in o.data});}}return o.common.async?Promise.resolve().then(async()=>{let c=[];for(let u of l){let v=await u.key,h=await u.value;c.push({key:v,value:h,alwaysSet:u.alwaysSet});}return c}).then(c=>j.mergeObjectSync(r,c)):j.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let o=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:w.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of R.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of R.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return je(this)}partial(e){let n={};for(let r of R.objectKeys(this.shape)){let o=this.shape[r];e&&!e[r]?n[r]=o:n[r]=o.optional();}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of R.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else {let s=this.shape[r];for(;s instanceof F;)s=s._def.innerType;n[r]=s;}return new t({...this._def,shape:()=>n})}keyof(){return $n(R.objectKeys(this.shape))}};B.create=(t,e)=>new B({shape:()=>t,unknownKeys:"strip",catchall:J.create(),typeName:_.ZodObject,...C(e)});B.strictCreate=(t,e)=>new B({shape:()=>t,unknownKeys:"strict",catchall:J.create(),typeName:_.ZodObject,...C(e)});B.lazycreate=(t,e)=>new B({shape:t,unknownKeys:"strip",catchall:J.create(),typeName:_.ZodObject,...C(e)});var we=class extends I{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new V(a.ctx.common.issues));return f(n,{code:m.invalid_union,unionErrors:i}),k}if(n.common.async)return Promise.all(r.map(async s=>{let i={...n,common:{...n.common,issues:[]},parent:null};return {result:await s._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(o);{let s,i=[];for(let l of r){let c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:c}),c.common.issues.length&&i.push(c.common.issues);}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(l=>new V(l));return f(n,{code:m.invalid_union,unionErrors:a}),k}}get options(){return this._def.options}};we.create=(t,e)=>new we({options:t,typeName:_.ZodUnion,...C(e)});var re=t=>t instanceof _e?re(t.schema):t instanceof Z?re(t.innerType()):t instanceof Te?[t.value]:t instanceof Se?t.options:t instanceof Ae?R.objectValues(t.enum):t instanceof Ce?re(t._def.innerType):t instanceof xe?[void 0]:t instanceof be?[null]:t instanceof F?[void 0,...re(t.unwrap())]:t instanceof Q?[null,...re(t.unwrap())]:t instanceof He||t instanceof Re?re(t.unwrap()):t instanceof Ie?re(t._def.innerType):[],rt=class t extends I{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return f(n,{code:m.invalid_type,expected:y.object,received:n.parsedType}),k;let r=this.discriminator,o=n.data[r],s=this.optionsMap.get(o);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(f(n,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),k)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let o=new Map;for(let s of n){let i=re(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,s);}}return new t({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:o,...C(r)})}};function At(t,e){let n=Y(t),r=Y(e);if(t===e)return {valid:true,data:t};if(n===y.object&&r===y.object){let o=R.objectKeys(e),s=R.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let l=At(t[a],e[a]);if(!l.valid)return {valid:false};i[a]=l.data;}return {valid:true,data:i}}else if(n===y.array&&r===y.array){if(t.length!==e.length)return {valid:false};let o=[];for(let s=0;s<t.length;s++){let i=t[s],a=e[s],l=At(i,a);if(!l.valid)return {valid:false};o.push(l.data);}return {valid:true,data:o}}else return n===y.date&&r===y.date&&+t==+e?{valid:true,data:t}:{valid:false}}var ke=class extends I{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=(s,i)=>{if(tt(s)||tt(i))return k;let a=At(s.value,i.value);return a.valid?((nt(s)||nt(i))&&n.dirty(),{status:n.value,value:a.data}):(f(r,{code:m.invalid_intersection_types}),k)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,i])=>o(s,i)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};ke.create=(t,e,n)=>new ke({left:t,right:e,typeName:_.ZodIntersection,...C(n)});var X=class t extends I{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return f(r,{code:m.invalid_type,expected:y.array,received:r.parsedType}),k;if(r.data.length<this._def.items.length)return f(r,{code:m.too_small,minimum:this._def.items.length,inclusive:true,exact:false,type:"array"}),k;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:m.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"}),n.dirty());let s=[...r.data].map((i,a)=>{let l=this._def.items[a]||this._def.rest;return l?l._parse(new K(r,i,r.path,a)):null}).filter(i=>!!i);return r.common.async?Promise.all(s).then(i=>j.mergeArray(n,i)):j.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};X.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new X({items:t,typeName:_.ZodTuple,rest:null,...C(e)})};var ot=class t extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return f(r,{code:m.invalid_type,expected:y.object,received:r.parsedType}),k;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in r.data)o.push({key:s._parse(new K(r,a,r.path,a)),value:i._parse(new K(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?j.mergeObjectAsync(n,o):j.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof I?new t({keyType:e,valueType:n,typeName:_.ZodRecord,...C(r)}):new t({keyType:ce.create(),valueType:e,typeName:_.ZodRecord,...C(n)})}},$e=class extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.map)return f(r,{code:m.invalid_type,expected:y.map,received:r.parsedType}),k;let o=this._def.keyType,s=this._def.valueType,i=[...r.data.entries()].map(([a,l],c)=>({key:o._parse(new K(r,a,r.path,[c,"key"])),value:s._parse(new K(r,l,r.path,[c,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of i){let c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return k;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value);}return {status:n.value,value:a}})}else {let a=new Map;for(let l of i){let c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return k;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value);}return {status:n.value,value:a}}}};$e.create=(t,e,n)=>new $e({valueType:e,keyType:t,typeName:_.ZodMap,...C(n)});var We=class t extends I{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return f(r,{code:m.invalid_type,expected:y.set,received:r.parsedType}),k;let o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(f(r,{code:m.too_small,minimum:o.minSize.value,type:"set",inclusive:true,exact:false,message:o.minSize.message}),n.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(f(r,{code:m.too_big,maximum:o.maxSize.value,type:"set",inclusive:true,exact:false,message:o.maxSize.message}),n.dirty());let s=this._def.valueType;function i(l){let c=new Set;for(let u of l){if(u.status==="aborted")return k;u.status==="dirty"&&n.dirty(),c.add(u.value);}return {status:n.value,value:c}}let a=[...r.data.values()].map((l,c)=>s._parse(new K(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>i(l)):i(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:w.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:w.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};We.create=(t,e)=>new We({valueType:t,minSize:null,maxSize:null,typeName:_.ZodSet,...C(e)});var st=class t extends I{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.function)return f(n,{code:m.invalid_type,expected:y.function,received:n.parsedType}),k;function r(a,l){return Ze({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Pe(),ne].filter(c=>!!c),issueData:{code:m.invalid_arguments,argumentsError:l}})}function o(a,l){return Ze({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Pe(),ne].filter(c=>!!c),issueData:{code:m.invalid_return_type,returnTypeError:l}})}let s={errorMap:n.common.contextualErrorMap},i=n.data;if(this._def.returns instanceof de){let a=this;return L(async function(...l){let c=new V([]),u=await a._def.args.parseAsync(l,s).catch(T=>{throw c.addIssue(r(l,T)),c}),v=await Reflect.apply(i,this,u);return await a._def.returns._def.type.parseAsync(v,s).catch(T=>{throw c.addIssue(o(v,T)),c})})}else {let a=this;return L(function(...l){let c=a._def.args.safeParse(l,s);if(!c.success)throw new V([r(l,c.error)]);let u=Reflect.apply(i,this,c.data),v=a._def.returns.safeParse(u,s);if(!v.success)throw new V([o(u,v.error)]);return v.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:X.create(e).rest(oe.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||X.create([]).rest(oe.create()),returns:n||oe.create(),typeName:_.ZodFunction,...C(r)})}},_e=class extends I{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};_e.create=(t,e)=>new _e({getter:t,typeName:_.ZodLazy,...C(e)});var Te=class extends I{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return f(n,{received:n.data,code:m.invalid_literal,expected:this._def.value}),k}return {status:"valid",value:e.data}}get value(){return this._def.value}};Te.create=(t,e)=>new Te({value:t,typeName:_.ZodLiteral,...C(e)});function $n(t,e){return new Se({values:t,typeName:_.ZodEnum,...C(e)})}var Se=class t extends I{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{expected:R.joinValues(r),received:n.parsedType,code:m.invalid_type}),k}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{received:n.data,code:m.invalid_enum_value,options:r}),k}return L(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};Se.create=$n;var Ae=class extends I{_parse(e){let n=R.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){let o=R.objectValues(n);return f(r,{expected:R.joinValues(o),received:r.parsedType,code:m.invalid_type}),k}if(this._cache||(this._cache=new Set(R.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=R.objectValues(n);return f(r,{received:r.data,code:m.invalid_enum_value,options:o}),k}return L(e.data)}get enum(){return this._def.values}};Ae.create=(t,e)=>new Ae({values:t,typeName:_.ZodNativeEnum,...C(e)});var de=class extends I{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.promise&&n.common.async===false)return f(n,{code:m.invalid_type,expected:y.promise,received:n.parsedType}),k;let r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return L(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};de.create=(t,e)=>new de({type:t,typeName:_.ZodPromise,...C(e)});var Z=class extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i=>{f(r,i),i.fatal?n.abort():n.dirty();},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(r.data,s);if(r.common.async)return Promise.resolve(i).then(async a=>{if(n.value==="aborted")return k;let l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?k:l.status==="dirty"?fe(l.value):n.value==="dirty"?fe(l.value):l});{if(n.value==="aborted")return k;let a=this._def.schema._parseSync({data:i,path:r.path,parent:r});return a.status==="aborted"?k:a.status==="dirty"?fe(a.value):n.value==="dirty"?fe(a.value):a}}if(o.type==="refinement"){let i=a=>{let l=o.refinement(a,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===false){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?k:(a.status==="dirty"&&n.dirty(),i(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?k:(a.status==="dirty"&&n.dirty(),i(a.value).then(()=>({status:n.value,value:a.value}))))}if(o.type==="transform")if(r.common.async===false){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ae(i))return k;let a=o.transform(i.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>ae(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:n.value,value:a})):k);R.assertNever(o);}};Z.create=(t,e,n)=>new Z({schema:t,typeName:_.ZodEffects,effect:e,...C(n)});Z.createWithPreprocess=(t,e,n)=>new Z({schema:e,effect:{type:"preprocess",transform:t},typeName:_.ZodEffects,...C(n)});var F=class extends I{_parse(e){return this._getType(e)===y.undefined?L(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};F.create=(t,e)=>new F({innerType:t,typeName:_.ZodOptional,...C(e)});var Q=class extends I{_parse(e){return this._getType(e)===y.null?L(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Q.create=(t,e)=>new Q({innerType:t,typeName:_.ZodNullable,...C(e)});var Ce=class extends I{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Ce.create=(t,e)=>new Ce({innerType:t,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...C(e)});var Ie=class extends I{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return De(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new V(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new V(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Ie.create=(t,e)=>new Ie({innerType:t,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...C(e)});var Ve=class extends I{_parse(e){if(this._getType(e)!==y.nan){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:y.nan,received:r.parsedType}),k}return {status:"valid",value:e.data}}};Ve.create=t=>new Ve({typeName:_.ZodNaN,...C(t)});var so=Symbol("zod_brand"),He=class extends I{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Je=class t extends I{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return (async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?k:s.status==="dirty"?(n.dirty(),fe(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{let o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?k:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:_.ZodPipeline})}},Re=class extends I{_parse(e){let n=this._def.innerType._parse(e),r=o=>(ae(o)&&(o.value=Object.freeze(o.value)),o);return De(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};Re.create=(t,e)=>new Re({innerType:t,typeName:_.ZodReadonly,...C(e)});function Dn(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Wn(t,e={},n){return t?le.create().superRefine((r,o)=>{let s=t(r);if(s instanceof Promise)return s.then(i=>{if(!i){let a=Dn(e,r),l=a.fatal??n??true;o.addIssue({code:"custom",...a,fatal:l});}});if(!s){let i=Dn(e,r),a=i.fatal??n??true;o.addIssue({code:"custom",...i,fatal:a});}}):le.create()}var io={object:B.lazycreate},_;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly";})(_||(_={}));var ao=(t,e={message:`Input not instance of ${t.name}`})=>Wn(n=>n instanceof t,e),Vn=ce.create,Bn=ge.create,co=Ve.create,lo=ye.create,Un=he.create,uo=ve.create,po=Ne.create,mo=xe.create,fo=be.create,go=le.create,yo=oe.create,ho=J.create,vo=Le.create,xo=se.create,bo=B.create,wo=B.strictCreate,ko=we.create,_o=rt.create,To=ke.create,So=X.create,Ao=ot.create,Co=$e.create,Io=We.create,Ro=st.create,Mo=_e.create,Eo=Te.create,Oo=Se.create,Po=Ae.create,Do=de.create,jo=Z.create,No=F.create,Lo=Q.create,$o=Z.createWithPreprocess,Wo=Je.create,Vo=()=>Vn().optional(),Bo=()=>Bn().optional(),Uo=()=>Un().optional(),Go={string:(t=>ce.create({...t,coerce:true})),number:(t=>ge.create({...t,coerce:true})),boolean:(t=>he.create({...t,coerce:true})),bigint:(t=>ye.create({...t,coerce:true})),date:(t=>ve.create({...t,coerce:true}))};var zo=k;var Be="agtx_pk_",it="agtx_sk_";d.string().min(Be.length+8).startsWith(Be,{message:`Publishable keys must start with "${Be}".`});d.string().min(it.length+8).startsWith(it,{message:`Secret keys must start with "${it}".`});var Gn=t=>t.startsWith(Be)?"publishable":t.startsWith(it)?"secret":"unknown",Me=d.enum(["webmcp","dom","screenshot","crawler"]),Ct=d.enum(["detected","declared","verified","linked"]),Fo=d.object({class:Me,trust:Ct,confidence:d.number().min(0).max(1).default(1),vendor:d.string().nullable(),userAgent:d.string().nullable(),detectionVersion:d.string().default("2026.04"),signals:d.record(d.unknown()).default({})}),Ko=d.enum(["bearer","oauth2","sso","spiffe","google-agent","mtls","detection","declaration","extension","session-link","x-agent-header","web-bot-auth","api-key","verified-crawler"]),qe=d.object({class:Me,vendor:d.string().min(1),token:d.string().min(8),expiresAt:d.string().datetime().optional()});d.object({publishableKey:d.string(),claim:qe,nonce:d.string().min(8),origin:d.string().url()});d.object({trust:Ct,vendor:d.string(),validUntil:d.string().datetime(),reason:d.string().optional(),subject:d.string().optional(),protocol:Ko.optional(),signals:d.record(d.unknown()).optional()});d.object({issuer:d.string().url(),audiences:d.array(d.string().min(1)).min(1)});d.object({trustDomain:d.string().min(1),bundleEndpoint:d.string().url(),audiences:d.array(d.string().min(1)).min(1),googleTrustDomains:d.array(d.string().min(1)).optional()});d.object({rootCerts:d.array(d.string().min(20)).min(1),spiffeTrustDomain:d.string().min(1).optional(),xfccEntryPolicy:d.enum(["last","first","only"]).default("last")});d.enum(["sso","spiffe","mtls"]);d.object({siteId:d.string().min(1),token:d.string().min(8).optional(),xfcc:d.string().min(1).optional(),headers:d.record(d.string()).optional(),origin:d.string().url().optional()});var q={detected:0,declared:1,verified:2,linked:3},zn=(t,e)=>q[t]>q[e],Fn=d.enum(["allow","deny","review"]),Ee=d.object({id:d.string(),tool:d.string(),minTrust:Ct,allowedClasses:d.array(Me).default([]),decision:Fn,rateLimit:d.object({max:d.number().int().positive(),windowSeconds:d.number().int().positive()}).optional()}),Zo=d.object({decision:Fn,ruleId:d.string().nullable(),reason:d.string()}),Ho=d.enum(["session","user","org"]),It=d.object({key:d.string().min(1),value:d.unknown(),scope:Ho.default("session"),ttlSeconds:d.number().int().positive().nullable().default(null),updatedAt:d.string().datetime().optional()}),Jo=d.object({path:d.string().min(1),name:d.string().optional(),purpose:d.string().optional(),availableActions:d.array(d.string()).optional(),prerequisites:d.array(d.string()).optional(),queryParams:d.record(d.string()).optional(),notes:d.string().optional()}),qo=d.object({pattern:d.string().optional(),flow:d.string().optional()}),Yo=d.object({pages:d.array(Jo).default([]),navigation:qo.optional()}),Xo=d.object({step:d.number().int().positive(),action:d.string().min(1)}),Qo=d.object({steps:d.array(Xo).default([]),notes:d.string().optional(),policy:d.string().optional()}),es=d.object({selector:d.string().min(1),behavior:d.string().optional(),location:d.string().optional(),showsCount:d.boolean().optional()}),ts=d.object({categories:d.array(d.string()).optional(),productSchema:d.object({fields:d.array(d.string()).optional(),idFormat:d.string().optional()}).optional(),searchBehavior:d.string().optional()}),Rt=d.object({path:d.string().min(1),payload:d.record(d.unknown()).default({}),updatedAt:d.string().datetime().optional()}).strict(),W=d.object({version:d.string().default("1"),siteMap:Yo.optional(),workflows:d.record(Qo).default({}),policies:d.record(d.union([d.string(),d.array(d.string())])).default({}),catalog:ts.optional(),uiGuidance:d.record(es).default({}),pageContexts:d.record(Rt).default({}),updatedAt:d.string().datetime().optional()}),Kn=W.parse({}),ns=d.object({name:d.string().min(1),title:d.string().optional(),group:d.string().optional(),page:d.string().optional(),description:d.string().default(""),inputSchema:d.record(d.unknown()).default({}),outputSchema:d.record(d.unknown()).optional(),annotations:d.record(d.boolean()).optional(),tokens:d.number().int().nonnegative().default(0)}),rs=d.object({tools:d.array(ns).default([])});rs.parse({});var os=d.enum(["agent.detected","agent.missed","auth.identity_presented","auth.identity_cleared","authz.policies_set","authz.evaluated","memory.accessed","memory.updated","tool.registered","tool.executed","tool.surfaced","tool.progressed","sdk.error"]),Mt=d.object({id:d.string(),siteId:d.string(),sessionId:d.string(),occurredAt:d.string().datetime(),type:os,tool:d.string().optional(),agent:Fo.nullable().optional(),policy:Zo.optional(),durationMs:d.number().int().nonnegative().optional(),outcome:d.enum(["success","error","blocked"]),error:d.string().optional(),metadata:d.record(d.unknown()).default({})});d.object({publishableKey:d.string().optional(),events:d.array(Mt).min(1).max(100)});var Ye=class extends Error{code;constructor(t,e){super(e),this.name="AgentronicsError",this.code=t;}};var M="0.1.2";var Et=(t,e)=>typeof t=="object"&&t!==null&&typeof t[e]=="function",Xe=t=>{let e=t??(typeof globalThis>"u"?null:globalThis);if(!e)return null;let n=e.document?.modelContext;if(Et(n,"registerTool"))return {source:"document",context:n};let r=e.navigator?.modelContext;return Et(r,"registerTool")?{source:"navigator",context:r}:Et(r,"provideContext")?{source:"legacy",context:r}:null},Ot=null,Pt=new Set,Dt=(t,e)=>{Ot={type:t,toolName:e,at:Date.now()},Pt.forEach(n=>n(Ot));},Zn=()=>Ot,jt=t=>(Pt.add(t),()=>{Pt.delete(t);});var ss=()=>{if(typeof navigator>"u")return null;let t=navigator.modelContext;return !t||typeof t!="object"?null:t.vendor||t.client?t:null},Hn=()=>Xe()?.source??null,Ue=async(t={})=>{let{pollMs:e=500}=t,n=Date.now();for(;;){let r=Zn();if(r)return is(r);let o=ss();if(o)return as(o);if(Date.now()-n>=e)return null;await new Promise(s=>setTimeout(s,50));}},Jn=()=>({class:"webmcp",trust:"detected",confidence:1,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M}),is=t=>({...Jn(),vendor:null,signals:{webmcp:true,source:Hn(),event:t.type,tool:t.toolName}}),as=t=>({...Jn(),vendor:t.vendor??t.client??null,signals:{webmcp:true,source:"legacy-extension",toolCount:Array.isArray(t.tools)?t.tools.length:0}});var Nt=[{name:"GPTBot",category:"ai",pattern:/GPTBot/i},{name:"OAI-SearchBot",category:"ai",pattern:/OAI-SearchBot/i},{name:"ChatGPT-User",category:"ai",pattern:/ChatGPT-User/i},{name:"Claude-User",category:"ai",pattern:/Claude-User/i},{name:"Claude-SearchBot",category:"ai",pattern:/Claude-SearchBot/i},{name:"ClaudeBot",category:"ai",pattern:/ClaudeBot/i},{name:"Claude-Web",category:"ai",pattern:/Claude-Web/i},{name:"anthropic-ai",category:"ai",pattern:/anthropic-ai/i},{name:"Perplexity-User",category:"ai",pattern:/Perplexity-User/i},{name:"PerplexityBot",category:"ai",pattern:/PerplexityBot/i},{name:"Google-Extended",category:"ai",pattern:/Google-Extended/i},{name:"Applebot-Extended",category:"ai",pattern:/Applebot-Extended/i},{name:"Amazonbot",category:"ai",pattern:/Amazonbot/i},{name:"Bytespider",category:"ai",pattern:/Bytespider/i},{name:"CCBot",category:"ai",pattern:/CCBot/i},{name:"Meta-ExternalAgent",category:"ai",pattern:/Meta-ExternalAgent/i},{name:"cohere-ai",category:"ai",pattern:/cohere-ai/i},{name:"Googlebot",category:"search",pattern:/Googlebot/i},{name:"Bingbot",category:"search",pattern:/bingbot/i},{name:"DuckDuckBot",category:"search",pattern:/DuckDuckBot/i},{name:"YandexBot",category:"search",pattern:/YandexBot/i},{name:"Baiduspider",category:"search",pattern:/Baiduspider/i},{name:"Applebot",category:"search",pattern:/Applebot/i}],Ge=(t={})=>{let{signatures:e=Nt,disable:n=false,confidence:r=.9}=t;if(n||typeof navigator>"u")return null;let o=navigator.userAgent??"";if(!o)return null;for(let s of e)if(s.pattern.test(o))return {class:"crawler",trust:"detected",confidence:r,vendor:s.name,userAgent:o,detectionVersion:M,signals:{matched:s.name,category:s.category,ua:o}};return null};var cs=[/HeadlessChrome/i,/Headless/i,/PhantomJS/i,/SlimerJS/i],ls=()=>({hit:(typeof navigator<"u"&&navigator.webdriver)===true,weight:.6,detail:"navigator.webdriver === true"}),ds=()=>{if(typeof window>"u")return {hit:false,weight:.5};let t=Object.keys(window).filter(e=>e.startsWith("cdc_"));return {hit:t.length>0,weight:.5,detail:`window.${t[0]??"cdc_*"}`}},us=["__playwright__binding__","__pwInitScripts","__puppeteer_evaluation_script__","_phantom","callPhantom","__nightmare","domAutomation","domAutomationController","__selenium_unwrapped","__webdriver_evaluate","__driver_evaluate","__fxdriver_unwrapped"],ps=()=>{if(typeof window>"u")return {hit:false,weight:.6};let t=us.find(e=>e in window);return t?{hit:true,weight:.6,detail:`window.${t}`}:{hit:false,weight:.6}},ms=()=>{if(typeof navigator>"u"||!navigator.plugins)return {hit:false,weight:.2};let t=/Win|Mac|Linux/.test(navigator.userAgent??""),e=navigator.plugins.length===0;return {hit:t&&e,weight:.2,detail:"desktop UA with no plugins"}},fs=()=>{if(typeof navigator>"u")return {hit:false,weight:.7};let t=navigator.userAgent??"",e=cs.some(n=>n.test(t));return e?{hit:e,weight:.7,detail:`headless UA: ${t}`}:{hit:e,weight:.7}},gs=()=>{if(typeof navigator>"u")return {hit:false,weight:.15};let t=navigator.languages;return {hit:!t||t.length===0,weight:.15,detail:"navigator.languages empty"}},ys=()=>{if(typeof navigator>"u")return {hit:false,weight:.1};let t="chrome"in window,e=navigator.userAgent??"";return {hit:/Chrome\//.test(e)&&!/Edg\//.test(e)&&!t,weight:.2,detail:"Chrome UA without window.chrome"}},hs={webdriver:ls,chromedriver:ds,automationGlobals:ps,headlessUa:fs,languages:gs,permissions:ys,plugins:ms},ze=(t={})=>{let{threshold:e=.4}=t,n={},r=0,o=0;for(let[i,a]of Object.entries(hs)){let l=a();r+=l.weight,n[i]={hit:l.hit,weight:l.weight,detail:l.detail},l.hit&&(o+=l.weight);}let s=r===0?0:o/r;return s<e?null:{class:"dom",trust:"detected",confidence:s,vendor:null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:n}};var Lt=()=>[{id:"webmcp.model-context",status:"stable",detect:()=>Ue({pollMs:0})},{id:"crawler.user-agent",status:"beta",detect:()=>Ge()},{id:"dom.automation-heuristics",status:"beta",detect:()=>ze()}],at=(t=Lt())=>{let e=new Map(t.map(n=>[n.id,n]));return {register(n){e.set(n.id,n);},list(n){let r=[...e.values()];return n?r.filter(o=>o.status===n):r},async detectAll(n=false){for(let r of e.values()){if(r.status==="research"&&!n)continue;let o=await r.detect();if(o)return o}return null}}};var $t=t=>{let e=Me.parse(t.class),n=t.verificationToken?"verified":"declared";return {class:e,trust:n,confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{declared:true,hasVerificationToken:!!t.verificationToken}}};var qn=({gatewayUrl:t,publishableKey:e,fetcher:n=fetch})=>{let r=null,o=[];return {snapshot(){return [...o]},async sync(){let s=await n(`${t.replace(/\/$/,"")}/v1/pub/detector-signatures`,{headers:{...e?{authorization:`Bearer ${e}`}:{},...r?{"if-none-match":r}:{}}});if(s.status===304)return this.snapshot();if(!s.ok)throw new Error(`Detector signature sync failed with status ${s.status}.`);return o=(await s.json()).signatures??[],r=s.headers.get("etag"),this.snapshot()}}};var ct=async(t={})=>{if(t.customDetectors?.length){let e=await at(t.customDetectors).detectAll(!!t.experimental);if(e)return e}if(t.webmcp!==false){let e=await Ue(t.webmcp??{});if(e)return e}if(t.crawler!==false){let e=Ge(t.crawler??{});if(e)return e}if(t.dom!==false){let e=ze(t.dom??{});if(e)return e}return null};var vs=new Set(["1024x768","1280x800","1280x720","1280x1024","1440x900","1920x1080"]),xs=t=>{if(t.length<6)return null;let e=t.reduce((r,o)=>r+o,0)/t.length;if(e<=0)return null;let n=t.reduce((r,o)=>r+(o-e)**2,0)/t.length;return Math.sqrt(n)/e},Wt=t=>{let e=0;return t.clicks>=2&&(e+=.35*(t.teleportClicks/t.clicks),e+=.25*(t.centreClicks/t.clicks),t.pointerMoves===0&&(e+=.15)),t.keyIntervalCv!==null&&t.keyIntervalCv<.15&&(e+=.2),t.insertWithoutKeys>0&&(e+=.15),t.wheelEvents===0&&t.clicks>=3&&(e+=.05),t.vmViewport&&(e+=.1),Math.min(1,e)},Vt=(t={})=>{let{threshold:e=.6,minInteractions:n=3,onDetect:r,acceptUntrustedEvents:o=false}=t,s=E=>E.isTrusted||o,i=t.documentRef??(typeof document>"u"?void 0:document),a={clicks:0,teleportClicks:0,centreClicks:0,keyIntervals:0,keyIntervalCv:null,insertWithoutKeys:0,pointerMoves:0,wheelEvents:0,vmViewport:false},l=Number.NEGATIVE_INFINITY,c=0,u=0,v=[],h=0,T=null,x=i?.defaultView;x&&(a.vmViewport=vs.has(`${x.innerWidth}x${x.innerHeight}`));let g=E=>({class:"screenshot",trust:"detected",confidence:Number(E.toFixed(2)),vendor:null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{vision:true,...a}}),A=()=>{if(T||a.clicks+h<n)return;let E=Wt(a);E>=e&&(T=g(E),r?.(T));},S=E=>{s(E)&&(a.pointerMoves+=1,l=E.timeStamp);},et=[["pointermove",S],["mousemove",S],["wheel",E=>{s(E)&&(a.wheelEvents+=1);}],["click",E=>{if(!s(E))return;let P=E;a.clicks+=1,E.timeStamp-l>400&&(a.teleportClicks+=1);let Fe=P.target instanceof Element?P.target:null;if(Fe&&typeof Fe.getBoundingClientRect=="function"){let ee=Fe.getBoundingClientRect();if(ee.width>8&&ee.height>8){let te=Math.abs(P.clientX-(ee.left+ee.width/2)),ie=Math.abs(P.clientY-(ee.top+ee.height/2));te<=1.5&&ie<=1.5&&(a.centreClicks+=1);}}A();}],["keydown",E=>{if(!s(E))return;let P=E.timeStamp;c&&P-c<1500?(v.push(P-c),v.length>60&&v.shift(),a.keyIntervals=v.length,a.keyIntervalCv=xs(v)):h+=1,c=P,u=P;}],["keyup",()=>A()],["input",E=>{if(!s(E))return;let P=E;P.inputType==="insertText"&&P.data&&P.data.length>1&&E.timeStamp-u>200&&(a.insertWithoutKeys+=1,h+=1,A());}]];for(let[E,P]of et)i?.addEventListener(E,P,{capture:true,passive:true});return {signals:()=>({...a}),score:()=>Wt(a),detected:()=>T,stop:()=>{for(let[E,P]of et)i?.removeEventListener(E,P,{capture:true});}}};var bs=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),Bt=()=>{let t=null;return {present(e){let n=qe.safeParse(e);if(!n.success)throw new Ye("invalid_api_key",`Invalid identity claim: ${n.error.issues[0]?.message??"unknown"}`);let r={claim:n.data,identity:bs(n.data)};return t=r,r},clear(){t=null;},preferOver(e){return t?e?zn(t.identity.trust,e.trust)?t.identity:e:t.identity:e},snapshot(){return t}}};var ws=({detected:t,declared:e,verified:n,linked:r})=>r?"linked":n?"verified":e?"declared":"detected",Ut=t=>{let e=null;for(let n of t)(!e||q[n.trust]>q[e.trust])&&(e=n);return e};var Yn=()=>({name:"bearer",async authenticate(t,e){if(!t.bearerToken)return null;let n=await e.verifyToken?.("bearer",t.bearerToken);return {class:t.classHint??"dom",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"bearer",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{bearer:true,verifiedRemotely:!!n}}}});var Xn=()=>({name:"detection",async authenticate(t){return t.detected??null}});var Qn=()=>({name:"extensionToken",async authenticate(t,e){if(!t.extensionToken)return null;let n=await e.verifyToken?.("extensionToken",t.extensionToken);return {class:"dom",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"browser-extension",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{extensionToken:true,verifiedRemotely:!!n}}}});var er=()=>({name:"mtls",async authenticate(t,e){if(!t.xfccHeader)return null;let n=await e.verifyToken?.("mtls",t.xfccHeader);return {class:t.classHint??"webmcp",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"mtls",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{mtls:true,subject:n?.subject??null,verifiedRemotely:!!n,...n?.signals??{}}}}});var tr=()=>({name:"oauth2",async authenticate(t,e){if(!t.oauth2AccessToken)return null;let n=await e.verifyToken?.("oauth2",t.oauth2AccessToken);return {class:t.classHint??"webmcp",trust:n?t.oauth2Subject&&n.trust!=="detected"&&n.trust!=="declared"?"linked":n.trust:"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"oauth2",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{oauth2:true,subject:t.oauth2Subject??null,verifiedRemotely:!!n}}}});var ks=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),nr=()=>({name:"selfDeclaration",async authenticate(t){return t.declaration?ks(qe.parse(t.declaration)):null}});var rr=()=>({name:"sessionLink",async authenticate(t,e){if(!t.sessionLinkToken)return null;let n=await e.verifyToken?.("sessionLink",t.sessionLinkToken);return {class:t.classHint??"screenshot",trust:n?t.linkedUserId&&n.trust!=="detected"&&n.trust!=="declared"?"linked":n.trust:"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"session-link",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{sessionLink:true,linkedUserId:t.linkedUserId??null,verifiedRemotely:!!n}}}});var or=()=>({name:"sso",async authenticate(t,e){if(!t.ssoIdToken)return null;let n=await e.verifyToken?.("sso",t.ssoIdToken);return {class:t.classHint??"dom",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"sso",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{sso:true,subject:n?.subject??null,verifiedRemotely:!!n,...n?.signals??{}}}}});var sr=()=>({name:"spiffe",async authenticate(t,e){if(!t.spiffeJwt)return null;let n=await e.verifyToken?.("spiffe",t.spiffeJwt),r=n?.vendor==="google";return {class:t.classHint??"webmcp",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"spiffe",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{spiffe:true,spiffeId:n?.subject??null,subject:n?.subject??null,verifiedRemotely:!!n,...r?{googleAgent:true}:{},...n?.signals??{}}}}});var ir=()=>({name:"xAgentHeader",async authenticate(t){if(!t.xAgentHeader)return null;let[e="x-agent",n="dom",r]=t.xAgentHeader.split(";"),o=Me.safeParse(n);return {class:o.success?o.data:"dom",trust:"declared",confidence:r?1:.8,vendor:e,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{xAgentHeader:true,hasProof:!!r}}}});var ar=new Set(["bearer","extensionToken","sessionLink","oauth2","sso","spiffe","mtls"]),_s=(t,e,n)=>{if(ar.has(t)&&e.signals?.verifiedRemotely===false){let r=t==="oauth2"&&n.oauth2Subject||t==="sessionLink"&&n.linkedUserId;return {...e,trust:r?"linked":"verified",signals:{...e.signals,compat:"0.6"}}}return t==="xAgentHeader"&&e.signals?.hasProof===true?{...e,trust:"verified",confidence:1,signals:{...e.signals,compat:"0.6"}}:e},Gt=()=>[Xn(),nr(),Yn(),ir(),Qn(),rr(),tr()],cr=()=>[or(),sr(),er()],Ts={detection:"detection",selfDeclaration:"declaration",bearer:"bearer",xAgentHeader:"x-agent-header",extensionToken:"extension",sessionLink:"session-link",oauth2:"oauth2",sso:"sso",spiffe:"spiffe",mtls:"mtls"},Ss=(t,e)=>t==="spiffe"&&e.signals?.googleAgent===true?"google-agent":Ts[t],zt=({compat:t,methods:e=t==="0.6"?[...Gt(),...cr()]:Gt(),context:n={},onTrace:r,onUnverifiedToken:o}={})=>{let s=false;return {async authenticate(i){let a=[],l={};for(let x of e){let g=await x.authenticate(i,n);l[x.name]=!!g,g&&(ar.has(x.name)&&g.signals?.verifiedRemotely===false&&!n.verifyToken&&!s&&(s=true,o?.(x.name)),t==="0.6"&&(g=_s(x.name,g,i)),a.push({method:x.name,identity:g}));}let c=Ut(a.map(x=>x.identity)),u=c?a.find(x=>x.identity===c):void 0,v=u?Ss(u.method,u.identity):void 0,h=typeof c?.signals?.subject=="string"?c.signals.subject:void 0,T={type:c?"auth.identity_presented":"sdk.error",agent:c,outcome:c?"success":"error",metadata:{methods:l,...v?{protocol:v}:{},...h?{subject:h}:{}}};return c||(T.error="No auth method produced an identity."),r?.(T),c},methods(){return e.map(i=>i.name)}}};var As={identity:null,source:"initial",updatedAt:null},Ft=()=>{let t=As,e=new Set,n=()=>{e.size!==0&&e.forEach(r=>r(t));};return {snapshot(){return t},set(r,o){t={identity:r,source:o,updatedAt:new Date().toISOString()},n();},subscribe(r){return e.add(r),()=>{e.delete(r);}}}};var Cs=()=>{let t=new Map;return {read:e=>t.get(e)??null,write:(e,n)=>{t.set(e,n);}}},Is=()=>typeof window>"u"||!window.localStorage?Cs():{read:t=>{try{return window.localStorage.getItem(t)}catch{return null}},write:(t,e)=>{try{window.localStorage.setItem(t,e);}catch{}}},Rs=t=>{if(!t)return null;try{let e=JSON.parse(t);if(typeof e=="object"&&e!==null&&Number.isFinite(e.count)&&Number.isFinite(e.resetAt))return e}catch{return null}return null},Kt=(t=Is())=>({consume(e,n,r=Date.now()){let o=`agtx:rate:${e}`,s=Rs(t.read(o)),i=s&&s.resetAt>r?s.resetAt:r+n.windowSeconds*1e3,a=s&&s.resetAt>r?s.count+1:1;return t.write(o,JSON.stringify({count:a,resetAt:i})),{allowed:a<=n.max,remaining:Math.max(0,n.max-a),resetAt:i}}});var Ms=(t,e)=>t==="*"||t===e?true:t.includes("*")?new RegExp("^"+t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")+"$").test(e):false,Es=(t,e)=>{let n=t?q[t.trust]:-1,r=q[e.minTrust];return n>=r},Os=(t,e)=>e.allowedClasses.length===0?true:t?e.allowedClasses.includes(t.class):false,lr="allow",Ps=(t,e)=>{let n=e?.class??"unknown",r=e?.vendor??"unknown",o=e?.trust??"none";return `${t}:${n}:${r}:${o}`},Zt=(t=[],e={})=>{let n=t.map(o=>Ee.parse(o)),r=e.rateLimiter??Kt();return {set(o){n=o.map(s=>Ee.parse(s));},list(){return [...n]},evaluate({tool:o,identity:s}){for(let i of n)if(Ms(i.tool,o)){if(!Es(s,i))return {decision:"deny",ruleId:i.id,reason:`Rule "${i.id}" requires trust >= ${i.minTrust}.`};if(!Os(s,i))return {decision:"deny",ruleId:i.id,reason:`Rule "${i.id}" restricts to classes: ${i.allowedClasses.join(", ")}.`};if(i.rateLimit){let a=r.consume(Ps(o,s),i.rateLimit);if(!a.allowed)return {decision:"deny",ruleId:i.id,reason:`Rule "${i.id}" rate limit exceeded. Resets at ${new Date(a.resetAt).toISOString()}.`}}return {decision:i.decision,ruleId:i.id,reason:`Matched rule "${i.id}".`}}return {decision:lr,ruleId:null,reason:`No rule matched tool "${o}". Falling back to "${lr}".`}}}};var Ht=({gatewayUrl:t,siteId:e,publishableKey:n,fetcher:r=fetch})=>{let o={policies:[],etag:null};return {snapshot(){return {policies:[...o.policies],etag:o.etag}},async sync(){let s=await r(`${t.replace(/\/$/,"")}/v1/pub/sites/${encodeURIComponent(e)}/policies`,{headers:{authorization:`Bearer ${n}`,...o.etag?{"if-none-match":o.etag}:{}}});if(s.status===304)return this.snapshot();if(!s.ok)throw new Error(`Policy sync failed with status ${s.status}.`);let i=await s.json();return o={policies:Ee.array().parse(i.policies??[]),etag:s.headers.get("etag")},this.snapshot()}}};var Jt=({message:t="Agent action blocked by site policy.",durationMs:e=2400,documentRef:n=typeof document>"u"?void 0:document}={})=>{if(!n?.body)return null;let r=n.createElement("div");return r.setAttribute("role","status"),r.setAttribute("data-agentronics-deny-overlay","true"),r.textContent=t,Object.assign(r.style,{position:"fixed",zIndex:"2147483647",left:"50%",bottom:"24px",transform:"translateX(-50%)",maxWidth:"min(520px, calc(100vw - 32px))",padding:"12px 16px",borderRadius:"12px",background:"#0B0B0C",color:"#FFFFFF",border:"2px solid #FF4D1F",font:"13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace"}),n.body.appendChild(r),window.setTimeout(()=>r.remove(),e),r};var qt=({policyEngine:t,getIdentity:e,documentRef:n=typeof document>"u"?void 0:document,selector:r="[data-agentronics-tool]"})=>{if(!n)return {uninstall:()=>{}};let o=s=>{let i=s.target instanceof Element?s.target.closest(r):null;if(!(i instanceof HTMLElement))return;let a=i.dataset.agentronicsTool;a&&Promise.resolve(e()).then(l=>{let c=t.evaluate({tool:a,identity:l});c.decision==="deny"&&(s.preventDefault(),s.stopPropagation(),Jt({message:c.reason,documentRef:n}));});};return n.addEventListener("click",o,true),{uninstall:()=>n.removeEventListener("click",o,true)}};var Yt=()=>{let t=new Map;return {read:e=>t.get(e)??null,write:(e,n)=>{t.set(e,n);},remove:e=>{t.delete(e);},keys:()=>[...t.keys()]}},dr=(t,e)=>({read:n=>{try{return t.getItem(e+n)}catch{return null}},write:(n,r)=>{try{t.setItem(e+n,r);}catch{}},remove:n=>{try{t.removeItem(e+n);}catch{}},keys:()=>{let n=[];try{for(let r=0;r<t.length;r++){let o=t.key(r);o&&o.startsWith(e)&&n.push(o.slice(e.length));}}catch{}return n}}),ur="agtx:",pr=()=>{let t=typeof window<"u",e=t&&typeof window.sessionStorage<"u"?dr(window.sessionStorage,ur+"session:"):Yt(),n=t&&typeof window.localStorage<"u"?dr(window.localStorage,ur+"user:"):Yt();return {session:e,user:n,org:Yt()}};var mr=(t,e)=>t.expiresAt!==null&&t.expiresAt<=e,fr=t=>{if(!t)return null;try{let e=JSON.parse(t);return typeof e!="object"||e===null?null:e}catch{return null}},Ds=t=>JSON.stringify(t),Xt=(t={})=>{let e=pr(),n=l=>{t.onTrace?.(l);};return {get:(l,c={})=>{let u=c.scope??"session",v=e[u],h=fr(v.read(l));if(!h){n({type:"memory.accessed",metadata:{operation:"get",key:l,scope:u,hit:false}});return}if(mr(h,Date.now())){v.remove(l),n({type:"memory.accessed",metadata:{operation:"get",key:l,scope:u,hit:false,expired:true}});return}return n({type:"memory.accessed",metadata:{operation:"get",key:l,scope:u,hit:true}}),h.value},set:(l,c,u={})=>{let v=u.scope??"session",h=u.ttlSeconds??null,T=Date.now(),x={value:c,expiresAt:h===null?null:T+h*1e3,updatedAt:new Date(T).toISOString()};return e[v].write(l,Ds(x)),n({type:"memory.updated",metadata:{operation:"set",key:l,scope:v,ttlSeconds:h}}),It.parse({key:l,value:c,scope:v,ttlSeconds:h,updatedAt:x.updatedAt})},remove:(l,c={})=>{let u=c.scope??"session";e[u].remove(l),n({type:"memory.updated",metadata:{operation:"remove",key:l,scope:u}});},list:(l={})=>{let c=l.scope??"session",u=e[c],v=Date.now(),h=[];for(let T of u.keys()){let x=fr(u.read(T));if(x){if(mr(x,v)){u.remove(T);continue}h.push(It.parse({key:T,value:x.value,scope:c,ttlSeconds:x.expiresAt===null?null:Math.max(0,Math.round((x.expiresAt-v)/1e3)),updatedAt:x.updatedAt}));}}return n({type:"memory.accessed",metadata:{operation:"list",scope:c,count:h.length}}),h},clear:(l={})=>{let c=l.scope??"session",u=e[c],v=u.keys().length;for(let h of u.keys())u.remove(h);n({type:"memory.updated",metadata:{operation:"clear",scope:c,count:v}});}}};var Qt=t=>W.parse(JSON.parse(JSON.stringify(t))),lt=t=>({...t,updatedAt:new Date().toISOString()}),en=(t={})=>{let e=W.parse({...Kn,...t.initial??{}}),n=null,r=new Set,o=g=>{t.onTrace?.(g);},s=()=>{n=null;},i=()=>{if(r.size===0)return;let g=Qt(e);n=g,r.forEach(A=>A(g));},a=g=>{let A=W.parse({...e,...g,workflows:{...e.workflows,...g.workflows??{}},policies:{...e.policies,...g.policies??{}},uiGuidance:{...e.uiGuidance,...g.uiGuidance??{}},pageContexts:{...e.pageContexts,...g.pageContexts??{}}});return e=lt(A),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"provide",keys:Object.keys(g)}}),i(),u()},l=(g,A)=>{let S=g.split(".").filter(Boolean);if(S.length===0)throw new Error("siteMemory.update() requires a non-empty dot-path.");let D=JSON.parse(JSON.stringify(e)),U=D;for(let G=0;G<S.length-1;G++){let N=S[G],z=U[N];(typeof z!="object"||z===null||Array.isArray(z))&&(U[N]={}),U=U[N];}return U[S[S.length-1]]=A,e=lt(W.parse(D)),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"update",path:g}}),i(),u()},c=g=>{let A=Rt.parse({path:g.path,payload:g.payload,updatedAt:new Date().toISOString()});return e=lt({...e,pageContexts:{...e.pageContexts,[g.path]:A}}),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"provideForPage",path:g.path}}),i(),{...A,payload:{...A.payload}}},u=()=>(n||(n=Qt(e)),n);return {provide:a,update:l,provideForPage:c,snapshot:u,get:g=>{if(o({type:"memory.accessed",metadata:{kind:"site",operation:g?"get":"snapshot",path:g??null}}),!g)return Qt(e);let A=g.split(".").filter(Boolean),S=e;for(let D of A){if(typeof S!="object"||S===null)return;S=S[D];}return S},getForPage:g=>{o({type:"memory.accessed",metadata:{kind:"site",operation:"getForPage",path:g}});let A=e.pageContexts[g];return A?{...A,payload:{...A.payload}}:null},replace:g=>(e=lt(W.parse(g)),s(),i(),u()),subscribe:g=>(r.add(g),()=>{r.delete(g);})}};var tn=({gatewayUrl:t,siteId:e,publishableKey:n,fetcher:r=fetch})=>{let o={memory:null,etag:null};return {snapshot(){return {memory:o.memory?W.parse(o.memory):null,etag:o.etag}},async sync(){let s=await r(`${t.replace(/\/$/,"")}/v1/pub/sites/${encodeURIComponent(e)}/memory`,{headers:{authorization:`Bearer ${n}`,...o.etag?{"if-none-match":o.etag}:{}}});if(s.status===304)return this.snapshot();if(!s.ok)throw new Error(`Memory sync failed with status ${s.status}.`);let i=await s.json();return o={memory:W.parse(i.memory??{}),etag:s.headers.get("etag")},this.snapshot()}}};var gr=({toolName:t="getSiteContext",description:e="Returns Agentronics site memory: page map, workflows, policies, UI guidance.",getSnapshot:n,onAccess:r})=>({name:t,description:e,inputSchema:{type:"object",properties:{path:{type:"string",description:'Optional dot-path into the site memory (e.g. "workflows.purchase").'}},required:[]},invoke(o={}){let s=n(),i=o.path??null;if(r?.(i),!i)return {content:s};let a=i.split(".").filter(Boolean),l=s;for(let c of a){if(typeof l!="object"||l===null)return {content:void 0};l=l[c];}return {content:l}}});var ue="agent-context-",nn="agentronics-site-context",js=t=>{try{return JSON.stringify(t)}catch{return "{}"}},dt=(t,e,n)=>{let r=t.querySelector(`meta[name="${e}"]`);r||(r=t.createElement("meta"),r.setAttribute("name",e),t.head.appendChild(r)),r.setAttribute("content",n);},ut=(t,e)=>{t.querySelectorAll(`meta[name="${e}"]`).forEach(n=>n.remove());},pt=({doc:t=typeof document>"u"?null:document,snapshot:e,schemaType:n="WebSite"})=>{if(!t)return {uninstall:()=>{}};dt(t,`${ue}version`,e.version),dt(t,`${ue}updated-at`,e.updatedAt??new Date().toISOString()),e.siteMap?.navigation?.flow&&dt(t,`${ue}flow`,e.siteMap.navigation.flow),dt(t,`${ue}workflows`,Object.keys(e.workflows).join(","));let r=t.getElementById(nn);return r||(r=t.createElement("script"),r.type="application/ld+json",r.id=nn,t.head.appendChild(r)),r.textContent=js({"@context":"https://schema.org","@type":n,name:"Agentronics Site Memory",agentronics:e}),{uninstall:()=>{ut(t,`${ue}version`),ut(t,`${ue}updated-at`),ut(t,`${ue}flow`),ut(t,`${ue}workflows`),t.getElementById(nn)?.remove();}}};var yr="agentronics-memory-overlay",Ns=t=>`
|
|
1
|
+
var Agentronics=(function(exports){'use strict';var Dr=Object.defineProperty;var jr=(t,e)=>{for(var n in e)Dr(t,n,{get:e[n],enumerable:true});};var u={};jr(u,{BRAND:()=>ao,DIRTY:()=>me,EMPTY_PATH:()=>Wr,INVALID:()=>_,NEVER:()=>Ko,OK:()=>L,ParseStatus:()=>j,Schema:()=>M,ZodAny:()=>le,ZodArray:()=>se,ZodBigInt:()=>ye,ZodBoolean:()=>he,ZodBranded:()=>He,ZodCatch:()=>Me,ZodDate:()=>ve,ZodDefault:()=>Ce,ZodDiscriminatedUnion:()=>rt,ZodEffects:()=>Z,ZodEnum:()=>Se,ZodError:()=>B,ZodFirstPartyTypeKind:()=>S,ZodFunction:()=>st,ZodIntersection:()=>ke,ZodIssueCode:()=>f,ZodLazy:()=>_e,ZodLiteral:()=>Te,ZodMap:()=>$e,ZodNaN:()=>Ve,ZodNativeEnum:()=>Ae,ZodNever:()=>J,ZodNull:()=>be,ZodNullable:()=>Q,ZodNumber:()=>ge,ZodObject:()=>U,ZodOptional:()=>F,ZodParsedType:()=>v,ZodPipeline:()=>Je,ZodPromise:()=>ue,ZodReadonly:()=>Re,ZodRecord:()=>ot,ZodSchema:()=>M,ZodSet:()=>We,ZodString:()=>ce,ZodSymbol:()=>Ne,ZodTransformer:()=>Z,ZodTuple:()=>X,ZodType:()=>M,ZodUndefined:()=>xe,ZodUnion:()=>we,ZodUnknown:()=>oe,ZodVoid:()=>Le,addIssueToContext:()=>h,any:()=>ho,array:()=>wo,bigint:()=>po,boolean:()=>Gn,coerce:()=>Fo,custom:()=>Vn,date:()=>fo,datetimeRegex:()=>$n,defaultErrorMap:()=>ne,discriminatedUnion:()=>So,effect:()=>Lo,enum:()=>Do,function:()=>Eo,getErrorMap:()=>Pe,getParsedType:()=>Y,instanceof:()=>lo,intersection:()=>Ao,isAborted:()=>tt,isAsync:()=>De,isDirty:()=>nt,isValid:()=>ae,late:()=>co,lazy:()=>Oo,literal:()=>Po,makeIssue:()=>Ze,map:()=>Ro,nan:()=>uo,nativeEnum:()=>jo,never:()=>xo,null:()=>yo,nullable:()=>Wo,number:()=>Un,object:()=>ko,objectUtil:()=>Tt,oboolean:()=>zo,onumber:()=>Go,optional:()=>$o,ostring:()=>Uo,pipeline:()=>Bo,preprocess:()=>Vo,promise:()=>No,quotelessJson:()=>Nr,record:()=>Mo,set:()=>Io,setErrorMap:()=>$r,strictObject:()=>_o,string:()=>Bn,symbol:()=>mo,transformer:()=>Lo,tuple:()=>Co,undefined:()=>go,union:()=>To,unknown:()=>vo,util:()=>R,void:()=>bo});var R;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function n(o){throw new Error}t.assertNever=n,t.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},t.find=(o,s)=>{for(let i of o)if(s(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s;})(R||(R={}));var Tt;(function(t){t.mergeShapes=(e,n)=>({...e,...n});})(Tt||(Tt={}));var v=R.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Y=t=>{switch(typeof t){case "undefined":return v.undefined;case "string":return v.string;case "number":return Number.isNaN(t)?v.nan:v.number;case "boolean":return v.boolean;case "function":return v.function;case "bigint":return v.bigint;case "symbol":return v.symbol;case "object":return Array.isArray(t)?v.array:t===null?v.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?v.promise:typeof Map<"u"&&t instanceof Map?v.map:typeof Set<"u"&&t instanceof Set?v.set:typeof Date<"u"&&t instanceof Date?v.date:v.object;default:return v.unknown}};var f=R.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"]),Nr=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),B=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r];},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r];};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e;}format(e){let n=e||function(s){return s.message},r={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)r._errors.push(n(i));else {let a=r,l=0;for(;l<i.path.length;){let c=i.path[l];l===i.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(i))):a[c]=a[c]||{_errors:[]},a=a[c],l++;}}};return o(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,R.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];n[s]=n[s]||[],n[s].push(e(o));}else r.push(e(o));return {formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};B.create=t=>new B(t);var Lr=(t,e)=>{let n;switch(t.code){case f.invalid_type:t.received===v.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,R.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:n=`Unrecognized key(s) in object: ${R.joinValues(t.keys,", ")}`;break;case f.invalid_union:n="Invalid input";break;case f.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${R.joinValues(t.options)}`;break;case f.invalid_enum_value:n=`Invalid enum value. Expected ${R.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:n="Invalid function arguments";break;case f.invalid_return_type:n="Invalid function return type";break;case f.invalid_date:n="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:R.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case f.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case f.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case f.custom:n="Invalid input";break;case f.invalid_intersection_types:n="Intersection results could not be merged";break;case f.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:n="Number must be finite";break;default:n=e.defaultError,R.assertNever(t);}return {message:n}},ne=Lr;var Pn=ne;function $r(t){Pn=t;}function Pe(){return Pn}var Ze=t=>{let{data:e,path:n,errorMaps:r,issueData:o}=t,s=[...n,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return {...o,path:s,message:o.message};let a="",l=r.filter(c=>!!c).slice().reverse();for(let c of l)a=c(i,{data:e,defaultError:a}).message;return {...o,path:s,message:a}},Wr=[];function h(t,e){let n=Pe(),r=Ze({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===ne?void 0:ne].filter(o=>!!o)});t.common.issues.push(r);}var j=class t{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(e,n){let r=[];for(let o of n){if(o.status==="aborted")return _;o.status==="dirty"&&e.dirty(),r.push(o.value);}return {status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let o of n){let s=await o.key,i=await o.value;r.push({key:s,value:i});}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let o of n){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return _;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(r[s.value]=i.value);}return {status:e.value,value:r}}},_=Object.freeze({status:"aborted"}),me=t=>({status:"dirty",value:t}),L=t=>({status:"valid",value:t}),tt=t=>t.status==="aborted",nt=t=>t.status==="dirty",ae=t=>t.status==="valid",De=t=>typeof Promise<"u"&&t instanceof Promise;var b;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message;})(b||(b={}));var K=class{constructor(e,n,r,o){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=o;}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}},Dn=(t,e)=>{if(ae(e))return {success:true,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return {success:false,get error(){if(this._error)return this._error;let n=new B(t.common.issues);return this._error=n,this._error}}};function C(t){if(!t)return {};let{errorMap:e,invalid_type_error:n,required_error:r,description:o}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,a)=>{let{message:l}=t;return i.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:o}}var M=class{get description(){return this._def.description}_getType(e){return Y(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Y(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return {status:new j,ctx:{common:e.parent.common,data:e.data,parsedType:Y(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(De(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??false,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Y(e)},o=this._parseSync({data:e,path:r.path,parent:r});return Dn(r,o)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Y(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return ae(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=true),n.common={issues:[],async:true};}return this._parseAsync({data:e,path:[],parent:n}).then(r=>ae(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:true},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Y(e)},o=this._parse({data:e,path:r.path,parent:r}),s=await(De(o)?o:Promise.resolve(o));return Dn(r,s)}refine(e,n){let r=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,s)=>{let i=e(o),a=()=>s.addIssue({code:f.custom,...r(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?true:(a(),false)):i?true:(a(),false)})}refinement(e,n){return this._refinement((r,o)=>e(r)?true:(o.addIssue(typeof n=="function"?n(r,o):n),false))}_refinement(e){return new Z({schema:this,typeName:S.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:n=>this["~validate"](n)};}optional(){return F.create(this,this._def)}nullable(){return Q.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return se.create(this)}promise(){return ue.create(this,this._def)}or(e){return we.create([this,e],this._def)}and(e){return ke.create(this,e,this._def)}transform(e){return new Z({...C(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Ce({...C(this._def),innerType:this,defaultValue:n,typeName:S.ZodDefault})}brand(){return new He({typeName:S.ZodBranded,type:this,...C(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Me({...C(this._def),innerType:this,catchValue:n,typeName:S.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Je.create(this,e)}readonly(){return Re.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Vr=/^c[^\s-]{8,}$/i,Br=/^[0-9a-z]+$/,Ur=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Gr=/^[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,zr=/^[a-z0-9_-]{21}$/i,Fr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Kr=/^[-+]?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)?)??$/,Zr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Hr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",St,Jr=/^(?:(?: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])$/,qr=/^(?:(?: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])$/,Yr=/^(([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]))$/,Xr=/^(([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])$/,Qr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,eo=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Nn="((\\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])))",to=new RegExp(`^${Nn}$`);function Ln(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function no(t){return new RegExp(`^${Ln(t)}$`)}function $n(t){let e=`${Nn}T${Ln(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function ro(t,e){return !!((e==="v4"||!e)&&Jr.test(t)||(e==="v6"||!e)&&Yr.test(t))}function oo(t,e){if(!Fr.test(t))return false;try{let[n]=t.split(".");if(!n)return !1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),o=JSON.parse(atob(r));return !(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return false}}function so(t,e){return !!((e==="v4"||!e)&&qr.test(t)||(e==="v6"||!e)&&Xr.test(t))}var ce=class t extends M{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==v.string){let s=this._getOrReturnCtx(e);return h(s,{code:f.invalid_type,expected:v.string,received:s.parsedType}),_}let r=new j,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),h(o,{code:f.too_small,minimum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),h(o,{code:f.too_big,maximum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),r.dirty());else if(s.kind==="length"){let i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?h(o,{code:f.too_big,maximum:s.value,type:"string",inclusive:true,exact:true,message:s.message}):a&&h(o,{code:f.too_small,minimum:s.value,type:"string",inclusive:true,exact:true,message:s.message}),r.dirty());}else if(s.kind==="email")Zr.test(e.data)||(o=this._getOrReturnCtx(e,o),h(o,{validation:"email",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")St||(St=new RegExp(Hr,"u")),St.test(e.data)||(o=this._getOrReturnCtx(e,o),h(o,{validation:"emoji",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")Gr.test(e.data)||(o=this._getOrReturnCtx(e,o),h(o,{validation:"uuid",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")zr.test(e.data)||(o=this._getOrReturnCtx(e,o),h(o,{validation:"nanoid",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")Vr.test(e.data)||(o=this._getOrReturnCtx(e,o),h(o,{validation:"cuid",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")Br.test(e.data)||(o=this._getOrReturnCtx(e,o),h(o,{validation:"cuid2",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")Ur.test(e.data)||(o=this._getOrReturnCtx(e,o),h(o,{validation:"ulid",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data);}catch{o=this._getOrReturnCtx(e,o),h(o,{validation:"url",code:f.invalid_string,message:s.message}),r.dirty();}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),h(o,{validation:"regex",code:f.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),h(o,{code:f.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),h(o,{code:f.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),h(o,{code:f.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?$n(s).test(e.data)||(o=this._getOrReturnCtx(e,o),h(o,{code:f.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?to.test(e.data)||(o=this._getOrReturnCtx(e,o),h(o,{code:f.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?no(s).test(e.data)||(o=this._getOrReturnCtx(e,o),h(o,{code:f.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?Kr.test(e.data)||(o=this._getOrReturnCtx(e,o),h(o,{validation:"duration",code:f.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?ro(e.data,s.version)||(o=this._getOrReturnCtx(e,o),h(o,{validation:"ip",code:f.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?oo(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),h(o,{validation:"jwt",code:f.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?so(e.data,s.version)||(o=this._getOrReturnCtx(e,o),h(o,{validation:"cidr",code:f.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?Qr.test(e.data)||(o=this._getOrReturnCtx(e,o),h(o,{validation:"base64",code:f.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?eo.test(e.data)||(o=this._getOrReturnCtx(e,o),h(o,{validation:"base64url",code:f.invalid_string,message:s.message}),r.dirty()):R.assertNever(s);return {status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(o=>e.test(o),{validation:n,code:f.invalid_string,...b.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...b.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...b.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:false,local:false,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??false,local:e?.local??false,...b.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,...b.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...b.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...b.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...b.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...b.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...b.errToObj(n)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};ce.create=t=>new ce({checks:[],typeName:S.ZodString,coerce:t?.coerce??false,...C(t)});function io(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,o=n>r?n:r,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}var ge=class t extends M{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)!==v.number){let s=this._getOrReturnCtx(e);return h(s,{code:f.invalid_type,expected:v.number,received:s.parsedType}),_}let r,o=new j;for(let s of this._def.checks)s.kind==="int"?R.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:f.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:f.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:f.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),o.dirty()):s.kind==="multipleOf"?io(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),h(r,{code:f.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:f.not_finite,message:s.message}),o.dirty()):R.assertNever(s);return {status:o.value,value:e.data}}gte(e,n){return this.setLimit("min",e,true,b.toString(n))}gt(e,n){return this.setLimit("min",e,false,b.toString(n))}lte(e,n){return this.setLimit("max",e,true,b.toString(n))}lt(e,n){return this.setLimit("max",e,false,b.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:false,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:false,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:true,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:true,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return !!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&R.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return true;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);}return Number.isFinite(n)&&Number.isFinite(e)}};ge.create=t=>new ge({checks:[],typeName:S.ZodNumber,coerce:t?.coerce||false,...C(t)});var ye=class t extends M{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)!==v.bigint)return this._getInvalidInput(e);let r,o=new j;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:f.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:f.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),h(r,{code:f.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):R.assertNever(s);return {status:o.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:v.bigint,received:n.parsedType}),_}gte(e,n){return this.setLimit("min",e,true,b.toString(n))}gt(e,n){return this.setLimit("min",e,false,b.toString(n))}lte(e,n){return this.setLimit("max",e,true,b.toString(n))}lt(e,n){return this.setLimit("max",e,false,b.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:false,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};ye.create=t=>new ye({checks:[],typeName:S.ZodBigInt,coerce:t?.coerce??false,...C(t)});var he=class extends M{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==v.boolean){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:v.boolean,received:r.parsedType}),_}return L(e.data)}};he.create=t=>new he({typeName:S.ZodBoolean,coerce:t?.coerce||false,...C(t)});var ve=class t extends M{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==v.date){let s=this._getOrReturnCtx(e);return h(s,{code:f.invalid_type,expected:v.date,received:s.parsedType}),_}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return h(s,{code:f.invalid_date}),_}let r=new j,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),h(o,{code:f.too_small,message:s.message,inclusive:true,exact:false,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),h(o,{code:f.too_big,message:s.message,inclusive:true,exact:false,maximum:s.value,type:"date"}),r.dirty()):R.assertNever(s);return {status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};ve.create=t=>new ve({checks:[],coerce:t?.coerce||false,typeName:S.ZodDate,...C(t)});var Ne=class extends M{_parse(e){if(this._getType(e)!==v.symbol){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:v.symbol,received:r.parsedType}),_}return L(e.data)}};Ne.create=t=>new Ne({typeName:S.ZodSymbol,...C(t)});var xe=class extends M{_parse(e){if(this._getType(e)!==v.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:v.undefined,received:r.parsedType}),_}return L(e.data)}};xe.create=t=>new xe({typeName:S.ZodUndefined,...C(t)});var be=class extends M{_parse(e){if(this._getType(e)!==v.null){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:v.null,received:r.parsedType}),_}return L(e.data)}};be.create=t=>new be({typeName:S.ZodNull,...C(t)});var le=class extends M{constructor(){super(...arguments),this._any=true;}_parse(e){return L(e.data)}};le.create=t=>new le({typeName:S.ZodAny,...C(t)});var oe=class extends M{constructor(){super(...arguments),this._unknown=true;}_parse(e){return L(e.data)}};oe.create=t=>new oe({typeName:S.ZodUnknown,...C(t)});var J=class extends M{_parse(e){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:v.never,received:n.parsedType}),_}};J.create=t=>new J({typeName:S.ZodNever,...C(t)});var Le=class extends M{_parse(e){if(this._getType(e)!==v.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:v.void,received:r.parsedType}),_}return L(e.data)}};Le.create=t=>new Le({typeName:S.ZodVoid,...C(t)});var se=class t extends M{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),o=this._def;if(n.parsedType!==v.array)return h(n,{code:f.invalid_type,expected:v.array,received:n.parsedType}),_;if(o.exactLength!==null){let i=n.data.length>o.exactLength.value,a=n.data.length<o.exactLength.value;(i||a)&&(h(n,{code:i?f.too_big:f.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:true,exact:true,message:o.exactLength.message}),r.dirty());}if(o.minLength!==null&&n.data.length<o.minLength.value&&(h(n,{code:f.too_small,minimum:o.minLength.value,type:"array",inclusive:true,exact:false,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&n.data.length>o.maxLength.value&&(h(n,{code:f.too_big,maximum:o.maxLength.value,type:"array",inclusive:true,exact:false,message:o.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((i,a)=>o.type._parseAsync(new K(n,i,n.path,a)))).then(i=>j.mergeArray(r,i));let s=[...n.data].map((i,a)=>o.type._parseSync(new K(n,i,n.path,a)));return j.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:b.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:b.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:b.toString(n)}})}nonempty(e){return this.min(1,e)}};se.create=(t,e)=>new se({type:t,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...C(e)});function je(t){if(t instanceof U){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=F.create(je(r));}return new U({...t._def,shape:()=>e})}else return t instanceof se?new se({...t._def,type:je(t.element)}):t instanceof F?F.create(je(t.unwrap())):t instanceof Q?Q.create(je(t.unwrap())):t instanceof X?X.create(t.items.map(e=>je(e))):t}var U=class t extends M{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(),n=R.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==v.object){let c=this._getOrReturnCtx(e);return h(c,{code:f.invalid_type,expected:v.object,received:c.parsedType}),_}let{status:r,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof J&&this._def.unknownKeys==="strip"))for(let c in o.data)i.includes(c)||a.push(c);let l=[];for(let c of i){let d=s[c],g=o.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new K(o,g,o.path,c)),alwaysSet:c in o.data});}if(this._def.catchall instanceof J){let c=this._def.unknownKeys;if(c==="passthrough")for(let d of a)l.push({key:{status:"valid",value:d},value:{status:"valid",value:o.data[d]}});else if(c==="strict")a.length>0&&(h(o,{code:f.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let c=this._def.catchall;for(let d of a){let g=o.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new K(o,g,o.path,d)),alwaysSet:d in o.data});}}return o.common.async?Promise.resolve().then(async()=>{let c=[];for(let d of l){let g=await d.key,y=await d.value;c.push({key:g,value:y,alwaysSet:d.alwaysSet});}return c}).then(c=>j.mergeObjectSync(r,c)):j.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let o=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:b.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:S.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of R.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of R.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return je(this)}partial(e){let n={};for(let r of R.objectKeys(this.shape)){let o=this.shape[r];e&&!e[r]?n[r]=o:n[r]=o.optional();}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of R.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else {let s=this.shape[r];for(;s instanceof F;)s=s._def.innerType;n[r]=s;}return new t({...this._def,shape:()=>n})}keyof(){return Wn(R.objectKeys(this.shape))}};U.create=(t,e)=>new U({shape:()=>t,unknownKeys:"strip",catchall:J.create(),typeName:S.ZodObject,...C(e)});U.strictCreate=(t,e)=>new U({shape:()=>t,unknownKeys:"strict",catchall:J.create(),typeName:S.ZodObject,...C(e)});U.lazycreate=(t,e)=>new U({shape:t,unknownKeys:"strip",catchall:J.create(),typeName:S.ZodObject,...C(e)});var we=class extends M{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new B(a.ctx.common.issues));return h(n,{code:f.invalid_union,unionErrors:i}),_}if(n.common.async)return Promise.all(r.map(async s=>{let i={...n,common:{...n.common,issues:[]},parent:null};return {result:await s._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(o);{let s,i=[];for(let l of r){let c={...n,common:{...n.common,issues:[]},parent:null},d=l._parseSync({data:n.data,path:n.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,ctx:c}),c.common.issues.length&&i.push(c.common.issues);}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(l=>new B(l));return h(n,{code:f.invalid_union,unionErrors:a}),_}}get options(){return this._def.options}};we.create=(t,e)=>new we({options:t,typeName:S.ZodUnion,...C(e)});var re=t=>t instanceof _e?re(t.schema):t instanceof Z?re(t.innerType()):t instanceof Te?[t.value]:t instanceof Se?t.options:t instanceof Ae?R.objectValues(t.enum):t instanceof Ce?re(t._def.innerType):t instanceof xe?[void 0]:t instanceof be?[null]:t instanceof F?[void 0,...re(t.unwrap())]:t instanceof Q?[null,...re(t.unwrap())]:t instanceof He||t instanceof Re?re(t.unwrap()):t instanceof Me?re(t._def.innerType):[],rt=class t extends M{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==v.object)return h(n,{code:f.invalid_type,expected:v.object,received:n.parsedType}),_;let r=this.discriminator,o=n.data[r],s=this.optionsMap.get(o);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(h(n,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),_)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let o=new Map;for(let s of n){let i=re(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,s);}}return new t({typeName:S.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:o,...C(r)})}};function At(t,e){let n=Y(t),r=Y(e);if(t===e)return {valid:true,data:t};if(n===v.object&&r===v.object){let o=R.objectKeys(e),s=R.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let l=At(t[a],e[a]);if(!l.valid)return {valid:false};i[a]=l.data;}return {valid:true,data:i}}else if(n===v.array&&r===v.array){if(t.length!==e.length)return {valid:false};let o=[];for(let s=0;s<t.length;s++){let i=t[s],a=e[s],l=At(i,a);if(!l.valid)return {valid:false};o.push(l.data);}return {valid:true,data:o}}else return n===v.date&&r===v.date&&+t==+e?{valid:true,data:t}:{valid:false}}var ke=class extends M{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=(s,i)=>{if(tt(s)||tt(i))return _;let a=At(s.value,i.value);return a.valid?((nt(s)||nt(i))&&n.dirty(),{status:n.value,value:a.data}):(h(r,{code:f.invalid_intersection_types}),_)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,i])=>o(s,i)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};ke.create=(t,e,n)=>new ke({left:t,right:e,typeName:S.ZodIntersection,...C(n)});var X=class t extends M{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.array)return h(r,{code:f.invalid_type,expected:v.array,received:r.parsedType}),_;if(r.data.length<this._def.items.length)return h(r,{code:f.too_small,minimum:this._def.items.length,inclusive:true,exact:false,type:"array"}),_;!this._def.rest&&r.data.length>this._def.items.length&&(h(r,{code:f.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"}),n.dirty());let s=[...r.data].map((i,a)=>{let l=this._def.items[a]||this._def.rest;return l?l._parse(new K(r,i,r.path,a)):null}).filter(i=>!!i);return r.common.async?Promise.all(s).then(i=>j.mergeArray(n,i)):j.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};X.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new X({items:t,typeName:S.ZodTuple,rest:null,...C(e)})};var ot=class t extends M{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.object)return h(r,{code:f.invalid_type,expected:v.object,received:r.parsedType}),_;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in r.data)o.push({key:s._parse(new K(r,a,r.path,a)),value:i._parse(new K(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?j.mergeObjectAsync(n,o):j.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof M?new t({keyType:e,valueType:n,typeName:S.ZodRecord,...C(r)}):new t({keyType:ce.create(),valueType:e,typeName:S.ZodRecord,...C(n)})}},$e=class extends M{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.map)return h(r,{code:f.invalid_type,expected:v.map,received:r.parsedType}),_;let o=this._def.keyType,s=this._def.valueType,i=[...r.data.entries()].map(([a,l],c)=>({key:o._parse(new K(r,a,r.path,[c,"key"])),value:s._parse(new K(r,l,r.path,[c,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of i){let c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return _;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(c.value,d.value);}return {status:n.value,value:a}})}else {let a=new Map;for(let l of i){let c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return _;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(c.value,d.value);}return {status:n.value,value:a}}}};$e.create=(t,e,n)=>new $e({valueType:e,keyType:t,typeName:S.ZodMap,...C(n)});var We=class t extends M{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.set)return h(r,{code:f.invalid_type,expected:v.set,received:r.parsedType}),_;let o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(h(r,{code:f.too_small,minimum:o.minSize.value,type:"set",inclusive:true,exact:false,message:o.minSize.message}),n.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(h(r,{code:f.too_big,maximum:o.maxSize.value,type:"set",inclusive:true,exact:false,message:o.maxSize.message}),n.dirty());let s=this._def.valueType;function i(l){let c=new Set;for(let d of l){if(d.status==="aborted")return _;d.status==="dirty"&&n.dirty(),c.add(d.value);}return {status:n.value,value:c}}let a=[...r.data.values()].map((l,c)=>s._parse(new K(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>i(l)):i(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:b.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:b.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};We.create=(t,e)=>new We({valueType:t,minSize:null,maxSize:null,typeName:S.ZodSet,...C(e)});var st=class t extends M{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==v.function)return h(n,{code:f.invalid_type,expected:v.function,received:n.parsedType}),_;function r(a,l){return Ze({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Pe(),ne].filter(c=>!!c),issueData:{code:f.invalid_arguments,argumentsError:l}})}function o(a,l){return Ze({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Pe(),ne].filter(c=>!!c),issueData:{code:f.invalid_return_type,returnTypeError:l}})}let s={errorMap:n.common.contextualErrorMap},i=n.data;if(this._def.returns instanceof ue){let a=this;return L(async function(...l){let c=new B([]),d=await a._def.args.parseAsync(l,s).catch(w=>{throw c.addIssue(r(l,w)),c}),g=await Reflect.apply(i,this,d);return await a._def.returns._def.type.parseAsync(g,s).catch(w=>{throw c.addIssue(o(g,w)),c})})}else {let a=this;return L(function(...l){let c=a._def.args.safeParse(l,s);if(!c.success)throw new B([r(l,c.error)]);let d=Reflect.apply(i,this,c.data),g=a._def.returns.safeParse(d,s);if(!g.success)throw new B([o(d,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:X.create(e).rest(oe.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||X.create([]).rest(oe.create()),returns:n||oe.create(),typeName:S.ZodFunction,...C(r)})}},_e=class extends M{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};_e.create=(t,e)=>new _e({getter:t,typeName:S.ZodLazy,...C(e)});var Te=class extends M{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return h(n,{received:n.data,code:f.invalid_literal,expected:this._def.value}),_}return {status:"valid",value:e.data}}get value(){return this._def.value}};Te.create=(t,e)=>new Te({value:t,typeName:S.ZodLiteral,...C(e)});function Wn(t,e){return new Se({values:t,typeName:S.ZodEnum,...C(e)})}var Se=class t extends M{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return h(n,{expected:R.joinValues(r),received:n.parsedType,code:f.invalid_type}),_}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return h(n,{received:n.data,code:f.invalid_enum_value,options:r}),_}return L(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};Se.create=Wn;var Ae=class extends M{_parse(e){let n=R.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==v.string&&r.parsedType!==v.number){let o=R.objectValues(n);return h(r,{expected:R.joinValues(o),received:r.parsedType,code:f.invalid_type}),_}if(this._cache||(this._cache=new Set(R.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=R.objectValues(n);return h(r,{received:r.data,code:f.invalid_enum_value,options:o}),_}return L(e.data)}get enum(){return this._def.values}};Ae.create=(t,e)=>new Ae({values:t,typeName:S.ZodNativeEnum,...C(e)});var ue=class extends M{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==v.promise&&n.common.async===false)return h(n,{code:f.invalid_type,expected:v.promise,received:n.parsedType}),_;let r=n.parsedType===v.promise?n.data:Promise.resolve(n.data);return L(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};ue.create=(t,e)=>new ue({type:t,typeName:S.ZodPromise,...C(e)});var Z=class extends M{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i=>{h(r,i),i.fatal?n.abort():n.dirty();},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(r.data,s);if(r.common.async)return Promise.resolve(i).then(async a=>{if(n.value==="aborted")return _;let l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?_:l.status==="dirty"?me(l.value):n.value==="dirty"?me(l.value):l});{if(n.value==="aborted")return _;let a=this._def.schema._parseSync({data:i,path:r.path,parent:r});return a.status==="aborted"?_:a.status==="dirty"?me(a.value):n.value==="dirty"?me(a.value):a}}if(o.type==="refinement"){let i=a=>{let l=o.refinement(a,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===false){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?_:(a.status==="dirty"&&n.dirty(),i(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?_:(a.status==="dirty"&&n.dirty(),i(a.value).then(()=>({status:n.value,value:a.value}))))}if(o.type==="transform")if(r.common.async===false){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ae(i))return _;let a=o.transform(i.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>ae(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:n.value,value:a})):_);R.assertNever(o);}};Z.create=(t,e,n)=>new Z({schema:t,typeName:S.ZodEffects,effect:e,...C(n)});Z.createWithPreprocess=(t,e,n)=>new Z({schema:e,effect:{type:"preprocess",transform:t},typeName:S.ZodEffects,...C(n)});var F=class extends M{_parse(e){return this._getType(e)===v.undefined?L(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};F.create=(t,e)=>new F({innerType:t,typeName:S.ZodOptional,...C(e)});var Q=class extends M{_parse(e){return this._getType(e)===v.null?L(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Q.create=(t,e)=>new Q({innerType:t,typeName:S.ZodNullable,...C(e)});var Ce=class extends M{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===v.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Ce.create=(t,e)=>new Ce({innerType:t,typeName:S.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...C(e)});var Me=class extends M{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return De(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new B(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new B(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Me.create=(t,e)=>new Me({innerType:t,typeName:S.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...C(e)});var Ve=class extends M{_parse(e){if(this._getType(e)!==v.nan){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:v.nan,received:r.parsedType}),_}return {status:"valid",value:e.data}}};Ve.create=t=>new Ve({typeName:S.ZodNaN,...C(t)});var ao=Symbol("zod_brand"),He=class extends M{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Je=class t extends M{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return (async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?_:s.status==="dirty"?(n.dirty(),me(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{let o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?_:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:S.ZodPipeline})}},Re=class extends M{_parse(e){let n=this._def.innerType._parse(e),r=o=>(ae(o)&&(o.value=Object.freeze(o.value)),o);return De(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};Re.create=(t,e)=>new Re({innerType:t,typeName:S.ZodReadonly,...C(e)});function jn(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Vn(t,e={},n){return t?le.create().superRefine((r,o)=>{let s=t(r);if(s instanceof Promise)return s.then(i=>{if(!i){let a=jn(e,r),l=a.fatal??n??true;o.addIssue({code:"custom",...a,fatal:l});}});if(!s){let i=jn(e,r),a=i.fatal??n??true;o.addIssue({code:"custom",...i,fatal:a});}}):le.create()}var co={object:U.lazycreate},S;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly";})(S||(S={}));var lo=(t,e={message:`Input not instance of ${t.name}`})=>Vn(n=>n instanceof t,e),Bn=ce.create,Un=ge.create,uo=Ve.create,po=ye.create,Gn=he.create,fo=ve.create,mo=Ne.create,go=xe.create,yo=be.create,ho=le.create,vo=oe.create,xo=J.create,bo=Le.create,wo=se.create,ko=U.create,_o=U.strictCreate,To=we.create,So=rt.create,Ao=ke.create,Co=X.create,Mo=ot.create,Ro=$e.create,Io=We.create,Eo=st.create,Oo=_e.create,Po=Te.create,Do=Se.create,jo=Ae.create,No=ue.create,Lo=Z.create,$o=F.create,Wo=Q.create,Vo=Z.createWithPreprocess,Bo=Je.create,Uo=()=>Bn().optional(),Go=()=>Un().optional(),zo=()=>Gn().optional(),Fo={string:(t=>ce.create({...t,coerce:true})),number:(t=>ge.create({...t,coerce:true})),boolean:(t=>he.create({...t,coerce:true})),bigint:(t=>ye.create({...t,coerce:true})),date:(t=>ve.create({...t,coerce:true}))};var Ko=_;var Be="agtx_pk_",it="agtx_sk_";u.string().min(Be.length+8).startsWith(Be,{message:`Publishable keys must start with "${Be}".`});u.string().min(it.length+8).startsWith(it,{message:`Secret keys must start with "${it}".`});var zn=t=>t.startsWith(Be)?"publishable":t.startsWith(it)?"secret":"unknown",Ie=u.enum(["webmcp","dom","screenshot","crawler"]),Ct=u.enum(["detected","declared","verified","linked"]),Zo=u.object({class:Ie,trust:Ct,confidence:u.number().min(0).max(1).default(1),vendor:u.string().nullable(),userAgent:u.string().nullable(),detectionVersion:u.string().default("2026.04"),signals:u.record(u.unknown()).default({})}),Ho=u.enum(["bearer","oauth2","sso","spiffe","google-agent","mtls","detection","declaration","extension","session-link","x-agent-header","web-bot-auth","api-key","verified-crawler"]),qe=u.object({class:Ie,vendor:u.string().min(1),token:u.string().min(8),expiresAt:u.string().datetime().optional()});u.object({publishableKey:u.string(),claim:qe,nonce:u.string().min(8),origin:u.string().url()});u.object({trust:Ct,vendor:u.string(),validUntil:u.string().datetime(),reason:u.string().optional(),subject:u.string().optional(),protocol:Ho.optional(),signals:u.record(u.unknown()).optional()});u.object({issuer:u.string().url(),audiences:u.array(u.string().min(1)).min(1)});u.object({trustDomain:u.string().min(1),bundleEndpoint:u.string().url(),audiences:u.array(u.string().min(1)).min(1),googleTrustDomains:u.array(u.string().min(1)).optional()});u.object({rootCerts:u.array(u.string().min(20)).min(1),spiffeTrustDomain:u.string().min(1).optional(),xfccEntryPolicy:u.enum(["last","first","only"]).default("last")});u.enum(["sso","spiffe","mtls"]);u.object({siteId:u.string().min(1),token:u.string().min(8).optional(),xfcc:u.string().min(1).optional(),headers:u.record(u.string()).optional(),origin:u.string().url().optional()});var q={detected:0,declared:1,verified:2,linked:3},Fn=(t,e)=>q[t]>q[e],Kn=u.enum(["allow","deny","review"]),Ee=u.object({id:u.string(),tool:u.string(),minTrust:Ct,allowedClasses:u.array(Ie).default([]),decision:Kn,rateLimit:u.object({max:u.number().int().positive(),windowSeconds:u.number().int().positive()}).optional()}),Jo=u.object({decision:Kn,ruleId:u.string().nullable(),reason:u.string()}),qo=u.enum(["session","user","org"]),Mt=u.object({key:u.string().min(1),value:u.unknown(),scope:qo.default("session"),ttlSeconds:u.number().int().positive().nullable().default(null),updatedAt:u.string().datetime().optional()}),Yo=u.object({path:u.string().min(1),name:u.string().optional(),purpose:u.string().optional(),availableActions:u.array(u.string()).optional(),prerequisites:u.array(u.string()).optional(),queryParams:u.record(u.string()).optional(),notes:u.string().optional()}),Xo=u.object({pattern:u.string().optional(),flow:u.string().optional()}),Qo=u.object({pages:u.array(Yo).default([]),navigation:Xo.optional()}),es=u.object({step:u.number().int().positive(),action:u.string().min(1)}),ts=u.object({steps:u.array(es).default([]),notes:u.string().optional(),policy:u.string().optional()}),ns=u.object({selector:u.string().min(1),behavior:u.string().optional(),location:u.string().optional(),showsCount:u.boolean().optional()}),rs=u.object({categories:u.array(u.string()).optional(),productSchema:u.object({fields:u.array(u.string()).optional(),idFormat:u.string().optional()}).optional(),searchBehavior:u.string().optional()}),Rt=u.object({path:u.string().min(1),payload:u.record(u.unknown()).default({}),updatedAt:u.string().datetime().optional()}).strict(),V=u.object({version:u.string().default("1"),siteMap:Qo.optional(),workflows:u.record(ts).default({}),policies:u.record(u.union([u.string(),u.array(u.string())])).default({}),catalog:rs.optional(),uiGuidance:u.record(ns).default({}),pageContexts:u.record(Rt).default({}),updatedAt:u.string().datetime().optional()}),Zn=V.parse({}),os=u.object({name:u.string().min(1),title:u.string().optional(),group:u.string().optional(),page:u.string().optional(),description:u.string().default(""),inputSchema:u.record(u.unknown()).default({}),outputSchema:u.record(u.unknown()).optional(),annotations:u.record(u.boolean()).optional(),tokens:u.number().int().nonnegative().default(0)}),ss=u.object({tools:u.array(os).default([])});ss.parse({});var is=u.enum(["agent.detected","agent.missed","auth.identity_presented","auth.identity_cleared","authz.policies_set","authz.evaluated","memory.accessed","memory.updated","tool.registered","tool.executed","tool.surfaced","tool.progressed","sdk.error"]),It=u.object({id:u.string(),siteId:u.string(),sessionId:u.string(),occurredAt:u.string().datetime(),type:is,tool:u.string().optional(),agent:Zo.nullable().optional(),policy:Jo.optional(),durationMs:u.number().int().nonnegative().optional(),outcome:u.enum(["success","error","blocked"]),error:u.string().optional(),metadata:u.record(u.unknown()).default({})});u.object({publishableKey:u.string().optional(),events:u.array(It).min(1).max(100)});var Ye=class extends Error{code;constructor(t,e){super(e),this.name="AgentronicsError",this.code=t;}};var I="0.1.2";var Et=(t,e)=>typeof t=="object"&&t!==null&&typeof t[e]=="function",Xe=t=>{let e=t??(typeof globalThis>"u"?null:globalThis);if(!e)return null;let n=e.document?.modelContext;if(Et(n,"registerTool"))return {source:"document",context:n};let r=e.navigator?.modelContext;return Et(r,"registerTool")?{source:"navigator",context:r}:Et(r,"provideContext")?{source:"legacy",context:r}:null},Ot=null,Pt=new Set,Dt=(t,e)=>{Ot={type:t,toolName:e,at:Date.now()},Pt.forEach(n=>n(Ot));},Hn=()=>Ot,jt=t=>(Pt.add(t),()=>{Pt.delete(t);});var as=()=>{if(typeof navigator>"u")return null;let t=navigator.modelContext;return !t||typeof t!="object"?null:t.vendor||t.client?t:null},Jn=()=>Xe()?.source??null,Ue=async(t={})=>{let{pollMs:e=500}=t,n=Date.now();for(;;){let r=Hn();if(r)return cs(r);let o=as();if(o)return ls(o);if(Date.now()-n>=e)return null;await new Promise(s=>setTimeout(s,50));}},qn=()=>({class:"webmcp",trust:"detected",confidence:1,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:I}),cs=t=>({...qn(),vendor:null,signals:{webmcp:true,source:Jn(),event:t.type,tool:t.toolName}}),ls=t=>({...qn(),vendor:t.vendor??t.client??null,signals:{webmcp:true,source:"legacy-extension",toolCount:Array.isArray(t.tools)?t.tools.length:0}});var Nt=[{name:"GPTBot",category:"ai",pattern:/GPTBot/i},{name:"OAI-SearchBot",category:"ai",pattern:/OAI-SearchBot/i},{name:"ChatGPT-User",category:"ai",pattern:/ChatGPT-User/i},{name:"Claude-User",category:"ai",pattern:/Claude-User/i},{name:"Claude-SearchBot",category:"ai",pattern:/Claude-SearchBot/i},{name:"ClaudeBot",category:"ai",pattern:/ClaudeBot/i},{name:"Claude-Web",category:"ai",pattern:/Claude-Web/i},{name:"anthropic-ai",category:"ai",pattern:/anthropic-ai/i},{name:"Perplexity-User",category:"ai",pattern:/Perplexity-User/i},{name:"PerplexityBot",category:"ai",pattern:/PerplexityBot/i},{name:"Google-Extended",category:"ai",pattern:/Google-Extended/i},{name:"Applebot-Extended",category:"ai",pattern:/Applebot-Extended/i},{name:"Amazonbot",category:"ai",pattern:/Amazonbot/i},{name:"Bytespider",category:"ai",pattern:/Bytespider/i},{name:"CCBot",category:"ai",pattern:/CCBot/i},{name:"Meta-ExternalAgent",category:"ai",pattern:/Meta-ExternalAgent/i},{name:"cohere-ai",category:"ai",pattern:/cohere-ai/i},{name:"Googlebot",category:"search",pattern:/Googlebot/i},{name:"Bingbot",category:"search",pattern:/bingbot/i},{name:"DuckDuckBot",category:"search",pattern:/DuckDuckBot/i},{name:"YandexBot",category:"search",pattern:/YandexBot/i},{name:"Baiduspider",category:"search",pattern:/Baiduspider/i},{name:"Applebot",category:"search",pattern:/Applebot/i}],Ge=(t={})=>{let{signatures:e=Nt,disable:n=false,confidence:r=.9}=t;if(n||typeof navigator>"u")return null;let o=navigator.userAgent??"";if(!o)return null;for(let s of e)if(s.pattern.test(o))return {class:"crawler",trust:"detected",confidence:r,vendor:s.name,userAgent:o,detectionVersion:I,signals:{matched:s.name,category:s.category,ua:o}};return null};var us=[/HeadlessChrome/i,/Headless/i,/PhantomJS/i,/SlimerJS/i],ds=()=>({hit:(typeof navigator<"u"&&navigator.webdriver)===true,weight:.6,detail:"navigator.webdriver === true"}),ps=()=>{if(typeof window>"u")return {hit:false,weight:.5};let t=Object.keys(window).filter(e=>e.startsWith("cdc_"));return {hit:t.length>0,weight:.5,detail:`window.${t[0]??"cdc_*"}`}},fs=["__playwright__binding__","__pwInitScripts","__puppeteer_evaluation_script__","_phantom","callPhantom","__nightmare","domAutomation","domAutomationController","__selenium_unwrapped","__webdriver_evaluate","__driver_evaluate","__fxdriver_unwrapped"],ms=()=>{if(typeof window>"u")return {hit:false,weight:.6};let t=fs.find(e=>e in window);return t?{hit:true,weight:.6,detail:`window.${t}`}:{hit:false,weight:.6}},gs=()=>{if(typeof navigator>"u"||!navigator.plugins)return {hit:false,weight:.2};let t=/Win|Mac|Linux/.test(navigator.userAgent??""),e=navigator.plugins.length===0;return {hit:t&&e,weight:.2,detail:"desktop UA with no plugins"}},ys=()=>{if(typeof navigator>"u")return {hit:false,weight:.7};let t=navigator.userAgent??"",e=us.some(n=>n.test(t));return e?{hit:e,weight:.7,detail:`headless UA: ${t}`}:{hit:e,weight:.7}},hs=()=>{if(typeof navigator>"u")return {hit:false,weight:.15};let t=navigator.languages;return {hit:!t||t.length===0,weight:.15,detail:"navigator.languages empty"}},vs=()=>{if(typeof navigator>"u")return {hit:false,weight:.1};let t="chrome"in window,e=navigator.userAgent??"";return {hit:/Chrome\//.test(e)&&!/Edg\//.test(e)&&!t,weight:.2,detail:"Chrome UA without window.chrome"}},xs={webdriver:ds,chromedriver:ps,automationGlobals:ms,headlessUa:ys,languages:hs,permissions:vs,plugins:gs},ze=(t={})=>{let{threshold:e=.4}=t,n={},r=0,o=0;for(let[i,a]of Object.entries(xs)){let l=a();r+=l.weight,n[i]={hit:l.hit,weight:l.weight,detail:l.detail},l.hit&&(o+=l.weight);}let s=r===0?0:o/r;return s<e?null:{class:"dom",trust:"detected",confidence:s,vendor:null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:I,signals:n}};var Lt=()=>[{id:"webmcp.model-context",status:"stable",detect:()=>Ue({pollMs:0})},{id:"crawler.user-agent",status:"beta",detect:()=>Ge()},{id:"dom.automation-heuristics",status:"beta",detect:()=>ze()}],at=(t=Lt())=>{let e=new Map(t.map(n=>[n.id,n]));return {register(n){e.set(n.id,n);},list(n){let r=[...e.values()];return n?r.filter(o=>o.status===n):r},async detectAll(n=false){for(let r of e.values()){if(r.status==="research"&&!n)continue;let o=await r.detect();if(o)return o}return null}}};var $t=t=>{let e=Ie.parse(t.class),n=t.verificationToken?"verified":"declared";return {class:e,trust:n,confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:I,signals:{declared:true,hasVerificationToken:!!t.verificationToken}}};var Yn=({gatewayUrl:t,publishableKey:e,fetcher:n=fetch})=>{let r=null,o=[];return {snapshot(){return [...o]},async sync(){let s=await n(`${t.replace(/\/$/,"")}/v1/pub/detector-signatures`,{headers:{...e?{authorization:`Bearer ${e}`}:{},...r?{"if-none-match":r}:{}}});if(s.status===304)return this.snapshot();if(!s.ok)throw new Error(`Detector signature sync failed with status ${s.status}.`);return o=(await s.json()).signatures??[],r=s.headers.get("etag"),this.snapshot()}}};var ct=async(t={})=>{if(t.customDetectors?.length){let e=await at(t.customDetectors).detectAll(!!t.experimental);if(e)return e}if(t.webmcp!==false){let e=await Ue(t.webmcp??{});if(e)return e}if(t.crawler!==false){let e=Ge(t.crawler??{});if(e)return e}if(t.dom!==false){let e=ze(t.dom??{});if(e)return e}return null};var bs=new Set(["1024x768","1280x800","1280x720","1280x1024","1440x900","1920x1080"]),ws=t=>{if(t.length<6)return null;let e=t.reduce((r,o)=>r+o,0)/t.length;if(e<=0)return null;let n=t.reduce((r,o)=>r+(o-e)**2,0)/t.length;return Math.sqrt(n)/e},Wt=t=>{let e=0;return t.clicks>=2&&(e+=.35*(t.teleportClicks/t.clicks),e+=.25*(t.centreClicks/t.clicks),t.pointerMoves===0&&(e+=.15)),t.keyIntervalCv!==null&&t.keyIntervalCv<.15&&(e+=.2),t.insertWithoutKeys>0&&(e+=.15),t.wheelEvents===0&&t.clicks>=3&&(e+=.05),t.vmViewport&&(e+=.1),Math.min(1,e)},Vt=(t={})=>{let{threshold:e=.6,minInteractions:n=3,onDetect:r,acceptUntrustedEvents:o=false}=t,s=E=>E.isTrusted||o,i=t.documentRef??(typeof document>"u"?void 0:document),a={clicks:0,teleportClicks:0,centreClicks:0,keyIntervals:0,keyIntervalCv:null,insertWithoutKeys:0,pointerMoves:0,wheelEvents:0,vmViewport:false},l=Number.NEGATIVE_INFINITY,c=0,d=0,g=[],y=0,w=null,T=i?.defaultView;T&&(a.vmViewport=bs.has(`${T.innerWidth}x${T.innerHeight}`));let m=E=>({class:"screenshot",trust:"detected",confidence:Number(E.toFixed(2)),vendor:null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:I,signals:{vision:true,...a}}),k=()=>{if(w||a.clicks+y<n)return;let E=Wt(a);E>=e&&(w=m(E),r?.(w));},A=E=>{s(E)&&(a.pointerMoves+=1,l=E.timeStamp);},et=[["pointermove",A],["mousemove",A],["wheel",E=>{s(E)&&(a.wheelEvents+=1);}],["click",E=>{if(!s(E))return;let P=E;a.clicks+=1,E.timeStamp-l>400&&(a.teleportClicks+=1);let Fe=P.target instanceof Element?P.target:null;if(Fe&&typeof Fe.getBoundingClientRect=="function"){let ee=Fe.getBoundingClientRect();if(ee.width>8&&ee.height>8){let te=Math.abs(P.clientX-(ee.left+ee.width/2)),ie=Math.abs(P.clientY-(ee.top+ee.height/2));te<=1.5&&ie<=1.5&&(a.centreClicks+=1);}}k();}],["keydown",E=>{if(!s(E))return;let P=E.timeStamp;c&&P-c<1500?(g.push(P-c),g.length>60&&g.shift(),a.keyIntervals=g.length,a.keyIntervalCv=ws(g)):y+=1,c=P,d=P;}],["keyup",()=>k()],["input",E=>{if(!s(E))return;let P=E;P.inputType==="insertText"&&P.data&&P.data.length>1&&E.timeStamp-d>200&&(a.insertWithoutKeys+=1,y+=1,k());}]];for(let[E,P]of et)i?.addEventListener(E,P,{capture:true,passive:true});return {signals:()=>({...a}),score:()=>Wt(a),detected:()=>w,stop:()=>{for(let[E,P]of et)i?.removeEventListener(E,P,{capture:true});}}};var ks=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:I,signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),Bt=()=>{let t=null;return {present(e){let n=qe.safeParse(e);if(!n.success)throw new Ye("invalid_api_key",`Invalid identity claim: ${n.error.issues[0]?.message??"unknown"}`);let r={claim:n.data,identity:ks(n.data)};return t=r,r},clear(){t=null;},preferOver(e){return t?e?Fn(t.identity.trust,e.trust)?t.identity:e:t.identity:e},snapshot(){return t}}};var _s=({detected:t,declared:e,verified:n,linked:r})=>r?"linked":n?"verified":e?"declared":"detected",Ut=t=>{let e=null;for(let n of t)(!e||q[n.trust]>q[e.trust])&&(e=n);return e};var Xn=()=>({name:"bearer",async authenticate(t,e){if(!t.bearerToken)return null;let n=await e.verifyToken?.("bearer",t.bearerToken);return {class:t.classHint??"dom",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"bearer",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:I,signals:{bearer:true,verifiedRemotely:!!n}}}});var Qn=()=>({name:"detection",async authenticate(t){return t.detected??null}});var er=()=>({name:"extensionToken",async authenticate(t,e){if(!t.extensionToken)return null;let n=await e.verifyToken?.("extensionToken",t.extensionToken);return {class:"dom",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"browser-extension",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:I,signals:{extensionToken:true,verifiedRemotely:!!n}}}});var tr=()=>({name:"mtls",async authenticate(t,e){if(!t.xfccHeader)return null;let n=await e.verifyToken?.("mtls",t.xfccHeader);return {class:t.classHint??"webmcp",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"mtls",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:I,signals:{mtls:true,subject:n?.subject??null,verifiedRemotely:!!n,...n?.signals??{}}}}});var nr=()=>({name:"oauth2",async authenticate(t,e){if(!t.oauth2AccessToken)return null;let n=await e.verifyToken?.("oauth2",t.oauth2AccessToken);return {class:t.classHint??"webmcp",trust:n?t.oauth2Subject&&n.trust!=="detected"&&n.trust!=="declared"?"linked":n.trust:"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"oauth2",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:I,signals:{oauth2:true,subject:t.oauth2Subject??null,verifiedRemotely:!!n}}}});var Ts=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:I,signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),rr=()=>({name:"selfDeclaration",async authenticate(t){return t.declaration?Ts(qe.parse(t.declaration)):null}});var or=()=>({name:"sessionLink",async authenticate(t,e){if(!t.sessionLinkToken)return null;let n=await e.verifyToken?.("sessionLink",t.sessionLinkToken);return {class:t.classHint??"screenshot",trust:n?t.linkedUserId&&n.trust!=="detected"&&n.trust!=="declared"?"linked":n.trust:"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"session-link",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:I,signals:{sessionLink:true,linkedUserId:t.linkedUserId??null,verifiedRemotely:!!n}}}});var sr=()=>({name:"sso",async authenticate(t,e){if(!t.ssoIdToken)return null;let n=await e.verifyToken?.("sso",t.ssoIdToken);return {class:t.classHint??"dom",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"sso",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:I,signals:{sso:true,subject:n?.subject??null,verifiedRemotely:!!n,...n?.signals??{}}}}});var ir=()=>({name:"spiffe",async authenticate(t,e){if(!t.spiffeJwt)return null;let n=await e.verifyToken?.("spiffe",t.spiffeJwt),r=n?.vendor==="google";return {class:t.classHint??"webmcp",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"spiffe",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:I,signals:{spiffe:true,spiffeId:n?.subject??null,subject:n?.subject??null,verifiedRemotely:!!n,...r?{googleAgent:true}:{},...n?.signals??{}}}}});var ar=()=>({name:"xAgentHeader",async authenticate(t){if(!t.xAgentHeader)return null;let[e="x-agent",n="dom",r]=t.xAgentHeader.split(";"),o=Ie.safeParse(n);return {class:o.success?o.data:"dom",trust:"declared",confidence:r?1:.8,vendor:e,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:I,signals:{xAgentHeader:true,hasProof:!!r}}}});var cr=new Set(["bearer","extensionToken","sessionLink","oauth2","sso","spiffe","mtls"]),Ss=(t,e,n)=>{if(cr.has(t)&&e.signals?.verifiedRemotely===false){let r=t==="oauth2"&&n.oauth2Subject||t==="sessionLink"&&n.linkedUserId;return {...e,trust:r?"linked":"verified",signals:{...e.signals,compat:"0.6"}}}return t==="xAgentHeader"&&e.signals?.hasProof===true?{...e,trust:"verified",confidence:1,signals:{...e.signals,compat:"0.6"}}:e},Gt=()=>[Qn(),rr(),Xn(),ar(),er(),or(),nr()],lr=()=>[sr(),ir(),tr()],As={detection:"detection",selfDeclaration:"declaration",bearer:"bearer",xAgentHeader:"x-agent-header",extensionToken:"extension",sessionLink:"session-link",oauth2:"oauth2",sso:"sso",spiffe:"spiffe",mtls:"mtls"},Cs=(t,e)=>t==="spiffe"&&e.signals?.googleAgent===true?"google-agent":As[t],zt=({compat:t,methods:e=t==="0.6"?[...Gt(),...lr()]:Gt(),context:n={},onTrace:r,onUnverifiedToken:o}={})=>{let s=false;return {async authenticate(i){let a=[],l={};for(let T of e){let m=await T.authenticate(i,n);l[T.name]=!!m,m&&(cr.has(T.name)&&m.signals?.verifiedRemotely===false&&!n.verifyToken&&!s&&(s=true,o?.(T.name)),t==="0.6"&&(m=Ss(T.name,m,i)),a.push({method:T.name,identity:m}));}let c=Ut(a.map(T=>T.identity)),d=c?a.find(T=>T.identity===c):void 0,g=d?Cs(d.method,d.identity):void 0,y=typeof c?.signals?.subject=="string"?c.signals.subject:void 0,w={type:c?"auth.identity_presented":"sdk.error",agent:c,outcome:c?"success":"error",metadata:{methods:l,...g?{protocol:g}:{},...y?{subject:y}:{}}};return c||(w.error="No auth method produced an identity."),r?.(w),c},methods(){return e.map(i=>i.name)}}};var Ms={identity:null,source:"initial",updatedAt:null},Ft=()=>{let t=Ms,e=new Set,n=()=>{e.size!==0&&e.forEach(r=>r(t));};return {snapshot(){return t},set(r,o){t={identity:r,source:o,updatedAt:new Date().toISOString()},n();},subscribe(r){return e.add(r),()=>{e.delete(r);}}}};var Rs=()=>{let t=new Map;return {read:e=>t.get(e)??null,write:(e,n)=>{t.set(e,n);}}},Is=()=>typeof window>"u"||!window.localStorage?Rs():{read:t=>{try{return window.localStorage.getItem(t)}catch{return null}},write:(t,e)=>{try{window.localStorage.setItem(t,e);}catch{}}},Es=t=>{if(!t)return null;try{let e=JSON.parse(t);if(typeof e=="object"&&e!==null&&Number.isFinite(e.count)&&Number.isFinite(e.resetAt))return e}catch{return null}return null},Kt=(t=Is())=>({consume(e,n,r=Date.now()){let o=`agtx:rate:${e}`,s=Es(t.read(o)),i=s&&s.resetAt>r?s.resetAt:r+n.windowSeconds*1e3,a=s&&s.resetAt>r?s.count+1:1;return t.write(o,JSON.stringify({count:a,resetAt:i})),{allowed:a<=n.max,remaining:Math.max(0,n.max-a),resetAt:i}}});var Os=(t,e)=>t==="*"||t===e?true:t.includes("*")?new RegExp("^"+t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")+"$").test(e):false,Ps=(t,e)=>{let n=t?q[t.trust]:-1,r=q[e.minTrust];return n>=r},Ds=(t,e)=>e.allowedClasses.length===0?true:t?e.allowedClasses.includes(t.class):false,ur="allow",js=(t,e)=>{let n=e?.class??"unknown",r=e?.vendor??"unknown",o=e?.trust??"none";return `${t}:${n}:${r}:${o}`},Zt=(t=[],e={})=>{let n=t.map(o=>Ee.parse(o)),r=e.rateLimiter??Kt();return {set(o){n=o.map(s=>Ee.parse(s));},list(){return [...n]},evaluate({tool:o,identity:s}){for(let i of n)if(Os(i.tool,o)){if(!Ps(s,i))return {decision:"deny",ruleId:i.id,reason:`Rule "${i.id}" requires trust >= ${i.minTrust}.`};if(!Ds(s,i))return {decision:"deny",ruleId:i.id,reason:`Rule "${i.id}" restricts to classes: ${i.allowedClasses.join(", ")}.`};if(i.rateLimit){let a=r.consume(js(o,s),i.rateLimit);if(!a.allowed)return {decision:"deny",ruleId:i.id,reason:`Rule "${i.id}" rate limit exceeded. Resets at ${new Date(a.resetAt).toISOString()}.`}}return {decision:i.decision,ruleId:i.id,reason:`Matched rule "${i.id}".`}}return {decision:ur,ruleId:null,reason:`No rule matched tool "${o}". Falling back to "${ur}".`}}}};var Ht=({gatewayUrl:t,siteId:e,publishableKey:n,fetcher:r=fetch})=>{let o={policies:[],etag:null};return {snapshot(){return {policies:[...o.policies],etag:o.etag}},async sync(){let s=await r(`${t.replace(/\/$/,"")}/v1/pub/sites/${encodeURIComponent(e)}/policies`,{headers:{authorization:`Bearer ${n}`,...o.etag?{"if-none-match":o.etag}:{}}});if(s.status===304)return this.snapshot();if(!s.ok)throw new Error(`Policy sync failed with status ${s.status}.`);let i=await s.json();return o={policies:Ee.array().parse(i.policies??[]),etag:s.headers.get("etag")},this.snapshot()}}};var Jt=({message:t="Agent action blocked by site policy.",durationMs:e=2400,documentRef:n=typeof document>"u"?void 0:document}={})=>{if(!n?.body)return null;let r=n.createElement("div");return r.setAttribute("role","status"),r.setAttribute("data-agentronics-deny-overlay","true"),r.textContent=t,Object.assign(r.style,{position:"fixed",zIndex:"2147483647",left:"50%",bottom:"24px",transform:"translateX(-50%)",maxWidth:"min(520px, calc(100vw - 32px))",padding:"12px 16px",borderRadius:"12px",background:"#0B0B0C",color:"#FFFFFF",border:"2px solid #FF4D1F",font:"13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace"}),n.body.appendChild(r),window.setTimeout(()=>r.remove(),e),r};var qt=({policyEngine:t,getIdentity:e,documentRef:n=typeof document>"u"?void 0:document,selector:r="[data-agentronics-tool]"})=>{if(!n)return {uninstall:()=>{}};let o=s=>{let i=s.target instanceof Element?s.target.closest(r):null;if(!(i instanceof HTMLElement))return;let a=i.dataset.agentronicsTool;a&&Promise.resolve(e()).then(l=>{let c=t.evaluate({tool:a,identity:l});c.decision==="deny"&&(s.preventDefault(),s.stopPropagation(),Jt({message:c.reason,documentRef:n}));});};return n.addEventListener("click",o,true),{uninstall:()=>n.removeEventListener("click",o,true)}};var Yt=()=>{let t=new Map;return {read:e=>t.get(e)??null,write:(e,n)=>{t.set(e,n);},remove:e=>{t.delete(e);},keys:()=>[...t.keys()]}},dr=(t,e)=>({read:n=>{try{return t.getItem(e+n)}catch{return null}},write:(n,r)=>{try{t.setItem(e+n,r);}catch{}},remove:n=>{try{t.removeItem(e+n);}catch{}},keys:()=>{let n=[];try{for(let r=0;r<t.length;r++){let o=t.key(r);o&&o.startsWith(e)&&n.push(o.slice(e.length));}}catch{}return n}}),pr="agtx:",fr=()=>{let t=typeof window<"u",e=t&&typeof window.sessionStorage<"u"?dr(window.sessionStorage,pr+"session:"):Yt(),n=t&&typeof window.localStorage<"u"?dr(window.localStorage,pr+"user:"):Yt();return {session:e,user:n,org:Yt()}};var mr=(t,e)=>t.expiresAt!==null&&t.expiresAt<=e,gr=t=>{if(!t)return null;try{let e=JSON.parse(t);return typeof e!="object"||e===null?null:e}catch{return null}},Ns=t=>JSON.stringify(t),Xt=(t={})=>{let e=fr(),n=l=>{t.onTrace?.(l);};return {get:(l,c={})=>{let d=c.scope??"session",g=e[d],y=gr(g.read(l));if(!y){n({type:"memory.accessed",metadata:{operation:"get",key:l,scope:d,hit:false}});return}if(mr(y,Date.now())){g.remove(l),n({type:"memory.accessed",metadata:{operation:"get",key:l,scope:d,hit:false,expired:true}});return}return n({type:"memory.accessed",metadata:{operation:"get",key:l,scope:d,hit:true}}),y.value},set:(l,c,d={})=>{let g=d.scope??"session",y=d.ttlSeconds??null,w=Date.now(),T={value:c,expiresAt:y===null?null:w+y*1e3,updatedAt:new Date(w).toISOString()};return e[g].write(l,Ns(T)),n({type:"memory.updated",metadata:{operation:"set",key:l,scope:g,ttlSeconds:y}}),Mt.parse({key:l,value:c,scope:g,ttlSeconds:y,updatedAt:T.updatedAt})},remove:(l,c={})=>{let d=c.scope??"session";e[d].remove(l),n({type:"memory.updated",metadata:{operation:"remove",key:l,scope:d}});},list:(l={})=>{let c=l.scope??"session",d=e[c],g=Date.now(),y=[];for(let w of d.keys()){let T=gr(d.read(w));if(T){if(mr(T,g)){d.remove(w);continue}y.push(Mt.parse({key:w,value:T.value,scope:c,ttlSeconds:T.expiresAt===null?null:Math.max(0,Math.round((T.expiresAt-g)/1e3)),updatedAt:T.updatedAt}));}}return n({type:"memory.accessed",metadata:{operation:"list",scope:c,count:y.length}}),y},clear:(l={})=>{let c=l.scope??"session",d=e[c],g=d.keys().length;for(let y of d.keys())d.remove(y);n({type:"memory.updated",metadata:{operation:"clear",scope:c,count:g}});}}};var Qt=t=>V.parse(JSON.parse(JSON.stringify(t))),lt=t=>({...t,updatedAt:new Date().toISOString()}),en=(t={})=>{let e=V.parse({...Zn,...t.initial??{}}),n=null,r=new Set,o=m=>{t.onTrace?.(m);},s=()=>{n=null;},i=()=>{if(r.size===0)return;let m=Qt(e);n=m,r.forEach(k=>k(m));},a=m=>{let k=V.parse({...e,...m,workflows:{...e.workflows,...m.workflows??{}},policies:{...e.policies,...m.policies??{}},uiGuidance:{...e.uiGuidance,...m.uiGuidance??{}},pageContexts:{...e.pageContexts,...m.pageContexts??{}}});return e=lt(k),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"provide",keys:Object.keys(m)}}),i(),d()},l=(m,k)=>{let A=m.split(".").filter(Boolean);if(A.length===0)throw new Error("siteMemory.update() requires a non-empty dot-path.");let D=JSON.parse(JSON.stringify(e)),$=D;for(let G=0;G<A.length-1;G++){let N=A[G],z=$[N];(typeof z!="object"||z===null||Array.isArray(z))&&($[N]={}),$=$[N];}return $[A[A.length-1]]=k,e=lt(V.parse(D)),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"update",path:m}}),i(),d()},c=m=>{let k=Rt.parse({path:m.path,payload:m.payload,updatedAt:new Date().toISOString()});return e=lt({...e,pageContexts:{...e.pageContexts,[m.path]:k}}),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"provideForPage",path:m.path}}),i(),{...k,payload:{...k.payload}}},d=()=>(n||(n=Qt(e)),n);return {provide:a,update:l,provideForPage:c,snapshot:d,get:m=>{if(o({type:"memory.accessed",metadata:{kind:"site",operation:m?"get":"snapshot",path:m??null}}),!m)return Qt(e);let k=m.split(".").filter(Boolean),A=e;for(let D of k){if(typeof A!="object"||A===null)return;A=A[D];}return A},getForPage:m=>{o({type:"memory.accessed",metadata:{kind:"site",operation:"getForPage",path:m}});let k=e.pageContexts[m];return k?{...k,payload:{...k.payload}}:null},replace:m=>(e=lt(V.parse(m)),s(),i(),d()),subscribe:m=>(r.add(m),()=>{r.delete(m);})}};var tn=({gatewayUrl:t,siteId:e,publishableKey:n,fetcher:r=fetch})=>{let o={memory:null,etag:null};return {snapshot(){return {memory:o.memory?V.parse(o.memory):null,etag:o.etag}},async sync(){let s=await r(`${t.replace(/\/$/,"")}/v1/pub/sites/${encodeURIComponent(e)}/memory`,{headers:{authorization:`Bearer ${n}`,...o.etag?{"if-none-match":o.etag}:{}}});if(s.status===304)return this.snapshot();if(!s.ok)throw new Error(`Memory sync failed with status ${s.status}.`);let i=await s.json();return o={memory:V.parse(i.memory??{}),etag:s.headers.get("etag")},this.snapshot()}}};var yr=({toolName:t="getSiteContext",description:e="Returns Agentronics site memory: page map, workflows, policies, UI guidance.",getSnapshot:n,onAccess:r})=>({name:t,description:e,inputSchema:{type:"object",properties:{path:{type:"string",description:'Optional dot-path into the site memory (e.g. "workflows.purchase").'}},required:[]},invoke(o={}){let s=n(),i=o.path??null;if(r?.(i),!i)return {content:s};let a=i.split(".").filter(Boolean),l=s;for(let c of a){if(typeof l!="object"||l===null)return {content:void 0};l=l[c];}return {content:l}}});var de="agent-context-",nn="agentronics-site-context",Ls=t=>{try{return JSON.stringify(t)}catch{return "{}"}},ut=(t,e,n)=>{let r=t.querySelector(`meta[name="${e}"]`);r||(r=t.createElement("meta"),r.setAttribute("name",e),t.head.appendChild(r)),r.setAttribute("content",n);},dt=(t,e)=>{t.querySelectorAll(`meta[name="${e}"]`).forEach(n=>n.remove());},pt=({doc:t=typeof document>"u"?null:document,snapshot:e,schemaType:n="WebSite"})=>{if(!t)return {uninstall:()=>{}};ut(t,`${de}version`,e.version),ut(t,`${de}updated-at`,e.updatedAt??new Date().toISOString()),e.siteMap?.navigation?.flow&&ut(t,`${de}flow`,e.siteMap.navigation.flow),ut(t,`${de}workflows`,Object.keys(e.workflows).join(","));let r=t.getElementById(nn);return r||(r=t.createElement("script"),r.type="application/ld+json",r.id=nn,t.head.appendChild(r)),r.textContent=Ls({"@context":"https://schema.org","@type":n,name:"Agentronics Site Memory",agentronics:e}),{uninstall:()=>{dt(t,`${de}version`),dt(t,`${de}updated-at`),dt(t,`${de}flow`),dt(t,`${de}workflows`),t.getElementById(nn)?.remove();}}};var hr="agentronics-memory-overlay",$s=t=>`
|
|
2
2
|
position: fixed;
|
|
3
3
|
bottom: 16px;
|
|
4
4
|
right: 16px;
|
|
@@ -12,7 +12,7 @@ border-radius: 10px;
|
|
|
12
12
|
z-index: 2147483647;
|
|
13
13
|
opacity: ${t?"0":"1"};
|
|
14
14
|
pointer-events: ${t?"none":"auto"};
|
|
15
|
-
`,hr=t=>{let e=t.siteMap?.pages?.length??0,n=Object.keys(t.workflows).length,r=Object.keys(t.uiGuidance).length;return `Agentronics site memory \xB7 pages:${e} \xB7 workflows:${n} \xB7 ui-hints:${r}`},mt=({doc:t=typeof document>"u"?null:document,snapshot:e,hidden:n=false})=>{if(!t)return {uninstall:()=>{},refresh:()=>{}};let r=t.getElementById(yr);return r||(r=t.createElement("div"),r.id=yr,r.setAttribute("role","note"),r.setAttribute("aria-label","Agentronics site memory summary"),r.setAttribute("data-agent-context","overlay"),t.body.appendChild(r)),r.setAttribute("style",Ns(n)),r.textContent=hr(e),{uninstall:()=>{r?.remove();},refresh:o=>{r&&(r.textContent=hr(o));}}};var rn="/.well-known/agent-context.json",ft=async({origin:t,fetcher:e=fetch,signal:n}={})=>{let r=(t?t.replace(/\/$/,""):typeof window<"u"?window.location.origin:"")+rn;if(!r.startsWith("http"))return null;let o={headers:{accept:"application/json"}};n!==void 0&&(o.signal=n);let s=await e(r,o);if(!s.ok){if(s.status===404)return null;throw new Error(`well-known agent-context fetch failed with status ${s.status}.`)}let i=await s.json();return W.parse(i)},vr=({snapshot:t})=>JSON.stringify(W.parse(t));var on=({evaluate:t,setPolicies:e,listPolicies:n,onTrace:r,identityResolver:o,reviewer:s})=>{let i=new Map,a=new Set,l=c=>{if(!c.authz||!e||!n)return;let u={id:`tool:${c.name}`,tool:c.name,...c.authz,rateLimit:c.rateLimit??c.authz.rateLimit};e([...n().filter(v=>v.id!==u.id),u]);};return {register(c){return i.set(c.name,c),a.delete(c.name),l(c),r?.({type:"tool.registered",tool:c.name,metadata:{version:c.version??null,group:c.group??null,stage:c.stage??null}}),()=>{i.delete(c.name),a.delete(c.name);}},unregister(c){i.delete(c),a.delete(c);},enable(c){!i.has(c)||!a.has(c)||(a.delete(c),r?.({type:"tool.surfaced",tool:c,metadata:{state:"enabled"}}));},disable(c){!i.has(c)||a.has(c)||(a.add(c),r?.({type:"tool.surfaced",tool:c,metadata:{state:"disabled"}}));},isEnabled:c=>i.has(c)&&!a.has(c),list({includeDisabled:c=false}={}){let u=[...i.values()];return c?u:u.filter(v=>!a.has(v.name))},get:c=>i.get(c),async execute(c,u,v,h={}){let T=v===void 0?o?.()??null:v,x=i.get(c);if(!x)throw new Error(`Tool "${c}" is not registered.`);if(a.has(c)){let S={decision:"deny",ruleId:`tool:${c}`,reason:"Tool is disabled."};throw r?.({type:"tool.executed",tool:c,agent:T,policy:S,outcome:"blocked"}),new Error(S.reason)}let g=await t(c,{identity:T});if(g.decision==="deny")throw r?.({type:"tool.executed",tool:c,agent:T,policy:g,outcome:"blocked"}),new Error(g.reason);if(g.decision==="review"){let S={tool:c,input:u,identity:T,reason:g.reason};x.title!==void 0&&(S.title=x.title),x.description!==void 0&&(S.description=x.description);let D=s?await s(S).catch(()=>false):false;if(r?.({type:"authz.evaluated",tool:c,agent:T,policy:g,outcome:D?"success":"blocked",metadata:{review:true,approved:D,reviewer:s?"configured":"none"}}),!D){let U={...g,decision:"deny",reason:s?"The person on the page did not approve this action.":"This action needs review and no reviewer is configured."};throw r?.({type:"tool.executed",tool:c,agent:T,policy:U,outcome:"blocked"}),new Error(U.reason)}g={...g,reason:`${g.reason} Approved by the person on the page.`};}let A=Date.now();try{let S={identity:T};h.signal&&(S.signal=h.signal);let D=await x.execute(u,S);return r?.({type:"tool.executed",tool:c,agent:T,policy:g,outcome:"success",durationMs:Date.now()-A}),D}catch(S){throw r?.({type:"tool.executed",tool:c,agent:T,policy:g,outcome:"error",durationMs:Date.now()-A,error:S instanceof Error?S.message:String(S)}),S}}}};var gt=t=>t===null||typeof t!="object"?JSON.stringify(t):Array.isArray(t)?`[${t.map(gt).join(",")}]`:`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${gt(t[n])}`).join(",")}}`,sn=t=>({name:t.name,...t.title?{title:t.title}:{},description:t.description??t.name,...t.inputSchema?{inputSchema:t.inputSchema}:{},...t.annotations?{annotations:t.annotations}:{}}),an=t=>Math.ceil(gt(sn(t)).length/4),xr=t=>{let e=gt(sn(t)).length;return {name:t.name,characters:e,tokens:Math.ceil(e/4)}},cn=t=>{let e=t.map(xr);return {total:e.reduce((r,o)=>r+o.tokens,0),perTool:e}};var ln=t=>{let e={name:t.name,description:t.description??"",inputSchema:t.inputSchema??{},tokens:0};return t.title&&(e.title=t.title),t.annotations&&(e.annotations={...t.annotations}),t.group&&(e.group=t.group),t.stage&&(e.page=t.stage),t.outputSchema&&(e.outputSchema=t.outputSchema),e.tokens=an(t),e},br=({gatewayUrl:t,siteId:e,publishableKey:n,fetcher:r=fetch})=>({async push(o){let s=o.map(ln),i=await r(`${t.replace(/\/$/,"")}/v1/pub/sites/${encodeURIComponent(e)}/tools`,{method:"PUT",headers:{authorization:`Bearer ${n}`,"content-type":"application/json"},body:JSON.stringify({registry:{tools:s}})});if(!i.ok)throw new Error(`Tool sync failed with status ${i.status}.`);return s.length}});var dn=(t,e={})=>{let n=new Map;for(let i of t.stages)n.set(i.name,i);if(!n.has(t.initial))throw new Error(`Initial stage "${t.initial}" is not declared in progression stages.`);let r=t.initial,o=()=>{let i=n.get(r);return i?.enables?[r,...i.enables]:[r]},s=(i,a)=>{let l=r;if(!n.has(i))throw new Error(`Cannot transition to unknown stage "${i}".`);return i===r?{changed:false,from:l,to:i}:(r=i,e.onTrace?.({type:"tool.progressed",metadata:{from:l,to:i,trigger:a}}),{changed:true,from:l,to:i})};return {current:()=>r,enabledStages:()=>o(),notify(i){let l=n.get(r)?.transitions?.find(c=>c.on===i);return l?s(l.to,i):{changed:false,from:r,to:r}},set(i){return s(i,"manual")},reset(){let i=r;r=t.initial,i!==r&&e.onTrace?.({type:"tool.progressed",metadata:{from:i,to:r,trigger:"reset"}});},snapshot:()=>({current:r,enabled:o()})}};var Ls=(t,e)=>{let n=t.authz?.minTrust;return n?e?q[e.trust]<q[n]?{ok:false,reason:`trust-too-low:${e.trust}<${n}`}:{ok:true,reason:"trust-ok"}:{ok:false,reason:`requires-trust:${n}`}:{ok:true,reason:"no-trust-floor"}},$s=(t,e)=>{let n=t.authz?.allowedClasses??[];return n.length===0?{ok:true,reason:"no-class-restriction"}:e?n.includes(e.class)?{ok:true,reason:"class-ok"}:{ok:false,reason:`class-not-allowed:${e.class}`}:{ok:false,reason:`requires-class:${n.join("|")}`}},Ws=(t,e)=>t.stage?e.enabledStages&&e.enabledStages.includes(t.stage)?{ok:true,reason:`stage-enabled:${t.stage}`}:e.stage===t.stage?{ok:true,reason:`stage-active:${t.stage}`}:{ok:false,reason:`stage-locked:${t.stage}`}:{ok:true,reason:"no-stage"},un=(t,e)=>{let n=Ls(t,e.identity);if(!n.ok)return {tool:t,visible:false,reason:n.reason};let r=$s(t,e.identity);if(!r.ok)return {tool:t,visible:false,reason:r.reason};let o=Ws(t,e);return o.ok?t.authz?.decision==="deny"?{tool:t,visible:false,reason:"authz-deny"}:{tool:t,visible:true,reason:"visible"}:{tool:t,visible:false,reason:o.reason}},pn=(t,e)=>t.filter(n=>un(n,e).visible),mn=(t,e)=>t.map(n=>un(n,e));var fn="default",gn=t=>{let e=new Map;for(let n of t){let r=n.group??fn,o=e.get(r)??[];o.push(n),e.set(r,o);}return [...e.entries()].sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({name:n,tools:r}))},Vs=t=>[...new Set(t.map(e=>e.group??fn))].sort();var Bs=(t,e)=>t==="legacy",Us=(t,e)=>{let n={name:t.name,description:t.description??t.name,execute:(r,{signal:o})=>e(t,r??{},o)};return t.title!==void 0&&(n.title=t.title),t.inputSchema!==void 0&&(n.inputSchema=t.inputSchema),t.annotations!==void 0&&(n.annotations={...t.annotations}),n},yn=(t={})=>{let e=t.invoke??(async(c,u)=>c.execute(u,{identity:null})),n=null,r=null,o=null,s=[],i=()=>{let c=t.modelContext??t.provider;return c?{source:typeof c.registerTool=="function"?"document":"legacy",context:c}:Xe(t.host)},a=()=>{n?.abort(),n=null,r?.revoke(),r=null;},l=c=>{if(o||typeof c.addEventListener!="function")return;let u=h=>Dt("activated",h.toolName??""),v=h=>Dt("cancelled",h.toolName??"");c.addEventListener("toolactivated",u),c.addEventListener("toolcancel",v),o=()=>{c.removeEventListener?.("toolactivated",u),c.removeEventListener?.("toolcancel",v),o=null;};};return {publish(c){let u=i();if(!u)return {revoked:false,registrations:Promise.resolve([])};if(a(),Bs(u.source,u.context))return r=u.context.provideContext({tools:c.map(x=>{let g={name:x.name,invoke:A=>e(x,A)};return x.description!==void 0&&(g.description=x.description),x.inputSchema!==void 0&&(g.inputSchema=x.inputSchema),g})}),s=c.map(x=>({name:x.name,status:"callable"})),{revoked:true,registrations:Promise.resolve(s)};let v=u.context;l(v);let h=new AbortController;return n=h,{revoked:true,registrations:Promise.all(c.map(async x=>{try{let g={signal:h.signal};return x.exposedTo?.length&&(g.exposedTo=x.exposedTo),await v.registerTool(Us(x,e),g),{name:x.name,status:"callable"}}catch(g){return {name:x.name,status:"failed",error:g instanceof Error?`${g.name}: ${g.message}`:String(g)}}})).then(x=>(n===h&&(s=x),x))}},revoke(){a(),o?.(),s=[];},available:()=>!!i(),source:()=>i()?.source??null,status:()=>[...s]}};var Gs=t=>t===null||typeof t!="object"?"":Object.entries(t).slice(0,6).map(([n,r])=>`${n}: ${typeof r=="string"?r:JSON.stringify(r)}`.slice(0,90)).join(`
|
|
16
|
-
`),hn=({documentRef:t=typeof document>"u"?void 0:document,timeoutMs:e=12e4}={})=>n=>new Promise(r=>{if(!t?.body)return r(false);let o=t,s=o.createElement("div");s.setAttribute("data-agentronics-review","true"),Object.assign(s.style,{position:"fixed",inset:"0",zIndex:"2147483647",background:"rgba(11,11,12,0.45)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"});let i=o.createElement("div");i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-label","Approve agent action"),Object.assign(i.style,{width:"min(440px, 100%)",background:"#FFFFFF",color:"#0B0B0C",border:"2px solid #0B0B0C",borderRadius:"16px",padding:"20px",boxShadow:"8px 8px 0 #0B0B0C",font:"14px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif"});let a=o.createElement("div");a.style.fontWeight="700",a.style.fontSize="16px";let l=n.identity?.vendor??"An AI agent";a.textContent=`${l} wants to ${n.title??n.tool}`;let c=o.createElement("div");c.style.margin="8px 0 0",c.style.color="rgba(11,11,12,0.65)",c.textContent=n.description??"Allow this action on your behalf?";let u=o.createElement("pre"),v=Gs(n.input);Object.assign(u.style,{display:v?"block":"none",margin:"12px 0 0",padding:"10px 12px",background:"rgba(11,11,12,0.06)",borderRadius:"10px",fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",whiteSpace:"pre-wrap",overflowWrap:"anywhere"}),u.textContent=v;let h=o.createElement("div");Object.assign(h.style,{display:"flex",gap:"8px",justifyContent:"flex-end",marginTop:"16px"});let T=(G,N)=>{let z=o.createElement("button");return z.type="button",z.textContent=G,Object.assign(z.style,{padding:"9px 16px",borderRadius:"10px",border:"2px solid #0B0B0C",background:N?"#D4FF3A":"#FFFFFF",color:"#0B0B0C",boxShadow:N?"3px 3px 0 #0B0B0C":"none",font:"inherit",fontWeight:"650",cursor:"pointer"}),z},x=T("Not now",false),g=T("Allow",true);h.append(x,g),i.append(a,c,u,h),s.append(i);let A=false,S=G=>{A||(A=true,clearTimeout(U),o.removeEventListener("keydown",D,true),s.remove(),r(G));},D=G=>{G.key==="Escape"&&S(false);},U=setTimeout(()=>S(false),e);g.addEventListener("click",()=>S(true)),x.addEventListener("click",()=>S(false)),o.addEventListener("keydown",D,true),o.body.appendChild(s),g.focus();});var yt=(t=500)=>{let e=[];return {add(n){e.push(n),e.length>t&&e.splice(0,e.length-t);},list(){return [...e]},clear(){e.length=0;}}};var wr=(t,e)=>t===void 0?e:Math.max(0,Math.min(1,t)),vn=(t={})=>{let e=wr(t.traceRate,1),n=wr(t.errorRate,1),r=t.random??Math.random;return {shouldKeep(o){let s=o.outcome==="error"?n:e;return r()<s}}};var zs="[REDACTED]",Fs=t=>{if(t!==void 0)return JSON.parse(JSON.stringify(t))},xn=(t,e)=>{if(e.length===0||typeof t!="object"||t===null)return;let[n,...r]=e;if(!n)return;if(Array.isArray(t)){for(let s of t)xn(s,e);return}let o=t;if(n in o){if(r.length===0){o[n]=zs;return}xn(o[n],r);}},bn=(t,e=[])=>{if(e.length===0)return t;let n=Fs(t);for(let r of e)xn(n,r.split(".").filter(Boolean));return n},wn=["metadata.password","metadata.token","metadata.authorization","metadata.cookie"];var Ks=()=>typeof location<"u"&&typeof location.pathname=="string"?location.pathname:void 0,kr=t=>{let e=globalThis.crypto;return e&&"randomUUID"in e?`${t}_${e.randomUUID()}`:`${t}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`},ht=({siteId:t,bufferSize:e,sessionId:n=kr("ses"),scrubPaths:r=wn,exporters:o=[],onExporterError:s,pageProvider:i=Ks,...a})=>{let l=yt(e),c=vn(a),u=()=>{try{return i()}catch{return}};return {sessionId:n,async emit(v){let h={...v.metadata};if(h.page===void 0){let x=u();x!==void 0&&(h.page=x);}let T=Mt.parse(bn({id:kr("trc"),siteId:t,sessionId:n,occurredAt:new Date().toISOString(),outcome:v.outcome??"success",...v,metadata:h},r));return c.shouldKeep(T)?(l.add(T),await Promise.all(o.map(async x=>{try{await x.export([T]);}catch(g){s?.(g,x,T);}})),T):null},list:()=>l.list(),clear:()=>l.clear()}};var vt=()=>({name:"console",export(t){for(let e of t)console.info("[agentronics:trace]",e.type,e);}});var xt=({gatewayUrl:t,publishableKey:e,fetcher:n=fetch})=>({name:"gateway",async export(r){let o={publishableKey:e,events:r};await n(`${t.replace(/\/$/,"")}/v1/pub/traces`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify(o)});}});var Zs=t=>new Promise(e=>setTimeout(e,t)),bt=({url:t,fetcher:e=fetch,maxRetries:n=2,queueLimit:r=500})=>({name:"webhook",async export(o){let i=[...Hs(t),...o].slice(-r),a=0;for(;;){let l=await e(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:i})});if(l.ok){_r(t,[]);return}if(a>=n)throw _r(t,i),new Error(`Webhook exporter failed with status ${l.status}.`);a+=1,await Zs(100*a);}}}),kn=t=>`agtx:webhook:${t}`,Hs=t=>{if(typeof window>"u"||!window.localStorage)return [];try{let e=window.localStorage.getItem(kn(t));return e?JSON.parse(e):[]}catch{return []}},_r=(t,e)=>{if(!(typeof window>"u"||!window.localStorage))try{if(e.length===0){window.localStorage.removeItem(kn(t));return}window.localStorage.setItem(kn(t),JSON.stringify(e));}catch{}};var Tr="/v1/sdk/events",_n=({url:t,ingestKey:e,fetcher:n=fetch})=>{let r=t.replace(/\/$/,""),o=r.endsWith(Tr)?r:`${r}${Tr}`;return {name:"intel",async export(s){let i={events:s},a=await n(o,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify(i)});if(!a.ok)throw new Error(`Intel exporter failed with status ${a.status}.`)}}},Tn=({url:t,ingestKey:e,siteId:n,fetcher:r=fetch})=>{let o=t.replace(/\/$/,""),s=async(l,c)=>{let u=await r(`${o}${l}`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify(c)});if(!u.ok)throw new Error(`Intel sync ${l} failed with status ${u.status}.`);return u},i=async(l,c)=>{await s(l,c);},a=new Map;return {async pushTools(l){let c=l.map(ln);return await i("/v1/sdk/tools",{siteId:n,tools:c}),c.length},async pushMemory(l,c){await i("/v1/sdk/memory",{siteId:n,snapshot:l,...typeof c=="number"?{score:c}:{}});},async pullConfig(){let l=await(await s("/v1/sdk/config",{siteId:n})).json();return {policies:Array.isArray(l.policies)?l.policies:[],toolDescriptions:l.toolDescriptions&&typeof l.toolDescriptions=="object"?l.toolDescriptions:{},siteMemory:l.siteMemory&&typeof l.siteMemory=="object"?l.siteMemory:null,fetchedAt:typeof l.fetchedAt=="string"?l.fetchedAt:new Date().toISOString()}},keyVerifier({cacheSeconds:l=60}={}){return async c=>{let u=a.get(c);if(u&&u.until>Date.now())return u.value;let v=null;try{let h=await(await s("/v1/sdk/agent-keys/verify",{key:c})).json();h.valid&&h.agentId&&(v={agentId:h.agentId},h.name&&(v.name=h.name),h.vendor&&(v.vendor=h.vendor));}catch{return u?u.value:null}return a.size>5e3&&a.delete(a.keys().next().value),a.set(c,{value:v,until:Date.now()+l*1e3}),v}}}},Sr=_n,Ar=Tn;var Qe="https://api.agentronics.dev",Js="https://gateway.agentronics.dev",qs=t=>{if(t===void 0||t.replace(/\/$/,"")===Qe||t.replace(/\/$/,"")===Js)return Qe;let e;try{e=new URL(t);}catch{throw new Error(`Agentronics SDK: \`gatewayUrl\` is not a valid URL: ${t}`)}if(e.hostname==="localhost"||e.hostname==="127.0.0.1")return t;throw new Error(`Agentronics SDK does not support custom API URLs. Omit \`gatewayUrl\` to use the canonical ${Qe}. The only accepted override is a localhost / 127.0.0.1 URL for local development. Got: ${t}`)},Cr=t=>{let{publishableKey:e,siteId:n="default",debug:r=false,policies:o=[],trace:s={}}=t,i=qs(t.gatewayUrl),a=Gn(e);if(a==="secret")throw new Ye("wrong_key_kind","A secret key was passed to Agentronics.init(). Browser code must use a publishable key (agtx_pk_*).");if(a!=="publishable")throw new Ye("invalid_api_key",`Agentronics.init() expected a key starting with "${Be}".`);let l=s.enabled??true,c=[...r?[vt()]:[],...s.gateway?[xt({gatewayUrl:i,publishableKey:e})]:[],...s.webhookUrl?[bt({url:s.webhookUrl})]:[],...s.exporters??[]],u={siteId:n,exporters:l?c:[],onExporterError:(p,b)=>{r&&console.warn(`[agentronics] trace exporter "${b.name}" failed`,p);}};s.bufferSize!==void 0&&(u.bufferSize=s.bufferSize),s.traceRate!==void 0&&(u.traceRate=s.traceRate),s.errorRate!==void 0&&(u.errorRate=s.errorRate),s.scrubPaths!==void 0&&(u.scrubPaths=s.scrubPaths);let v=ht(u),h=p=>{l&&v.emit(p);},T=Bt(),x={onTrace:h};t.auth!==void 0&&(x.context=t.auth),t.compat==="0.6"&&(x.compat="0.6",console.warn("[agentronics] compat: '0.6' is on \u2014 unverified tokens are trusted and review rules run without asking. Remove it once you have upgraded: https://agentronics.dev/docs/guides/upgrade-0-7")),x.onUnverifiedToken=p=>{t.compat!=="0.6"&&console.warn(`[agentronics] A ${p} credential was presented but nothing verifies it, so the agent is 'declared', not 'verified'. Wire auth.verifyToken to your backend: https://agentronics.dev/docs/auth/overview#in-the-browser`);};let g=zt(x),A=Ft(),S=Zt(o),D=Ht({gatewayUrl:i,siteId:n,publishableKey:e}),U=Xt({onTrace:h}),G={onTrace:h};t.siteMemory!==void 0&&(G.initial=t.siteMemory);let N=en(G),z=tn({gatewayUrl:i,siteId:n,publishableKey:e}),et=br({gatewayUrl:i,siteId:n,publishableKey:e}),E=async p=>{let b=Date.now(),O=await ct(p),$=T.preferOver(O);return l&&await v.emit({type:$?"agent.detected":"agent.missed",agent:$,durationMs:Date.now()-b,metadata:{detectedClass:O?.class??null,presented:T.snapshot()!==null}}),A.set($,"detect"),$},P=async(p,b={})=>{let O=Date.now(),$=b.identity!==void 0?b.identity:await E(),H=S.evaluate({tool:p,identity:$});return l&&await v.emit({type:"authz.evaluated",tool:p,agent:$,policy:H,outcome:H.decision==="deny"?"blocked":"success",durationMs:Date.now()-O}),H},Fe=async()=>true,ee=t.review===false?void 0:t.review??(t.compat==="0.6"?Fe:typeof document>"u"?void 0:hn()),te=on({evaluate:P,...ee?{reviewer:ee}:{},setPolicies:p=>S.set(p),listPolicies:()=>S.list(),onTrace:h,identityResolver:()=>A.snapshot().identity});for(let p of t.tools??[])te.register(p);let ie=t.progression?dn(t.progression,{onTrace:h}):null,Sn=p=>{let b={identity:p};return ie&&(b.stage=ie.current(),b.enabledStages=ie.enabledStages()),b},An={...t.toolDescriptions??{}},Ir=p=>p.map(b=>{let O=An[b.name];return O?{...b,description:O}:b}),pe=p=>Ir(pn(te.list(),Sn(p))),Cn=p=>{An={...p},me!==null&&(me=null,wt(pe(A.snapshot().identity)));},me=null,In=p=>p.map(b=>b.name).sort().join(`
|
|
17
|
-
`),wt=p=>{let
|
|
15
|
+
`,vr=t=>{let e=t.siteMap?.pages?.length??0,n=Object.keys(t.workflows).length,r=Object.keys(t.uiGuidance).length;return `Agentronics site memory \xB7 pages:${e} \xB7 workflows:${n} \xB7 ui-hints:${r}`},ft=({doc:t=typeof document>"u"?null:document,snapshot:e,hidden:n=false})=>{if(!t)return {uninstall:()=>{},refresh:()=>{}};let r=t.getElementById(hr);return r||(r=t.createElement("div"),r.id=hr,r.setAttribute("role","note"),r.setAttribute("aria-label","Agentronics site memory summary"),r.setAttribute("data-agent-context","overlay"),t.body.appendChild(r)),r.setAttribute("style",$s(n)),r.textContent=vr(e),{uninstall:()=>{r?.remove();},refresh:o=>{r&&(r.textContent=vr(o));}}};var rn="/.well-known/agent-context.json",mt=async({origin:t,fetcher:e=fetch,signal:n}={})=>{let r=(t?t.replace(/\/$/,""):typeof window<"u"?window.location.origin:"")+rn;if(!r.startsWith("http"))return null;let o={headers:{accept:"application/json"}};n!==void 0&&(o.signal=n);let s=await e(r,o);if(!s.ok){if(s.status===404)return null;throw new Error(`well-known agent-context fetch failed with status ${s.status}.`)}let i=await s.json();return V.parse(i)},xr=({snapshot:t})=>JSON.stringify(V.parse(t));var on=({evaluate:t,setPolicies:e,listPolicies:n,onTrace:r,identityResolver:o,reviewer:s})=>{let i=new Map,a=new Set,l=c=>{if(!c.authz||!e||!n)return;let d={id:`tool:${c.name}`,tool:c.name,...c.authz,rateLimit:c.rateLimit??c.authz.rateLimit};e([...n().filter(g=>g.id!==d.id),d]);};return {register(c){return i.set(c.name,c),a.delete(c.name),l(c),r?.({type:"tool.registered",tool:c.name,metadata:{version:c.version??null,group:c.group??null,stage:c.stage??null}}),()=>{i.delete(c.name),a.delete(c.name);}},unregister(c){i.delete(c),a.delete(c);},enable(c){!i.has(c)||!a.has(c)||(a.delete(c),r?.({type:"tool.surfaced",tool:c,metadata:{state:"enabled"}}));},disable(c){!i.has(c)||a.has(c)||(a.add(c),r?.({type:"tool.surfaced",tool:c,metadata:{state:"disabled"}}));},isEnabled:c=>i.has(c)&&!a.has(c),list({includeDisabled:c=false}={}){let d=[...i.values()];return c?d:d.filter(g=>!a.has(g.name))},get:c=>i.get(c),async execute(c,d,g,y={}){let w=g===void 0?o?.()??null:g,T=i.get(c);if(!T)throw new Error(`Tool "${c}" is not registered.`);if(a.has(c)){let A={decision:"deny",ruleId:`tool:${c}`,reason:"Tool is disabled."};throw r?.({type:"tool.executed",tool:c,agent:w,policy:A,outcome:"blocked"}),new Error(A.reason)}let m=await t(c,{identity:w});if(m.decision==="deny")throw r?.({type:"tool.executed",tool:c,agent:w,policy:m,outcome:"blocked"}),new Error(m.reason);if(m.decision==="review"){let A={tool:c,input:d,identity:w,reason:m.reason};T.title!==void 0&&(A.title=T.title),T.description!==void 0&&(A.description=T.description);let D=s?await s(A).catch(()=>false):false;if(r?.({type:"authz.evaluated",tool:c,agent:w,policy:m,outcome:D?"success":"blocked",metadata:{review:true,approved:D,reviewer:s?"configured":"none"}}),!D){let $={...m,decision:"deny",reason:s?"The person on the page did not approve this action.":"This action needs review and no reviewer is configured."};throw r?.({type:"tool.executed",tool:c,agent:w,policy:$,outcome:"blocked"}),new Error($.reason)}m={...m,reason:`${m.reason} Approved by the person on the page.`};}let k=Date.now();try{let A={identity:w};y.signal&&(A.signal=y.signal);let D=await T.execute(d,A);return r?.({type:"tool.executed",tool:c,agent:w,policy:m,outcome:"success",durationMs:Date.now()-k}),D}catch(A){throw r?.({type:"tool.executed",tool:c,agent:w,policy:m,outcome:"error",durationMs:Date.now()-k,error:A instanceof Error?A.message:String(A)}),A}}}};var gt=t=>t===null||typeof t!="object"?JSON.stringify(t):Array.isArray(t)?`[${t.map(gt).join(",")}]`:`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${gt(t[n])}`).join(",")}}`,sn=t=>({name:t.name,...t.title?{title:t.title}:{},description:t.description??t.name,...t.inputSchema?{inputSchema:t.inputSchema}:{},...t.annotations?{annotations:t.annotations}:{}}),an=t=>Math.ceil(gt(sn(t)).length/4),br=t=>{let e=gt(sn(t)).length;return {name:t.name,characters:e,tokens:Math.ceil(e/4)}},cn=t=>{let e=t.map(br);return {total:e.reduce((r,o)=>r+o.tokens,0),perTool:e}};var ln=t=>{let e={name:t.name,description:t.description??"",inputSchema:t.inputSchema??{},tokens:0};return t.title&&(e.title=t.title),t.annotations&&(e.annotations={...t.annotations}),t.group&&(e.group=t.group),t.stage&&(e.page=t.stage),t.outputSchema&&(e.outputSchema=t.outputSchema),e.tokens=an(t),e},wr=({gatewayUrl:t,siteId:e,publishableKey:n,fetcher:r=fetch})=>({async push(o){let s=o.map(ln),i=await r(`${t.replace(/\/$/,"")}/v1/pub/sites/${encodeURIComponent(e)}/tools`,{method:"PUT",headers:{authorization:`Bearer ${n}`,"content-type":"application/json"},body:JSON.stringify({registry:{tools:s}})});if(!i.ok)throw new Error(`Tool sync failed with status ${i.status}.`);return s.length}});var un=(t,e={})=>{let n=new Map;for(let i of t.stages)n.set(i.name,i);if(!n.has(t.initial))throw new Error(`Initial stage "${t.initial}" is not declared in progression stages.`);let r=t.initial,o=()=>{let i=n.get(r);return i?.enables?[r,...i.enables]:[r]},s=(i,a)=>{let l=r;if(!n.has(i))throw new Error(`Cannot transition to unknown stage "${i}".`);return i===r?{changed:false,from:l,to:i}:(r=i,e.onTrace?.({type:"tool.progressed",metadata:{from:l,to:i,trigger:a}}),{changed:true,from:l,to:i})};return {current:()=>r,enabledStages:()=>o(),notify(i){let l=n.get(r)?.transitions?.find(c=>c.on===i);return l?s(l.to,i):{changed:false,from:r,to:r}},set(i){return s(i,"manual")},reset(){let i=r;r=t.initial,i!==r&&e.onTrace?.({type:"tool.progressed",metadata:{from:i,to:r,trigger:"reset"}});},snapshot:()=>({current:r,enabled:o()})}};var Ws=(t,e)=>{let n=t.authz?.minTrust;return n?e?q[e.trust]<q[n]?{ok:false,reason:`trust-too-low:${e.trust}<${n}`}:{ok:true,reason:"trust-ok"}:{ok:false,reason:`requires-trust:${n}`}:{ok:true,reason:"no-trust-floor"}},Vs=(t,e)=>{let n=t.authz?.allowedClasses??[];return n.length===0?{ok:true,reason:"no-class-restriction"}:e?n.includes(e.class)?{ok:true,reason:"class-ok"}:{ok:false,reason:`class-not-allowed:${e.class}`}:{ok:false,reason:`requires-class:${n.join("|")}`}},Bs=(t,e)=>t.stage?e.enabledStages&&e.enabledStages.includes(t.stage)?{ok:true,reason:`stage-enabled:${t.stage}`}:e.stage===t.stage?{ok:true,reason:`stage-active:${t.stage}`}:{ok:false,reason:`stage-locked:${t.stage}`}:{ok:true,reason:"no-stage"},dn=(t,e)=>{let n=Ws(t,e.identity);if(!n.ok)return {tool:t,visible:false,reason:n.reason};let r=Vs(t,e.identity);if(!r.ok)return {tool:t,visible:false,reason:r.reason};let o=Bs(t,e);return o.ok?t.authz?.decision==="deny"?{tool:t,visible:false,reason:"authz-deny"}:{tool:t,visible:true,reason:"visible"}:{tool:t,visible:false,reason:o.reason}},pn=(t,e)=>t.filter(n=>dn(n,e).visible),fn=(t,e)=>t.map(n=>dn(n,e));var mn="default",gn=t=>{let e=new Map;for(let n of t){let r=n.group??mn,o=e.get(r)??[];o.push(n),e.set(r,o);}return [...e.entries()].sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({name:n,tools:r}))},Us=t=>[...new Set(t.map(e=>e.group??mn))].sort();var Gs=(t,e)=>t==="legacy",yn=3e4,zs=t=>{let e=t;if(typeof e=="string")try{e=JSON.parse(e);}catch{return {}}return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}},Fs=async t=>{if(t===void 0)return {ok:true};if(typeof Response<"u"&&t instanceof Response){let e=await t.text().catch(()=>""),n=e;try{n=JSON.parse(e);}catch{}return t.ok?n:{error:`Request failed (${t.status})`,detail:typeof n=="string"?n.slice(0,2e3):n}}try{return JSON.parse(JSON.stringify(t))??null}catch{return String(t)}},kr=async(t,e,n,r=yn)=>{let o=new AbortController,s=false,i,a=()=>o.abort(n?.reason),l=new Promise((c,d)=>{a=()=>{o.abort(n?.reason),d(n?.reason??new DOMException("The agent cancelled the call.","AbortError"));},n?.aborted?a():n?.addEventListener?.("abort",a,{once:true}),r>0&&(i=setTimeout(()=>{s=true,o.abort(),d(new Error("timeout"));},r));});try{let c=await Promise.race([(async()=>t(zs(e),o.signal))(),l]);return await Fs(c)}catch(c){if(s)return {error:`The tool didn't finish within ${Math.round(r/1e3)} s.`,hint:"Try again, or with narrower arguments."};if(n?.aborted)throw c;return {error:c instanceof Error?c.message:String(c)}}finally{i!==void 0&&clearTimeout(i),n?.removeEventListener?.("abort",a);}},Ks=(t,e,n=yn)=>{let r={name:t.name,description:t.description||t.name,execute:(o,s)=>kr((i,a)=>e(t,i,a),o,s?.signal,n)};return t.title!==void 0&&(r.title=t.title),t.inputSchema!==void 0&&(r.inputSchema=t.inputSchema),t.annotations!==void 0&&(r.annotations={...t.annotations}),r},hn=(t={})=>{let e=t.invoke??(async(d,g,y)=>d.execute(g,y?{identity:null,signal:y}:{identity:null})),n=t.toolTimeoutMs??yn,r=null,o=null,s=null,i=[],a=()=>{let d=t.modelContext??t.provider;return d?{source:typeof d.registerTool=="function"?"document":"legacy",context:d}:Xe(t.host)},l=()=>{r?.abort(),r=null,o?.revoke(),o=null;},c=d=>{if(s||typeof d.addEventListener!="function")return;let g=w=>Dt("activated",w.toolName??""),y=w=>Dt("cancelled",w.toolName??"");d.addEventListener("toolactivated",g),d.addEventListener("toolcancel",y),s=()=>{d.removeEventListener?.("toolactivated",g),d.removeEventListener?.("toolcancel",y),s=null;};};return {publish(d){let g=a();if(!g)return {revoked:false,registrations:Promise.resolve([])};if(l(),Gs(g.source,g.context))return o=g.context.provideContext({tools:d.map(m=>{let k={name:m.name,invoke:A=>kr((D,$)=>e(m,D,$),A,void 0,n)};return m.description!==void 0&&(k.description=m.description),m.inputSchema!==void 0&&(k.inputSchema=m.inputSchema),k})}),i=d.map(m=>({name:m.name,status:"callable"})),{revoked:true,registrations:Promise.resolve(i)};let y=g.context;c(y);let w=new AbortController;return r=w,{revoked:true,registrations:Promise.all(d.map(async m=>{try{let k={signal:w.signal};return m.exposedTo?.length&&(k.exposedTo=m.exposedTo),await y.registerTool(Ks(m,e,n),k),{name:m.name,status:"callable"}}catch(k){return {name:m.name,status:"failed",error:k instanceof Error?`${k.name}: ${k.message}`:String(k)}}})).then(m=>(r===w&&(i=m),m))}},revoke(){l(),s?.(),i=[];},available:()=>!!a(),source:()=>a()?.source??null,status:()=>[...i]}};var Zs=t=>t===null||typeof t!="object"?"":Object.entries(t).slice(0,6).map(([n,r])=>`${n}: ${typeof r=="string"?r:JSON.stringify(r)}`.slice(0,90)).join(`
|
|
16
|
+
`),vn=({documentRef:t=typeof document>"u"?void 0:document,timeoutMs:e=12e4}={})=>n=>new Promise(r=>{if(!t?.body)return r(false);let o=t,s=o.createElement("div");s.setAttribute("data-agentronics-review","true"),Object.assign(s.style,{position:"fixed",inset:"0",zIndex:"2147483647",background:"rgba(11,11,12,0.45)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"});let i=o.createElement("div");i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-label","Approve agent action"),Object.assign(i.style,{width:"min(440px, 100%)",background:"#FFFFFF",color:"#0B0B0C",border:"2px solid #0B0B0C",borderRadius:"16px",padding:"20px",boxShadow:"8px 8px 0 #0B0B0C",font:"14px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif"});let a=o.createElement("div");a.style.fontWeight="700",a.style.fontSize="16px";let l=n.identity?.vendor??"An AI agent";a.textContent=`${l} wants to ${n.title??n.tool}`;let c=o.createElement("div");c.style.margin="8px 0 0",c.style.color="rgba(11,11,12,0.65)",c.textContent=n.description??"Allow this action on your behalf?";let d=o.createElement("pre"),g=Zs(n.input);Object.assign(d.style,{display:g?"block":"none",margin:"12px 0 0",padding:"10px 12px",background:"rgba(11,11,12,0.06)",borderRadius:"10px",fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",whiteSpace:"pre-wrap",overflowWrap:"anywhere"}),d.textContent=g;let y=o.createElement("div");Object.assign(y.style,{display:"flex",gap:"8px",justifyContent:"flex-end",marginTop:"16px"});let w=(G,N)=>{let z=o.createElement("button");return z.type="button",z.textContent=G,Object.assign(z.style,{padding:"9px 16px",borderRadius:"10px",border:"2px solid #0B0B0C",background:N?"#D4FF3A":"#FFFFFF",color:"#0B0B0C",boxShadow:N?"3px 3px 0 #0B0B0C":"none",font:"inherit",fontWeight:"650",cursor:"pointer"}),z},T=w("Not now",false),m=w("Allow",true);y.append(T,m),i.append(a,c,d,y),s.append(i);let k=false,A=G=>{k||(k=true,clearTimeout($),o.removeEventListener("keydown",D,true),s.remove(),r(G));},D=G=>{G.key==="Escape"&&A(false);},$=setTimeout(()=>A(false),e);m.addEventListener("click",()=>A(true)),T.addEventListener("click",()=>A(false)),o.addEventListener("keydown",D,true),o.body.appendChild(s),m.focus();});var yt=(t=500)=>{let e=[];return {add(n){e.push(n),e.length>t&&e.splice(0,e.length-t);},list(){return [...e]},clear(){e.length=0;}}};var _r=(t,e)=>t===void 0?e:Math.max(0,Math.min(1,t)),xn=(t={})=>{let e=_r(t.traceRate,1),n=_r(t.errorRate,1),r=t.random??Math.random;return {shouldKeep(o){let s=o.outcome==="error"?n:e;return r()<s}}};var Hs="[REDACTED]",Js=t=>{if(t!==void 0)return JSON.parse(JSON.stringify(t))},bn=(t,e)=>{if(e.length===0||typeof t!="object"||t===null)return;let[n,...r]=e;if(!n)return;if(Array.isArray(t)){for(let s of t)bn(s,e);return}let o=t;if(n in o){if(r.length===0){o[n]=Hs;return}bn(o[n],r);}},wn=(t,e=[])=>{if(e.length===0)return t;let n=Js(t);for(let r of e)bn(n,r.split(".").filter(Boolean));return n},kn=["metadata.password","metadata.token","metadata.authorization","metadata.cookie"];var qs=()=>typeof location<"u"&&typeof location.pathname=="string"?location.pathname:void 0,Tr=t=>{let e=globalThis.crypto;return e&&"randomUUID"in e?`${t}_${e.randomUUID()}`:`${t}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`},ht=({siteId:t,bufferSize:e,sessionId:n=Tr("ses"),scrubPaths:r=kn,exporters:o=[],onExporterError:s,pageProvider:i=qs,...a})=>{let l=yt(e),c=xn(a),d=()=>{try{return i()}catch{return}};return {sessionId:n,async emit(g){let y={...g.metadata};if(y.page===void 0){let T=d();T!==void 0&&(y.page=T);}let w=It.parse(wn({id:Tr("trc"),siteId:t,sessionId:n,occurredAt:new Date().toISOString(),outcome:g.outcome??"success",...g,metadata:y},r));return c.shouldKeep(w)?(l.add(w),await Promise.all(o.map(async T=>{try{await T.export([w]);}catch(m){s?.(m,T,w);}})),w):null},list:()=>l.list(),clear:()=>l.clear()}};var vt=()=>({name:"console",export(t){for(let e of t)console.info("[agentronics:trace]",e.type,e);}});var xt=({gatewayUrl:t,publishableKey:e,fetcher:n,flushMs:r=2e3,maxBatch:o=50,maxQueue:s=500})=>{let i=`${t.replace(/\/$/,"")}/v1/pub/traces`,a=Math.max(1,Math.min(100,o)),l=[],c=null,d=(y,w)=>{let T=n??(typeof fetch=="function"?fetch:null);if(!T)return Promise.resolve();let m={publishableKey:e,events:y};try{return Promise.resolve(T(i,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify(m),...w?{keepalive:!0}:{}})).then(()=>{},()=>{})}catch{return Promise.resolve()}},g=(y=false)=>{c!==null&&(clearTimeout(c),c=null);let w=[];for(;l.length;)w.push(d(l.splice(0,a),y));return Promise.all(w).then(()=>{})};return typeof document<"u"&&typeof document.addEventListener=="function"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&g(true);}),typeof addEventListener=="function"&&addEventListener("pagehide",()=>{g(true);}),{name:"gateway",export(y){l.push(...y),l.length>s&&(l=l.slice(l.length-s)),l.length>=a?g():c===null&&(c=setTimeout(()=>{g();},r));},flush:g}};var Ys=t=>new Promise(e=>setTimeout(e,t)),bt=({url:t,fetcher:e=fetch,maxRetries:n=2,queueLimit:r=500})=>({name:"webhook",async export(o){let i=[...Xs(t),...o].slice(-r),a=0;for(;;){let l=await e(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:i})});if(l.ok){Sr(t,[]);return}if(a>=n)throw Sr(t,i),new Error(`Webhook exporter failed with status ${l.status}.`);a+=1,await Ys(100*a);}}}),_n=t=>`agtx:webhook:${t}`,Xs=t=>{if(typeof window>"u"||!window.localStorage)return [];try{let e=window.localStorage.getItem(_n(t));return e?JSON.parse(e):[]}catch{return []}},Sr=(t,e)=>{if(!(typeof window>"u"||!window.localStorage))try{if(e.length===0){window.localStorage.removeItem(_n(t));return}window.localStorage.setItem(_n(t),JSON.stringify(e));}catch{}};var Ar="/v1/sdk/events",Tn=({url:t,ingestKey:e,fetcher:n=fetch})=>{let r=t.replace(/\/$/,""),o=r.endsWith(Ar)?r:`${r}${Ar}`;return {name:"intel",async export(s){let i={events:s},a=await n(o,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify(i)});if(!a.ok)throw new Error(`Intel exporter failed with status ${a.status}.`)}}},Sn=({url:t,ingestKey:e,siteId:n,fetcher:r=fetch})=>{let o=t.replace(/\/$/,""),s=async(l,c)=>{let d=await r(`${o}${l}`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify(c)});if(!d.ok)throw new Error(`Intel sync ${l} failed with status ${d.status}.`);return d},i=async(l,c)=>{await s(l,c);},a=new Map;return {async pushTools(l){let c=l.map(ln);return await i("/v1/sdk/tools",{siteId:n,tools:c}),c.length},async pushMemory(l,c){await i("/v1/sdk/memory",{siteId:n,snapshot:l,...typeof c=="number"?{score:c}:{}});},async pullConfig(){let l=await(await s("/v1/sdk/config",{siteId:n})).json();return {policies:Array.isArray(l.policies)?l.policies:[],toolDescriptions:l.toolDescriptions&&typeof l.toolDescriptions=="object"?l.toolDescriptions:{},siteMemory:l.siteMemory&&typeof l.siteMemory=="object"?l.siteMemory:null,fetchedAt:typeof l.fetchedAt=="string"?l.fetchedAt:new Date().toISOString()}},keyVerifier({cacheSeconds:l=60}={}){return async c=>{let d=a.get(c);if(d&&d.until>Date.now())return d.value;let g=null;try{let y=await(await s("/v1/sdk/agent-keys/verify",{key:c})).json();y.valid&&y.agentId&&(g={agentId:y.agentId},y.name&&(g.name=y.name),y.vendor&&(g.vendor=y.vendor));}catch{return d?d.value:null}return a.size>5e3&&a.delete(a.keys().next().value),a.set(c,{value:g,until:Date.now()+l*1e3}),g}}}},Cr=Tn,Mr=Sn;var Qe="https://api.agentronics.dev",Qs="https://gateway.agentronics.dev",ei=t=>{if(t===void 0||t.replace(/\/$/,"")===Qe||t.replace(/\/$/,"")===Qs)return Qe;let e;try{e=new URL(t);}catch{throw new Error(`Agentronics SDK: \`gatewayUrl\` is not a valid URL: ${t}`)}if(e.hostname==="localhost"||e.hostname==="127.0.0.1")return t;throw new Error(`Agentronics SDK does not support custom API URLs. Omit \`gatewayUrl\` to use the canonical ${Qe}. The only accepted override is a localhost / 127.0.0.1 URL for local development. Got: ${t}`)},Rr=t=>{let{publishableKey:e,siteId:n="default",debug:r=false,policies:o=[],trace:s={}}=t,i=ei(t.gatewayUrl),a=zn(e);if(a==="secret")throw new Ye("wrong_key_kind","A secret key was passed to Agentronics.init(). Browser code must use a publishable key (agtx_pk_*).");if(a!=="publishable")throw new Ye("invalid_api_key",`Agentronics.init() expected a key starting with "${Be}".`);let l=s.enabled??true,c=[...r?[vt()]:[],...s.gateway?[xt({gatewayUrl:i,publishableKey:e})]:[],...s.webhookUrl?[bt({url:s.webhookUrl})]:[],...s.exporters??[]],d={siteId:n,exporters:l?c:[],onExporterError:(p,x)=>{r&&console.warn(`[agentronics] trace exporter "${x.name}" failed`,p);}};s.bufferSize!==void 0&&(d.bufferSize=s.bufferSize),s.traceRate!==void 0&&(d.traceRate=s.traceRate),s.errorRate!==void 0&&(d.errorRate=s.errorRate),s.scrubPaths!==void 0&&(d.scrubPaths=s.scrubPaths);let g=ht(d),y=p=>{l&&g.emit(p);},w=Bt(),T={onTrace:y};t.auth!==void 0&&(T.context=t.auth),t.compat==="0.6"&&(T.compat="0.6",console.warn("[agentronics] compat: '0.6' is on \u2014 unverified tokens are trusted and review rules run without asking. Remove it once you have upgraded: https://agentronics.dev/docs/guides/upgrade-0-7")),T.onUnverifiedToken=p=>{t.compat!=="0.6"&&console.warn(`[agentronics] A ${p} credential was presented but nothing verifies it, so the agent is 'declared', not 'verified'. Wire auth.verifyToken to your backend: https://agentronics.dev/docs/auth/overview#in-the-browser`);};let m=zt(T),k=Ft(),A=Zt(o),D=Ht({gatewayUrl:i,siteId:n,publishableKey:e}),$=Xt({onTrace:y}),G={onTrace:y};t.siteMemory!==void 0&&(G.initial=t.siteMemory);let N=en(G),z=tn({gatewayUrl:i,siteId:n,publishableKey:e}),et=wr({gatewayUrl:i,siteId:n,publishableKey:e}),E=async p=>{let x=Date.now(),O=await ct(p),W=w.preferOver(O);return l&&await g.emit({type:W?"agent.detected":"agent.missed",agent:W,durationMs:Date.now()-x,metadata:{detectedClass:O?.class??null,presented:w.snapshot()!==null}}),k.set(W,"detect"),W},P=async(p,x={})=>{let O=Date.now(),W=x.identity!==void 0?x.identity:await E(),H=A.evaluate({tool:p,identity:W});return l&&await g.emit({type:"authz.evaluated",tool:p,agent:W,policy:H,outcome:H.decision==="deny"?"blocked":"success",durationMs:Date.now()-O}),H},Fe=async()=>true,ee=t.review===false?void 0:t.review??(t.compat==="0.6"?Fe:typeof document>"u"?void 0:vn()),te=on({evaluate:P,...ee?{reviewer:ee}:{},setPolicies:p=>A.set(p),listPolicies:()=>A.list(),onTrace:y,identityResolver:()=>k.snapshot().identity});for(let p of t.tools??[])te.register(p);let ie=t.progression?un(t.progression,{onTrace:y}):null,An=p=>{let x={identity:p};return ie&&(x.stage=ie.current(),x.enabledStages=ie.enabledStages()),x},Cn={...t.toolDescriptions??{}},Ir=p=>p.map(x=>{let O=Cn[x.name];return O?{...x,description:O}:x}),pe=p=>Ir(pn(te.list(),An(p))),Mn=p=>{Cn={...p},fe!==null&&(fe=null,wt(pe(k.snapshot().identity)));},fe=null,Rn=p=>p.map(x=>x.name).sort().join(`
|
|
17
|
+
`),wt=p=>{let x=Rn(p);return x===fe?null:(fe=x,Oe.publish(p))},In=p=>{if(!ie)return;ie.notify(p).changed&&fe!==null&&wt(pe(k.snapshot().identity));},En={class:"webmcp",trust:"detected",confidence:1,vendor:null,userAgent:typeof navigator<"u"?navigator.userAgent:null,detectionVersion:I,signals:{source:"navigator.modelContext"}},Oe=hn({...t.toolTimeoutMs!==void 0?{toolTimeoutMs:t.toolTimeoutMs}:{},invoke:async(p,x,O)=>{Er(p.name);let W=k.snapshot().identity??En,H=await te.execute(p.name,x,W,O?{signal:O}:{});return In(p.name),H}}),On=p=>{let x=k.snapshot().identity;if(x&&x.trust!=="detected"||x?.class==="webmcp")return;let O={...En,signals:{source:Oe.source()??"document",tool:p}};k.set(O,"detect"),y({type:"agent.detected",agent:O,metadata:{detectedClass:"webmcp",via:"webmcp-activity"}});},Er=p=>On(p);jt(p=>{p.type==="activated"&&On(p.toolName);}),k.subscribe(p=>{fe===null||!Oe.available()||wt(pe(p.identity));});let kt=t.visionDetection??t.autoDetect!==false,Or=kt===false||typeof document>"u"?null:Vt({...kt===true?{}:kt,onDetect:p=>{let x=k.snapshot().identity;x&&(x.trust!=="detected"||x.class==="webmcp")||(k.set(p,"detect"),y({type:"agent.detected",agent:p,metadata:{detectedClass:"screenshot",via:"vision-behaviour"}}));}}),_t=t.autoDetect??true,Pr=_t===false?Promise.resolve(null):(async()=>{let p=_t===true?{}:_t;try{return await E(p)}catch(x){return r&&console.warn("[agentronics] autoDetect failed:",x),null}})();return Object.freeze({publishableKey:e,siteId:n,gatewayUrl:i,debug:r,memory:$,siteMemory:N,memoryCache:z,tracer:g,auth:m,agentContext:k,authz:A,policyCache:D,tools:te,progression:ie,webmcp:Oe,vision:Or,ready:Pr,detect:E,authenticate:async p=>{let x=await m.authenticate(p);return k.set(x,"authenticate"),x},presentIdentity:p=>{let x=w.present(p);return y({type:"auth.identity_presented",agent:x.identity,metadata:{vendor:x.identity.vendor,class:x.identity.class}}),k.set(x.identity,"declare"),x},clearIdentity:()=>{w.clear(),y({type:"auth.identity_cleared"}),k.set(null,"cleared");},presentedIdentity:()=>w.snapshot(),setPolicies:p=>{A.set(p),y({type:"authz.policies_set",metadata:{count:p.length}});},listPolicies:()=>A.list(),syncPolicies:async()=>{let p=await D.sync();return A.set(p.policies),y({type:"authz.policies_set",metadata:{count:p.policies.length,synced:true}}),p.policies},syncSiteMemory:async()=>{let p=await z.sync();return p.memory&&(N.replace(p.memory),y({type:"memory.updated",metadata:{kind:"site",operation:"sync",etag:p.etag}})),p.memory},syncConfig:async()=>{let p=await fetch(`${i.replace(/\/$/,"")}/v1/pub/sites/${encodeURIComponent(n)}/config`,{headers:{authorization:`Bearer ${e}`}});if(!p.ok)throw new Error(`Config sync failed with status ${p.status}.`);let x=await p.json(),O=Ee.array().parse(x.policies??[]);A.set(O),y({type:"authz.policies_set",metadata:{count:O.length,synced:true}});let W=x.siteMemory&&typeof x.siteMemory=="object"&&Object.keys(x.siteMemory).length?N.replace(V.parse(x.siteMemory)):null,H=x.toolDescriptions&&typeof x.toolDescriptions=="object"?x.toolDescriptions:{};return Mn(H),{policies:O,toolDescriptions:H,siteMemory:W}},provideSiteMemory:p=>N.provide(p),provideForPage:p=>{N.provideForPage(p);},installMemoryDelivery:({metaTags:p=true,overlay:x=false}={})=>{let O=[];return p&&O.push(pt({snapshot:N.snapshot()})),x&&O.push(ft({snapshot:N.snapshot()})),{uninstall:()=>{O.forEach(W=>W.uninstall());}}},fetchWellKnown:async p=>{let x={};p!==void 0&&(x.origin=p);let O=await mt(x);return O&&(N.replace(O),y({type:"memory.updated",metadata:{kind:"site",operation:"wellKnown",origin:p??null}})),O},installDomEnforcer:()=>qt({policyEngine:A,getIdentity:()=>E({webmcp:{pollMs:0}})}),registerTool:p=>te.register(p),setToolDescriptions:p=>Mn(p),syncTools:async()=>{let p=te.list({includeDisabled:true}),x=await et.push(p);return y({type:"tool.registered",metadata:{operation:"sync",count:x}}),x},surfaceTools:({identity:p=null}={})=>pe(p),explainSurfacing:({identity:p=null}={})=>fn(te.list(),An(p)),groupedTools:({identity:p=null}={})=>gn(pe(p)),estimateTokens:({identity:p=null}={})=>cn(pe(p)),publishToWebMcp:({identity:p=null}={})=>{let x=pe(p);fe=Rn(x);let O=Oe.publish(x),W=O.registrations.then(H=>(H.forEach(Ke=>{y({type:"tool.surfaced",tool:Ke.name,outcome:Ke.status==="callable"?"success":"error",...Ke.error?{error:Ke.error}:{},metadata:{state:Ke.status==="callable"?"published":"failed",source:Oe.source(),trust:p?.trust??null}});}),H));return {revoked:O.revoked,surfaced:x.length,registrations:W}},notifyToolInvoked:p=>In(p),evaluate:P,traces:()=>g.list(),clearTraces:()=>g.clear(),async ping(){try{let p=await fetch(`${i.replace(/\/$/,"")}/v1/pub/health`,{method:"GET",headers:{authorization:`Bearer ${e}`}});if(!p.ok)return {ok:!1,status:p.status,error:`gateway returned ${p.status}`};let x=await p.json().catch(()=>null)??{};return {ok:!0,status:p.status,body:x}}catch(p){return {ok:false,status:0,error:p instanceof Error?p.message:String(p)}}}})};var iu={init:Rr,declareAgent:$t,detectAgent:ct};exports.Agentronics=iu;exports.CRAWLER_SIGNATURES=Nt;exports.DEFAULT_GROUP=mn;exports.VERSION=I;exports.WELL_KNOWN_PATH=rn;exports.bundledDetectors=Lt;exports.createAgentContextStore=Ft;exports.createAuthEngine=zt;exports.createConsoleExporter=vt;exports.createDashboardExporter=Cr;exports.createDashboardSync=Mr;exports.createDetectorRegistry=at;exports.createGatewayExporter=xt;exports.createIdentityStore=Bt;exports.createIntelExporter=Tn;exports.createIntelSync=Sn;exports.createMemoryCache=tn;exports.createMemoryStore=Xt;exports.createPolicyCache=Ht;exports.createPolicyEngine=Zt;exports.createProgressionStore=un;exports.createRateLimiter=Kt;exports.createReviewPrompt=vn;exports.createSignatureLoader=Yn;exports.createSiteMemoryStore=en;exports.createToolRegistry=on;exports.createTraceBuffer=yt;exports.createTracer=ht;exports.createVisionDetector=Vt;exports.createWebMcpAdapter=hn;exports.createWebMcpContextTool=yr;exports.createWebhookExporter=bt;exports.decideSurfacing=dn;exports.declareAgent=$t;exports.defaultAuthMethods=Gt;exports.deriveTrustLevel=_s;exports.descriptorTokens=an;exports.detectAgent=ct;exports.detectCrawler=Ge;exports.detectDom=ze;exports.detectWebMcp=Ue;exports.estimateBudget=cn;exports.estimateToolTokens=br;exports.explainSurfacing=fn;exports.fetchWellKnownContext=mt;exports.groupTools=gn;exports.highestTrust=Ut;exports.init=Rr;exports.installDomEnforcer=qt;exports.installMemoryOverlay=ft;exports.installMetaTags=pt;exports.listGroupNames=Us;exports.modelFacingDescriptor=sn;exports.onWebMcpActivity=jt;exports.previewAuthMethods=lr;exports.resolveModelContext=Xe;exports.scoreVisionSignals=Wt;exports.serializeWellKnownContext=xr;exports.showDenyOverlay=Jt;exports.surfaceTools=pn;exports.webMcpSupport=Jn;return exports;})({});//# sourceMappingURL=index.global.js.map
|
|
18
18
|
//# sourceMappingURL=index.global.js.map
|