@rizom/brain 0.2.0-alpha.123 → 0.2.0-alpha.125

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/plugins.js CHANGED
@@ -116,7 +116,7 @@ return `+str.trim()+`;
116
116
  `+$.slice(W,V),W=V+1;q=J}if(U+=`
117
117
  `,$.length-W>G&&q>W)U+=$.slice(W,q)+`
118
118
  `+$.slice(q+1);else U+=$.slice(W);return U.slice(1)}function CK($){var G="",X=0,Y;for(var W=0;W<$.length;X>=65536?W+=2:W++)if(X=S4($,W),Y=T1[X],!Y&&b4(X)){if(G+=$[W],X>=65536)G+=$[W+1]}else G+=Y||PK(X);return G}function SK($,G,X){var Y="",W=$.tag,V,q,J;for(V=0,q=X.length;V<q;V+=1){if(J=X[V],$.replacer)J=$.replacer.call(X,String(V),J);if(P0($,G,J,!1,!1)||typeof J>"u"&&P0($,G,null,!1,!1)){if(Y!=="")Y+=","+(!$.condenseFlow?" ":"");Y+=$.dump}}$.tag=W,$.dump="["+Y+"]"}function XX($,G,X,Y){var W="",V=$.tag,q,J,U;for(q=0,J=X.length;q<J;q+=1){if(U=X[q],$.replacer)U=$.replacer.call(X,String(q),U);if(P0($,G+1,U,!0,!0,!1,!0)||typeof U>"u"&&P0($,G+1,null,!0,!0,!1,!0)){if(!Y||W!=="")W+=y9($,G);if($.dump&&x4===$.dump.charCodeAt(0))W+="-";else W+="- ";W+=$.dump}}$.tag=V,$.dump=W||"[]"}function IK($,G,X){var Y="",W=$.tag,V=Object.keys(X),q,J,U,R,D;for(q=0,J=V.length;q<J;q+=1){if(D="",Y!=="")D+=", ";if($.condenseFlow)D+='"';if(U=V[q],R=X[U],$.replacer)R=$.replacer.call(X,U,R);if(!P0($,G,U,!1,!1))continue;if($.dump.length>1024)D+="? ";if(D+=$.dump+($.condenseFlow?'"':"")+":"+($.condenseFlow?"":" "),!P0($,G,R,!1,!1))continue;D+=$.dump,Y+=D}$.tag=W,$.dump="{"+Y+"}"}function xK($,G,X,Y){var W="",V=$.tag,q=Object.keys(X),J,U,R,D,M,A;if($.sortKeys===!0)q.sort();else if(typeof $.sortKeys==="function")q.sort($.sortKeys);else if($.sortKeys)throw new y1("sortKeys must be a boolean or a function");for(J=0,U=q.length;J<U;J+=1){if(A="",!Y||W!=="")A+=y9($,G);if(R=q[J],D=X[R],$.replacer)D=$.replacer.call(X,R,D);if(!P0($,G+1,R,!0,!0,!0))continue;if(M=$.tag!==null&&$.tag!=="?"||$.dump&&$.dump.length>1024,M)if($.dump&&x4===$.dump.charCodeAt(0))A+="?";else A+="? ";if(A+=$.dump,M)A+=y9($,G);if(!P0($,G+1,D,!0,M))continue;if($.dump&&x4===$.dump.charCodeAt(0))A+=":";else A+=": ";A+=$.dump,W+=A}$.tag=V,$.dump=W||"{}"}function YX($,G,X){var Y,W,V,q,J,U;W=X?$.explicitTypes:$.implicitTypes;for(V=0,q=W.length;V<q;V+=1)if(J=W[V],(J.instanceOf||J.predicate)&&(!J.instanceOf||typeof G==="object"&&G instanceof J.instanceOf)&&(!J.predicate||J.predicate(G))){if(X)if(J.multi&&J.representName)$.tag=J.representName(G);else $.tag=J.tag;else $.tag="?";if(J.represent){if(U=$.styleMap[J.tag]||J.defaultStyle,OX.call(J.represent)==="[object Function]")Y=J.represent(G,U);else if(PX.call(J.represent,U))Y=J.represent[U](G,U);else throw new y1("!<"+J.tag+'> tag resolver accepts not "'+U+'" style');$.dump=Y}return!0}return!1}function P0($,G,X,Y,W,V,q){if($.tag=null,$.dump=X,!YX($,X,!1))YX($,X,!0);var J=OX.call($.dump),U=Y,R;if(Y)Y=$.flowLevel<0||$.flowLevel>G;var D=J==="[object Object]"||J==="[object Array]",M,A;if(D)M=$.duplicates.indexOf(X),A=M!==-1;if($.tag!==null&&$.tag!=="?"||A||$.indent!==2&&G>0)W=!1;if(A&&$.usedDuplicates[M])$.dump="*ref_"+M;else{if(D&&A&&!$.usedDuplicates[M])$.usedDuplicates[M]=!0;if(J==="[object Object]"){if(Y&&Object.keys($.dump).length!==0){if(xK($,G,$.dump,W),A)$.dump="&ref_"+M+$.dump}else if(IK($,G,$.dump),A)$.dump="&ref_"+M+" "+$.dump}else if(J==="[object Array]"){if(Y&&$.dump.length!==0){if($.noArrayIndent&&!q&&G>0)XX($,G-1,$.dump,W);else XX($,G,$.dump,W);if(A)$.dump="&ref_"+M+$.dump}else if(SK($,G,$.dump),A)$.dump="&ref_"+M+" "+$.dump}else if(J==="[object String]"){if($.tag!=="?")jK($,$.dump,G,V,U)}else if(J==="[object Undefined]")return!1;else{if($.skipInvalid)return!1;throw new y1("unacceptable kind of an object to dump "+J)}if($.tag!==null&&$.tag!=="?"){if(R=encodeURI($.tag[0]==="!"?$.tag.slice(1):$.tag).replace(/!/g,"%21"),$.tag[0]==="!")R="!"+R;else if(R.slice(0,18)==="tag:yaml.org,2002:")R="!!"+R.slice(18);else R="!<"+R+">";$.dump=R+" "+$.dump}}return!0}function kK($,G){var X=[],Y=[],W,V;m9($,X,Y);for(W=0,V=Y.length;W<V;W+=1)G.duplicates.push(X[Y[W]]);G.usedDuplicates=Array(V)}function m9($,G,X){var Y,W,V;if($!==null&&typeof $==="object")if(W=G.indexOf($),W!==-1){if(X.indexOf(W)===-1)X.push(W)}else if(G.push($),Array.isArray($))for(W=0,V=$.length;W<V;W+=1)m9($[W],G,X);else{Y=Object.keys($);for(W=0,V=Y.length;W<V;W+=1)m9($[Y[W]],G,X)}}function bK($,G){G=G||{};var X=new ZK(G);if(!X.noRefs)kK($,X);var Y=$;if(X.replacer)Y=X.replacer.call({"":Y},"",Y);if(P0(X,0,Y,!0,!0))return X.dump+`
119
- `;return""}var vK=bK,gK={dump:vK};function d9($,G){return function(){throw Error("Function yaml."+$+" is removed in js-yaml 4. Use yaml."+G+" instead, which is now safe by default.")}}var{load:hK,loadAll:Sj}=BX,yK=gK.dump;var Ij=d9("safeLoad","load"),xj=d9("safeLoadAll","loadAll"),kj=d9("safeDump","dump");import{webcrypto as IX}from"crypto";var SX="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var mK=128,U2,r2;function uK($){if($<0||$>1024)throw RangeError("Wrong ID size");if(!U2||U2.length<$)U2=Buffer.allocUnsafe($*mK),IX.getRandomValues(U2),r2=0;else if(r2+$>U2.length)IX.getRandomValues(U2),r2=0;r2+=$}function xX($=21){uK($|=0);let G="";for(let X=r2-$;X<r2;X++)G+=SX[U2[X]&63];return G}function g0($=12){return xX($)}var H={};v8(H,{void:()=>LF,util:()=>a,unknown:()=>zF,union:()=>CF,undefined:()=>PF,tuple:()=>xF,transformer:()=>pF,symbol:()=>OF,string:()=>uX,strictObject:()=>TF,setErrorMap:()=>rK,set:()=>vF,record:()=>kF,quotelessJson:()=>pK,promise:()=>uF,preprocess:()=>dF,pipeline:()=>cF,ostring:()=>iF,optional:()=>lF,onumber:()=>nF,oboolean:()=>oF,objectUtil:()=>c9,object:()=>jF,number:()=>pX,nullable:()=>rF,null:()=>NF,never:()=>_F,nativeEnum:()=>mF,nan:()=>AF,map:()=>bF,makeIssue:()=>v4,literal:()=>yF,lazy:()=>hF,late:()=>KF,isValid:()=>h0,isDirty:()=>c6,isAsync:()=>c2,isAborted:()=>d6,intersection:()=>IF,instanceof:()=>FF,getParsedType:()=>J0,getErrorMap:()=>d2,function:()=>gF,enum:()=>fF,effect:()=>pF,discriminatedUnion:()=>SF,defaultErrorMap:()=>N0,datetimeRegex:()=>yX,date:()=>BF,custom:()=>mX,coerce:()=>sF,boolean:()=>lX,bigint:()=>wF,array:()=>EF,any:()=>ZF,addIssueToContext:()=>x,ZodVoid:()=>h4,ZodUnknown:()=>y0,ZodUnion:()=>t2,ZodUndefined:()=>s2,ZodType:()=>o,ZodTuple:()=>U0,ZodTransformer:()=>G0,ZodSymbol:()=>g4,ZodString:()=>a1,ZodSet:()=>Q2,ZodSchema:()=>o,ZodRecord:()=>y4,ZodReadonly:()=>V4,ZodPromise:()=>K2,ZodPipeline:()=>u4,ZodParsedType:()=>C,ZodOptional:()=>e1,ZodObject:()=>q1,ZodNumber:()=>f0,ZodNullable:()=>z0,ZodNull:()=>a2,ZodNever:()=>H0,ZodNativeEnum:()=>X4,ZodNaN:()=>m4,ZodMap:()=>f4,ZodLiteral:()=>G4,ZodLazy:()=>$4,ZodIssueCode:()=>T,ZodIntersection:()=>e2,ZodFunction:()=>n2,ZodFirstPartyTypeKind:()=>p,ZodError:()=>C1,ZodEnum:()=>u0,ZodEffects:()=>G0,ZodDiscriminatedUnion:()=>i6,ZodDefault:()=>Y4,ZodDate:()=>D2,ZodCatch:()=>W4,ZodBranded:()=>n6,ZodBoolean:()=>o2,ZodBigInt:()=>m0,ZodArray:()=>t1,ZodAny:()=>M2,Schema:()=>o,ParseStatus:()=>_1,OK:()=>S1,NEVER:()=>aF,INVALID:()=>u,EMPTY_PATH:()=>dK,DIRTY:()=>R2,BRAND:()=>QF});var a;(function($){$.assertEqual=(W)=>{};function G(W){}$.assertIs=G;function X(W){throw Error()}$.assertNever=X,$.arrayToEnum=(W)=>{let V={};for(let q of W)V[q]=q;return V},$.getValidEnumValues=(W)=>{let V=$.objectKeys(W).filter((J)=>typeof W[W[J]]!=="number"),q={};for(let J of V)q[J]=W[J];return $.objectValues(q)},$.objectValues=(W)=>{return $.objectKeys(W).map(function(V){return W[V]})},$.objectKeys=typeof Object.keys==="function"?(W)=>Object.keys(W):(W)=>{let V=[];for(let q in W)if(Object.prototype.hasOwnProperty.call(W,q))V.push(q);return V},$.find=(W,V)=>{for(let q of W)if(V(q))return q;return},$.isInteger=typeof Number.isInteger==="function"?(W)=>Number.isInteger(W):(W)=>typeof W==="number"&&Number.isFinite(W)&&Math.floor(W)===W;function Y(W,V=" | "){return W.map((q)=>typeof q==="string"?`'${q}'`:q).join(V)}$.joinValues=Y,$.jsonStringifyReplacer=(W,V)=>{if(typeof V==="bigint")return V.toString();return V}})(a||(a={}));var c9;(function($){$.mergeShapes=(G,X)=>{return{...G,...X}}})(c9||(c9={}));var C=a.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),J0=($)=>{switch(typeof $){case"undefined":return C.undefined;case"string":return C.string;case"number":return Number.isNaN($)?C.nan:C.number;case"boolean":return C.boolean;case"function":return C.function;case"bigint":return C.bigint;case"symbol":return C.symbol;case"object":if(Array.isArray($))return C.array;if($===null)return C.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return C.promise;if(typeof Map<"u"&&$ instanceof Map)return C.map;if(typeof Set<"u"&&$ instanceof Set)return C.set;if(typeof Date<"u"&&$ instanceof Date)return C.date;return C.object;default:return C.unknown}};var T=a.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"]),pK=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class C1 extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(X)=>{this.issues=[...this.issues,X]},this.addIssues=(X=[])=>{this.issues=[...this.issues,...X]};let G=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,G);else this.__proto__=G;this.name="ZodError",this.issues=$}format($){let G=$||function(W){return W.message},X={_errors:[]},Y=(W)=>{for(let V of W.issues)if(V.code==="invalid_union")V.unionErrors.map(Y);else if(V.code==="invalid_return_type")Y(V.returnTypeError);else if(V.code==="invalid_arguments")Y(V.argumentsError);else if(V.path.length===0)X._errors.push(G(V));else{let q=X,J=0;while(J<V.path.length){let U=V.path[J];if(J!==V.path.length-1)q[U]=q[U]||{_errors:[]};else q[U]=q[U]||{_errors:[]},q[U]._errors.push(G(V));q=q[U],J++}}};return Y(this),X}static assert($){if(!($ instanceof C1))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,a.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(G)=>G.message){let G={},X=[];for(let Y of this.issues)if(Y.path.length>0){let W=Y.path[0];G[W]=G[W]||[],G[W].push($(Y))}else X.push($(Y));return{formErrors:X,fieldErrors:G}}get formErrors(){return this.flatten()}}C1.create=($)=>{return new C1($)};var lK=($,G)=>{let X;switch($.code){case T.invalid_type:if($.received===C.undefined)X="Required";else X=`Expected ${$.expected}, received ${$.received}`;break;case T.invalid_literal:X=`Invalid literal value, expected ${JSON.stringify($.expected,a.jsonStringifyReplacer)}`;break;case T.unrecognized_keys:X=`Unrecognized key(s) in object: ${a.joinValues($.keys,", ")}`;break;case T.invalid_union:X="Invalid input";break;case T.invalid_union_discriminator:X=`Invalid discriminator value. Expected ${a.joinValues($.options)}`;break;case T.invalid_enum_value:X=`Invalid enum value. Expected ${a.joinValues($.options)}, received '${$.received}'`;break;case T.invalid_arguments:X="Invalid function arguments";break;case T.invalid_return_type:X="Invalid function return type";break;case T.invalid_date:X="Invalid date";break;case T.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(X=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")X=`${X} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)X=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)X=`Invalid input: must end with "${$.validation.endsWith}"`;else a.assertNever($.validation);else if($.validation!=="regex")X=`Invalid ${$.validation}`;else X="Invalid";break;case T.too_small:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else X="Invalid input";break;case T.too_big:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")X=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else X="Invalid input";break;case T.custom:X="Invalid input";break;case T.invalid_intersection_types:X="Intersection results could not be merged";break;case T.not_multiple_of:X=`Number must be a multiple of ${$.multipleOf}`;break;case T.not_finite:X="Number must be finite";break;default:X=G.defaultError,a.assertNever($)}return{message:X}},N0=lK;var kX=N0;function rK($){kX=$}function d2(){return kX}var v4=($)=>{let{data:G,path:X,errorMaps:Y,issueData:W}=$,V=[...X,...W.path||[]],q={...W,path:V};if(W.message!==void 0)return{...W,path:V,message:W.message};let J="",U=Y.filter((R)=>!!R).slice().reverse();for(let R of U)J=R(q,{data:G,defaultError:J}).message;return{...W,path:V,message:J}},dK=[];function x($,G){let X=d2(),Y=v4({issueData:G,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,X,X===N0?void 0:N0].filter((W)=>!!W)});$.common.issues.push(Y)}class _1{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,G){let X=[];for(let Y of G){if(Y.status==="aborted")return u;if(Y.status==="dirty")$.dirty();X.push(Y.value)}return{status:$.value,value:X}}static async mergeObjectAsync($,G){let X=[];for(let Y of G){let W=await Y.key,V=await Y.value;X.push({key:W,value:V})}return _1.mergeObjectSync($,X)}static mergeObjectSync($,G){let X={};for(let Y of G){let{key:W,value:V}=Y;if(W.status==="aborted")return u;if(V.status==="aborted")return u;if(W.status==="dirty")$.dirty();if(V.status==="dirty")$.dirty();if(W.value!=="__proto__"&&(typeof V.value<"u"||Y.alwaysSet))X[W.value]=V.value}return{status:$.value,value:X}}}var u=Object.freeze({status:"aborted"}),R2=($)=>({status:"dirty",value:$}),S1=($)=>({status:"valid",value:$}),d6=($)=>$.status==="aborted",c6=($)=>$.status==="dirty",h0=($)=>$.status==="valid",c2=($)=>typeof Promise<"u"&&$ instanceof Promise;var g;(function($){$.errToObj=(G)=>typeof G==="string"?{message:G}:G||{},$.toString=(G)=>typeof G==="string"?G:G?.message})(g||(g={}));class $0{constructor($,G,X,Y){this._cachedPath=[],this.parent=$,this.data=G,this._path=X,this._key=Y}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var bX=($,G)=>{if(h0(G))return{success:!0,data:G.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let X=new C1($.common.issues);return this._error=X,this._error}}}};function c($){if(!$)return{};let{errorMap:G,invalid_type_error:X,required_error:Y,description:W}=$;if(G&&(X||Y))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(G)return{errorMap:G,description:W};return{errorMap:(q,J)=>{let{message:U}=$;if(q.code==="invalid_enum_value")return{message:U??J.defaultError};if(typeof J.data>"u")return{message:U??Y??J.defaultError};if(q.code!=="invalid_type")return{message:J.defaultError};return{message:U??X??J.defaultError}},description:W}}class o{get description(){return this._def.description}_getType($){return J0($.data)}_getOrReturnCtx($,G){return G||{common:$.parent.common,data:$.data,parsedType:J0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new _1,ctx:{common:$.parent.common,data:$.data,parsedType:J0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let G=this._parse($);if(c2(G))throw Error("Synchronous parse encountered promise.");return G}_parseAsync($){let G=this._parse($);return Promise.resolve(G)}parse($,G){let X=this.safeParse($,G);if(X.success)return X.data;throw X.error}safeParse($,G){let X={common:{issues:[],async:G?.async??!1,contextualErrorMap:G?.errorMap},path:G?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:J0($)},Y=this._parseSync({data:$,path:X.path,parent:X});return bX(X,Y)}"~validate"($){let G={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:J0($)};if(!this["~standard"].async)try{let X=this._parseSync({data:$,path:[],parent:G});return h0(X)?{value:X.value}:{issues:G.common.issues}}catch(X){if(X?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;G.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:G}).then((X)=>h0(X)?{value:X.value}:{issues:G.common.issues})}async parseAsync($,G){let X=await this.safeParseAsync($,G);if(X.success)return X.data;throw X.error}async safeParseAsync($,G){let X={common:{issues:[],contextualErrorMap:G?.errorMap,async:!0},path:G?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:J0($)},Y=this._parse({data:$,path:X.path,parent:X}),W=await(c2(Y)?Y:Promise.resolve(Y));return bX(X,W)}refine($,G){let X=(Y)=>{if(typeof G==="string"||typeof G>"u")return{message:G};else if(typeof G==="function")return G(Y);else return G};return this._refinement((Y,W)=>{let V=$(Y),q=()=>W.addIssue({code:T.custom,...X(Y)});if(typeof Promise<"u"&&V instanceof Promise)return V.then((J)=>{if(!J)return q(),!1;else return!0});if(!V)return q(),!1;else return!0})}refinement($,G){return this._refinement((X,Y)=>{if(!$(X))return Y.addIssue(typeof G==="function"?G(X,Y):G),!1;else return!0})}_refinement($){return new G0({schema:this,typeName:p.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,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:(G)=>this["~validate"](G)}}optional(){return e1.create(this,this._def)}nullable(){return z0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return t1.create(this)}promise(){return K2.create(this,this._def)}or($){return t2.create([this,$],this._def)}and($){return e2.create(this,$,this._def)}transform($){return new G0({...c(this._def),schema:this,typeName:p.ZodEffects,effect:{type:"transform",transform:$}})}default($){let G=typeof $==="function"?$:()=>$;return new Y4({...c(this._def),innerType:this,defaultValue:G,typeName:p.ZodDefault})}brand(){return new n6({typeName:p.ZodBranded,type:this,...c(this._def)})}catch($){let G=typeof $==="function"?$:()=>$;return new W4({...c(this._def),innerType:this,catchValue:G,typeName:p.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return u4.create(this,$)}readonly(){return V4.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var cK=/^c[^\s-]{8,}$/i,iK=/^[0-9a-z]+$/,nK=/^[0-9A-HJKMNP-TV-Z]{26}$/i,oK=/^[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,sK=/^[a-z0-9_-]{21}$/i,aK=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,tK=/^[-+]?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)?)??$/,eK=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,$F="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",i9,GF=/^(?:(?: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])$/,XF=/^(?:(?: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])$/,YF=/^(([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]))$/,WF=/^(([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])$/,VF=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qF=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,gX="((\\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])))",JF=new RegExp(`^${gX}$`);function hX($){let G="[0-5]\\d";if($.precision)G=`${G}\\.\\d{${$.precision}}`;else if($.precision==null)G=`${G}(\\.\\d+)?`;let X=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${G})${X}`}function HF($){return new RegExp(`^${hX($)}$`)}function yX($){let G=`${gX}T${hX($)}`,X=[];if(X.push($.local?"Z?":"Z"),$.offset)X.push("([+-]\\d{2}:?\\d{2})");return G=`${G}(${X.join("|")})`,new RegExp(`^${G}$`)}function UF($,G){if((G==="v4"||!G)&&GF.test($))return!0;if((G==="v6"||!G)&&YF.test($))return!0;return!1}function RF($,G){if(!aK.test($))return!1;try{let[X]=$.split(".");if(!X)return!1;let Y=X.replace(/-/g,"+").replace(/_/g,"/").padEnd(X.length+(4-X.length%4)%4,"="),W=JSON.parse(atob(Y));if(typeof W!=="object"||W===null)return!1;if("typ"in W&&W?.typ!=="JWT")return!1;if(!W.alg)return!1;if(G&&W.alg!==G)return!1;return!0}catch{return!1}}function DF($,G){if((G==="v4"||!G)&&XF.test($))return!0;if((G==="v6"||!G)&&WF.test($))return!0;return!1}class a1 extends o{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==C.string){let W=this._getOrReturnCtx($);return x(W,{code:T.invalid_type,expected:C.string,received:W.parsedType}),u}let X=new _1,Y=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.length<W.value)Y=this._getOrReturnCtx($,Y),x(Y,{code:T.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),X.dirty()}else if(W.kind==="max"){if($.data.length>W.value)Y=this._getOrReturnCtx($,Y),x(Y,{code:T.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),X.dirty()}else if(W.kind==="length"){let V=$.data.length>W.value,q=$.data.length<W.value;if(V||q){if(Y=this._getOrReturnCtx($,Y),V)x(Y,{code:T.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});else if(q)x(Y,{code:T.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});X.dirty()}}else if(W.kind==="email"){if(!eK.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"email",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="emoji"){if(!i9)i9=new RegExp($F,"u");if(!i9.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"emoji",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="uuid"){if(!oK.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"uuid",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="nanoid"){if(!sK.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"nanoid",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="cuid"){if(!cK.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"cuid",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="cuid2"){if(!iK.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"cuid2",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="ulid"){if(!nK.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"ulid",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="url")try{new URL($.data)}catch{Y=this._getOrReturnCtx($,Y),x(Y,{validation:"url",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="regex"){if(W.regex.lastIndex=0,!W.regex.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"regex",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="trim")$.data=$.data.trim();else if(W.kind==="includes"){if(!$.data.includes(W.value,W.position))Y=this._getOrReturnCtx($,Y),x(Y,{code:T.invalid_string,validation:{includes:W.value,position:W.position},message:W.message}),X.dirty()}else if(W.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(W.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(W.kind==="startsWith"){if(!$.data.startsWith(W.value))Y=this._getOrReturnCtx($,Y),x(Y,{code:T.invalid_string,validation:{startsWith:W.value},message:W.message}),X.dirty()}else if(W.kind==="endsWith"){if(!$.data.endsWith(W.value))Y=this._getOrReturnCtx($,Y),x(Y,{code:T.invalid_string,validation:{endsWith:W.value},message:W.message}),X.dirty()}else if(W.kind==="datetime"){if(!yX(W).test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{code:T.invalid_string,validation:"datetime",message:W.message}),X.dirty()}else if(W.kind==="date"){if(!JF.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{code:T.invalid_string,validation:"date",message:W.message}),X.dirty()}else if(W.kind==="time"){if(!HF(W).test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{code:T.invalid_string,validation:"time",message:W.message}),X.dirty()}else if(W.kind==="duration"){if(!tK.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"duration",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="ip"){if(!UF($.data,W.version))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"ip",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="jwt"){if(!RF($.data,W.alg))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"jwt",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="cidr"){if(!DF($.data,W.version))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"cidr",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="base64"){if(!VF.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"base64",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="base64url"){if(!qF.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"base64url",code:T.invalid_string,message:W.message}),X.dirty()}else a.assertNever(W);return{status:X.value,value:$.data}}_regex($,G,X){return this.refinement((Y)=>$.test(Y),{validation:G,code:T.invalid_string,...g.errToObj(X)})}_addCheck($){return new a1({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...g.errToObj($)})}url($){return this._addCheck({kind:"url",...g.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...g.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...g.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...g.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...g.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...g.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...g.errToObj($)})}base64($){return this._addCheck({kind:"base64",...g.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...g.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...g.errToObj($)})}ip($){return this._addCheck({kind:"ip",...g.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...g.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...g.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...g.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...g.errToObj($)})}regex($,G){return this._addCheck({kind:"regex",regex:$,...g.errToObj(G)})}includes($,G){return this._addCheck({kind:"includes",value:$,position:G?.position,...g.errToObj(G?.message)})}startsWith($,G){return this._addCheck({kind:"startsWith",value:$,...g.errToObj(G)})}endsWith($,G){return this._addCheck({kind:"endsWith",value:$,...g.errToObj(G)})}min($,G){return this._addCheck({kind:"min",value:$,...g.errToObj(G)})}max($,G){return this._addCheck({kind:"max",value:$,...g.errToObj(G)})}length($,G){return this._addCheck({kind:"length",value:$,...g.errToObj(G)})}nonempty($){return this.min(1,g.errToObj($))}trim(){return new a1({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new a1({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new a1({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $}get maxLength(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $}}a1.create=($)=>{return new a1({checks:[],typeName:p.ZodString,coerce:$?.coerce??!1,...c($)})};function MF($,G){let X=($.toString().split(".")[1]||"").length,Y=(G.toString().split(".")[1]||"").length,W=X>Y?X:Y,V=Number.parseInt($.toFixed(W).replace(".","")),q=Number.parseInt(G.toFixed(W).replace(".",""));return V%q/10**W}class f0 extends o{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==C.number){let W=this._getOrReturnCtx($);return x(W,{code:T.invalid_type,expected:C.number,received:W.parsedType}),u}let X=void 0,Y=new _1;for(let W of this._def.checks)if(W.kind==="int"){if(!a.isInteger($.data))X=this._getOrReturnCtx($,X),x(X,{code:T.invalid_type,expected:"integer",received:"float",message:W.message}),Y.dirty()}else if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)X=this._getOrReturnCtx($,X),x(X,{code:T.too_small,minimum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),Y.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)X=this._getOrReturnCtx($,X),x(X,{code:T.too_big,maximum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),Y.dirty()}else if(W.kind==="multipleOf"){if(MF($.data,W.value)!==0)X=this._getOrReturnCtx($,X),x(X,{code:T.not_multiple_of,multipleOf:W.value,message:W.message}),Y.dirty()}else if(W.kind==="finite"){if(!Number.isFinite($.data))X=this._getOrReturnCtx($,X),x(X,{code:T.not_finite,message:W.message}),Y.dirty()}else a.assertNever(W);return{status:Y.value,value:$.data}}gte($,G){return this.setLimit("min",$,!0,g.toString(G))}gt($,G){return this.setLimit("min",$,!1,g.toString(G))}lte($,G){return this.setLimit("max",$,!0,g.toString(G))}lt($,G){return this.setLimit("max",$,!1,g.toString(G))}setLimit($,G,X,Y){return new f0({...this._def,checks:[...this._def.checks,{kind:$,value:G,inclusive:X,message:g.toString(Y)}]})}_addCheck($){return new f0({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:g.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString($)})}multipleOf($,G){return this._addCheck({kind:"multipleOf",value:$,message:g.toString(G)})}finite($){return this._addCheck({kind:"finite",message:g.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.toString($)})}get minValue(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $}get maxValue(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&a.isInteger($.value))}get isFinite(){let $=null,G=null;for(let X of this._def.checks)if(X.kind==="finite"||X.kind==="int"||X.kind==="multipleOf")return!0;else if(X.kind==="min"){if(G===null||X.value>G)G=X.value}else if(X.kind==="max"){if($===null||X.value<$)$=X.value}return Number.isFinite(G)&&Number.isFinite($)}}f0.create=($)=>{return new f0({checks:[],typeName:p.ZodNumber,coerce:$?.coerce||!1,...c($)})};class m0 extends o{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==C.bigint)return this._getInvalidInput($);let X=void 0,Y=new _1;for(let W of this._def.checks)if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)X=this._getOrReturnCtx($,X),x(X,{code:T.too_small,type:"bigint",minimum:W.value,inclusive:W.inclusive,message:W.message}),Y.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)X=this._getOrReturnCtx($,X),x(X,{code:T.too_big,type:"bigint",maximum:W.value,inclusive:W.inclusive,message:W.message}),Y.dirty()}else if(W.kind==="multipleOf"){if($.data%W.value!==BigInt(0))X=this._getOrReturnCtx($,X),x(X,{code:T.not_multiple_of,multipleOf:W.value,message:W.message}),Y.dirty()}else a.assertNever(W);return{status:Y.value,value:$.data}}_getInvalidInput($){let G=this._getOrReturnCtx($);return x(G,{code:T.invalid_type,expected:C.bigint,received:G.parsedType}),u}gte($,G){return this.setLimit("min",$,!0,g.toString(G))}gt($,G){return this.setLimit("min",$,!1,g.toString(G))}lte($,G){return this.setLimit("max",$,!0,g.toString(G))}lt($,G){return this.setLimit("max",$,!1,g.toString(G))}setLimit($,G,X,Y){return new m0({...this._def,checks:[...this._def.checks,{kind:$,value:G,inclusive:X,message:g.toString(Y)}]})}_addCheck($){return new m0({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString($)})}multipleOf($,G){return this._addCheck({kind:"multipleOf",value:$,message:g.toString(G)})}get minValue(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $}get maxValue(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $}}m0.create=($)=>{return new m0({checks:[],typeName:p.ZodBigInt,coerce:$?.coerce??!1,...c($)})};class o2 extends o{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==C.boolean){let X=this._getOrReturnCtx($);return x(X,{code:T.invalid_type,expected:C.boolean,received:X.parsedType}),u}return S1($.data)}}o2.create=($)=>{return new o2({typeName:p.ZodBoolean,coerce:$?.coerce||!1,...c($)})};class D2 extends o{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==C.date){let W=this._getOrReturnCtx($);return x(W,{code:T.invalid_type,expected:C.date,received:W.parsedType}),u}if(Number.isNaN($.data.getTime())){let W=this._getOrReturnCtx($);return x(W,{code:T.invalid_date}),u}let X=new _1,Y=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.getTime()<W.value)Y=this._getOrReturnCtx($,Y),x(Y,{code:T.too_small,message:W.message,inclusive:!0,exact:!1,minimum:W.value,type:"date"}),X.dirty()}else if(W.kind==="max"){if($.data.getTime()>W.value)Y=this._getOrReturnCtx($,Y),x(Y,{code:T.too_big,message:W.message,inclusive:!0,exact:!1,maximum:W.value,type:"date"}),X.dirty()}else a.assertNever(W);return{status:X.value,value:new Date($.data.getTime())}}_addCheck($){return new D2({...this._def,checks:[...this._def.checks,$]})}min($,G){return this._addCheck({kind:"min",value:$.getTime(),message:g.toString(G)})}max($,G){return this._addCheck({kind:"max",value:$.getTime(),message:g.toString(G)})}get minDate(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $!=null?new Date($):null}}D2.create=($)=>{return new D2({checks:[],coerce:$?.coerce||!1,typeName:p.ZodDate,...c($)})};class g4 extends o{_parse($){if(this._getType($)!==C.symbol){let X=this._getOrReturnCtx($);return x(X,{code:T.invalid_type,expected:C.symbol,received:X.parsedType}),u}return S1($.data)}}g4.create=($)=>{return new g4({typeName:p.ZodSymbol,...c($)})};class s2 extends o{_parse($){if(this._getType($)!==C.undefined){let X=this._getOrReturnCtx($);return x(X,{code:T.invalid_type,expected:C.undefined,received:X.parsedType}),u}return S1($.data)}}s2.create=($)=>{return new s2({typeName:p.ZodUndefined,...c($)})};class a2 extends o{_parse($){if(this._getType($)!==C.null){let X=this._getOrReturnCtx($);return x(X,{code:T.invalid_type,expected:C.null,received:X.parsedType}),u}return S1($.data)}}a2.create=($)=>{return new a2({typeName:p.ZodNull,...c($)})};class M2 extends o{constructor(){super(...arguments);this._any=!0}_parse($){return S1($.data)}}M2.create=($)=>{return new M2({typeName:p.ZodAny,...c($)})};class y0 extends o{constructor(){super(...arguments);this._unknown=!0}_parse($){return S1($.data)}}y0.create=($)=>{return new y0({typeName:p.ZodUnknown,...c($)})};class H0 extends o{_parse($){let G=this._getOrReturnCtx($);return x(G,{code:T.invalid_type,expected:C.never,received:G.parsedType}),u}}H0.create=($)=>{return new H0({typeName:p.ZodNever,...c($)})};class h4 extends o{_parse($){if(this._getType($)!==C.undefined){let X=this._getOrReturnCtx($);return x(X,{code:T.invalid_type,expected:C.void,received:X.parsedType}),u}return S1($.data)}}h4.create=($)=>{return new h4({typeName:p.ZodVoid,...c($)})};class t1 extends o{_parse($){let{ctx:G,status:X}=this._processInputParams($),Y=this._def;if(G.parsedType!==C.array)return x(G,{code:T.invalid_type,expected:C.array,received:G.parsedType}),u;if(Y.exactLength!==null){let V=G.data.length>Y.exactLength.value,q=G.data.length<Y.exactLength.value;if(V||q)x(G,{code:V?T.too_big:T.too_small,minimum:q?Y.exactLength.value:void 0,maximum:V?Y.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:Y.exactLength.message}),X.dirty()}if(Y.minLength!==null){if(G.data.length<Y.minLength.value)x(G,{code:T.too_small,minimum:Y.minLength.value,type:"array",inclusive:!0,exact:!1,message:Y.minLength.message}),X.dirty()}if(Y.maxLength!==null){if(G.data.length>Y.maxLength.value)x(G,{code:T.too_big,maximum:Y.maxLength.value,type:"array",inclusive:!0,exact:!1,message:Y.maxLength.message}),X.dirty()}if(G.common.async)return Promise.all([...G.data].map((V,q)=>{return Y.type._parseAsync(new $0(G,V,G.path,q))})).then((V)=>{return _1.mergeArray(X,V)});let W=[...G.data].map((V,q)=>{return Y.type._parseSync(new $0(G,V,G.path,q))});return _1.mergeArray(X,W)}get element(){return this._def.type}min($,G){return new t1({...this._def,minLength:{value:$,message:g.toString(G)}})}max($,G){return new t1({...this._def,maxLength:{value:$,message:g.toString(G)}})}length($,G){return new t1({...this._def,exactLength:{value:$,message:g.toString(G)}})}nonempty($){return this.min(1,$)}}t1.create=($,G)=>{return new t1({type:$,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,...c(G)})};function i2($){if($ instanceof q1){let G={};for(let X in $.shape){let Y=$.shape[X];G[X]=e1.create(i2(Y))}return new q1({...$._def,shape:()=>G})}else if($ instanceof t1)return new t1({...$._def,type:i2($.element)});else if($ instanceof e1)return e1.create(i2($.unwrap()));else if($ instanceof z0)return z0.create(i2($.unwrap()));else if($ instanceof U0)return U0.create($.items.map((G)=>i2(G)));else return $}class q1 extends o{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),G=a.objectKeys($);return this._cached={shape:$,keys:G},this._cached}_parse($){if(this._getType($)!==C.object){let U=this._getOrReturnCtx($);return x(U,{code:T.invalid_type,expected:C.object,received:U.parsedType}),u}let{status:X,ctx:Y}=this._processInputParams($),{shape:W,keys:V}=this._getCached(),q=[];if(!(this._def.catchall instanceof H0&&this._def.unknownKeys==="strip")){for(let U in Y.data)if(!V.includes(U))q.push(U)}let J=[];for(let U of V){let R=W[U],D=Y.data[U];J.push({key:{status:"valid",value:U},value:R._parse(new $0(Y,D,Y.path,U)),alwaysSet:U in Y.data})}if(this._def.catchall instanceof H0){let U=this._def.unknownKeys;if(U==="passthrough")for(let R of q)J.push({key:{status:"valid",value:R},value:{status:"valid",value:Y.data[R]}});else if(U==="strict"){if(q.length>0)x(Y,{code:T.unrecognized_keys,keys:q}),X.dirty()}else if(U==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let U=this._def.catchall;for(let R of q){let D=Y.data[R];J.push({key:{status:"valid",value:R},value:U._parse(new $0(Y,D,Y.path,R)),alwaysSet:R in Y.data})}}if(Y.common.async)return Promise.resolve().then(async()=>{let U=[];for(let R of J){let D=await R.key,M=await R.value;U.push({key:D,value:M,alwaysSet:R.alwaysSet})}return U}).then((U)=>{return _1.mergeObjectSync(X,U)});else return _1.mergeObjectSync(X,J)}get shape(){return this._def.shape()}strict($){return g.errToObj,new q1({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(G,X)=>{let Y=this._def.errorMap?.(G,X).message??X.defaultError;if(G.code==="unrecognized_keys")return{message:g.errToObj($).message??Y};return{message:Y}}}:{}})}strip(){return new q1({...this._def,unknownKeys:"strip"})}passthrough(){return new q1({...this._def,unknownKeys:"passthrough"})}extend($){return new q1({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new q1({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:p.ZodObject})}setKey($,G){return this.augment({[$]:G})}catchall($){return new q1({...this._def,catchall:$})}pick($){let G={};for(let X of a.objectKeys($))if($[X]&&this.shape[X])G[X]=this.shape[X];return new q1({...this._def,shape:()=>G})}omit($){let G={};for(let X of a.objectKeys(this.shape))if(!$[X])G[X]=this.shape[X];return new q1({...this._def,shape:()=>G})}deepPartial(){return i2(this)}partial($){let G={};for(let X of a.objectKeys(this.shape)){let Y=this.shape[X];if($&&!$[X])G[X]=Y;else G[X]=Y.optional()}return new q1({...this._def,shape:()=>G})}required($){let G={};for(let X of a.objectKeys(this.shape))if($&&!$[X])G[X]=this.shape[X];else{let W=this.shape[X];while(W instanceof e1)W=W._def.innerType;G[X]=W}return new q1({...this._def,shape:()=>G})}keyof(){return fX(a.objectKeys(this.shape))}}q1.create=($,G)=>{return new q1({shape:()=>$,unknownKeys:"strip",catchall:H0.create(),typeName:p.ZodObject,...c(G)})};q1.strictCreate=($,G)=>{return new q1({shape:()=>$,unknownKeys:"strict",catchall:H0.create(),typeName:p.ZodObject,...c(G)})};q1.lazycreate=($,G)=>{return new q1({shape:$,unknownKeys:"strip",catchall:H0.create(),typeName:p.ZodObject,...c(G)})};class t2 extends o{_parse($){let{ctx:G}=this._processInputParams($),X=this._def.options;function Y(W){for(let q of W)if(q.result.status==="valid")return q.result;for(let q of W)if(q.result.status==="dirty")return G.common.issues.push(...q.ctx.common.issues),q.result;let V=W.map((q)=>new C1(q.ctx.common.issues));return x(G,{code:T.invalid_union,unionErrors:V}),u}if(G.common.async)return Promise.all(X.map(async(W)=>{let V={...G,common:{...G.common,issues:[]},parent:null};return{result:await W._parseAsync({data:G.data,path:G.path,parent:V}),ctx:V}})).then(Y);else{let W=void 0,V=[];for(let J of X){let U={...G,common:{...G.common,issues:[]},parent:null},R=J._parseSync({data:G.data,path:G.path,parent:U});if(R.status==="valid")return R;else if(R.status==="dirty"&&!W)W={result:R,ctx:U};if(U.common.issues.length)V.push(U.common.issues)}if(W)return G.common.issues.push(...W.ctx.common.issues),W.result;let q=V.map((J)=>new C1(J));return x(G,{code:T.invalid_union,unionErrors:q}),u}}get options(){return this._def.options}}t2.create=($,G)=>{return new t2({options:$,typeName:p.ZodUnion,...c(G)})};var Z0=($)=>{if($ instanceof $4)return Z0($.schema);else if($ instanceof G0)return Z0($.innerType());else if($ instanceof G4)return[$.value];else if($ instanceof u0)return $.options;else if($ instanceof X4)return a.objectValues($.enum);else if($ instanceof Y4)return Z0($._def.innerType);else if($ instanceof s2)return[void 0];else if($ instanceof a2)return[null];else if($ instanceof e1)return[void 0,...Z0($.unwrap())];else if($ instanceof z0)return[null,...Z0($.unwrap())];else if($ instanceof n6)return Z0($.unwrap());else if($ instanceof V4)return Z0($.unwrap());else if($ instanceof W4)return Z0($._def.innerType);else return[]};class i6 extends o{_parse($){let{ctx:G}=this._processInputParams($);if(G.parsedType!==C.object)return x(G,{code:T.invalid_type,expected:C.object,received:G.parsedType}),u;let X=this.discriminator,Y=G.data[X],W=this.optionsMap.get(Y);if(!W)return x(G,{code:T.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[X]}),u;if(G.common.async)return W._parseAsync({data:G.data,path:G.path,parent:G});else return W._parseSync({data:G.data,path:G.path,parent:G})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,G,X){let Y=new Map;for(let W of G){let V=Z0(W.shape[$]);if(!V.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let q of V){if(Y.has(q))throw Error(`Discriminator property ${String($)} has duplicate value ${String(q)}`);Y.set(q,W)}}return new i6({typeName:p.ZodDiscriminatedUnion,discriminator:$,options:G,optionsMap:Y,...c(X)})}}function n9($,G){let X=J0($),Y=J0(G);if($===G)return{valid:!0,data:$};else if(X===C.object&&Y===C.object){let W=a.objectKeys(G),V=a.objectKeys($).filter((J)=>W.indexOf(J)!==-1),q={...$,...G};for(let J of V){let U=n9($[J],G[J]);if(!U.valid)return{valid:!1};q[J]=U.data}return{valid:!0,data:q}}else if(X===C.array&&Y===C.array){if($.length!==G.length)return{valid:!1};let W=[];for(let V=0;V<$.length;V++){let q=$[V],J=G[V],U=n9(q,J);if(!U.valid)return{valid:!1};W.push(U.data)}return{valid:!0,data:W}}else if(X===C.date&&Y===C.date&&+$===+G)return{valid:!0,data:$};else return{valid:!1}}class e2 extends o{_parse($){let{status:G,ctx:X}=this._processInputParams($),Y=(W,V)=>{if(d6(W)||d6(V))return u;let q=n9(W.value,V.value);if(!q.valid)return x(X,{code:T.invalid_intersection_types}),u;if(c6(W)||c6(V))G.dirty();return{status:G.value,value:q.data}};if(X.common.async)return Promise.all([this._def.left._parseAsync({data:X.data,path:X.path,parent:X}),this._def.right._parseAsync({data:X.data,path:X.path,parent:X})]).then(([W,V])=>Y(W,V));else return Y(this._def.left._parseSync({data:X.data,path:X.path,parent:X}),this._def.right._parseSync({data:X.data,path:X.path,parent:X}))}}e2.create=($,G,X)=>{return new e2({left:$,right:G,typeName:p.ZodIntersection,...c(X)})};class U0 extends o{_parse($){let{status:G,ctx:X}=this._processInputParams($);if(X.parsedType!==C.array)return x(X,{code:T.invalid_type,expected:C.array,received:X.parsedType}),u;if(X.data.length<this._def.items.length)return x(X,{code:T.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),u;if(!this._def.rest&&X.data.length>this._def.items.length)x(X,{code:T.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),G.dirty();let W=[...X.data].map((V,q)=>{let J=this._def.items[q]||this._def.rest;if(!J)return null;return J._parse(new $0(X,V,X.path,q))}).filter((V)=>!!V);if(X.common.async)return Promise.all(W).then((V)=>{return _1.mergeArray(G,V)});else return _1.mergeArray(G,W)}get items(){return this._def.items}rest($){return new U0({...this._def,rest:$})}}U0.create=($,G)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new U0({items:$,typeName:p.ZodTuple,rest:null,...c(G)})};class y4 extends o{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:G,ctx:X}=this._processInputParams($);if(X.parsedType!==C.object)return x(X,{code:T.invalid_type,expected:C.object,received:X.parsedType}),u;let Y=[],W=this._def.keyType,V=this._def.valueType;for(let q in X.data)Y.push({key:W._parse(new $0(X,q,X.path,q)),value:V._parse(new $0(X,X.data[q],X.path,q)),alwaysSet:q in X.data});if(X.common.async)return _1.mergeObjectAsync(G,Y);else return _1.mergeObjectSync(G,Y)}get element(){return this._def.valueType}static create($,G,X){if(G instanceof o)return new y4({keyType:$,valueType:G,typeName:p.ZodRecord,...c(X)});return new y4({keyType:a1.create(),valueType:$,typeName:p.ZodRecord,...c(G)})}}class f4 extends o{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:G,ctx:X}=this._processInputParams($);if(X.parsedType!==C.map)return x(X,{code:T.invalid_type,expected:C.map,received:X.parsedType}),u;let Y=this._def.keyType,W=this._def.valueType,V=[...X.data.entries()].map(([q,J],U)=>{return{key:Y._parse(new $0(X,q,X.path,[U,"key"])),value:W._parse(new $0(X,J,X.path,[U,"value"]))}});if(X.common.async){let q=new Map;return Promise.resolve().then(async()=>{for(let J of V){let U=await J.key,R=await J.value;if(U.status==="aborted"||R.status==="aborted")return u;if(U.status==="dirty"||R.status==="dirty")G.dirty();q.set(U.value,R.value)}return{status:G.value,value:q}})}else{let q=new Map;for(let J of V){let{key:U,value:R}=J;if(U.status==="aborted"||R.status==="aborted")return u;if(U.status==="dirty"||R.status==="dirty")G.dirty();q.set(U.value,R.value)}return{status:G.value,value:q}}}}f4.create=($,G,X)=>{return new f4({valueType:G,keyType:$,typeName:p.ZodMap,...c(X)})};class Q2 extends o{_parse($){let{status:G,ctx:X}=this._processInputParams($);if(X.parsedType!==C.set)return x(X,{code:T.invalid_type,expected:C.set,received:X.parsedType}),u;let Y=this._def;if(Y.minSize!==null){if(X.data.size<Y.minSize.value)x(X,{code:T.too_small,minimum:Y.minSize.value,type:"set",inclusive:!0,exact:!1,message:Y.minSize.message}),G.dirty()}if(Y.maxSize!==null){if(X.data.size>Y.maxSize.value)x(X,{code:T.too_big,maximum:Y.maxSize.value,type:"set",inclusive:!0,exact:!1,message:Y.maxSize.message}),G.dirty()}let W=this._def.valueType;function V(J){let U=new Set;for(let R of J){if(R.status==="aborted")return u;if(R.status==="dirty")G.dirty();U.add(R.value)}return{status:G.value,value:U}}let q=[...X.data.values()].map((J,U)=>W._parse(new $0(X,J,X.path,U)));if(X.common.async)return Promise.all(q).then((J)=>V(J));else return V(q)}min($,G){return new Q2({...this._def,minSize:{value:$,message:g.toString(G)}})}max($,G){return new Q2({...this._def,maxSize:{value:$,message:g.toString(G)}})}size($,G){return this.min($,G).max($,G)}nonempty($){return this.min(1,$)}}Q2.create=($,G)=>{return new Q2({valueType:$,minSize:null,maxSize:null,typeName:p.ZodSet,...c(G)})};class n2 extends o{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:G}=this._processInputParams($);if(G.parsedType!==C.function)return x(G,{code:T.invalid_type,expected:C.function,received:G.parsedType}),u;function X(q,J){return v4({data:q,path:G.path,errorMaps:[G.common.contextualErrorMap,G.schemaErrorMap,d2(),N0].filter((U)=>!!U),issueData:{code:T.invalid_arguments,argumentsError:J}})}function Y(q,J){return v4({data:q,path:G.path,errorMaps:[G.common.contextualErrorMap,G.schemaErrorMap,d2(),N0].filter((U)=>!!U),issueData:{code:T.invalid_return_type,returnTypeError:J}})}let W={errorMap:G.common.contextualErrorMap},V=G.data;if(this._def.returns instanceof K2){let q=this;return S1(async function(...J){let U=new C1([]),R=await q._def.args.parseAsync(J,W).catch((A)=>{throw U.addIssue(X(J,A)),U}),D=await Reflect.apply(V,this,R);return await q._def.returns._def.type.parseAsync(D,W).catch((A)=>{throw U.addIssue(Y(D,A)),U})})}else{let q=this;return S1(function(...J){let U=q._def.args.safeParse(J,W);if(!U.success)throw new C1([X(J,U.error)]);let R=Reflect.apply(V,this,U.data),D=q._def.returns.safeParse(R,W);if(!D.success)throw new C1([Y(R,D.error)]);return D.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new n2({...this._def,args:U0.create($).rest(y0.create())})}returns($){return new n2({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,G,X){return new n2({args:$?$:U0.create([]).rest(y0.create()),returns:G||y0.create(),typeName:p.ZodFunction,...c(X)})}}class $4 extends o{get schema(){return this._def.getter()}_parse($){let{ctx:G}=this._processInputParams($);return this._def.getter()._parse({data:G.data,path:G.path,parent:G})}}$4.create=($,G)=>{return new $4({getter:$,typeName:p.ZodLazy,...c(G)})};class G4 extends o{_parse($){if($.data!==this._def.value){let G=this._getOrReturnCtx($);return x(G,{received:G.data,code:T.invalid_literal,expected:this._def.value}),u}return{status:"valid",value:$.data}}get value(){return this._def.value}}G4.create=($,G)=>{return new G4({value:$,typeName:p.ZodLiteral,...c(G)})};function fX($,G){return new u0({values:$,typeName:p.ZodEnum,...c(G)})}class u0 extends o{_parse($){if(typeof $.data!=="string"){let G=this._getOrReturnCtx($),X=this._def.values;return x(G,{expected:a.joinValues(X),received:G.parsedType,code:T.invalid_type}),u}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let G=this._getOrReturnCtx($),X=this._def.values;return x(G,{received:G.data,code:T.invalid_enum_value,options:X}),u}return S1($.data)}get options(){return this._def.values}get enum(){let $={};for(let G of this._def.values)$[G]=G;return $}get Values(){let $={};for(let G of this._def.values)$[G]=G;return $}get Enum(){let $={};for(let G of this._def.values)$[G]=G;return $}extract($,G=this._def){return u0.create($,{...this._def,...G})}exclude($,G=this._def){return u0.create(this.options.filter((X)=>!$.includes(X)),{...this._def,...G})}}u0.create=fX;class X4 extends o{_parse($){let G=a.getValidEnumValues(this._def.values),X=this._getOrReturnCtx($);if(X.parsedType!==C.string&&X.parsedType!==C.number){let Y=a.objectValues(G);return x(X,{expected:a.joinValues(Y),received:X.parsedType,code:T.invalid_type}),u}if(!this._cache)this._cache=new Set(a.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let Y=a.objectValues(G);return x(X,{received:X.data,code:T.invalid_enum_value,options:Y}),u}return S1($.data)}get enum(){return this._def.values}}X4.create=($,G)=>{return new X4({values:$,typeName:p.ZodNativeEnum,...c(G)})};class K2 extends o{unwrap(){return this._def.type}_parse($){let{ctx:G}=this._processInputParams($);if(G.parsedType!==C.promise&&G.common.async===!1)return x(G,{code:T.invalid_type,expected:C.promise,received:G.parsedType}),u;let X=G.parsedType===C.promise?G.data:Promise.resolve(G.data);return S1(X.then((Y)=>{return this._def.type.parseAsync(Y,{path:G.path,errorMap:G.common.contextualErrorMap})}))}}K2.create=($,G)=>{return new K2({type:$,typeName:p.ZodPromise,...c(G)})};class G0 extends o{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===p.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:G,ctx:X}=this._processInputParams($),Y=this._def.effect||null,W={addIssue:(V)=>{if(x(X,V),V.fatal)G.abort();else G.dirty()},get path(){return X.path}};if(W.addIssue=W.addIssue.bind(W),Y.type==="preprocess"){let V=Y.transform(X.data,W);if(X.common.async)return Promise.resolve(V).then(async(q)=>{if(G.value==="aborted")return u;let J=await this._def.schema._parseAsync({data:q,path:X.path,parent:X});if(J.status==="aborted")return u;if(J.status==="dirty")return R2(J.value);if(G.value==="dirty")return R2(J.value);return J});else{if(G.value==="aborted")return u;let q=this._def.schema._parseSync({data:V,path:X.path,parent:X});if(q.status==="aborted")return u;if(q.status==="dirty")return R2(q.value);if(G.value==="dirty")return R2(q.value);return q}}if(Y.type==="refinement"){let V=(q)=>{let J=Y.refinement(q,W);if(X.common.async)return Promise.resolve(J);if(J instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return q};if(X.common.async===!1){let q=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(q.status==="aborted")return u;if(q.status==="dirty")G.dirty();return V(q.value),{status:G.value,value:q.value}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((q)=>{if(q.status==="aborted")return u;if(q.status==="dirty")G.dirty();return V(q.value).then(()=>{return{status:G.value,value:q.value}})})}if(Y.type==="transform")if(X.common.async===!1){let V=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(!h0(V))return u;let q=Y.transform(V.value,W);if(q instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:G.value,value:q}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((V)=>{if(!h0(V))return u;return Promise.resolve(Y.transform(V.value,W)).then((q)=>({status:G.value,value:q}))});a.assertNever(Y)}}G0.create=($,G,X)=>{return new G0({schema:$,typeName:p.ZodEffects,effect:G,...c(X)})};G0.createWithPreprocess=($,G,X)=>{return new G0({schema:G,effect:{type:"preprocess",transform:$},typeName:p.ZodEffects,...c(X)})};class e1 extends o{_parse($){if(this._getType($)===C.undefined)return S1(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}e1.create=($,G)=>{return new e1({innerType:$,typeName:p.ZodOptional,...c(G)})};class z0 extends o{_parse($){if(this._getType($)===C.null)return S1(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}z0.create=($,G)=>{return new z0({innerType:$,typeName:p.ZodNullable,...c(G)})};class Y4 extends o{_parse($){let{ctx:G}=this._processInputParams($),X=G.data;if(G.parsedType===C.undefined)X=this._def.defaultValue();return this._def.innerType._parse({data:X,path:G.path,parent:G})}removeDefault(){return this._def.innerType}}Y4.create=($,G)=>{return new Y4({innerType:$,typeName:p.ZodDefault,defaultValue:typeof G.default==="function"?G.default:()=>G.default,...c(G)})};class W4 extends o{_parse($){let{ctx:G}=this._processInputParams($),X={...G,common:{...G.common,issues:[]}},Y=this._def.innerType._parse({data:X.data,path:X.path,parent:{...X}});if(c2(Y))return Y.then((W)=>{return{status:"valid",value:W.status==="valid"?W.value:this._def.catchValue({get error(){return new C1(X.common.issues)},input:X.data})}});else return{status:"valid",value:Y.status==="valid"?Y.value:this._def.catchValue({get error(){return new C1(X.common.issues)},input:X.data})}}removeCatch(){return this._def.innerType}}W4.create=($,G)=>{return new W4({innerType:$,typeName:p.ZodCatch,catchValue:typeof G.catch==="function"?G.catch:()=>G.catch,...c(G)})};class m4 extends o{_parse($){if(this._getType($)!==C.nan){let X=this._getOrReturnCtx($);return x(X,{code:T.invalid_type,expected:C.nan,received:X.parsedType}),u}return{status:"valid",value:$.data}}}m4.create=($)=>{return new m4({typeName:p.ZodNaN,...c($)})};var QF=Symbol("zod_brand");class n6 extends o{_parse($){let{ctx:G}=this._processInputParams($),X=G.data;return this._def.type._parse({data:X,path:G.path,parent:G})}unwrap(){return this._def.type}}class u4 extends o{_parse($){let{status:G,ctx:X}=this._processInputParams($);if(X.common.async)return(async()=>{let W=await this._def.in._parseAsync({data:X.data,path:X.path,parent:X});if(W.status==="aborted")return u;if(W.status==="dirty")return G.dirty(),R2(W.value);else return this._def.out._parseAsync({data:W.value,path:X.path,parent:X})})();else{let Y=this._def.in._parseSync({data:X.data,path:X.path,parent:X});if(Y.status==="aborted")return u;if(Y.status==="dirty")return G.dirty(),{status:"dirty",value:Y.value};else return this._def.out._parseSync({data:Y.value,path:X.path,parent:X})}}static create($,G){return new u4({in:$,out:G,typeName:p.ZodPipeline})}}class V4 extends o{_parse($){let G=this._def.innerType._parse($),X=(Y)=>{if(h0(Y))Y.value=Object.freeze(Y.value);return Y};return c2(G)?G.then((Y)=>X(Y)):X(G)}unwrap(){return this._def.innerType}}V4.create=($,G)=>{return new V4({innerType:$,typeName:p.ZodReadonly,...c(G)})};function vX($,G){let X=typeof $==="function"?$(G):typeof $==="string"?{message:$}:$;return typeof X==="string"?{message:X}:X}function mX($,G={},X){if($)return M2.create().superRefine((Y,W)=>{let V=$(Y);if(V instanceof Promise)return V.then((q)=>{if(!q){let J=vX(G,Y),U=J.fatal??X??!0;W.addIssue({code:"custom",...J,fatal:U})}});if(!V){let q=vX(G,Y),J=q.fatal??X??!0;W.addIssue({code:"custom",...q,fatal:J})}return});return M2.create()}var KF={object:q1.lazycreate},p;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(p||(p={}));var FF=($,G={message:`Input not instance of ${$.name}`})=>mX((X)=>X instanceof $,G),uX=a1.create,pX=f0.create,AF=m4.create,wF=m0.create,lX=o2.create,BF=D2.create,OF=g4.create,PF=s2.create,NF=a2.create,ZF=M2.create,zF=y0.create,_F=H0.create,LF=h4.create,EF=t1.create,jF=q1.create,TF=q1.strictCreate,CF=t2.create,SF=i6.create,IF=e2.create,xF=U0.create,kF=y4.create,bF=f4.create,vF=Q2.create,gF=n2.create,hF=$4.create,yF=G4.create,fF=u0.create,mF=X4.create,uF=K2.create,pF=G0.create,lF=e1.create,rF=z0.create,dF=G0.createWithPreprocess,cF=u4.create,iF=()=>uX().optional(),nF=()=>pX().optional(),oF=()=>lX().optional(),sF={string:($)=>a1.create({...$,coerce:!0}),number:($)=>f0.create({...$,coerce:!0}),boolean:($)=>o2.create({...$,coerce:!0}),bigint:($)=>m0.create({...$,coerce:!0}),date:($)=>D2.create({...$,coerce:!0})};var aF=u;function R0($){return $ instanceof Error?$.message:String($)}function GA($){return $}function XA($){return $}function YA($){return $===void 0?{success:!0}:{success:!0,data:$}}function WA($){return{success:!1,error:$}}var VA=H.object({captureUrls:H.boolean().default(!1),blockedUrlDomains:H.array(H.string()).default(["meet.google.com","zoom.us","teams.microsoft.com","whereby.com","gather.town","calendly.com","cal.com","discord.com","discord.gg","cdn.discordapp.com","media.discordapp.net","giphy.com","tenor.com","wetransfer.com","file.io"])});function qA($,G){return{name:$,schema:G}}var p0=H.enum(["anchor","trusted","public"]),HA=H.enum(["create","update","delete","extract","publish"]),q4=H.enum(["never","anchor","trusted","public"]),rX=H.object({create:q4.optional(),update:q4.optional(),delete:q4.optional(),extract:q4.optional(),publish:q4.optional()}).strict(),UA=H.record(H.string(),rX);var RA=H.object({name:H.string(),description:H.string(),schema:H.any(),basePrompt:H.string().optional(),useKnowledgeContext:H.boolean().optional(),requiredPermission:p0,formatter:H.any().optional(),layout:H.object({component:H.any(),fullscreen:H.boolean().optional()}).optional(),dataSourceId:H.string().optional()});class p4{static canGenerate($){return!!$.basePrompt&&!!$.dataSourceId&&$.dataSourceId.includes("ai-content")}static canFetch($){return!!$.dataSourceId&&!this.canGenerate($)}static canRender($){return!!$.layout?.component}static isStaticOnly($){return!this.canGenerate($)&&!this.canFetch($)}static getCapabilities($){return{canGenerate:this.canGenerate($),canFetch:this.canFetch($),canRender:this.canRender($),isStaticOnly:this.isStaticOnly($)}}static validate($){let G=[];if($.dataSourceId?.includes("ai-content")&&!$.basePrompt)G.push(`Template "${$.name}" has AI-content dataSourceId but no basePrompt. AI generation requires a basePrompt.`);if($.basePrompt&&(!$.dataSourceId||!$.dataSourceId.includes("ai-content")))G.push(`Template "${$.name}" has basePrompt but no AI-content dataSourceId. The basePrompt won't be used.`);return G}static logCapabilities($,G){let X=this.getCapabilities($),Y=this.validate($);if(G)G.debug(`Template capabilities for "${$.name}":`,{...X,errors:Y.length>0?Y:void 0})}}var DA=H.enum(["site-content-preview","site-content-production"]),MA=H.enum(["web","image","pdf"]),QA=H.object({name:H.string(),schema:H.any(),description:H.string().optional(),pluginId:H.string(),renderers:H.object({web:H.union([H.function(),H.string()]).optional(),image:H.union([H.function(),H.string()]).optional(),pdf:H.union([H.function(),H.string()]).optional()})}),KA=H.object({enableContentGeneration:H.boolean().default(!1),outputDir:H.string(),workingDir:H.string().optional(),environment:H.enum(["preview","production"]).default("preview"),siteConfig:H.object({title:H.string(),description:H.string(),url:H.string().optional()}).optional()}),FA=H.object({success:H.boolean(),routesBuilt:H.number(),errors:H.array(H.string()).optional(),warnings:H.array(H.string()).optional()});var dX=H.enum(["anchor","trusted","public"]),wA=H.object({conversationId:H.string().min(1),message:H.string(),interfaceType:H.string().min(1),channelId:H.string().optional(),channelName:H.string().optional(),userPermissionLevel:dX}),cX=H.object({id:H.string().min(1),source:H.string().min(1),title:H.string().optional(),content:H.string().min(1),provenance:H.record(H.string(),H.unknown()).optional()}),BA=H.object({items:H.array(cX).default([])});var OA=H.object({url:H.string(),authToken:H.string().optional()});var PA=H.object({success:H.boolean(),entityId:H.string().optional(),error:H.string().optional()});var F2=H.enum(["user","assistant"]);var iX=H.object({message:H.string().describe("Natural language response to the query"),summary:H.string().optional().describe("Brief summary if applicable"),topics:H.array(H.string()).optional().describe("Related topics mentioned"),sources:H.array(H.object({id:H.string(),type:H.string(),excerpt:H.string().optional(),relevance:H.number().min(0).max(1).optional()})).optional().describe("Source entities used to answer the query"),metadata:H.record(H.string(),H.unknown()).optional()}).describe("defaultQueryResponse"),nX=H.object({message:H.string()}).describe("simpleTextResponse"),oX=H.object({success:H.boolean(),entityId:H.string().optional(),message:H.string()}).describe("createEntityResponse"),sX=H.object({success:H.boolean(),entityId:H.string(),changes:H.array(H.string()).optional(),message:H.string()}).describe("updateEntityResponse");var NA=H.object({status:H.enum(["healthy","warning","error","unknown"]),message:H.string().optional(),lastCheck:H.date().optional(),details:H.record(H.string(),H.unknown()).optional()}),aX=H.object({name:H.string(),pluginId:H.string(),status:H.string(),health:NA.optional()});import{McpServer as IS,ResourceTemplate as xS}from"@modelcontextprotocol/sdk/server/mcp.js";var o6=H.object({interfaceType:H.string(),userId:H.string(),conversationId:H.string().optional(),channelId:H.string().optional(),channelName:H.string().optional(),userPermissionLevel:H.enum(["anchor","trusted","public"]).optional()}),tX=H.object({success:H.literal(!0),data:H.unknown(),message:H.string().optional()}).strict().superRefine(($,G)=>{if(!Object.prototype.hasOwnProperty.call($,"data"))G.addIssue({code:H.ZodIssueCode.custom,path:["data"],message:"Required"})}),eX=H.object({success:H.literal(!1),error:H.string(),code:H.string().optional()}).strict(),$Y=H.object({needsConfirmation:H.literal(!0),toolName:H.string(),summary:H.string(),preview:H.string().optional(),args:H.unknown()}).strict(),o9=H.union([tX,eX,$Y]);var LS=H.union([H.object({success:H.literal(!0),data:H.unknown()}).superRefine(($,G)=>{if(!Object.prototype.hasOwnProperty.call($,"data"))G.addIssue({code:H.ZodIssueCode.custom,path:["data"],message:"Required"})}),H.object({success:H.literal(!1),error:H.string()})]);var ZA=H.union([H.object({success:H.literal(!0),data:H.unknown(),message:H.string().optional()}),H.object({success:H.literal(!1),error:H.string(),code:H.string().optional()})]);var KI=H.object({id:H.string(),type:H.string(),version:H.string(),status:H.string()}),FI=H.object({name:H.string(),description:H.string()}),s9=H.object({label:H.string(),url:H.string(),pluginId:H.string(),priority:H.number().default(100),visibility:p0.default("public")}),zA=H.enum(["human","agent","admin","protocol"]),_A=H.enum(["available","coming-soon","disabled"]),a9=H.object({id:H.string(),label:H.string(),description:H.string().optional(),href:H.string(),kind:zA,pluginId:H.string(),priority:H.number().default(100),visibility:p0.default("public"),status:_A.default("available")}),t9=H.object({entityType:H.string(),count:H.number()}),AI=H.object({model:H.string(),version:H.string(),uptime:H.number(),entities:H.number(),entityCounts:H.array(t9),embeddings:H.number(),ai:H.object({model:H.string(),embeddingModel:H.string()}),daemons:H.array(aX),endpoints:H.array(s9),interactions:H.array(a9)});var wI=H.object({id:H.string(),version:H.string(),type:H.enum(["core","entity","service","interface"]),description:H.string().optional(),dependencies:H.array(H.string()).optional(),packageName:H.string()});var LA=H.object({toolName:H.string(),args:H.unknown(),progressToken:H.union([H.string(),H.number()]).optional(),hasProgress:H.boolean().optional(),...o6.shape}),EA=H.object({resourceUri:H.string()});class A2{id;version;description;packageName;config;context;get logger(){return this.context?.logger??N1.createFresh({context:this.id})}constructor($,G,X,Y){this.id=$,this.packageName=G.name,this.version=G.version,this.description=G.description??`${G.name} plugin`,this.config=Y.parse(X)}setupMessageHandlers($){$.messaging.subscribe(`plugin:${this.id}:tool:execute`,async(G)=>{try{let{toolName:X,args:Y,progressToken:W,hasProgress:V,interfaceType:q,userId:J,channelId:U,userPermissionLevel:R}=LA.parse(G.payload),M=(await this.getTools()).find((Z)=>Z.name===X);if(!M)return{success:!1,error:`Tool not found: ${X}`};let A={interfaceType:q,userId:J,...U&&{channelId:U},...R&&{userPermissionLevel:R},...V&&W!==void 0&&{progressToken:W,sendProgress:async(Z)=>{await $.messaging.send({type:`plugin:${this.id}:progress`,payload:{progressToken:W,notification:Z}})}}};return{success:!0,data:await M.handler(Y,A)}}catch(X){if(X instanceof H.ZodError)return{success:!1,error:"Invalid tool execution request format"};return this.logger.error("Tool execution error",X),{success:!1,error:R0(X)}}}),$.messaging.subscribe(`plugin:${this.id}:resource:get`,async(G)=>{try{let{resourceUri:X}=EA.parse(G.payload),W=(await this.getResources()).find((q)=>q.uri===X);if(!W)return{success:!1,error:`Resource not found: ${X}`};return{success:!0,data:await W.handler()}}catch(X){if(X instanceof H.ZodError)return{success:!1,error:"Invalid resource get request format"};return this.logger.error("Resource fetch error",X),{success:!1,error:R0(X)}}})}async onRegister($){}async onReady($){}async ready(){await this.onReady(this.getContext())}async getCapabilities(){let $=await this.getInstructions();return{tools:await this.getTools(),resources:await this.getResources(),...$&&{instructions:$}}}async getTools(){return[]}async getResources(){return[]}async getInstructions(){return}async shutdown(){await this.onShutdown()}async onShutdown(){}getContext(){if(!this.context)throw Error(`Plugin ${this.id}: Plugin not registered yet`);return this.context}determineUserPermissionLevel($){return"public"}createProgressBridge($){if(!$)return;let G=this.context;if(!G)return;let X=this.id;return x0.from(async(Y)=>{await G.messaging.send({type:`plugin:${X}:progress`,payload:{progressToken:$,notification:{progress:Y.progress,total:Y.total,message:Y.message}}})})}}var GY=H.object({id:H.string(),template:H.string(),content:H.unknown().optional(),dataQuery:H.object({entityType:H.string().optional(),template:H.string().optional(),query:H.object({id:H.string().optional(),limit:H.number().optional(),offset:H.number().optional()}).passthrough().optional()}).passthrough().optional(),order:H.number().optional()}),XY=["primary","secondary"],YY=H.object({show:H.boolean().default(!1),label:H.string().optional(),slot:H.enum(XY).default("primary"),priority:H.number().min(0).max(100).default(50)}).optional(),WY=H.object({id:H.string(),path:H.string(),title:H.string().default(""),pageLabel:H.string().optional(),description:H.string().default(""),sections:H.array(GY).default([]),layout:H.string().default("default"),fullscreen:H.boolean().optional(),pluginId:H.string().optional(),sourceEntityType:H.string().optional(),external:H.boolean().optional(),navigation:YY}),jA=H.object({routes:H.array(WY),pluginId:H.string()}),TA=H.object({paths:H.array(H.string()).optional(),pluginId:H.string().optional()}),CA=H.object({pluginId:H.string().optional()}),SA=H.object({path:H.string()}),s6=H.object({label:H.string(),href:H.string(),priority:H.number()});var VY=H.object({heading:H.string().describe("Main CTA heading text"),buttonText:H.string().describe("Call-to-action button text"),buttonLink:H.string().describe("URL or anchor for the CTA button")}),qY=H.object({blurb:H.string().optional().describe("Short italic subtitle under the section title")}),JY=H.object({title:H.string().describe("The site's title"),description:H.string().describe("The site's description"),url:H.string().optional().describe("Canonical site URL"),copyright:H.string().optional().describe("Copyright notice text"),logo:H.boolean().optional().describe("Whether to display logo instead of title text in header"),themeMode:H.enum(["light","dark"]).optional().describe("Default theme mode"),analyticsScript:H.string().optional().describe("Analytics script HTML"),cta:VY.optional().describe("Call-to-action configuration"),sections:H.record(H.string(),qY).optional().describe("Optional per-section blurbs, keyed by section id (e.g. 'essays', 'presentations', 'about'). Used by homepage templates that render editorial section headers.")}),IA=H.object({platform:H.enum(["github","instagram","linkedin","email","website"]).describe("Social media platform"),url:H.string().describe("Profile or contact URL"),label:H.string().optional().describe("Optional display label")}),xA=JY.extend({navigation:H.object({primary:H.array(s6),secondary:H.array(s6)}),copyright:H.string(),socialLinks:H.array(IA).optional().describe("Social media links from profile metadata")});function e9($){return`preview.${$.trim().replace(/^https?:\/\//,"")}`}var kA=H.string(),bA=H.object({id:H.string().min(1)}).passthrough(),vA=H.object({label:H.string().min(1)}).passthrough(),gA=H.object({layouts:H.record(H.unknown()),plugin:H.function(),routes:H.array(bA),entityDisplay:H.record(vA),staticAssets:H.record(H.string()).optional()}).passthrough(),hA=H.custom(($)=>gA.safeParse($).success);var HY=H.enum(["file_operations","content_operations","data_processing","batch_processing"]),UY=H.object({pluginId:H.string().optional(),progressToken:H.union([H.string(),H.number()]).optional(),operationType:HY,operationTarget:H.string().optional(),interfaceType:H.string().optional(),channelId:H.string().optional()}),l4=UY.extend({rootJobId:H.string()}),dI=H.enum(["none","skip","replace","coalesce"]);var $8=H.enum(["pending","processing","completed","failed"]),RY=H.enum(["completed","failed"]);var yA=H.object({id:H.string(),type:H.string(),status:$8,data:H.unknown(),result:H.unknown().optional(),lastError:H.string().optional().nullable(),attempts:H.number(),maxRetries:H.number(),priority:H.number(),createdAt:H.date(),updatedAt:H.date(),processedAt:H.date().optional().nullable(),completedAt:H.date().optional().nullable(),failedAt:H.date().optional().nullable()}),fA=H.object({jobId:H.string(),type:H.string(),status:RY,result:H.unknown().optional(),error:H.string().optional()}),DY=H.object({success:H.literal(!1),error:H.string().optional()}),G8=H.object({id:H.string(),type:H.enum(["job","batch"]),status:$8,message:H.string().optional(),progress:H.object({current:H.number(),total:H.number(),percentage:H.number()}).optional(),aggregationKey:H.string().optional(),batchDetails:H.object({totalOperations:H.number(),completedOperations:H.number(),failedOperations:H.number(),currentOperation:H.string().optional(),errors:H.array(H.string()).optional()}).optional(),jobDetails:H.object({jobType:H.string(),priority:H.number(),retryCount:H.number()}).optional(),metadata:l4});import{createClient as gk}from"@libsql/client";var I=Symbol.for("drizzle:entityKind");function b1($,G){if(!$||typeof $!=="object")return!1;if($ instanceof G)return!0;if(!Object.prototype.hasOwnProperty.call(G,I))throw Error(`Class "${G.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let X=Object.getPrototypeOf($).constructor;if(X)while(X){if(I in X&&X[I]===G[I])return!0;X=Object.getPrototypeOf(X)}return!1}class l0{constructor($,G){this.table=$,this.config=G,this.name=G.name,this.keyAsName=G.keyAsName,this.notNull=G.notNull,this.default=G.default,this.defaultFn=G.defaultFn,this.onUpdateFn=G.onUpdateFn,this.hasDefault=G.hasDefault,this.primary=G.primaryKey,this.isUnique=G.isUnique,this.uniqueName=G.uniqueName,this.uniqueType=G.uniqueType,this.dataType=G.dataType,this.columnType=G.columnType,this.generated=G.generated,this.generatedIdentity=G.generatedIdentity}static[I]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue($){return $}mapToDriverValue($){return $}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class X8{static[I]="ColumnBuilder";config;constructor($,G,X){this.config={name:$,keyAsName:$==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:G,columnType:X,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default($){return this.config.default=$,this.config.hasDefault=!0,this}$defaultFn($){return this.config.defaultFn=$,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn($){return this.config.onUpdateFn=$,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName($){if(this.config.name!=="")return;this.config.name=$}}var X0=Symbol.for("drizzle:Name");function MY($,...G){return $(...G)}function QY($,G){return`${$[X0]}_${G.join("_")}_unique`}class r4 extends l0{constructor($,G){if(!G.uniqueName)G.uniqueName=QY($,[G.name]);super($,G);this.table=$}static[I]="PgColumn"}class mA extends r4{static[I]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op($){return this.indexConfig.opClass=$,this}}class uA extends r4{static[I]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor($,G){super($,G);this.enum=G.enum}getSQLType(){return this.enum.enumName}}var KY=Symbol.for("drizzle:isPgEnum");function FY($){return!!$&&typeof $==="function"&&KY in $&&$[KY]===!0}class pA extends r4{static[I]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor($,G){super($,G);this.enum=G.enum}getSQLType(){return this.enum.enumName}}class a6{static[I]="Subquery";constructor($,G,X,Y=!1,W=[]){this._={brand:"Subquery",sql:$,selectedFields:G,alias:X,isWith:Y,usedTables:W}}}var AY="0.44.7";var Y8,W8,wY={startActiveSpan($,G){if(!Y8)return G();if(!W8)W8=Y8.trace.getTracer("drizzle-orm",AY);return MY((X,Y)=>Y.startActiveSpan($,(W)=>{try{return G(W)}catch(V){throw W.setStatus({code:X.SpanStatusCode.ERROR,message:V instanceof Error?V.message:"Unknown error"}),V}finally{W.end()}}),Y8,W8)}};var J4=Symbol.for("drizzle:ViewBaseConfig");var V8=Symbol.for("drizzle:Schema"),BY=Symbol.for("drizzle:Columns"),OY=Symbol.for("drizzle:ExtraConfigColumns"),q8=Symbol.for("drizzle:OriginalName"),J8=Symbol.for("drizzle:BaseName"),d4=Symbol.for("drizzle:IsAlias"),PY=Symbol.for("drizzle:ExtraConfigBuilder"),lA=Symbol.for("drizzle:IsDrizzleTable");class M1{static[I]="Table";static Symbol={Name:X0,Schema:V8,OriginalName:q8,Columns:BY,ExtraConfigColumns:OY,BaseName:J8,IsAlias:d4,ExtraConfigBuilder:PY};[X0];[q8];[V8];[BY];[OY];[J8];[d4]=!1;[lA]=!0;[PY]=void 0;constructor($,G,X){this[X0]=this[q8]=$,this[V8]=G,this[J8]=X}}function rA($){return $!==null&&$!==void 0&&typeof $.getSQL==="function"}function dA($){let G={sql:"",params:[]};for(let X of $)if(G.sql+=X.sql,G.params.push(...X.params),X.typings?.length){if(!G.typings)G.typings=[];G.typings.push(...X.typings)}return G}class o1{static[I]="StringChunk";value;constructor($){this.value=Array.isArray($)?$:[$]}getSQL(){return new Q1([this])}}class Q1{constructor($){this.queryChunks=$;for(let G of $)if(b1(G,M1)){let X=G[M1.Symbol.Schema];this.usedTables.push(X===void 0?G[M1.Symbol.Name]:X+"."+G[M1.Symbol.Name])}}static[I]="SQL";decoder=NY;shouldInlineParams=!1;usedTables=[];append($){return this.queryChunks.push(...$.queryChunks),this}toQuery($){return wY.startActiveSpan("drizzle.buildSQL",(G)=>{let X=this.buildQueryFromSourceParams(this.queryChunks,$);return G?.setAttributes({"drizzle.query.text":X.sql,"drizzle.query.params":JSON.stringify(X.params)}),X})}buildQueryFromSourceParams($,G){let X=Object.assign({},G,{inlineParams:G.inlineParams||this.shouldInlineParams,paramStartIndex:G.paramStartIndex||{value:0}}),{casing:Y,escapeName:W,escapeParam:V,prepareTyping:q,inlineParams:J,paramStartIndex:U}=X;return dA($.map((R)=>{if(b1(R,o1))return{sql:R.value.join(""),params:[]};if(b1(R,t6))return{sql:W(R.value),params:[]};if(R===void 0)return{sql:"",params:[]};if(Array.isArray(R)){let D=[new o1("(")];for(let[M,A]of R.entries())if(D.push(A),M<R.length-1)D.push(new o1(", "));return D.push(new o1(")")),this.buildQueryFromSourceParams(D,X)}if(b1(R,Q1))return this.buildQueryFromSourceParams(R.queryChunks,{...X,inlineParams:J||R.shouldInlineParams});if(b1(R,M1)){let D=R[M1.Symbol.Schema],M=R[M1.Symbol.Name];return{sql:D===void 0||R[d4]?W(M):W(D)+"."+W(M),params:[]}}if(b1(R,l0)){let D=Y.getColumnCasing(R);if(G.invokeSource==="indexes")return{sql:W(D),params:[]};let M=R.table[M1.Symbol.Schema];return{sql:R.table[d4]||M===void 0?W(R.table[M1.Symbol.Name])+"."+W(D):W(M)+"."+W(R.table[M1.Symbol.Name])+"."+W(D),params:[]}}if(b1(R,zY)){let D=R[J4].schema,M=R[J4].name;return{sql:D===void 0||R[J4].isAlias?W(M):W(D)+"."+W(M),params:[]}}if(b1(R,H8)){if(b1(R.value,e6))return{sql:V(U.value++,R),params:[R],typings:["none"]};let D=R.value===null?null:R.encoder.mapToDriverValue(R.value);if(b1(D,Q1))return this.buildQueryFromSourceParams([D],X);if(J)return{sql:this.mapInlineParam(D,X),params:[]};let M=["none"];if(q)M=[q(R.encoder)];return{sql:V(U.value++,D),params:[D],typings:M}}if(b1(R,e6))return{sql:V(U.value++,R),params:[R],typings:["none"]};if(b1(R,Q1.Aliased)&&R.fieldAlias!==void 0)return{sql:W(R.fieldAlias),params:[]};if(b1(R,a6)){if(R._.isWith)return{sql:W(R._.alias),params:[]};return this.buildQueryFromSourceParams([new o1("("),R._.sql,new o1(") "),new t6(R._.alias)],X)}if(FY(R)){if(R.schema)return{sql:W(R.schema)+"."+W(R.enumName),params:[]};return{sql:W(R.enumName),params:[]}}if(rA(R)){if(R.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([R.getSQL()],X);return this.buildQueryFromSourceParams([new o1("("),R.getSQL(),new o1(")")],X)}if(J)return{sql:this.mapInlineParam(R,X),params:[]};return{sql:V(U.value++,R),params:[R],typings:["none"]}}))}mapInlineParam($,{escapeString:G}){if($===null)return"null";if(typeof $==="number"||typeof $==="boolean")return $.toString();if(typeof $==="string")return G($);if(typeof $==="object"){let X=$.toString();if(X==="[object Object]")return G(JSON.stringify($));return G(X)}throw Error("Unexpected param value: "+$)}getSQL(){return this}as($){if($===void 0)return this;return new Q1.Aliased(this,$)}mapWith($){return this.decoder=typeof $==="function"?{mapFromDriverValue:$}:$,this}inlineParams(){return this.shouldInlineParams=!0,this}if($){return $?this:void 0}}class t6{constructor($){this.value=$}static[I]="Name";brand;getSQL(){return new Q1([this])}}var NY={mapFromDriverValue:($)=>$},ZY={mapToDriverValue:($)=>$},Sx={...NY,...ZY};class H8{constructor($,G=ZY){this.value=$,this.encoder=G}static[I]="Param";brand;getSQL(){return new Q1([this])}}function w2($,...G){let X=[];if(G.length>0||$.length>0&&$[0]!=="")X.push(new o1($[0]));for(let[Y,W]of G.entries())X.push(W,new o1($[Y+1]));return new Q1(X)}(($)=>{function G(){return new Q1([])}$.empty=G;function X(U){return new Q1(U)}$.fromList=X;function Y(U){return new Q1([new o1(U)])}$.raw=Y;function W(U,R){let D=[];for(let[M,A]of U.entries()){if(M>0&&R!==void 0)D.push(R);D.push(A)}return new Q1(D)}$.join=W;function V(U){return new t6(U)}$.identifier=V;function q(U){return new e6(U)}$.placeholder=q;function J(U,R){return new H8(U,R)}$.param=J})(w2||(w2={}));(($)=>{class G{constructor(X,Y){this.sql=X,this.fieldAlias=Y}static[I]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new G(this.sql,this.fieldAlias)}}$.Aliased=G})(Q1||(Q1={}));class e6{constructor($){this.name=$}static[I]="Placeholder";getSQL(){return new Q1([this])}}var cA=Symbol.for("drizzle:IsDrizzleView");class zY{static[I]="View";[J4];[cA]=!0;constructor({name:$,schema:G,selectedFields:X,query:Y}){this[J4]={name:$,originalName:$,schema:G,selectedFields:X,query:Y,isExisting:!Y,isAlias:!1}}getSQL(){return new Q1([this])}}l0.prototype.getSQL=function(){return new Q1([this])};M1.prototype.getSQL=function(){return new Q1([this])};a6.prototype.getSQL=function(){return new Q1([this])};function D0($,G){return{name:typeof $==="string"&&$.length>0?$:"",config:typeof $==="object"?$:G}}var U8=typeof TextDecoder>"u"?null:new TextDecoder;class R8{static[I]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor($,G){if(this.reference=()=>{let{name:X,columns:Y,foreignColumns:W}=$();return{name:X,columns:Y,foreignTable:W[0].table,foreignColumns:W}},G)this._onUpdate=G.onUpdate,this._onDelete=G.onDelete}onUpdate($){return this._onUpdate=$,this}onDelete($){return this._onDelete=$,this}build($){return new _Y($,this)}}class _Y{constructor($,G){this.table=$,this.reference=G.reference,this.onUpdate=G._onUpdate,this.onDelete=G._onDelete}static[I]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:$,columns:G,foreignColumns:X}=this.reference(),Y=G.map((q)=>q.name),W=X.map((q)=>q.name),V=[this.table[X0],...Y,X[0].table[X0],...W];return $??`${V.join("_")}_fk`}}function LY($,G){return`${$[X0]}_${G.join("_")}_unique`}class O1 extends X8{static[I]="SQLiteColumnBuilder";foreignKeyConfigs=[];references($,G={}){return this.foreignKeyConfigs.push({ref:$,actions:G}),this}unique($){return this.config.isUnique=!0,this.config.uniqueName=$,this}generatedAlwaysAs($,G){return this.config.generated={as:$,type:"always",mode:G?.mode??"virtual"},this}buildForeignKeys($,G){return this.foreignKeyConfigs.map(({ref:X,actions:Y})=>{return((W,V)=>{let q=new R8(()=>{let J=W();return{columns:[$],foreignColumns:[J]}});if(V.onUpdate)q.onUpdate(V.onUpdate);if(V.onDelete)q.onDelete(V.onDelete);return q.build(G)})(X,Y)})}}class P1 extends l0{constructor($,G){if(!G.uniqueName)G.uniqueName=LY($,[G.name]);super($,G);this.table=$}static[I]="SQLiteColumn"}class EY extends O1{static[I]="SQLiteBigIntBuilder";constructor($){super($,"bigint","SQLiteBigInt")}build($){return new jY($,this.config)}}class jY extends P1{static[I]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue($){if(typeof Buffer<"u"&&Buffer.from){let G=Buffer.isBuffer($)?$:$ instanceof ArrayBuffer?Buffer.from($):$.buffer?Buffer.from($.buffer,$.byteOffset,$.byteLength):Buffer.from($);return BigInt(G.toString("utf8"))}return BigInt(U8.decode($))}mapToDriverValue($){return Buffer.from($.toString())}}class TY extends O1{static[I]="SQLiteBlobJsonBuilder";constructor($){super($,"json","SQLiteBlobJson")}build($){return new CY($,this.config)}}class CY extends P1{static[I]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue($){if(typeof Buffer<"u"&&Buffer.from){let G=Buffer.isBuffer($)?$:$ instanceof ArrayBuffer?Buffer.from($):$.buffer?Buffer.from($.buffer,$.byteOffset,$.byteLength):Buffer.from($);return JSON.parse(G.toString("utf8"))}return JSON.parse(U8.decode($))}mapToDriverValue($){return Buffer.from(JSON.stringify($))}}class SY extends O1{static[I]="SQLiteBlobBufferBuilder";constructor($){super($,"buffer","SQLiteBlobBuffer")}build($){return new IY($,this.config)}}class IY extends P1{static[I]="SQLiteBlobBuffer";mapFromDriverValue($){if(Buffer.isBuffer($))return $;return Buffer.from($)}getSQLType(){return"blob"}}function xY($,G){let{name:X,config:Y}=D0($,G);if(Y?.mode==="json")return new TY(X);if(Y?.mode==="bigint")return new EY(X);return new SY(X)}class kY extends O1{static[I]="SQLiteCustomColumnBuilder";constructor($,G,X){super($,"custom","SQLiteCustomColumn");this.config.fieldConfig=G,this.config.customTypeParams=X}build($){return new bY($,this.config)}}class bY extends P1{static[I]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor($,G){super($,G);this.sqlName=G.customTypeParams.dataType(G.fieldConfig),this.mapTo=G.customTypeParams.toDriver,this.mapFrom=G.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue($){return typeof this.mapFrom==="function"?this.mapFrom($):$}mapToDriverValue($){return typeof this.mapTo==="function"?this.mapTo($):$}}function $5($){return(G,X)=>{let{name:Y,config:W}=D0(G,X);return new kY(Y,W,$)}}class G5 extends O1{static[I]="SQLiteBaseIntegerBuilder";constructor($,G,X){super($,G,X);this.config.autoIncrement=!1}primaryKey($){if($?.autoIncrement)this.config.autoIncrement=!0;return this.config.hasDefault=!0,super.primaryKey()}}class X5 extends P1{static[I]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}}class vY extends G5{static[I]="SQLiteIntegerBuilder";constructor($){super($,"number","SQLiteInteger")}build($){return new gY($,this.config)}}class gY extends X5{static[I]="SQLiteInteger"}class hY extends G5{static[I]="SQLiteTimestampBuilder";constructor($,G){super($,"date","SQLiteTimestamp");this.config.mode=G}defaultNow(){return this.default(w2`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build($){return new yY($,this.config)}}class yY extends X5{static[I]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue($){if(this.config.mode==="timestamp")return new Date($*1000);return new Date($)}mapToDriverValue($){let G=$.getTime();if(this.config.mode==="timestamp")return Math.floor(G/1000);return G}}class fY extends G5{static[I]="SQLiteBooleanBuilder";constructor($,G){super($,"boolean","SQLiteBoolean");this.config.mode=G}build($){return new mY($,this.config)}}class mY extends X5{static[I]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue($){return Number($)===1}mapToDriverValue($){return $?1:0}}function v1($,G){let{name:X,config:Y}=D0($,G);if(Y?.mode==="timestamp"||Y?.mode==="timestamp_ms")return new hY(X,Y.mode);if(Y?.mode==="boolean")return new fY(X,Y.mode);return new vY(X)}class uY extends O1{static[I]="SQLiteNumericBuilder";constructor($){super($,"string","SQLiteNumeric")}build($){return new pY($,this.config)}}class pY extends P1{static[I]="SQLiteNumeric";mapFromDriverValue($){if(typeof $==="string")return $;return String($)}getSQLType(){return"numeric"}}class lY extends O1{static[I]="SQLiteNumericNumberBuilder";constructor($){super($,"number","SQLiteNumericNumber")}build($){return new rY($,this.config)}}class rY extends P1{static[I]="SQLiteNumericNumber";mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}mapToDriverValue=String;getSQLType(){return"numeric"}}class dY extends O1{static[I]="SQLiteNumericBigIntBuilder";constructor($){super($,"bigint","SQLiteNumericBigInt")}build($){return new cY($,this.config)}}class cY extends P1{static[I]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}function iY($,G){let{name:X,config:Y}=D0($,G),W=Y?.mode;return W==="number"?new lY(X):W==="bigint"?new dY(X):new uY(X)}class nY extends O1{static[I]="SQLiteRealBuilder";constructor($){super($,"number","SQLiteReal")}build($){return new oY($,this.config)}}class oY extends P1{static[I]="SQLiteReal";getSQLType(){return"real"}}function sY($){return new nY($??"")}class aY extends O1{static[I]="SQLiteTextBuilder";constructor($,G){super($,"string","SQLiteText");this.config.enumValues=G.enum,this.config.length=G.length}build($){return new tY($,this.config)}}class tY extends P1{static[I]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor($,G){super($,G)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}}class eY extends O1{static[I]="SQLiteTextJsonBuilder";constructor($){super($,"json","SQLiteTextJson")}build($){return new $W($,this.config)}}class $W extends P1{static[I]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue($){return JSON.parse($)}mapToDriverValue($){return JSON.stringify($)}}function i($,G={}){let{name:X,config:Y}=D0($,G);if(Y.mode==="json")return new eY(X);return new aY(X,Y)}function GW(){return{blob:xY,customType:$5,integer:v1,numeric:iY,real:sY,text:i}}var D8=Symbol.for("drizzle:SQLiteInlineForeignKeys");class c4 extends M1{static[I]="SQLiteTable";static Symbol=Object.assign({},M1.Symbol,{InlineForeignKeys:D8});[M1.Symbol.Columns];[D8]=[];[M1.Symbol.ExtraConfigBuilder]=void 0}function iA($,G,X,Y,W=$){let V=new c4($,Y,W),q=typeof G==="function"?G(GW()):G,J=Object.fromEntries(Object.entries(q).map(([R,D])=>{let M=D;M.setName(R);let A=M.build(V);return V[D8].push(...M.buildForeignKeys(A,V)),[R,A]})),U=Object.assign(V,J);if(U[M1.Symbol.Columns]=J,U[M1.Symbol.ExtraConfigColumns]=J,X)U[c4.Symbol.ExtraConfigBuilder]=X;return U}var M0=($,G,X)=>{return iA($,G,X)};class XW{constructor($,G){this.name=$,this.value=G}static[I]="SQLiteCheckBuilder";brand;build($){return new YW($,this)}}class YW{constructor($,G){this.table=$,this.name=G.name,this.value=G.value}static[I]="SQLiteCheck";name;value}function WW($,G){return new XW($,G)}class VW{constructor($,G){this.name=$,this.unique=G}static[I]="SQLiteIndexBuilderOn";on(...$){return new qW(this.name,$,this.unique)}}class qW{static[I]="SQLiteIndexBuilder";config;constructor($,G,X){this.config={name:$,columns:G,unique:X,where:void 0}}where($){return this.config.where=$,this}build($){return new JW(this.config,$)}}class JW{static[I]="SQLiteIndex";config;constructor($,G){this.config={...$,table:G}}}function Y0($){return new VW($,!1)}function Y5(...$){if($[0].columns)return new M8($[0].columns,$[0].name);return new M8($)}class M8{static[I]="SQLitePrimaryKeyBuilder";columns;name;constructor($,G){this.columns=$,this.name=G}build($){return new HW($,this.columns,this.name)}}class HW{constructor($,G,X){this.table=$,this.columns=G,this.name=X}static[I]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[c4.Symbol.Name]}_${this.columns.map(($)=>$.name).join("_")}_pk`}}var UW=M0("job_queue",{id:i("id").primaryKey().$defaultFn(()=>g0()),type:i("type").notNull(),data:i("data").notNull(),result:i("result",{mode:"json"}),source:i("source"),metadata:i("metadata",{mode:"json"}).$type().notNull(),status:i("status",{enum:["pending","processing","completed","failed"]}).notNull().default("pending"),priority:v1("priority").notNull().default(0),retryCount:v1("retryCount").notNull().default(0),maxRetries:v1("maxRetries").notNull().default(3),lastError:i("lastError"),createdAt:v1("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:v1("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:v1("startedAt"),completedAt:v1("completedAt")},($)=>({queueReadyIdx:Y0("idx_job_queue_ready").on($.status,$.priority,$.scheduledFor),jobTypeIdx:Y0("idx_job_queue_type").on($.type,$.status),jobSourceIdx:Y0("idx_job_queue_source").on($.source)}));var nA=H.object({id:H.string(),type:H.string(),data:H.string(),status:H.enum(["pending","processing","completed","failed"]),source:H.string().nullable(),priority:H.number(),retryCount:H.number(),maxRetries:H.number(),lastError:H.string().nullable(),createdAt:H.number(),scheduledFor:H.number(),startedAt:H.number().nullable(),completedAt:H.number().nullable(),metadata:l4,result:H.unknown().nullable().optional()});function Q8($,G,X){return async(Y)=>{let{type:W,data:V,toolContext:q=null,options:J}=Y,{metadata:U,...R}=J??{},D={source:G,...J?.rootJobId&&{rootJobId:J.rootJobId},...R,metadata:{operationType:"data_processing",pluginId:G,...q&&{interfaceType:q.interfaceType,channelId:q.channelId},...U}},M=X&&!W.includes(":")?`${G}:${W}`:W;return $.enqueue({type:M,data:V,options:D})}}function K8($,G){return async(X,Y)=>{let W=g0(),V=X.map((J)=>({...J,type:J.type.includes(":")?J.type:`${G}:${J.type}`})),q={...Y,source:G,rootJobId:W,metadata:{...Y?.metadata,operationType:"batch_processing",pluginId:G}};return await $.enqueueBatch(V,q,W,G),W}}function F8($,G){return(X,Y)=>{let W=X.includes(":")?X:`${G}:${X}`;$.registerHandler(W,Y,G)}}var oA=H.object({name:H.string(),schema:H.custom(($)=>$ instanceof H.ZodType)});function RW($){return oA.safeParse($).success}function sA($){if(!$)return;return{status:$.status,message:$.message,lastCheck:$.lastCheck?.toISOString(),details:$.details}}function DW($){return{model:$.model,version:$.version,uptime:$.uptime,entities:$.entities,entityCounts:$.entityCounts,embeddings:$.embeddings,ai:$.ai,daemons:$.daemons.map((G)=>({name:G.name,pluginId:G.pluginId,status:G.status,health:sA(G.health)})),endpoints:$.endpoints,interactions:$.interactions}}var H4=H.record(H.unknown());var aA=H.object({id:H.string(),sessionId:H.string(),interfaceType:H.string(),channelId:H.string(),channelName:H.string().optional(),startedAt:H.string(),lastActiveAt:H.string(),createdAt:H.string(),updatedAt:H.string(),metadata:H4}),tA=H.object({id:H.string(),conversationId:H.string(),role:F2,content:H.string(),timestamp:H.string(),metadata:H4});function MW($){if(!$)return{};try{let G=JSON.parse($);if(G&&typeof G==="object"&&!Array.isArray(G))return G}catch{}return{}}function eA($){let G=F2.safeParse($);return G.success?G.data:"user"}function W5($){let G=MW($.metadata),X=typeof G.channelName==="string"?G.channelName:void 0;return{id:$.id,sessionId:$.sessionId,interfaceType:$.interfaceType,channelId:$.channelId,channelName:X,startedAt:$.started,lastActiveAt:$.lastActive,createdAt:$.created,updatedAt:$.updated,metadata:G}}function QW($){return{id:$.id,conversationId:$.conversationId,role:eA($.role),content:$.content,timestamp:$.timestamp,metadata:MW($.metadata)}}var A8=H.object({name:H.string(),role:H.string(),purpose:H.string(),values:H.array(H.string())}),w8=H.object({name:H.string(),kind:H.enum(["professional","team","collective"]),organization:H.string().optional(),description:H.string().optional(),avatar:H.string().optional(),website:H.string().optional(),email:H.string().optional(),socialLinks:H.array(H.object({platform:H.enum(["github","instagram","linkedin","email","website"]),url:H.string(),label:H.string().optional()})).optional()});function KW($){return A8.parse($)}function FW($){return w8.parse($)}function AW($){return async()=>{return DW(await $.getAppInfo())}}function wW($,G){return{get:()=>KW($.getIdentity()),getProfile:()=>FW($.getProfile()),getAppInfo:G}}function BW($,G,X){let Y=$.getMessageBus();return{send:async(V)=>{return Y.send({...V,sender:G})},subscribe:(V,q)=>{if(RW(V)){let J=V,U=q,R=async(D)=>{let M=J.schema.safeParse(D.payload);if(!M.success)return X.warn(`Invalid payload for channel ${J.name}`,{error:M.error.message}),{noop:!0};let{payload:A,...F}=D;return U(M.data,F)};return Y.subscribe(J.name,R)}return Y.subscribe(V,q)}}}function OW($,G){let X=$.getJobQueueService();return{...$.jobs,enqueue:Q8(X,G,!0),enqueueBatch:K8($.jobs,G),registerHandler:F8(X,G)}}function PW($){let G=$.getPermissionService();return{assertEntityActionAllowed:(X,Y,W)=>{G.assertEntityActionAllowed(X,Y,W.userPermissionLevel)}}}function NW($){return{get:async(G)=>{let Y=await $.getConversationService().getConversation(G);return Y?W5(Y):null},search:async(G)=>{return(await $.getConversationService().searchConversations(G)).map(W5)},list:async(G)=>{return(await $.getConversationService().listConversations(G)).map(W5)},getMessages:async(G,X)=>{return(await $.getConversationService().getMessages(G,X)).map(QW)},countMessages:async(G)=>{return $.getConversationService().countMessages(G)}}}function ZW($,G){return{registerHandler:(X,Y)=>{$.registerEvalHandler(G,X,Y)}}}function zW($){return{register:(G,X)=>{$.getInsightsRegistry().register(G,X)}}}function _W($,G){return{register:(X)=>{$.registerEndpoint({...X,pluginId:G})}}}function LW($,G){return{register:(X)=>{$.registerInteraction({...X,pluginId:G})}}}function U4($,G,X){let Y=$.getEntityService(),W=$.getLogger().child(G),V=$.getDomain(),q=$.getLocalSiteUrl(),J=$.shouldPreferLocalUrls(),U=$.getThemeCSS(),R=AW($),D=$.getAttachmentRegistry(),M=$.getRuntimeUploadRegistry();return{pluginId:G,logger:W,entityService:Y,identity:wW($,R),appInfo:R,domain:V,siteUrl:V?`https://${V}`:void 0,localSiteUrl:q,previewUrl:V?`https://${e9(V)}`:void 0,preferLocalUrls:J,themeCSS:U,entityDisplay:X?.entityDisplay,spaces:$.getSpaces(),permissions:PW($),messaging:BW($,G,W),jobs:OW($,G),attachments:D,uploads:M,conversations:NW($),dataDir:$.getDataDir(),eval:ZW($,G),insights:zW($),endpoints:_W($,G),interactions:LW($,G)}}import{createClient as Jv}from"@libsql/client";var V5=M0("entities",{id:i("id").notNull(),entityType:i("entityType").notNull(),content:i("content").notNull(),contentHash:i("contentHash").notNull(),visibility:i("visibility",{enum:["public","shared","restricted"]}).notNull().default("public"),metadata:i("metadata",{mode:"json"}).$type().notNull().default(w2`'{}'`),created:v1("created").notNull().$defaultFn(()=>Date.now()),updated:v1("updated").notNull().$defaultFn(()=>Date.now())},($)=>{return{pk:Y5({columns:[$.id,$.entityType]}),visibilityCheck:WW("entities_visibility_check",w2`${$.visibility} IN ('public', 'shared', 'restricted')`)}});import{createClient as Av}from"@libsql/client";var EW=$5({dataType(){return"F32_BLOB(1536)"},toDriver($){return Buffer.from($.buffer)},fromDriver($){return new Float32Array($.buffer,$.byteOffset,$.byteLength/4)}});var q5=M0("embeddings",{entityId:i("entity_id").notNull(),entityType:i("entity_type").notNull(),embedding:EW("embedding").notNull(),contentHash:i("content_hash").notNull()},($)=>{return{pk:Y5({columns:[$.entityId,$.entityType]})}});var $w=H.enum(["public","shared","restricted"]),B2=H.union([$w,H.literal("private")]).optional().transform(($)=>{if($===void 0)return"public";if($==="private")return"restricted";return $});var O8=H.object({id:H.string(),entityType:H.string(),content:H.string(),created:H.string().datetime(),updated:H.string().datetime(),visibility:B2,metadata:H.record(H.string(),H.unknown()),contentHash:H.string()}),Ww=H.object({mediaType:H.string(),url:H.string(),downloadUrl:H.string().optional(),previewUrl:H.string().optional(),filename:H.string().optional(),sizeBytes:H.number().optional(),source:H.object({entityType:H.string().optional(),entityId:H.string().optional(),attachmentType:H.string().optional()}).optional()});var Sv=H.object({id:H.string().min(1,"Entity ID is required"),entityType:H.string().min(1,"Entity type is required"),contentHash:H.string().min(1,"Content hash is required"),operation:H.enum(["create","update"])});var vv=H.object({limit:H.number().int().positive().optional().default(20),offset:H.number().int().min(0).optional().default(0),types:H.array(H.string()).optional().default([]),excludeTypes:H.array(H.string()).optional().default([]),weight:H.record(H.string(),H.number()).optional(),visibilityScope:H.enum(["public","shared","restricted"]).optional(),includeUngenerated:H.boolean().optional().default(!1)});var N8=t4(y5(),1);function J5($,G){if(Object.keys(G).length===0)return $;let X=Object.fromEntries(Object.entries(G).filter(([,Y])=>Y!==void 0));return N8.default.stringify($,X)}function P8($){if($ instanceof Date)return $.toISOString();if(Array.isArray($))return $.map(P8);if($!==null&&typeof $==="object"){let G={};for(let[X,Y]of Object.entries($))G[X]=P8(Y);return G}return $}function n4($,G){let{content:X,data:Y}=N8.default($),W=P8(Y);return{content:X.trim(),metadata:G.parse(W)}}var fv=H.object({visibility:B2});var Hw=H.object({field:H.string(),direction:H.enum(["asc","desc"]),nullsFirst:H.boolean().optional()}),tv=H.object({limit:H.number().int().positive().optional(),offset:H.number().int().min(0).optional().default(0),sortFields:H.array(Hw).optional(),filter:H.object({metadata:H.record(H.string(),H.unknown()).optional(),visibilityScope:H.enum(["public","shared","restricted"]).optional()}).optional(),publishedOnly:H.boolean().optional()});var Ow=H.object({currentPage:H.number(),totalPages:H.number(),totalItems:H.number(),pageSize:H.number(),hasNextPage:H.boolean(),hasPrevPage:H.boolean()});function Pw($){return $.replace(/:/g,"-")}function Nw($){return $.split(/[:.-]/).map((G)=>G.charAt(0).toUpperCase()+G.slice(1)).join(" ")}var Z8=new Map;async function CW($,G,X){let Y=Z8.get(G);if(Y!==void 0)return Y;let W=Pw(G),V;try{V=await $.getEntity({entityType:"prompt",id:W})}catch{return X}if(V?.content){let q=n4(V.content,H.record(H.unknown())).content;return Z8.set(G,q),q}try{let q=Nw(G),J=J5(X,{title:q,target:G});await $.createEntity({entity:{id:W,entityType:"prompt",content:J,metadata:{title:q,target:G,slug:W}}})}catch{}return Z8.set(G,X),X}function H5($){let G=$.getEntityService(),X=$.getEntityRegistry(),Y=$.getDataSourceRegistry();return{register:(W,V,q,J)=>{X.registerEntityType(W,V,q,J)},getAdapter:(W)=>{try{return X.getAdapter(W)}catch{return}},extendFrontmatterSchema:(W,V)=>{X.extendFrontmatterSchema(W,V)},getEffectiveFrontmatterSchema:(W)=>{return X.getEffectiveFrontmatterSchema(W)},registerCreateInterceptor:(W,V)=>{X.registerCreateInterceptor(W,V)},update:async(W)=>{return G.updateEntity({entity:W})},registerDataSource:(W)=>{Y.register(W)}}}function U5($){return{resolve:(G,X)=>{return CW($,G,X)}}}function SW($,G,X){let Y=U4($,G,X),W=$.getEntityService();return{...Y,entityService:W,entities:H5($),ai:{query:(V,q)=>$.query(V,q),generate:async(V)=>{return $.generateContent(V)},generateObject:async(V,q)=>{return $.generateObject(V,q)},generateImage:async(V,q)=>{return $.generateImage(V,q)},canGenerateImages:()=>{return $.canGenerateImages()}},prompts:U5(W),permissions:Y.permissions}}function xW($,G,X){let Y=!1,W=!1;if($.jobs.registerHandler(X.job.type,X.job.handler),X.initialSync){let V=X.initialSync;$.messaging.subscribe("sync:initial:completed",async()=>{if(Y)return{success:!0};if(Y=!0,!(await V.shouldEnqueue?.()??!0))return G.info("Skipping derived entity projection initial sync",{projectionId:X.id,targetType:X.targetType}),{success:!0};return W=await IW($,G,X,V.jobData,zw(V.jobOptions),"initial-sync"),{success:!0}})}if(X.sourceChange){let V=X.sourceChange,q=new Set(V.sourceTypes),J=V.events??["entity:created","entity:updated"],U=async(R)=>{if(V.requireInitialSync&&!Y)return{success:!0};let D=R.payload,M=Zw(V,D);if(!M||!q.has("*")&&!q.has(M))return{success:!0};if(!(await V.shouldEnqueue?.(D)??!0))return{success:!0};let F=await V.jobData(D);if(!F)return{success:!0};return await IW($,G,X,F,V.jobOptions?.(D),"source-change"),{success:!0}};for(let R of J)$.messaging.subscribe(R,U)}return{hasObservedInitialSync:()=>Y,hasQueuedInitialSync:()=>W}}function Zw($,G){if($.sourceType)return $.sourceType;if($.sourceKind&&$.sourceKind!=="entity")return $.sourceKind;return G.entityType}async function IW($,G,X,Y,W,V){try{return await $.jobs.enqueue({type:X.job.type,data:Y,...W?{options:W}:{}}),G.info("Queued derived entity projection",{projectionId:X.id,targetType:X.targetType,reason:V}),!0}catch(q){return G.error("Failed to queue derived entity projection",{projectionId:X.id,targetType:X.targetType,reason:V,error:R0(q)}),!1}}function zw($){return typeof $==="function"?$():$}var _w=H.object({});class R5 extends A2{type="entity";entityActionPolicy;derivedEntityProjectionControllers=new Map;constructor($,G,X={},Y=_w,W){super($,G,X,Y);if(W!==void 0)this.entityActionPolicy=W}async register($,G){let X=SW($,this.id,G);if(this.context=X,this.setupMessageHandlers(X),X.entities.register(this.entityType,this.schema,this.adapter,this.getEntityTypeConfig()),this.interceptCreate!==R5.prototype.interceptCreate)X.entities.registerCreateInterceptor(this.entityType,(U,R)=>this.interceptCreate(U,R,X));let Y=this.createGenerationHandler(X);if(Y)X.jobs.registerHandler(`${this.entityType}:generation`,Y);let W=this.getTemplates();if(W&&Object.keys(W).length>0)$.registerTemplates(W,this.id);let V=this.getDataSources();for(let U of V)X.entities.registerDataSource(U);let q=this.getDerivedEntityProjections(X);for(let U of q){let R=xW(X,this.logger,U);this.derivedEntityProjectionControllers.set(U.id,R)}await this.onRegister(this.context);let J=await this.getInstructions();return{tools:[],resources:[],...J&&{instructions:J}}}async interceptCreate($,G,X){return{kind:"continue",input:$}}createGenerationHandler($){return null}getTemplates(){return null}getDataSources(){return[]}getEntityTypeConfig(){return}getDerivedEntityProjections($){return[]}getDerivedEntityProjectionController($){return this.derivedEntityProjectionControllers.get($)}}class kW extends R5{hooks;constructor($,G,X,Y,W){super($,G,X,Y);this.hooks=W}get entityType(){return this.hooks.getEntityType()}get schema(){return this.hooks.getSchema()}get adapter(){return this.hooks.getAdapter()}onRegister($){return this.hooks.onRegister($)}onReady($){return this.hooks.onReady($)}onShutdown(){return this.hooks.onShutdown()}getEntityTypeConfig(){return this.hooks.getEntityTypeConfig()}getDataSources(){return this.hooks.getDataSources()}getInstructions(){return this.hooks.getInstructions()}interceptCreate($,G,X){return this.hooks.interceptCreate($,G,X)}}class z8{type="entity";id;version;packageName;description;delegate;constructor($,G,X,Y){if(this.id=$,this.version=G.version,this.packageName=G.name,G.description!==void 0)this.description=G.description;this.delegate=new kW($,G,X,Y,{getEntityType:()=>this.entityType,getSchema:()=>this.schema,getAdapter:()=>this.adapter,onRegister:(W)=>this.onRegister(W),onReady:(W)=>this.onReady(W),onShutdown:()=>this.onShutdown(),getEntityTypeConfig:()=>this.getEntityTypeConfig(),getDataSources:()=>this.getDataSources(),getInstructions:()=>this.getInstructions(),interceptCreate:(W,V,q)=>this.interceptCreate(W,V,q)})}register($,G){return this.delegate.register($,G)}async onRegister($){}async onReady($){}async onShutdown(){}async getInstructions(){return}getEntityTypeConfig(){return}getDataSources(){return[]}async interceptCreate($,G,X){return{kind:"continue",input:$}}ready(){return this.delegate.ready()}shutdown(){return this.delegate.shutdown?.()??Promise.resolve()}}import{createClient as rh}from"@libsql/client";var D5=M0("conversations",{id:i("id").primaryKey(),sessionId:i("session_id").notNull(),interfaceType:i("interface_type").notNull(),channelId:i("channel_id").notNull(),started:i("started").notNull(),lastActive:i("last_active").notNull(),metadata:i("metadata"),created:i("created").notNull(),updated:i("updated").notNull()},($)=>({sessionIdx:Y0("idx_conversations_session").on($.sessionId),channelIdx:Y0("idx_conversations_channel").on($.channelId),interfaceSessionIdx:Y0("idx_conversations_interface_session").on($.interfaceType,$.sessionId),interfaceChannelIdx:Y0("idx_conversations_interface_channel").on($.interfaceType,$.channelId)})),bW=M0("messages",{id:i("id").primaryKey(),conversationId:i("conversation_id").notNull().references(()=>D5.id,{onDelete:"cascade"}),role:i("role").notNull(),content:i("content").notNull(),timestamp:i("timestamp").notNull(),metadata:i("metadata")},($)=>({conversationIdx:Y0("idx_messages_conversation").on($.conversationId),timestampIdx:Y0("idx_messages_timestamp").on($.timestamp)})),vW=M0("summary_tracking",{conversationId:i("conversation_id").primaryKey().references(()=>D5.id,{onDelete:"cascade"}),lastSummarizedAt:i("last_summarized_at"),lastMessageId:i("last_message_id"),messagesSinceSummary:v1("messages_since_summary").default(0),updated:i("updated").notNull()});var nh=H.preprocess(($)=>{if(typeof $!=="string")return $;try{return JSON.parse($)}catch{return}},H.record(H.unknown())).catch({});var M5=H.object({actorId:H.string(),canonicalId:H.string().optional(),interfaceType:H.string(),role:F2,displayName:H.string().optional(),username:H.string().optional(),isBot:H.boolean().optional()}),Q5=H.object({messageId:H.string().optional(),channelId:H.string().optional(),channelName:H.string().optional(),threadId:H.string().optional(),metadata:H.record(H.unknown()).optional()}),Lw=H.object({actor:M5.optional(),source:Q5.optional()}).passthrough(),Ew=H.object({id:H.string(),conversationId:H.string(),role:H.string(),content:H.string(),timestamp:H.string(),metadata:H.string().nullable()}),jw=H.object({conversationId:H.string(),messageCount:H.number(),messages:H.array(Ew),windowStart:H.number(),windowEnd:H.number(),windowSize:H.number(),timestamp:H.string()});var gW=H.object({kind:H.string().min(1),id:H.string().min(1)}),Iw=H.object({kind:H.literal("text"),filename:H.string().min(1),mediaType:H.string().min(1),content:H.string(),sizeBytes:H.number().nonnegative().optional(),source:gW.optional()}),xw=H.instanceof(Uint8Array),kw=H.object({kind:H.literal("file"),filename:H.string().min(1),mediaType:H.string().min(1),data:xw,sizeBytes:H.number().nonnegative().optional(),source:gW.optional()}),bw=H.discriminatedUnion("kind",[Iw,kw]),vw=H.object({userPermissionLevel:p0.optional(),interfaceType:H.string().optional(),channelId:H.string().optional(),channelName:H.string().optional(),actor:M5.optional(),source:Q5.optional(),attachments:H.array(bw).optional()}),hW=H.object({id:H.string(),toolCallId:H.string().optional(),toolName:H.string(),summary:H.string(),preview:H.string().optional(),args:H.unknown()}),gw=H.enum(["approval-requested","approval-responded","output-available","output-denied","output-error"]),hw=H.object({kind:H.literal("tool-approval"),id:H.string(),toolCallId:H.string().optional(),toolName:H.string(),input:H.record(H.unknown()).optional(),summary:H.string(),preview:H.string().optional(),state:gw,output:H.unknown().optional(),error:H.string().optional()}),yw=H.object({entityType:H.string().optional(),entityId:H.string().optional(),attachmentType:H.string().optional()}),fw=H.object({mediaType:H.string().min(1),url:H.string().min(1),downloadUrl:H.string().min(1).optional(),previewUrl:H.string().min(1).optional(),filename:H.string().min(1).optional(),sizeBytes:H.number().nonnegative().optional(),source:yw.optional()}),mw=H.object({kind:H.literal("attachment"),id:H.string(),jobId:H.string().optional(),title:H.string(),description:H.string().optional(),attachment:fw}),uw=H.object({id:H.string().min(1),title:H.string().min(1).optional(),source:H.string().min(1),url:H.string().min(1).optional(),entityType:H.string().min(1).optional(),entityId:H.string().min(1).optional(),excerpt:H.string().min(1).optional(),provenance:H.record(H.unknown()).optional()}),pw=H.object({kind:H.literal("sources"),id:H.string().min(1),title:H.string().min(1).optional(),sources:H.array(uw).min(1)}),lw=H.object({type:H.literal("prompt"),id:H.string().min(1),label:H.string().min(1),prompt:H.string().min(1),description:H.string().min(1).optional()}),rw=H.object({type:H.literal("event"),id:H.string().min(1),label:H.string().min(1),event:H.string().min(1),description:H.string().min(1).optional()}),dw=H.discriminatedUnion("type",[lw,rw]),cw=H.object({kind:H.literal("actions"),id:H.string().min(1),title:H.string().min(1).optional(),defaultOpen:H.boolean().optional(),actions:H.array(dw).min(1)}),iw=H.discriminatedUnion("kind",[hw,mw,pw,cw]);function yW($){return{kind:"actions",id:$.id,...$.title!==void 0&&{title:$.title},...$.defaultOpen!==void 0&&{defaultOpen:$.defaultOpen},actions:$.actions.map((G)=>{if(G.type==="prompt")return{type:"prompt",id:G.id,label:G.label,prompt:G.prompt,...G.description!==void 0&&{description:G.description}};return{type:"event",id:G.id,label:G.label,event:G.event,...G.description!==void 0&&{description:G.description}}})}}function fW($){return{kind:"sources",id:$.id,...$.title!==void 0&&{title:$.title},sources:$.sources.map((G)=>({id:G.id,...G.title!==void 0&&{title:G.title},source:G.source,...G.url!==void 0&&{url:G.url},...G.entityType!==void 0&&{entityType:G.entityType},...G.entityId!==void 0&&{entityId:G.entityId},...G.excerpt!==void 0&&{excerpt:G.excerpt},...G.provenance!==void 0&&{provenance:G.provenance}}))}}function mW($){let{attachment:G}=$,{source:X}=G;return{kind:"attachment",id:$.id,...$.jobId!==void 0&&{jobId:$.jobId},title:$.title,...$.description!==void 0&&{description:$.description},attachment:{mediaType:G.mediaType,url:G.url,...G.downloadUrl!==void 0&&{downloadUrl:G.downloadUrl},...G.previewUrl!==void 0&&{previewUrl:G.previewUrl},...G.filename!==void 0&&{filename:G.filename},...G.sizeBytes!==void 0&&{sizeBytes:G.sizeBytes},...X!==void 0&&{source:{...X.entityType!==void 0&&{entityType:X.entityType},...X.entityId!==void 0&&{entityId:X.entityId},...X.attachmentType!==void 0&&{attachmentType:X.attachmentType}}}}}}var uW=H.object({toolName:H.string(),args:H.record(H.unknown()).optional(),jobId:H.string().optional(),data:H.unknown().optional()}),nw=H.object({text:H.string(),toolResults:H.array(uW).optional(),cards:H.array(iw).optional(),pendingConfirmations:H.array(hW).optional(),usage:H.object({promptTokens:H.number(),completionTokens:H.number(),totalTokens:H.number()})});function pW($){return{text:$.text,...$.toolResults&&{toolResults:$.toolResults.map((G)=>({toolName:G.toolName,...G.args&&{args:G.args},...G.jobId!==void 0&&{jobId:G.jobId},...G.data!==void 0&&{data:G.data}}))},...$.cards&&{cards:$.cards.map(ow)},...$.pendingConfirmations&&{pendingConfirmations:$.pendingConfirmations.map((G)=>sw(G))},usage:$.usage}}function ow($){if($.kind==="attachment")return mW($);if($.kind==="sources")return fW($);if($.kind==="actions")return yW($);return{kind:$.kind,id:$.id,...$.toolCallId!==void 0&&{toolCallId:$.toolCallId},toolName:$.toolName,...$.input!==void 0&&{input:$.input},summary:$.summary,...$.preview!==void 0&&{preview:$.preview},state:$.state,...$.output!==void 0&&{output:$.output},...$.error!==void 0&&{error:$.error}}}function sw($){return{id:$.id,...$.toolCallId!==void 0&&{toolCallId:$.toolCallId},toolName:$.toolName,summary:$.summary,...$.preview!==void 0&&{preview:$.preview},args:$.args}}function lW($){if(!$)return;return{...$.userPermissionLevel&&{userPermissionLevel:$.userPermissionLevel},...$.interfaceType&&{interfaceType:$.interfaceType},...$.channelId&&{channelId:$.channelId},...$.channelName&&{channelName:$.channelName},...$.actor&&{actor:$.actor},...$.source&&{source:$.source},...$.attachments&&{attachments:$.attachments}}}function rW($){return{chat:async(G,X,Y)=>{return pW(await $.chat(G,X,lW(Y)))},confirmPendingAction:async(G,X,Y,W)=>{let V=lW(W);if(!V)throw Error("Confirmation requires caller context.");return pW(await $.confirmPendingAction(G,X,Y,V))},invalidate:()=>{$.invalidateAgent()}}}function dW($,G,X){let Y=U4($,G,X),W=$.getMCPService(),V=$.getPermissionService(),q=rW($.getAgentService());return{...Y,mcpTransport:W,agent:q,permissions:{...Y.permissions,getUserLevel:(J,U,R)=>{return V.determineUserLevel(J,U,R)}},daemons:{register:(J,U)=>{let R=`${G}:${J}`;$.registerDaemon(R,U,G),Y.logger.debug(`Registered daemon: ${R}`)}},conversations:{...Y.conversations,start:async(J)=>{return $.getConversationService().startConversation(J)},addMessage:async(J)=>{await $.getConversationService().addMessage(J)},updateMetadata:async(J)=>{return $.getConversationService().updateConversationMetadata(J)},delete:async(J)=>{return $.getConversationService().deleteConversation(J)}},tools:{listForPermissionLevel:(J)=>{return $.listToolsForPermissionLevel(J)}},apiRoutes:{getRoutes:()=>{return $.getPluginApiRoutes()},getMessageBus:()=>{return $.getMessageBus()}},webRoutes:{getRoutes:()=>{return $.getPluginWebRoutes()}},plugins:{has:(J)=>$.hasPlugin(J)}}}var aw=3600000;class o4 extends A2{type="interface";daemon;jobTrackingEntries=new Map;jobTrackingTtlMs=aw;async register($,G){let X=dW($,this.id,G);if(this.context=X,this.initializeDaemon(),this.daemon)await this.registerDaemon(X);return this.setupMessageHandlers(X),await this.onRegister(X),this.getCapabilities()}async onRegister($){}async registerDaemon($){if(!this.daemon)return;$.daemons.register(this.id,this.daemon),$.logger.debug(`Registered daemon for interface: ${this.id}`)}createDaemon(){return}requiresDaemonStartup(){return!1}getWebRoutes(){return[]}initializeDaemon(){let $=this.createDaemon();if($)this.daemon=$}async handleProgressEvent($,G){}cleanupExpiredEntries(){let $=Date.now(),G=[];for(let[X,Y]of this.jobTrackingEntries)if($-Y.createdAt>this.jobTrackingTtlMs)G.push(X);for(let X of G)this.jobTrackingEntries.delete(X)}ownsJob($,G){return this.jobTrackingEntries.has($)||G!==void 0&&this.jobTrackingEntries.has(G)}getJobTracking($,G){let X=this.jobTrackingEntries.get($);if(X)return X.info;if(G){let Y=this.jobTrackingEntries.get(G);if(Y)return Y.info}return}setJobTracking($,G){this.cleanupExpiredEntries(),this.jobTrackingEntries.set($,{info:G,createdAt:Date.now()})}removeJobTracking($){this.jobTrackingEntries.delete($)}async createJobWithTracking($,G){let Y=await this.getContext().jobs.enqueue($);return this.setJobTracking(Y,G),Y}async createBatchWithTracking($,G,X){let W=await this.getContext().jobs.enqueueBatch($,X);return this.setJobTracking(W,G),W}}class cW extends o4{hooks;constructor($,G,X,Y,W){super($,G,X,Y);this.hooks=W}onRegister($){return this.hooks.onRegister($)}onReady($){return this.hooks.onReady($)}onShutdown(){return this.hooks.onShutdown()}getTools(){return this.hooks.getTools()}getResources(){return this.hooks.getResources()}getInstructions(){return this.hooks.getInstructions()}getWebRoutes(){return this.hooks.getWebRoutes()}requiresDaemonStartup(){return this.hooks.requiresDaemonStartup()}}class s4{type="interface";id;version;packageName;description;delegate;constructor($,G,X,Y){if(this.id=$,this.version=G.version,this.packageName=G.name,G.description!==void 0)this.description=G.description;this.delegate=new cW($,G,X,Y,{onRegister:(W)=>this.onRegister(W),onReady:(W)=>this.onReady(W),onShutdown:()=>this.onShutdown(),getTools:()=>this.getTools(),getResources:()=>this.getResources(),getInstructions:()=>this.getInstructions(),getWebRoutes:()=>this.getWebRoutes(),requiresDaemonStartup:()=>this.requiresDaemonStartup()})}register($,G){return this.delegate.register($,G)}async onRegister($){}async onReady($){}async onShutdown(){}async getTools(){return[]}async getResources(){return[]}async getInstructions(){return}getWebRoutes(){return[]}requiresDaemonStartup(){return!1}ready(){return this.delegate.ready()}shutdown(){return this.delegate.shutdown?.()??Promise.resolve()}}function iW($,G){$.messaging.subscribe("job-progress",async(X)=>{try{let Y=G8.safeParse(X.payload);if(!Y.success)return G.onInvalidSchema(),{success:!1};let W=Y.data;return await G.onProgress(W,W.metadata),{success:!0}}catch(Y){return G.onError(Y),{success:!1}}})}function nW($){let G=$.status==="completed"?"\u2705":"\u274C",X=$.status==="completed"?"completed":"failed",Y=$.metadata.operationType.replace(/_/g," "),W=$.metadata.operationTarget?`: ${$.metadata.operationTarget}`:"",V=`${G} **${Y}${W}** ${X}`;if($.message)V+=`
119
+ `;return""}var vK=bK,gK={dump:vK};function d9($,G){return function(){throw Error("Function yaml."+$+" is removed in js-yaml 4. Use yaml."+G+" instead, which is now safe by default.")}}var{load:hK,loadAll:Sj}=BX,yK=gK.dump;var Ij=d9("safeLoad","load"),xj=d9("safeLoadAll","loadAll"),kj=d9("safeDump","dump");import{webcrypto as IX}from"crypto";var SX="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var mK=128,U2,r2;function uK($){if($<0||$>1024)throw RangeError("Wrong ID size");if(!U2||U2.length<$)U2=Buffer.allocUnsafe($*mK),IX.getRandomValues(U2),r2=0;else if(r2+$>U2.length)IX.getRandomValues(U2),r2=0;r2+=$}function xX($=21){uK($|=0);let G="";for(let X=r2-$;X<r2;X++)G+=SX[U2[X]&63];return G}function g0($=12){return xX($)}var H={};v8(H,{void:()=>LF,util:()=>a,unknown:()=>zF,union:()=>CF,undefined:()=>PF,tuple:()=>xF,transformer:()=>pF,symbol:()=>OF,string:()=>uX,strictObject:()=>TF,setErrorMap:()=>rK,set:()=>vF,record:()=>kF,quotelessJson:()=>pK,promise:()=>uF,preprocess:()=>dF,pipeline:()=>cF,ostring:()=>iF,optional:()=>lF,onumber:()=>nF,oboolean:()=>oF,objectUtil:()=>c9,object:()=>jF,number:()=>pX,nullable:()=>rF,null:()=>NF,never:()=>_F,nativeEnum:()=>mF,nan:()=>AF,map:()=>bF,makeIssue:()=>v4,literal:()=>yF,lazy:()=>hF,late:()=>KF,isValid:()=>h0,isDirty:()=>c6,isAsync:()=>c2,isAborted:()=>d6,intersection:()=>IF,instanceof:()=>FF,getParsedType:()=>J0,getErrorMap:()=>d2,function:()=>gF,enum:()=>fF,effect:()=>pF,discriminatedUnion:()=>SF,defaultErrorMap:()=>N0,datetimeRegex:()=>yX,date:()=>BF,custom:()=>mX,coerce:()=>sF,boolean:()=>lX,bigint:()=>wF,array:()=>EF,any:()=>ZF,addIssueToContext:()=>x,ZodVoid:()=>h4,ZodUnknown:()=>y0,ZodUnion:()=>t2,ZodUndefined:()=>s2,ZodType:()=>o,ZodTuple:()=>U0,ZodTransformer:()=>G0,ZodSymbol:()=>g4,ZodString:()=>a1,ZodSet:()=>Q2,ZodSchema:()=>o,ZodRecord:()=>y4,ZodReadonly:()=>V4,ZodPromise:()=>K2,ZodPipeline:()=>u4,ZodParsedType:()=>C,ZodOptional:()=>e1,ZodObject:()=>q1,ZodNumber:()=>f0,ZodNullable:()=>z0,ZodNull:()=>a2,ZodNever:()=>H0,ZodNativeEnum:()=>X4,ZodNaN:()=>m4,ZodMap:()=>f4,ZodLiteral:()=>G4,ZodLazy:()=>$4,ZodIssueCode:()=>T,ZodIntersection:()=>e2,ZodFunction:()=>n2,ZodFirstPartyTypeKind:()=>p,ZodError:()=>C1,ZodEnum:()=>u0,ZodEffects:()=>G0,ZodDiscriminatedUnion:()=>i6,ZodDefault:()=>Y4,ZodDate:()=>D2,ZodCatch:()=>W4,ZodBranded:()=>n6,ZodBoolean:()=>o2,ZodBigInt:()=>m0,ZodArray:()=>t1,ZodAny:()=>M2,Schema:()=>o,ParseStatus:()=>_1,OK:()=>S1,NEVER:()=>aF,INVALID:()=>u,EMPTY_PATH:()=>dK,DIRTY:()=>R2,BRAND:()=>QF});var a;(function($){$.assertEqual=(W)=>{};function G(W){}$.assertIs=G;function X(W){throw Error()}$.assertNever=X,$.arrayToEnum=(W)=>{let V={};for(let q of W)V[q]=q;return V},$.getValidEnumValues=(W)=>{let V=$.objectKeys(W).filter((J)=>typeof W[W[J]]!=="number"),q={};for(let J of V)q[J]=W[J];return $.objectValues(q)},$.objectValues=(W)=>{return $.objectKeys(W).map(function(V){return W[V]})},$.objectKeys=typeof Object.keys==="function"?(W)=>Object.keys(W):(W)=>{let V=[];for(let q in W)if(Object.prototype.hasOwnProperty.call(W,q))V.push(q);return V},$.find=(W,V)=>{for(let q of W)if(V(q))return q;return},$.isInteger=typeof Number.isInteger==="function"?(W)=>Number.isInteger(W):(W)=>typeof W==="number"&&Number.isFinite(W)&&Math.floor(W)===W;function Y(W,V=" | "){return W.map((q)=>typeof q==="string"?`'${q}'`:q).join(V)}$.joinValues=Y,$.jsonStringifyReplacer=(W,V)=>{if(typeof V==="bigint")return V.toString();return V}})(a||(a={}));var c9;(function($){$.mergeShapes=(G,X)=>{return{...G,...X}}})(c9||(c9={}));var C=a.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),J0=($)=>{switch(typeof $){case"undefined":return C.undefined;case"string":return C.string;case"number":return Number.isNaN($)?C.nan:C.number;case"boolean":return C.boolean;case"function":return C.function;case"bigint":return C.bigint;case"symbol":return C.symbol;case"object":if(Array.isArray($))return C.array;if($===null)return C.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return C.promise;if(typeof Map<"u"&&$ instanceof Map)return C.map;if(typeof Set<"u"&&$ instanceof Set)return C.set;if(typeof Date<"u"&&$ instanceof Date)return C.date;return C.object;default:return C.unknown}};var T=a.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"]),pK=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class C1 extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(X)=>{this.issues=[...this.issues,X]},this.addIssues=(X=[])=>{this.issues=[...this.issues,...X]};let G=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,G);else this.__proto__=G;this.name="ZodError",this.issues=$}format($){let G=$||function(W){return W.message},X={_errors:[]},Y=(W)=>{for(let V of W.issues)if(V.code==="invalid_union")V.unionErrors.map(Y);else if(V.code==="invalid_return_type")Y(V.returnTypeError);else if(V.code==="invalid_arguments")Y(V.argumentsError);else if(V.path.length===0)X._errors.push(G(V));else{let q=X,J=0;while(J<V.path.length){let U=V.path[J];if(J!==V.path.length-1)q[U]=q[U]||{_errors:[]};else q[U]=q[U]||{_errors:[]},q[U]._errors.push(G(V));q=q[U],J++}}};return Y(this),X}static assert($){if(!($ instanceof C1))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,a.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(G)=>G.message){let G={},X=[];for(let Y of this.issues)if(Y.path.length>0){let W=Y.path[0];G[W]=G[W]||[],G[W].push($(Y))}else X.push($(Y));return{formErrors:X,fieldErrors:G}}get formErrors(){return this.flatten()}}C1.create=($)=>{return new C1($)};var lK=($,G)=>{let X;switch($.code){case T.invalid_type:if($.received===C.undefined)X="Required";else X=`Expected ${$.expected}, received ${$.received}`;break;case T.invalid_literal:X=`Invalid literal value, expected ${JSON.stringify($.expected,a.jsonStringifyReplacer)}`;break;case T.unrecognized_keys:X=`Unrecognized key(s) in object: ${a.joinValues($.keys,", ")}`;break;case T.invalid_union:X="Invalid input";break;case T.invalid_union_discriminator:X=`Invalid discriminator value. Expected ${a.joinValues($.options)}`;break;case T.invalid_enum_value:X=`Invalid enum value. Expected ${a.joinValues($.options)}, received '${$.received}'`;break;case T.invalid_arguments:X="Invalid function arguments";break;case T.invalid_return_type:X="Invalid function return type";break;case T.invalid_date:X="Invalid date";break;case T.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(X=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")X=`${X} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)X=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)X=`Invalid input: must end with "${$.validation.endsWith}"`;else a.assertNever($.validation);else if($.validation!=="regex")X=`Invalid ${$.validation}`;else X="Invalid";break;case T.too_small:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else X="Invalid input";break;case T.too_big:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")X=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else X="Invalid input";break;case T.custom:X="Invalid input";break;case T.invalid_intersection_types:X="Intersection results could not be merged";break;case T.not_multiple_of:X=`Number must be a multiple of ${$.multipleOf}`;break;case T.not_finite:X="Number must be finite";break;default:X=G.defaultError,a.assertNever($)}return{message:X}},N0=lK;var kX=N0;function rK($){kX=$}function d2(){return kX}var v4=($)=>{let{data:G,path:X,errorMaps:Y,issueData:W}=$,V=[...X,...W.path||[]],q={...W,path:V};if(W.message!==void 0)return{...W,path:V,message:W.message};let J="",U=Y.filter((R)=>!!R).slice().reverse();for(let R of U)J=R(q,{data:G,defaultError:J}).message;return{...W,path:V,message:J}},dK=[];function x($,G){let X=d2(),Y=v4({issueData:G,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,X,X===N0?void 0:N0].filter((W)=>!!W)});$.common.issues.push(Y)}class _1{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,G){let X=[];for(let Y of G){if(Y.status==="aborted")return u;if(Y.status==="dirty")$.dirty();X.push(Y.value)}return{status:$.value,value:X}}static async mergeObjectAsync($,G){let X=[];for(let Y of G){let W=await Y.key,V=await Y.value;X.push({key:W,value:V})}return _1.mergeObjectSync($,X)}static mergeObjectSync($,G){let X={};for(let Y of G){let{key:W,value:V}=Y;if(W.status==="aborted")return u;if(V.status==="aborted")return u;if(W.status==="dirty")$.dirty();if(V.status==="dirty")$.dirty();if(W.value!=="__proto__"&&(typeof V.value<"u"||Y.alwaysSet))X[W.value]=V.value}return{status:$.value,value:X}}}var u=Object.freeze({status:"aborted"}),R2=($)=>({status:"dirty",value:$}),S1=($)=>({status:"valid",value:$}),d6=($)=>$.status==="aborted",c6=($)=>$.status==="dirty",h0=($)=>$.status==="valid",c2=($)=>typeof Promise<"u"&&$ instanceof Promise;var g;(function($){$.errToObj=(G)=>typeof G==="string"?{message:G}:G||{},$.toString=(G)=>typeof G==="string"?G:G?.message})(g||(g={}));class $0{constructor($,G,X,Y){this._cachedPath=[],this.parent=$,this.data=G,this._path=X,this._key=Y}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var bX=($,G)=>{if(h0(G))return{success:!0,data:G.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let X=new C1($.common.issues);return this._error=X,this._error}}}};function c($){if(!$)return{};let{errorMap:G,invalid_type_error:X,required_error:Y,description:W}=$;if(G&&(X||Y))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(G)return{errorMap:G,description:W};return{errorMap:(q,J)=>{let{message:U}=$;if(q.code==="invalid_enum_value")return{message:U??J.defaultError};if(typeof J.data>"u")return{message:U??Y??J.defaultError};if(q.code!=="invalid_type")return{message:J.defaultError};return{message:U??X??J.defaultError}},description:W}}class o{get description(){return this._def.description}_getType($){return J0($.data)}_getOrReturnCtx($,G){return G||{common:$.parent.common,data:$.data,parsedType:J0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new _1,ctx:{common:$.parent.common,data:$.data,parsedType:J0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let G=this._parse($);if(c2(G))throw Error("Synchronous parse encountered promise.");return G}_parseAsync($){let G=this._parse($);return Promise.resolve(G)}parse($,G){let X=this.safeParse($,G);if(X.success)return X.data;throw X.error}safeParse($,G){let X={common:{issues:[],async:G?.async??!1,contextualErrorMap:G?.errorMap},path:G?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:J0($)},Y=this._parseSync({data:$,path:X.path,parent:X});return bX(X,Y)}"~validate"($){let G={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:J0($)};if(!this["~standard"].async)try{let X=this._parseSync({data:$,path:[],parent:G});return h0(X)?{value:X.value}:{issues:G.common.issues}}catch(X){if(X?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;G.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:G}).then((X)=>h0(X)?{value:X.value}:{issues:G.common.issues})}async parseAsync($,G){let X=await this.safeParseAsync($,G);if(X.success)return X.data;throw X.error}async safeParseAsync($,G){let X={common:{issues:[],contextualErrorMap:G?.errorMap,async:!0},path:G?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:J0($)},Y=this._parse({data:$,path:X.path,parent:X}),W=await(c2(Y)?Y:Promise.resolve(Y));return bX(X,W)}refine($,G){let X=(Y)=>{if(typeof G==="string"||typeof G>"u")return{message:G};else if(typeof G==="function")return G(Y);else return G};return this._refinement((Y,W)=>{let V=$(Y),q=()=>W.addIssue({code:T.custom,...X(Y)});if(typeof Promise<"u"&&V instanceof Promise)return V.then((J)=>{if(!J)return q(),!1;else return!0});if(!V)return q(),!1;else return!0})}refinement($,G){return this._refinement((X,Y)=>{if(!$(X))return Y.addIssue(typeof G==="function"?G(X,Y):G),!1;else return!0})}_refinement($){return new G0({schema:this,typeName:p.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,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:(G)=>this["~validate"](G)}}optional(){return e1.create(this,this._def)}nullable(){return z0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return t1.create(this)}promise(){return K2.create(this,this._def)}or($){return t2.create([this,$],this._def)}and($){return e2.create(this,$,this._def)}transform($){return new G0({...c(this._def),schema:this,typeName:p.ZodEffects,effect:{type:"transform",transform:$}})}default($){let G=typeof $==="function"?$:()=>$;return new Y4({...c(this._def),innerType:this,defaultValue:G,typeName:p.ZodDefault})}brand(){return new n6({typeName:p.ZodBranded,type:this,...c(this._def)})}catch($){let G=typeof $==="function"?$:()=>$;return new W4({...c(this._def),innerType:this,catchValue:G,typeName:p.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return u4.create(this,$)}readonly(){return V4.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var cK=/^c[^\s-]{8,}$/i,iK=/^[0-9a-z]+$/,nK=/^[0-9A-HJKMNP-TV-Z]{26}$/i,oK=/^[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,sK=/^[a-z0-9_-]{21}$/i,aK=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,tK=/^[-+]?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)?)??$/,eK=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,$F="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",i9,GF=/^(?:(?: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])$/,XF=/^(?:(?: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])$/,YF=/^(([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]))$/,WF=/^(([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])$/,VF=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qF=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,gX="((\\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])))",JF=new RegExp(`^${gX}$`);function hX($){let G="[0-5]\\d";if($.precision)G=`${G}\\.\\d{${$.precision}}`;else if($.precision==null)G=`${G}(\\.\\d+)?`;let X=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${G})${X}`}function HF($){return new RegExp(`^${hX($)}$`)}function yX($){let G=`${gX}T${hX($)}`,X=[];if(X.push($.local?"Z?":"Z"),$.offset)X.push("([+-]\\d{2}:?\\d{2})");return G=`${G}(${X.join("|")})`,new RegExp(`^${G}$`)}function UF($,G){if((G==="v4"||!G)&&GF.test($))return!0;if((G==="v6"||!G)&&YF.test($))return!0;return!1}function RF($,G){if(!aK.test($))return!1;try{let[X]=$.split(".");if(!X)return!1;let Y=X.replace(/-/g,"+").replace(/_/g,"/").padEnd(X.length+(4-X.length%4)%4,"="),W=JSON.parse(atob(Y));if(typeof W!=="object"||W===null)return!1;if("typ"in W&&W?.typ!=="JWT")return!1;if(!W.alg)return!1;if(G&&W.alg!==G)return!1;return!0}catch{return!1}}function DF($,G){if((G==="v4"||!G)&&XF.test($))return!0;if((G==="v6"||!G)&&WF.test($))return!0;return!1}class a1 extends o{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==C.string){let W=this._getOrReturnCtx($);return x(W,{code:T.invalid_type,expected:C.string,received:W.parsedType}),u}let X=new _1,Y=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.length<W.value)Y=this._getOrReturnCtx($,Y),x(Y,{code:T.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),X.dirty()}else if(W.kind==="max"){if($.data.length>W.value)Y=this._getOrReturnCtx($,Y),x(Y,{code:T.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),X.dirty()}else if(W.kind==="length"){let V=$.data.length>W.value,q=$.data.length<W.value;if(V||q){if(Y=this._getOrReturnCtx($,Y),V)x(Y,{code:T.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});else if(q)x(Y,{code:T.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});X.dirty()}}else if(W.kind==="email"){if(!eK.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"email",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="emoji"){if(!i9)i9=new RegExp($F,"u");if(!i9.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"emoji",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="uuid"){if(!oK.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"uuid",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="nanoid"){if(!sK.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"nanoid",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="cuid"){if(!cK.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"cuid",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="cuid2"){if(!iK.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"cuid2",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="ulid"){if(!nK.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"ulid",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="url")try{new URL($.data)}catch{Y=this._getOrReturnCtx($,Y),x(Y,{validation:"url",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="regex"){if(W.regex.lastIndex=0,!W.regex.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"regex",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="trim")$.data=$.data.trim();else if(W.kind==="includes"){if(!$.data.includes(W.value,W.position))Y=this._getOrReturnCtx($,Y),x(Y,{code:T.invalid_string,validation:{includes:W.value,position:W.position},message:W.message}),X.dirty()}else if(W.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(W.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(W.kind==="startsWith"){if(!$.data.startsWith(W.value))Y=this._getOrReturnCtx($,Y),x(Y,{code:T.invalid_string,validation:{startsWith:W.value},message:W.message}),X.dirty()}else if(W.kind==="endsWith"){if(!$.data.endsWith(W.value))Y=this._getOrReturnCtx($,Y),x(Y,{code:T.invalid_string,validation:{endsWith:W.value},message:W.message}),X.dirty()}else if(W.kind==="datetime"){if(!yX(W).test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{code:T.invalid_string,validation:"datetime",message:W.message}),X.dirty()}else if(W.kind==="date"){if(!JF.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{code:T.invalid_string,validation:"date",message:W.message}),X.dirty()}else if(W.kind==="time"){if(!HF(W).test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{code:T.invalid_string,validation:"time",message:W.message}),X.dirty()}else if(W.kind==="duration"){if(!tK.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"duration",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="ip"){if(!UF($.data,W.version))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"ip",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="jwt"){if(!RF($.data,W.alg))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"jwt",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="cidr"){if(!DF($.data,W.version))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"cidr",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="base64"){if(!VF.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"base64",code:T.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="base64url"){if(!qF.test($.data))Y=this._getOrReturnCtx($,Y),x(Y,{validation:"base64url",code:T.invalid_string,message:W.message}),X.dirty()}else a.assertNever(W);return{status:X.value,value:$.data}}_regex($,G,X){return this.refinement((Y)=>$.test(Y),{validation:G,code:T.invalid_string,...g.errToObj(X)})}_addCheck($){return new a1({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...g.errToObj($)})}url($){return this._addCheck({kind:"url",...g.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...g.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...g.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...g.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...g.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...g.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...g.errToObj($)})}base64($){return this._addCheck({kind:"base64",...g.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...g.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...g.errToObj($)})}ip($){return this._addCheck({kind:"ip",...g.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...g.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...g.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...g.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...g.errToObj($)})}regex($,G){return this._addCheck({kind:"regex",regex:$,...g.errToObj(G)})}includes($,G){return this._addCheck({kind:"includes",value:$,position:G?.position,...g.errToObj(G?.message)})}startsWith($,G){return this._addCheck({kind:"startsWith",value:$,...g.errToObj(G)})}endsWith($,G){return this._addCheck({kind:"endsWith",value:$,...g.errToObj(G)})}min($,G){return this._addCheck({kind:"min",value:$,...g.errToObj(G)})}max($,G){return this._addCheck({kind:"max",value:$,...g.errToObj(G)})}length($,G){return this._addCheck({kind:"length",value:$,...g.errToObj(G)})}nonempty($){return this.min(1,g.errToObj($))}trim(){return new a1({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new a1({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new a1({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $}get maxLength(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $}}a1.create=($)=>{return new a1({checks:[],typeName:p.ZodString,coerce:$?.coerce??!1,...c($)})};function MF($,G){let X=($.toString().split(".")[1]||"").length,Y=(G.toString().split(".")[1]||"").length,W=X>Y?X:Y,V=Number.parseInt($.toFixed(W).replace(".","")),q=Number.parseInt(G.toFixed(W).replace(".",""));return V%q/10**W}class f0 extends o{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==C.number){let W=this._getOrReturnCtx($);return x(W,{code:T.invalid_type,expected:C.number,received:W.parsedType}),u}let X=void 0,Y=new _1;for(let W of this._def.checks)if(W.kind==="int"){if(!a.isInteger($.data))X=this._getOrReturnCtx($,X),x(X,{code:T.invalid_type,expected:"integer",received:"float",message:W.message}),Y.dirty()}else if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)X=this._getOrReturnCtx($,X),x(X,{code:T.too_small,minimum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),Y.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)X=this._getOrReturnCtx($,X),x(X,{code:T.too_big,maximum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),Y.dirty()}else if(W.kind==="multipleOf"){if(MF($.data,W.value)!==0)X=this._getOrReturnCtx($,X),x(X,{code:T.not_multiple_of,multipleOf:W.value,message:W.message}),Y.dirty()}else if(W.kind==="finite"){if(!Number.isFinite($.data))X=this._getOrReturnCtx($,X),x(X,{code:T.not_finite,message:W.message}),Y.dirty()}else a.assertNever(W);return{status:Y.value,value:$.data}}gte($,G){return this.setLimit("min",$,!0,g.toString(G))}gt($,G){return this.setLimit("min",$,!1,g.toString(G))}lte($,G){return this.setLimit("max",$,!0,g.toString(G))}lt($,G){return this.setLimit("max",$,!1,g.toString(G))}setLimit($,G,X,Y){return new f0({...this._def,checks:[...this._def.checks,{kind:$,value:G,inclusive:X,message:g.toString(Y)}]})}_addCheck($){return new f0({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:g.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString($)})}multipleOf($,G){return this._addCheck({kind:"multipleOf",value:$,message:g.toString(G)})}finite($){return this._addCheck({kind:"finite",message:g.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.toString($)})}get minValue(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $}get maxValue(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&a.isInteger($.value))}get isFinite(){let $=null,G=null;for(let X of this._def.checks)if(X.kind==="finite"||X.kind==="int"||X.kind==="multipleOf")return!0;else if(X.kind==="min"){if(G===null||X.value>G)G=X.value}else if(X.kind==="max"){if($===null||X.value<$)$=X.value}return Number.isFinite(G)&&Number.isFinite($)}}f0.create=($)=>{return new f0({checks:[],typeName:p.ZodNumber,coerce:$?.coerce||!1,...c($)})};class m0 extends o{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==C.bigint)return this._getInvalidInput($);let X=void 0,Y=new _1;for(let W of this._def.checks)if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)X=this._getOrReturnCtx($,X),x(X,{code:T.too_small,type:"bigint",minimum:W.value,inclusive:W.inclusive,message:W.message}),Y.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)X=this._getOrReturnCtx($,X),x(X,{code:T.too_big,type:"bigint",maximum:W.value,inclusive:W.inclusive,message:W.message}),Y.dirty()}else if(W.kind==="multipleOf"){if($.data%W.value!==BigInt(0))X=this._getOrReturnCtx($,X),x(X,{code:T.not_multiple_of,multipleOf:W.value,message:W.message}),Y.dirty()}else a.assertNever(W);return{status:Y.value,value:$.data}}_getInvalidInput($){let G=this._getOrReturnCtx($);return x(G,{code:T.invalid_type,expected:C.bigint,received:G.parsedType}),u}gte($,G){return this.setLimit("min",$,!0,g.toString(G))}gt($,G){return this.setLimit("min",$,!1,g.toString(G))}lte($,G){return this.setLimit("max",$,!0,g.toString(G))}lt($,G){return this.setLimit("max",$,!1,g.toString(G))}setLimit($,G,X,Y){return new m0({...this._def,checks:[...this._def.checks,{kind:$,value:G,inclusive:X,message:g.toString(Y)}]})}_addCheck($){return new m0({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString($)})}multipleOf($,G){return this._addCheck({kind:"multipleOf",value:$,message:g.toString(G)})}get minValue(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $}get maxValue(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $}}m0.create=($)=>{return new m0({checks:[],typeName:p.ZodBigInt,coerce:$?.coerce??!1,...c($)})};class o2 extends o{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==C.boolean){let X=this._getOrReturnCtx($);return x(X,{code:T.invalid_type,expected:C.boolean,received:X.parsedType}),u}return S1($.data)}}o2.create=($)=>{return new o2({typeName:p.ZodBoolean,coerce:$?.coerce||!1,...c($)})};class D2 extends o{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==C.date){let W=this._getOrReturnCtx($);return x(W,{code:T.invalid_type,expected:C.date,received:W.parsedType}),u}if(Number.isNaN($.data.getTime())){let W=this._getOrReturnCtx($);return x(W,{code:T.invalid_date}),u}let X=new _1,Y=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.getTime()<W.value)Y=this._getOrReturnCtx($,Y),x(Y,{code:T.too_small,message:W.message,inclusive:!0,exact:!1,minimum:W.value,type:"date"}),X.dirty()}else if(W.kind==="max"){if($.data.getTime()>W.value)Y=this._getOrReturnCtx($,Y),x(Y,{code:T.too_big,message:W.message,inclusive:!0,exact:!1,maximum:W.value,type:"date"}),X.dirty()}else a.assertNever(W);return{status:X.value,value:new Date($.data.getTime())}}_addCheck($){return new D2({...this._def,checks:[...this._def.checks,$]})}min($,G){return this._addCheck({kind:"min",value:$.getTime(),message:g.toString(G)})}max($,G){return this._addCheck({kind:"max",value:$.getTime(),message:g.toString(G)})}get minDate(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $!=null?new Date($):null}}D2.create=($)=>{return new D2({checks:[],coerce:$?.coerce||!1,typeName:p.ZodDate,...c($)})};class g4 extends o{_parse($){if(this._getType($)!==C.symbol){let X=this._getOrReturnCtx($);return x(X,{code:T.invalid_type,expected:C.symbol,received:X.parsedType}),u}return S1($.data)}}g4.create=($)=>{return new g4({typeName:p.ZodSymbol,...c($)})};class s2 extends o{_parse($){if(this._getType($)!==C.undefined){let X=this._getOrReturnCtx($);return x(X,{code:T.invalid_type,expected:C.undefined,received:X.parsedType}),u}return S1($.data)}}s2.create=($)=>{return new s2({typeName:p.ZodUndefined,...c($)})};class a2 extends o{_parse($){if(this._getType($)!==C.null){let X=this._getOrReturnCtx($);return x(X,{code:T.invalid_type,expected:C.null,received:X.parsedType}),u}return S1($.data)}}a2.create=($)=>{return new a2({typeName:p.ZodNull,...c($)})};class M2 extends o{constructor(){super(...arguments);this._any=!0}_parse($){return S1($.data)}}M2.create=($)=>{return new M2({typeName:p.ZodAny,...c($)})};class y0 extends o{constructor(){super(...arguments);this._unknown=!0}_parse($){return S1($.data)}}y0.create=($)=>{return new y0({typeName:p.ZodUnknown,...c($)})};class H0 extends o{_parse($){let G=this._getOrReturnCtx($);return x(G,{code:T.invalid_type,expected:C.never,received:G.parsedType}),u}}H0.create=($)=>{return new H0({typeName:p.ZodNever,...c($)})};class h4 extends o{_parse($){if(this._getType($)!==C.undefined){let X=this._getOrReturnCtx($);return x(X,{code:T.invalid_type,expected:C.void,received:X.parsedType}),u}return S1($.data)}}h4.create=($)=>{return new h4({typeName:p.ZodVoid,...c($)})};class t1 extends o{_parse($){let{ctx:G,status:X}=this._processInputParams($),Y=this._def;if(G.parsedType!==C.array)return x(G,{code:T.invalid_type,expected:C.array,received:G.parsedType}),u;if(Y.exactLength!==null){let V=G.data.length>Y.exactLength.value,q=G.data.length<Y.exactLength.value;if(V||q)x(G,{code:V?T.too_big:T.too_small,minimum:q?Y.exactLength.value:void 0,maximum:V?Y.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:Y.exactLength.message}),X.dirty()}if(Y.minLength!==null){if(G.data.length<Y.minLength.value)x(G,{code:T.too_small,minimum:Y.minLength.value,type:"array",inclusive:!0,exact:!1,message:Y.minLength.message}),X.dirty()}if(Y.maxLength!==null){if(G.data.length>Y.maxLength.value)x(G,{code:T.too_big,maximum:Y.maxLength.value,type:"array",inclusive:!0,exact:!1,message:Y.maxLength.message}),X.dirty()}if(G.common.async)return Promise.all([...G.data].map((V,q)=>{return Y.type._parseAsync(new $0(G,V,G.path,q))})).then((V)=>{return _1.mergeArray(X,V)});let W=[...G.data].map((V,q)=>{return Y.type._parseSync(new $0(G,V,G.path,q))});return _1.mergeArray(X,W)}get element(){return this._def.type}min($,G){return new t1({...this._def,minLength:{value:$,message:g.toString(G)}})}max($,G){return new t1({...this._def,maxLength:{value:$,message:g.toString(G)}})}length($,G){return new t1({...this._def,exactLength:{value:$,message:g.toString(G)}})}nonempty($){return this.min(1,$)}}t1.create=($,G)=>{return new t1({type:$,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,...c(G)})};function i2($){if($ instanceof q1){let G={};for(let X in $.shape){let Y=$.shape[X];G[X]=e1.create(i2(Y))}return new q1({...$._def,shape:()=>G})}else if($ instanceof t1)return new t1({...$._def,type:i2($.element)});else if($ instanceof e1)return e1.create(i2($.unwrap()));else if($ instanceof z0)return z0.create(i2($.unwrap()));else if($ instanceof U0)return U0.create($.items.map((G)=>i2(G)));else return $}class q1 extends o{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),G=a.objectKeys($);return this._cached={shape:$,keys:G},this._cached}_parse($){if(this._getType($)!==C.object){let U=this._getOrReturnCtx($);return x(U,{code:T.invalid_type,expected:C.object,received:U.parsedType}),u}let{status:X,ctx:Y}=this._processInputParams($),{shape:W,keys:V}=this._getCached(),q=[];if(!(this._def.catchall instanceof H0&&this._def.unknownKeys==="strip")){for(let U in Y.data)if(!V.includes(U))q.push(U)}let J=[];for(let U of V){let R=W[U],D=Y.data[U];J.push({key:{status:"valid",value:U},value:R._parse(new $0(Y,D,Y.path,U)),alwaysSet:U in Y.data})}if(this._def.catchall instanceof H0){let U=this._def.unknownKeys;if(U==="passthrough")for(let R of q)J.push({key:{status:"valid",value:R},value:{status:"valid",value:Y.data[R]}});else if(U==="strict"){if(q.length>0)x(Y,{code:T.unrecognized_keys,keys:q}),X.dirty()}else if(U==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let U=this._def.catchall;for(let R of q){let D=Y.data[R];J.push({key:{status:"valid",value:R},value:U._parse(new $0(Y,D,Y.path,R)),alwaysSet:R in Y.data})}}if(Y.common.async)return Promise.resolve().then(async()=>{let U=[];for(let R of J){let D=await R.key,M=await R.value;U.push({key:D,value:M,alwaysSet:R.alwaysSet})}return U}).then((U)=>{return _1.mergeObjectSync(X,U)});else return _1.mergeObjectSync(X,J)}get shape(){return this._def.shape()}strict($){return g.errToObj,new q1({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(G,X)=>{let Y=this._def.errorMap?.(G,X).message??X.defaultError;if(G.code==="unrecognized_keys")return{message:g.errToObj($).message??Y};return{message:Y}}}:{}})}strip(){return new q1({...this._def,unknownKeys:"strip"})}passthrough(){return new q1({...this._def,unknownKeys:"passthrough"})}extend($){return new q1({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new q1({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:p.ZodObject})}setKey($,G){return this.augment({[$]:G})}catchall($){return new q1({...this._def,catchall:$})}pick($){let G={};for(let X of a.objectKeys($))if($[X]&&this.shape[X])G[X]=this.shape[X];return new q1({...this._def,shape:()=>G})}omit($){let G={};for(let X of a.objectKeys(this.shape))if(!$[X])G[X]=this.shape[X];return new q1({...this._def,shape:()=>G})}deepPartial(){return i2(this)}partial($){let G={};for(let X of a.objectKeys(this.shape)){let Y=this.shape[X];if($&&!$[X])G[X]=Y;else G[X]=Y.optional()}return new q1({...this._def,shape:()=>G})}required($){let G={};for(let X of a.objectKeys(this.shape))if($&&!$[X])G[X]=this.shape[X];else{let W=this.shape[X];while(W instanceof e1)W=W._def.innerType;G[X]=W}return new q1({...this._def,shape:()=>G})}keyof(){return fX(a.objectKeys(this.shape))}}q1.create=($,G)=>{return new q1({shape:()=>$,unknownKeys:"strip",catchall:H0.create(),typeName:p.ZodObject,...c(G)})};q1.strictCreate=($,G)=>{return new q1({shape:()=>$,unknownKeys:"strict",catchall:H0.create(),typeName:p.ZodObject,...c(G)})};q1.lazycreate=($,G)=>{return new q1({shape:$,unknownKeys:"strip",catchall:H0.create(),typeName:p.ZodObject,...c(G)})};class t2 extends o{_parse($){let{ctx:G}=this._processInputParams($),X=this._def.options;function Y(W){for(let q of W)if(q.result.status==="valid")return q.result;for(let q of W)if(q.result.status==="dirty")return G.common.issues.push(...q.ctx.common.issues),q.result;let V=W.map((q)=>new C1(q.ctx.common.issues));return x(G,{code:T.invalid_union,unionErrors:V}),u}if(G.common.async)return Promise.all(X.map(async(W)=>{let V={...G,common:{...G.common,issues:[]},parent:null};return{result:await W._parseAsync({data:G.data,path:G.path,parent:V}),ctx:V}})).then(Y);else{let W=void 0,V=[];for(let J of X){let U={...G,common:{...G.common,issues:[]},parent:null},R=J._parseSync({data:G.data,path:G.path,parent:U});if(R.status==="valid")return R;else if(R.status==="dirty"&&!W)W={result:R,ctx:U};if(U.common.issues.length)V.push(U.common.issues)}if(W)return G.common.issues.push(...W.ctx.common.issues),W.result;let q=V.map((J)=>new C1(J));return x(G,{code:T.invalid_union,unionErrors:q}),u}}get options(){return this._def.options}}t2.create=($,G)=>{return new t2({options:$,typeName:p.ZodUnion,...c(G)})};var Z0=($)=>{if($ instanceof $4)return Z0($.schema);else if($ instanceof G0)return Z0($.innerType());else if($ instanceof G4)return[$.value];else if($ instanceof u0)return $.options;else if($ instanceof X4)return a.objectValues($.enum);else if($ instanceof Y4)return Z0($._def.innerType);else if($ instanceof s2)return[void 0];else if($ instanceof a2)return[null];else if($ instanceof e1)return[void 0,...Z0($.unwrap())];else if($ instanceof z0)return[null,...Z0($.unwrap())];else if($ instanceof n6)return Z0($.unwrap());else if($ instanceof V4)return Z0($.unwrap());else if($ instanceof W4)return Z0($._def.innerType);else return[]};class i6 extends o{_parse($){let{ctx:G}=this._processInputParams($);if(G.parsedType!==C.object)return x(G,{code:T.invalid_type,expected:C.object,received:G.parsedType}),u;let X=this.discriminator,Y=G.data[X],W=this.optionsMap.get(Y);if(!W)return x(G,{code:T.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[X]}),u;if(G.common.async)return W._parseAsync({data:G.data,path:G.path,parent:G});else return W._parseSync({data:G.data,path:G.path,parent:G})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,G,X){let Y=new Map;for(let W of G){let V=Z0(W.shape[$]);if(!V.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let q of V){if(Y.has(q))throw Error(`Discriminator property ${String($)} has duplicate value ${String(q)}`);Y.set(q,W)}}return new i6({typeName:p.ZodDiscriminatedUnion,discriminator:$,options:G,optionsMap:Y,...c(X)})}}function n9($,G){let X=J0($),Y=J0(G);if($===G)return{valid:!0,data:$};else if(X===C.object&&Y===C.object){let W=a.objectKeys(G),V=a.objectKeys($).filter((J)=>W.indexOf(J)!==-1),q={...$,...G};for(let J of V){let U=n9($[J],G[J]);if(!U.valid)return{valid:!1};q[J]=U.data}return{valid:!0,data:q}}else if(X===C.array&&Y===C.array){if($.length!==G.length)return{valid:!1};let W=[];for(let V=0;V<$.length;V++){let q=$[V],J=G[V],U=n9(q,J);if(!U.valid)return{valid:!1};W.push(U.data)}return{valid:!0,data:W}}else if(X===C.date&&Y===C.date&&+$===+G)return{valid:!0,data:$};else return{valid:!1}}class e2 extends o{_parse($){let{status:G,ctx:X}=this._processInputParams($),Y=(W,V)=>{if(d6(W)||d6(V))return u;let q=n9(W.value,V.value);if(!q.valid)return x(X,{code:T.invalid_intersection_types}),u;if(c6(W)||c6(V))G.dirty();return{status:G.value,value:q.data}};if(X.common.async)return Promise.all([this._def.left._parseAsync({data:X.data,path:X.path,parent:X}),this._def.right._parseAsync({data:X.data,path:X.path,parent:X})]).then(([W,V])=>Y(W,V));else return Y(this._def.left._parseSync({data:X.data,path:X.path,parent:X}),this._def.right._parseSync({data:X.data,path:X.path,parent:X}))}}e2.create=($,G,X)=>{return new e2({left:$,right:G,typeName:p.ZodIntersection,...c(X)})};class U0 extends o{_parse($){let{status:G,ctx:X}=this._processInputParams($);if(X.parsedType!==C.array)return x(X,{code:T.invalid_type,expected:C.array,received:X.parsedType}),u;if(X.data.length<this._def.items.length)return x(X,{code:T.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),u;if(!this._def.rest&&X.data.length>this._def.items.length)x(X,{code:T.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),G.dirty();let W=[...X.data].map((V,q)=>{let J=this._def.items[q]||this._def.rest;if(!J)return null;return J._parse(new $0(X,V,X.path,q))}).filter((V)=>!!V);if(X.common.async)return Promise.all(W).then((V)=>{return _1.mergeArray(G,V)});else return _1.mergeArray(G,W)}get items(){return this._def.items}rest($){return new U0({...this._def,rest:$})}}U0.create=($,G)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new U0({items:$,typeName:p.ZodTuple,rest:null,...c(G)})};class y4 extends o{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:G,ctx:X}=this._processInputParams($);if(X.parsedType!==C.object)return x(X,{code:T.invalid_type,expected:C.object,received:X.parsedType}),u;let Y=[],W=this._def.keyType,V=this._def.valueType;for(let q in X.data)Y.push({key:W._parse(new $0(X,q,X.path,q)),value:V._parse(new $0(X,X.data[q],X.path,q)),alwaysSet:q in X.data});if(X.common.async)return _1.mergeObjectAsync(G,Y);else return _1.mergeObjectSync(G,Y)}get element(){return this._def.valueType}static create($,G,X){if(G instanceof o)return new y4({keyType:$,valueType:G,typeName:p.ZodRecord,...c(X)});return new y4({keyType:a1.create(),valueType:$,typeName:p.ZodRecord,...c(G)})}}class f4 extends o{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:G,ctx:X}=this._processInputParams($);if(X.parsedType!==C.map)return x(X,{code:T.invalid_type,expected:C.map,received:X.parsedType}),u;let Y=this._def.keyType,W=this._def.valueType,V=[...X.data.entries()].map(([q,J],U)=>{return{key:Y._parse(new $0(X,q,X.path,[U,"key"])),value:W._parse(new $0(X,J,X.path,[U,"value"]))}});if(X.common.async){let q=new Map;return Promise.resolve().then(async()=>{for(let J of V){let U=await J.key,R=await J.value;if(U.status==="aborted"||R.status==="aborted")return u;if(U.status==="dirty"||R.status==="dirty")G.dirty();q.set(U.value,R.value)}return{status:G.value,value:q}})}else{let q=new Map;for(let J of V){let{key:U,value:R}=J;if(U.status==="aborted"||R.status==="aborted")return u;if(U.status==="dirty"||R.status==="dirty")G.dirty();q.set(U.value,R.value)}return{status:G.value,value:q}}}}f4.create=($,G,X)=>{return new f4({valueType:G,keyType:$,typeName:p.ZodMap,...c(X)})};class Q2 extends o{_parse($){let{status:G,ctx:X}=this._processInputParams($);if(X.parsedType!==C.set)return x(X,{code:T.invalid_type,expected:C.set,received:X.parsedType}),u;let Y=this._def;if(Y.minSize!==null){if(X.data.size<Y.minSize.value)x(X,{code:T.too_small,minimum:Y.minSize.value,type:"set",inclusive:!0,exact:!1,message:Y.minSize.message}),G.dirty()}if(Y.maxSize!==null){if(X.data.size>Y.maxSize.value)x(X,{code:T.too_big,maximum:Y.maxSize.value,type:"set",inclusive:!0,exact:!1,message:Y.maxSize.message}),G.dirty()}let W=this._def.valueType;function V(J){let U=new Set;for(let R of J){if(R.status==="aborted")return u;if(R.status==="dirty")G.dirty();U.add(R.value)}return{status:G.value,value:U}}let q=[...X.data.values()].map((J,U)=>W._parse(new $0(X,J,X.path,U)));if(X.common.async)return Promise.all(q).then((J)=>V(J));else return V(q)}min($,G){return new Q2({...this._def,minSize:{value:$,message:g.toString(G)}})}max($,G){return new Q2({...this._def,maxSize:{value:$,message:g.toString(G)}})}size($,G){return this.min($,G).max($,G)}nonempty($){return this.min(1,$)}}Q2.create=($,G)=>{return new Q2({valueType:$,minSize:null,maxSize:null,typeName:p.ZodSet,...c(G)})};class n2 extends o{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:G}=this._processInputParams($);if(G.parsedType!==C.function)return x(G,{code:T.invalid_type,expected:C.function,received:G.parsedType}),u;function X(q,J){return v4({data:q,path:G.path,errorMaps:[G.common.contextualErrorMap,G.schemaErrorMap,d2(),N0].filter((U)=>!!U),issueData:{code:T.invalid_arguments,argumentsError:J}})}function Y(q,J){return v4({data:q,path:G.path,errorMaps:[G.common.contextualErrorMap,G.schemaErrorMap,d2(),N0].filter((U)=>!!U),issueData:{code:T.invalid_return_type,returnTypeError:J}})}let W={errorMap:G.common.contextualErrorMap},V=G.data;if(this._def.returns instanceof K2){let q=this;return S1(async function(...J){let U=new C1([]),R=await q._def.args.parseAsync(J,W).catch((A)=>{throw U.addIssue(X(J,A)),U}),D=await Reflect.apply(V,this,R);return await q._def.returns._def.type.parseAsync(D,W).catch((A)=>{throw U.addIssue(Y(D,A)),U})})}else{let q=this;return S1(function(...J){let U=q._def.args.safeParse(J,W);if(!U.success)throw new C1([X(J,U.error)]);let R=Reflect.apply(V,this,U.data),D=q._def.returns.safeParse(R,W);if(!D.success)throw new C1([Y(R,D.error)]);return D.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new n2({...this._def,args:U0.create($).rest(y0.create())})}returns($){return new n2({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,G,X){return new n2({args:$?$:U0.create([]).rest(y0.create()),returns:G||y0.create(),typeName:p.ZodFunction,...c(X)})}}class $4 extends o{get schema(){return this._def.getter()}_parse($){let{ctx:G}=this._processInputParams($);return this._def.getter()._parse({data:G.data,path:G.path,parent:G})}}$4.create=($,G)=>{return new $4({getter:$,typeName:p.ZodLazy,...c(G)})};class G4 extends o{_parse($){if($.data!==this._def.value){let G=this._getOrReturnCtx($);return x(G,{received:G.data,code:T.invalid_literal,expected:this._def.value}),u}return{status:"valid",value:$.data}}get value(){return this._def.value}}G4.create=($,G)=>{return new G4({value:$,typeName:p.ZodLiteral,...c(G)})};function fX($,G){return new u0({values:$,typeName:p.ZodEnum,...c(G)})}class u0 extends o{_parse($){if(typeof $.data!=="string"){let G=this._getOrReturnCtx($),X=this._def.values;return x(G,{expected:a.joinValues(X),received:G.parsedType,code:T.invalid_type}),u}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let G=this._getOrReturnCtx($),X=this._def.values;return x(G,{received:G.data,code:T.invalid_enum_value,options:X}),u}return S1($.data)}get options(){return this._def.values}get enum(){let $={};for(let G of this._def.values)$[G]=G;return $}get Values(){let $={};for(let G of this._def.values)$[G]=G;return $}get Enum(){let $={};for(let G of this._def.values)$[G]=G;return $}extract($,G=this._def){return u0.create($,{...this._def,...G})}exclude($,G=this._def){return u0.create(this.options.filter((X)=>!$.includes(X)),{...this._def,...G})}}u0.create=fX;class X4 extends o{_parse($){let G=a.getValidEnumValues(this._def.values),X=this._getOrReturnCtx($);if(X.parsedType!==C.string&&X.parsedType!==C.number){let Y=a.objectValues(G);return x(X,{expected:a.joinValues(Y),received:X.parsedType,code:T.invalid_type}),u}if(!this._cache)this._cache=new Set(a.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let Y=a.objectValues(G);return x(X,{received:X.data,code:T.invalid_enum_value,options:Y}),u}return S1($.data)}get enum(){return this._def.values}}X4.create=($,G)=>{return new X4({values:$,typeName:p.ZodNativeEnum,...c(G)})};class K2 extends o{unwrap(){return this._def.type}_parse($){let{ctx:G}=this._processInputParams($);if(G.parsedType!==C.promise&&G.common.async===!1)return x(G,{code:T.invalid_type,expected:C.promise,received:G.parsedType}),u;let X=G.parsedType===C.promise?G.data:Promise.resolve(G.data);return S1(X.then((Y)=>{return this._def.type.parseAsync(Y,{path:G.path,errorMap:G.common.contextualErrorMap})}))}}K2.create=($,G)=>{return new K2({type:$,typeName:p.ZodPromise,...c(G)})};class G0 extends o{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===p.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:G,ctx:X}=this._processInputParams($),Y=this._def.effect||null,W={addIssue:(V)=>{if(x(X,V),V.fatal)G.abort();else G.dirty()},get path(){return X.path}};if(W.addIssue=W.addIssue.bind(W),Y.type==="preprocess"){let V=Y.transform(X.data,W);if(X.common.async)return Promise.resolve(V).then(async(q)=>{if(G.value==="aborted")return u;let J=await this._def.schema._parseAsync({data:q,path:X.path,parent:X});if(J.status==="aborted")return u;if(J.status==="dirty")return R2(J.value);if(G.value==="dirty")return R2(J.value);return J});else{if(G.value==="aborted")return u;let q=this._def.schema._parseSync({data:V,path:X.path,parent:X});if(q.status==="aborted")return u;if(q.status==="dirty")return R2(q.value);if(G.value==="dirty")return R2(q.value);return q}}if(Y.type==="refinement"){let V=(q)=>{let J=Y.refinement(q,W);if(X.common.async)return Promise.resolve(J);if(J instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return q};if(X.common.async===!1){let q=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(q.status==="aborted")return u;if(q.status==="dirty")G.dirty();return V(q.value),{status:G.value,value:q.value}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((q)=>{if(q.status==="aborted")return u;if(q.status==="dirty")G.dirty();return V(q.value).then(()=>{return{status:G.value,value:q.value}})})}if(Y.type==="transform")if(X.common.async===!1){let V=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(!h0(V))return u;let q=Y.transform(V.value,W);if(q instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:G.value,value:q}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((V)=>{if(!h0(V))return u;return Promise.resolve(Y.transform(V.value,W)).then((q)=>({status:G.value,value:q}))});a.assertNever(Y)}}G0.create=($,G,X)=>{return new G0({schema:$,typeName:p.ZodEffects,effect:G,...c(X)})};G0.createWithPreprocess=($,G,X)=>{return new G0({schema:G,effect:{type:"preprocess",transform:$},typeName:p.ZodEffects,...c(X)})};class e1 extends o{_parse($){if(this._getType($)===C.undefined)return S1(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}e1.create=($,G)=>{return new e1({innerType:$,typeName:p.ZodOptional,...c(G)})};class z0 extends o{_parse($){if(this._getType($)===C.null)return S1(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}z0.create=($,G)=>{return new z0({innerType:$,typeName:p.ZodNullable,...c(G)})};class Y4 extends o{_parse($){let{ctx:G}=this._processInputParams($),X=G.data;if(G.parsedType===C.undefined)X=this._def.defaultValue();return this._def.innerType._parse({data:X,path:G.path,parent:G})}removeDefault(){return this._def.innerType}}Y4.create=($,G)=>{return new Y4({innerType:$,typeName:p.ZodDefault,defaultValue:typeof G.default==="function"?G.default:()=>G.default,...c(G)})};class W4 extends o{_parse($){let{ctx:G}=this._processInputParams($),X={...G,common:{...G.common,issues:[]}},Y=this._def.innerType._parse({data:X.data,path:X.path,parent:{...X}});if(c2(Y))return Y.then((W)=>{return{status:"valid",value:W.status==="valid"?W.value:this._def.catchValue({get error(){return new C1(X.common.issues)},input:X.data})}});else return{status:"valid",value:Y.status==="valid"?Y.value:this._def.catchValue({get error(){return new C1(X.common.issues)},input:X.data})}}removeCatch(){return this._def.innerType}}W4.create=($,G)=>{return new W4({innerType:$,typeName:p.ZodCatch,catchValue:typeof G.catch==="function"?G.catch:()=>G.catch,...c(G)})};class m4 extends o{_parse($){if(this._getType($)!==C.nan){let X=this._getOrReturnCtx($);return x(X,{code:T.invalid_type,expected:C.nan,received:X.parsedType}),u}return{status:"valid",value:$.data}}}m4.create=($)=>{return new m4({typeName:p.ZodNaN,...c($)})};var QF=Symbol("zod_brand");class n6 extends o{_parse($){let{ctx:G}=this._processInputParams($),X=G.data;return this._def.type._parse({data:X,path:G.path,parent:G})}unwrap(){return this._def.type}}class u4 extends o{_parse($){let{status:G,ctx:X}=this._processInputParams($);if(X.common.async)return(async()=>{let W=await this._def.in._parseAsync({data:X.data,path:X.path,parent:X});if(W.status==="aborted")return u;if(W.status==="dirty")return G.dirty(),R2(W.value);else return this._def.out._parseAsync({data:W.value,path:X.path,parent:X})})();else{let Y=this._def.in._parseSync({data:X.data,path:X.path,parent:X});if(Y.status==="aborted")return u;if(Y.status==="dirty")return G.dirty(),{status:"dirty",value:Y.value};else return this._def.out._parseSync({data:Y.value,path:X.path,parent:X})}}static create($,G){return new u4({in:$,out:G,typeName:p.ZodPipeline})}}class V4 extends o{_parse($){let G=this._def.innerType._parse($),X=(Y)=>{if(h0(Y))Y.value=Object.freeze(Y.value);return Y};return c2(G)?G.then((Y)=>X(Y)):X(G)}unwrap(){return this._def.innerType}}V4.create=($,G)=>{return new V4({innerType:$,typeName:p.ZodReadonly,...c(G)})};function vX($,G){let X=typeof $==="function"?$(G):typeof $==="string"?{message:$}:$;return typeof X==="string"?{message:X}:X}function mX($,G={},X){if($)return M2.create().superRefine((Y,W)=>{let V=$(Y);if(V instanceof Promise)return V.then((q)=>{if(!q){let J=vX(G,Y),U=J.fatal??X??!0;W.addIssue({code:"custom",...J,fatal:U})}});if(!V){let q=vX(G,Y),J=q.fatal??X??!0;W.addIssue({code:"custom",...q,fatal:J})}return});return M2.create()}var KF={object:q1.lazycreate},p;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(p||(p={}));var FF=($,G={message:`Input not instance of ${$.name}`})=>mX((X)=>X instanceof $,G),uX=a1.create,pX=f0.create,AF=m4.create,wF=m0.create,lX=o2.create,BF=D2.create,OF=g4.create,PF=s2.create,NF=a2.create,ZF=M2.create,zF=y0.create,_F=H0.create,LF=h4.create,EF=t1.create,jF=q1.create,TF=q1.strictCreate,CF=t2.create,SF=i6.create,IF=e2.create,xF=U0.create,kF=y4.create,bF=f4.create,vF=Q2.create,gF=n2.create,hF=$4.create,yF=G4.create,fF=u0.create,mF=X4.create,uF=K2.create,pF=G0.create,lF=e1.create,rF=z0.create,dF=G0.createWithPreprocess,cF=u4.create,iF=()=>uX().optional(),nF=()=>pX().optional(),oF=()=>lX().optional(),sF={string:($)=>a1.create({...$,coerce:!0}),number:($)=>f0.create({...$,coerce:!0}),boolean:($)=>o2.create({...$,coerce:!0}),bigint:($)=>m0.create({...$,coerce:!0}),date:($)=>D2.create({...$,coerce:!0})};var aF=u;function R0($){return $ instanceof Error?$.message:String($)}function GA($){return $}function XA($){return $}function YA($){return $===void 0?{success:!0}:{success:!0,data:$}}function WA($){return{success:!1,error:$}}var VA=H.object({captureUrls:H.boolean().default(!1),blockedUrlDomains:H.array(H.string()).default(["meet.google.com","zoom.us","teams.microsoft.com","whereby.com","gather.town","calendly.com","cal.com","discord.com","discord.gg","cdn.discordapp.com","media.discordapp.net","giphy.com","tenor.com","wetransfer.com","file.io"])});function qA($,G){return{name:$,schema:G}}var p0=H.enum(["anchor","trusted","public"]),HA=H.enum(["create","update","delete","extract","publish"]),q4=H.enum(["never","anchor","trusted","public"]),rX=H.object({create:q4.optional(),update:q4.optional(),delete:q4.optional(),extract:q4.optional(),publish:q4.optional()}).strict(),UA=H.record(H.string(),rX);var RA=H.object({name:H.string(),description:H.string(),schema:H.any(),basePrompt:H.string().optional(),useKnowledgeContext:H.boolean().optional(),requiredPermission:p0,formatter:H.any().optional(),layout:H.object({component:H.any(),fullscreen:H.boolean().optional()}).optional(),dataSourceId:H.string().optional()});class p4{static canGenerate($){return!!$.basePrompt&&!!$.dataSourceId&&$.dataSourceId.includes("ai-content")}static canFetch($){return!!$.dataSourceId&&!this.canGenerate($)}static canRender($){return!!$.layout?.component}static isStaticOnly($){return!this.canGenerate($)&&!this.canFetch($)}static getCapabilities($){return{canGenerate:this.canGenerate($),canFetch:this.canFetch($),canRender:this.canRender($),isStaticOnly:this.isStaticOnly($)}}static validate($){let G=[];if($.dataSourceId?.includes("ai-content")&&!$.basePrompt)G.push(`Template "${$.name}" has AI-content dataSourceId but no basePrompt. AI generation requires a basePrompt.`);if($.basePrompt&&(!$.dataSourceId||!$.dataSourceId.includes("ai-content")))G.push(`Template "${$.name}" has basePrompt but no AI-content dataSourceId. The basePrompt won't be used.`);return G}static logCapabilities($,G){let X=this.getCapabilities($),Y=this.validate($);if(G)G.debug(`Template capabilities for "${$.name}":`,{...X,errors:Y.length>0?Y:void 0})}}var DA=H.enum(["site-content-preview","site-content-production"]),MA=H.enum(["web","image","pdf"]),QA=H.object({name:H.string(),schema:H.any(),description:H.string().optional(),pluginId:H.string(),renderers:H.object({web:H.union([H.function(),H.string()]).optional(),image:H.union([H.function(),H.string()]).optional(),pdf:H.union([H.function(),H.string()]).optional()})}),KA=H.object({enableContentGeneration:H.boolean().default(!1),outputDir:H.string(),workingDir:H.string().optional(),environment:H.enum(["preview","production"]).default("preview"),siteConfig:H.object({title:H.string(),description:H.string(),url:H.string().optional()}).optional()}),FA=H.object({success:H.boolean(),routesBuilt:H.number(),errors:H.array(H.string()).optional(),warnings:H.array(H.string()).optional()});var dX=H.enum(["anchor","trusted","public"]),wA=H.object({conversationId:H.string().min(1),message:H.string(),interfaceType:H.string().min(1),channelId:H.string().optional(),channelName:H.string().optional(),userPermissionLevel:dX}),cX=H.object({id:H.string().min(1),source:H.string().min(1),title:H.string().optional(),content:H.string().min(1),provenance:H.record(H.string(),H.unknown()).optional()}),BA=H.object({items:H.array(cX).default([])});var OA=H.object({url:H.string(),authToken:H.string().optional()});var PA=H.object({success:H.boolean(),entityId:H.string().optional(),error:H.string().optional()});var F2=H.enum(["user","assistant"]);var iX=H.object({message:H.string().describe("Natural language response to the query"),summary:H.string().optional().describe("Brief summary if applicable"),topics:H.array(H.string()).optional().describe("Related topics mentioned"),sources:H.array(H.object({id:H.string(),type:H.string(),excerpt:H.string().optional(),relevance:H.number().min(0).max(1).optional()})).optional().describe("Source entities used to answer the query"),metadata:H.record(H.string(),H.unknown()).optional()}).describe("defaultQueryResponse"),nX=H.object({message:H.string()}).describe("simpleTextResponse"),oX=H.object({success:H.boolean(),entityId:H.string().optional(),message:H.string()}).describe("createEntityResponse"),sX=H.object({success:H.boolean(),entityId:H.string(),changes:H.array(H.string()).optional(),message:H.string()}).describe("updateEntityResponse");var NA=H.object({status:H.enum(["healthy","warning","error","unknown"]),message:H.string().optional(),lastCheck:H.date().optional(),details:H.record(H.string(),H.unknown()).optional()}),aX=H.object({name:H.string(),pluginId:H.string(),status:H.string(),health:NA.optional()});import{McpServer as IS,ResourceTemplate as xS}from"@modelcontextprotocol/sdk/server/mcp.js";var o6=H.object({interfaceType:H.string(),userId:H.string(),conversationId:H.string().optional(),channelId:H.string().optional(),channelName:H.string().optional(),userPermissionLevel:H.enum(["anchor","trusted","public"]).optional()}),tX=H.object({success:H.literal(!0),data:H.unknown(),message:H.string().optional()}).strict().superRefine(($,G)=>{if(!Object.prototype.hasOwnProperty.call($,"data"))G.addIssue({code:H.ZodIssueCode.custom,path:["data"],message:"Required"})}),eX=H.object({success:H.literal(!1),error:H.string(),code:H.string().optional()}).strict(),$Y=H.object({needsConfirmation:H.literal(!0),toolName:H.string(),summary:H.string(),preview:H.string().optional(),args:H.unknown()}).strict(),o9=H.union([tX,eX,$Y]);var LS=H.union([H.object({success:H.literal(!0),data:H.unknown()}).superRefine(($,G)=>{if(!Object.prototype.hasOwnProperty.call($,"data"))G.addIssue({code:H.ZodIssueCode.custom,path:["data"],message:"Required"})}),H.object({success:H.literal(!1),error:H.string()})]);var ZA=H.union([H.object({success:H.literal(!0),data:H.unknown(),message:H.string().optional()}),H.object({success:H.literal(!1),error:H.string(),code:H.string().optional()})]);var KI=H.object({id:H.string(),type:H.string(),version:H.string(),status:H.string()}),FI=H.object({name:H.string(),description:H.string()}),s9=H.object({label:H.string(),url:H.string(),pluginId:H.string(),priority:H.number().default(100),visibility:p0.default("public")}),zA=H.enum(["human","agent","admin","protocol"]),_A=H.enum(["available","coming-soon","disabled"]),a9=H.object({id:H.string(),label:H.string(),description:H.string().optional(),href:H.string(),kind:zA,pluginId:H.string(),priority:H.number().default(100),visibility:p0.default("public"),status:_A.default("available")}),t9=H.object({entityType:H.string(),count:H.number()}),AI=H.object({model:H.string(),version:H.string(),uptime:H.number(),entities:H.number(),entityCounts:H.array(t9),embeddings:H.number(),ai:H.object({model:H.string(),embeddingModel:H.string()}),daemons:H.array(aX),endpoints:H.array(s9),interactions:H.array(a9)});var wI=H.object({id:H.string(),version:H.string(),type:H.enum(["core","entity","service","interface"]),description:H.string().optional(),dependencies:H.array(H.string()).optional(),packageName:H.string()});var LA=H.object({toolName:H.string(),args:H.unknown(),progressToken:H.union([H.string(),H.number()]).optional(),hasProgress:H.boolean().optional(),...o6.shape}),EA=H.object({resourceUri:H.string()});class A2{id;version;description;packageName;config;context;get logger(){return this.context?.logger??N1.createFresh({context:this.id})}constructor($,G,X,Y){this.id=$,this.packageName=G.name,this.version=G.version,this.description=G.description??`${G.name} plugin`,this.config=Y.parse(X)}setupMessageHandlers($){$.messaging.subscribe(`plugin:${this.id}:tool:execute`,async(G)=>{try{let{toolName:X,args:Y,progressToken:W,hasProgress:V,interfaceType:q,userId:J,channelId:U,userPermissionLevel:R}=LA.parse(G.payload),M=(await this.getTools()).find((Z)=>Z.name===X);if(!M)return{success:!1,error:`Tool not found: ${X}`};let A={interfaceType:q,userId:J,...U&&{channelId:U},...R&&{userPermissionLevel:R},...V&&W!==void 0&&{progressToken:W,sendProgress:async(Z)=>{await $.messaging.send({type:`plugin:${this.id}:progress`,payload:{progressToken:W,notification:Z}})}}};return{success:!0,data:await M.handler(Y,A)}}catch(X){if(X instanceof H.ZodError)return{success:!1,error:"Invalid tool execution request format"};return this.logger.error("Tool execution error",X),{success:!1,error:R0(X)}}}),$.messaging.subscribe(`plugin:${this.id}:resource:get`,async(G)=>{try{let{resourceUri:X}=EA.parse(G.payload),W=(await this.getResources()).find((q)=>q.uri===X);if(!W)return{success:!1,error:`Resource not found: ${X}`};return{success:!0,data:await W.handler()}}catch(X){if(X instanceof H.ZodError)return{success:!1,error:"Invalid resource get request format"};return this.logger.error("Resource fetch error",X),{success:!1,error:R0(X)}}})}async onRegister($){}async onReady($){}async ready(){await this.onReady(this.getContext())}async getCapabilities(){let $=await this.getInstructions();return{tools:await this.getTools(),resources:await this.getResources(),...$&&{instructions:$}}}async getTools(){return[]}async getResources(){return[]}async getInstructions(){return}async shutdown(){await this.onShutdown()}async onShutdown(){}getContext(){if(!this.context)throw Error(`Plugin ${this.id}: Plugin not registered yet`);return this.context}determineUserPermissionLevel($){return"public"}createProgressBridge($){if(!$)return;let G=this.context;if(!G)return;let X=this.id;return x0.from(async(Y)=>{await G.messaging.send({type:`plugin:${X}:progress`,payload:{progressToken:$,notification:{progress:Y.progress,total:Y.total,message:Y.message}}})})}}var GY=H.object({id:H.string(),template:H.string(),content:H.unknown().optional(),dataQuery:H.object({entityType:H.string().optional(),template:H.string().optional(),query:H.object({id:H.string().optional(),limit:H.number().optional(),offset:H.number().optional()}).passthrough().optional()}).passthrough().optional(),order:H.number().optional()}),XY=["primary","secondary"],YY=H.object({show:H.boolean().default(!1),label:H.string().optional(),slot:H.enum(XY).default("primary"),priority:H.number().min(0).max(100).default(50)}).optional(),WY=H.object({id:H.string(),path:H.string(),title:H.string().default(""),pageLabel:H.string().optional(),description:H.string().default(""),sections:H.array(GY).default([]),layout:H.string().default("default"),fullscreen:H.boolean().optional(),pluginId:H.string().optional(),sourceEntityType:H.string().optional(),external:H.boolean().optional(),navigation:YY}),jA=H.object({routes:H.array(WY),pluginId:H.string()}),TA=H.object({paths:H.array(H.string()).optional(),pluginId:H.string().optional()}),CA=H.object({pluginId:H.string().optional()}),SA=H.object({path:H.string()}),s6=H.object({label:H.string(),href:H.string(),priority:H.number()});var VY=H.object({heading:H.string().describe("Main CTA heading text"),buttonText:H.string().describe("Call-to-action button text"),buttonLink:H.string().describe("URL or anchor for the CTA button")}),qY=H.object({blurb:H.string().optional().describe("Short italic subtitle under the section title")}),JY=H.object({title:H.string().describe("The site's title"),description:H.string().describe("The site's description"),url:H.string().optional().describe("Canonical site URL"),copyright:H.string().optional().describe("Copyright notice text"),logo:H.boolean().optional().describe("Whether to display logo instead of title text in header"),themeMode:H.enum(["light","dark"]).optional().describe("Default theme mode"),analyticsScript:H.string().optional().describe("Analytics script HTML"),cta:VY.optional().describe("Call-to-action configuration"),sections:H.record(H.string(),qY).optional().describe("Optional per-section blurbs, keyed by section id (e.g. 'essays', 'presentations', 'about'). Used by homepage templates that render editorial section headers.")}),IA=H.object({platform:H.enum(["github","instagram","linkedin","email","website"]).describe("Social media platform"),url:H.string().describe("Profile or contact URL"),label:H.string().optional().describe("Optional display label")}),xA=JY.extend({navigation:H.object({primary:H.array(s6),secondary:H.array(s6)}),copyright:H.string(),socialLinks:H.array(IA).optional().describe("Social media links from profile metadata")});function e9($){return`preview.${$.trim().replace(/^https?:\/\//,"")}`}var kA=H.string(),bA=H.object({id:H.string().min(1)}).passthrough(),vA=H.object({label:H.string().min(1)}).passthrough(),gA=H.object({layouts:H.record(H.unknown()),plugin:H.function(),routes:H.array(bA),entityDisplay:H.record(vA),staticAssets:H.record(H.string()).optional()}).passthrough(),hA=H.custom(($)=>gA.safeParse($).success);var HY=H.enum(["file_operations","content_operations","data_processing","batch_processing"]),UY=H.object({pluginId:H.string().optional(),progressToken:H.union([H.string(),H.number()]).optional(),operationType:HY,operationTarget:H.string().optional(),interfaceType:H.string().optional(),channelId:H.string().optional()}),l4=UY.extend({rootJobId:H.string()}),dI=H.enum(["none","skip","replace","coalesce"]);var $8=H.enum(["pending","processing","completed","failed"]),RY=H.enum(["completed","failed"]);var yA=H.object({id:H.string(),type:H.string(),status:$8,data:H.unknown(),result:H.unknown().optional(),lastError:H.string().optional().nullable(),attempts:H.number(),maxRetries:H.number(),priority:H.number(),createdAt:H.date(),updatedAt:H.date(),processedAt:H.date().optional().nullable(),completedAt:H.date().optional().nullable(),failedAt:H.date().optional().nullable()}),fA=H.object({jobId:H.string(),type:H.string(),status:RY,result:H.unknown().optional(),error:H.string().optional()}),DY=H.object({success:H.literal(!1),error:H.string().optional()}),G8=H.object({id:H.string(),type:H.enum(["job","batch"]),status:$8,message:H.string().optional(),progress:H.object({current:H.number(),total:H.number(),percentage:H.number()}).optional(),aggregationKey:H.string().optional(),batchDetails:H.object({totalOperations:H.number(),completedOperations:H.number(),failedOperations:H.number(),currentOperation:H.string().optional(),errors:H.array(H.string()).optional()}).optional(),jobDetails:H.object({jobType:H.string(),priority:H.number(),retryCount:H.number()}).optional(),metadata:l4});import{createClient as gk}from"@libsql/client";var I=Symbol.for("drizzle:entityKind");function b1($,G){if(!$||typeof $!=="object")return!1;if($ instanceof G)return!0;if(!Object.prototype.hasOwnProperty.call(G,I))throw Error(`Class "${G.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let X=Object.getPrototypeOf($).constructor;if(X)while(X){if(I in X&&X[I]===G[I])return!0;X=Object.getPrototypeOf(X)}return!1}class l0{constructor($,G){this.table=$,this.config=G,this.name=G.name,this.keyAsName=G.keyAsName,this.notNull=G.notNull,this.default=G.default,this.defaultFn=G.defaultFn,this.onUpdateFn=G.onUpdateFn,this.hasDefault=G.hasDefault,this.primary=G.primaryKey,this.isUnique=G.isUnique,this.uniqueName=G.uniqueName,this.uniqueType=G.uniqueType,this.dataType=G.dataType,this.columnType=G.columnType,this.generated=G.generated,this.generatedIdentity=G.generatedIdentity}static[I]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue($){return $}mapToDriverValue($){return $}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class X8{static[I]="ColumnBuilder";config;constructor($,G,X){this.config={name:$,keyAsName:$==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:G,columnType:X,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default($){return this.config.default=$,this.config.hasDefault=!0,this}$defaultFn($){return this.config.defaultFn=$,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn($){return this.config.onUpdateFn=$,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName($){if(this.config.name!=="")return;this.config.name=$}}var X0=Symbol.for("drizzle:Name");function MY($,...G){return $(...G)}function QY($,G){return`${$[X0]}_${G.join("_")}_unique`}class r4 extends l0{constructor($,G){if(!G.uniqueName)G.uniqueName=QY($,[G.name]);super($,G);this.table=$}static[I]="PgColumn"}class mA extends r4{static[I]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op($){return this.indexConfig.opClass=$,this}}class uA extends r4{static[I]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor($,G){super($,G);this.enum=G.enum}getSQLType(){return this.enum.enumName}}var KY=Symbol.for("drizzle:isPgEnum");function FY($){return!!$&&typeof $==="function"&&KY in $&&$[KY]===!0}class pA extends r4{static[I]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor($,G){super($,G);this.enum=G.enum}getSQLType(){return this.enum.enumName}}class a6{static[I]="Subquery";constructor($,G,X,Y=!1,W=[]){this._={brand:"Subquery",sql:$,selectedFields:G,alias:X,isWith:Y,usedTables:W}}}var AY="0.44.7";var Y8,W8,wY={startActiveSpan($,G){if(!Y8)return G();if(!W8)W8=Y8.trace.getTracer("drizzle-orm",AY);return MY((X,Y)=>Y.startActiveSpan($,(W)=>{try{return G(W)}catch(V){throw W.setStatus({code:X.SpanStatusCode.ERROR,message:V instanceof Error?V.message:"Unknown error"}),V}finally{W.end()}}),Y8,W8)}};var J4=Symbol.for("drizzle:ViewBaseConfig");var V8=Symbol.for("drizzle:Schema"),BY=Symbol.for("drizzle:Columns"),OY=Symbol.for("drizzle:ExtraConfigColumns"),q8=Symbol.for("drizzle:OriginalName"),J8=Symbol.for("drizzle:BaseName"),d4=Symbol.for("drizzle:IsAlias"),PY=Symbol.for("drizzle:ExtraConfigBuilder"),lA=Symbol.for("drizzle:IsDrizzleTable");class M1{static[I]="Table";static Symbol={Name:X0,Schema:V8,OriginalName:q8,Columns:BY,ExtraConfigColumns:OY,BaseName:J8,IsAlias:d4,ExtraConfigBuilder:PY};[X0];[q8];[V8];[BY];[OY];[J8];[d4]=!1;[lA]=!0;[PY]=void 0;constructor($,G,X){this[X0]=this[q8]=$,this[V8]=G,this[J8]=X}}function rA($){return $!==null&&$!==void 0&&typeof $.getSQL==="function"}function dA($){let G={sql:"",params:[]};for(let X of $)if(G.sql+=X.sql,G.params.push(...X.params),X.typings?.length){if(!G.typings)G.typings=[];G.typings.push(...X.typings)}return G}class o1{static[I]="StringChunk";value;constructor($){this.value=Array.isArray($)?$:[$]}getSQL(){return new Q1([this])}}class Q1{constructor($){this.queryChunks=$;for(let G of $)if(b1(G,M1)){let X=G[M1.Symbol.Schema];this.usedTables.push(X===void 0?G[M1.Symbol.Name]:X+"."+G[M1.Symbol.Name])}}static[I]="SQL";decoder=NY;shouldInlineParams=!1;usedTables=[];append($){return this.queryChunks.push(...$.queryChunks),this}toQuery($){return wY.startActiveSpan("drizzle.buildSQL",(G)=>{let X=this.buildQueryFromSourceParams(this.queryChunks,$);return G?.setAttributes({"drizzle.query.text":X.sql,"drizzle.query.params":JSON.stringify(X.params)}),X})}buildQueryFromSourceParams($,G){let X=Object.assign({},G,{inlineParams:G.inlineParams||this.shouldInlineParams,paramStartIndex:G.paramStartIndex||{value:0}}),{casing:Y,escapeName:W,escapeParam:V,prepareTyping:q,inlineParams:J,paramStartIndex:U}=X;return dA($.map((R)=>{if(b1(R,o1))return{sql:R.value.join(""),params:[]};if(b1(R,t6))return{sql:W(R.value),params:[]};if(R===void 0)return{sql:"",params:[]};if(Array.isArray(R)){let D=[new o1("(")];for(let[M,A]of R.entries())if(D.push(A),M<R.length-1)D.push(new o1(", "));return D.push(new o1(")")),this.buildQueryFromSourceParams(D,X)}if(b1(R,Q1))return this.buildQueryFromSourceParams(R.queryChunks,{...X,inlineParams:J||R.shouldInlineParams});if(b1(R,M1)){let D=R[M1.Symbol.Schema],M=R[M1.Symbol.Name];return{sql:D===void 0||R[d4]?W(M):W(D)+"."+W(M),params:[]}}if(b1(R,l0)){let D=Y.getColumnCasing(R);if(G.invokeSource==="indexes")return{sql:W(D),params:[]};let M=R.table[M1.Symbol.Schema];return{sql:R.table[d4]||M===void 0?W(R.table[M1.Symbol.Name])+"."+W(D):W(M)+"."+W(R.table[M1.Symbol.Name])+"."+W(D),params:[]}}if(b1(R,zY)){let D=R[J4].schema,M=R[J4].name;return{sql:D===void 0||R[J4].isAlias?W(M):W(D)+"."+W(M),params:[]}}if(b1(R,H8)){if(b1(R.value,e6))return{sql:V(U.value++,R),params:[R],typings:["none"]};let D=R.value===null?null:R.encoder.mapToDriverValue(R.value);if(b1(D,Q1))return this.buildQueryFromSourceParams([D],X);if(J)return{sql:this.mapInlineParam(D,X),params:[]};let M=["none"];if(q)M=[q(R.encoder)];return{sql:V(U.value++,D),params:[D],typings:M}}if(b1(R,e6))return{sql:V(U.value++,R),params:[R],typings:["none"]};if(b1(R,Q1.Aliased)&&R.fieldAlias!==void 0)return{sql:W(R.fieldAlias),params:[]};if(b1(R,a6)){if(R._.isWith)return{sql:W(R._.alias),params:[]};return this.buildQueryFromSourceParams([new o1("("),R._.sql,new o1(") "),new t6(R._.alias)],X)}if(FY(R)){if(R.schema)return{sql:W(R.schema)+"."+W(R.enumName),params:[]};return{sql:W(R.enumName),params:[]}}if(rA(R)){if(R.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([R.getSQL()],X);return this.buildQueryFromSourceParams([new o1("("),R.getSQL(),new o1(")")],X)}if(J)return{sql:this.mapInlineParam(R,X),params:[]};return{sql:V(U.value++,R),params:[R],typings:["none"]}}))}mapInlineParam($,{escapeString:G}){if($===null)return"null";if(typeof $==="number"||typeof $==="boolean")return $.toString();if(typeof $==="string")return G($);if(typeof $==="object"){let X=$.toString();if(X==="[object Object]")return G(JSON.stringify($));return G(X)}throw Error("Unexpected param value: "+$)}getSQL(){return this}as($){if($===void 0)return this;return new Q1.Aliased(this,$)}mapWith($){return this.decoder=typeof $==="function"?{mapFromDriverValue:$}:$,this}inlineParams(){return this.shouldInlineParams=!0,this}if($){return $?this:void 0}}class t6{constructor($){this.value=$}static[I]="Name";brand;getSQL(){return new Q1([this])}}var NY={mapFromDriverValue:($)=>$},ZY={mapToDriverValue:($)=>$},Sx={...NY,...ZY};class H8{constructor($,G=ZY){this.value=$,this.encoder=G}static[I]="Param";brand;getSQL(){return new Q1([this])}}function w2($,...G){let X=[];if(G.length>0||$.length>0&&$[0]!=="")X.push(new o1($[0]));for(let[Y,W]of G.entries())X.push(W,new o1($[Y+1]));return new Q1(X)}(($)=>{function G(){return new Q1([])}$.empty=G;function X(U){return new Q1(U)}$.fromList=X;function Y(U){return new Q1([new o1(U)])}$.raw=Y;function W(U,R){let D=[];for(let[M,A]of U.entries()){if(M>0&&R!==void 0)D.push(R);D.push(A)}return new Q1(D)}$.join=W;function V(U){return new t6(U)}$.identifier=V;function q(U){return new e6(U)}$.placeholder=q;function J(U,R){return new H8(U,R)}$.param=J})(w2||(w2={}));(($)=>{class G{constructor(X,Y){this.sql=X,this.fieldAlias=Y}static[I]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new G(this.sql,this.fieldAlias)}}$.Aliased=G})(Q1||(Q1={}));class e6{constructor($){this.name=$}static[I]="Placeholder";getSQL(){return new Q1([this])}}var cA=Symbol.for("drizzle:IsDrizzleView");class zY{static[I]="View";[J4];[cA]=!0;constructor({name:$,schema:G,selectedFields:X,query:Y}){this[J4]={name:$,originalName:$,schema:G,selectedFields:X,query:Y,isExisting:!Y,isAlias:!1}}getSQL(){return new Q1([this])}}l0.prototype.getSQL=function(){return new Q1([this])};M1.prototype.getSQL=function(){return new Q1([this])};a6.prototype.getSQL=function(){return new Q1([this])};function D0($,G){return{name:typeof $==="string"&&$.length>0?$:"",config:typeof $==="object"?$:G}}var U8=typeof TextDecoder>"u"?null:new TextDecoder;class R8{static[I]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor($,G){if(this.reference=()=>{let{name:X,columns:Y,foreignColumns:W}=$();return{name:X,columns:Y,foreignTable:W[0].table,foreignColumns:W}},G)this._onUpdate=G.onUpdate,this._onDelete=G.onDelete}onUpdate($){return this._onUpdate=$,this}onDelete($){return this._onDelete=$,this}build($){return new _Y($,this)}}class _Y{constructor($,G){this.table=$,this.reference=G.reference,this.onUpdate=G._onUpdate,this.onDelete=G._onDelete}static[I]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:$,columns:G,foreignColumns:X}=this.reference(),Y=G.map((q)=>q.name),W=X.map((q)=>q.name),V=[this.table[X0],...Y,X[0].table[X0],...W];return $??`${V.join("_")}_fk`}}function LY($,G){return`${$[X0]}_${G.join("_")}_unique`}class O1 extends X8{static[I]="SQLiteColumnBuilder";foreignKeyConfigs=[];references($,G={}){return this.foreignKeyConfigs.push({ref:$,actions:G}),this}unique($){return this.config.isUnique=!0,this.config.uniqueName=$,this}generatedAlwaysAs($,G){return this.config.generated={as:$,type:"always",mode:G?.mode??"virtual"},this}buildForeignKeys($,G){return this.foreignKeyConfigs.map(({ref:X,actions:Y})=>{return((W,V)=>{let q=new R8(()=>{let J=W();return{columns:[$],foreignColumns:[J]}});if(V.onUpdate)q.onUpdate(V.onUpdate);if(V.onDelete)q.onDelete(V.onDelete);return q.build(G)})(X,Y)})}}class P1 extends l0{constructor($,G){if(!G.uniqueName)G.uniqueName=LY($,[G.name]);super($,G);this.table=$}static[I]="SQLiteColumn"}class EY extends O1{static[I]="SQLiteBigIntBuilder";constructor($){super($,"bigint","SQLiteBigInt")}build($){return new jY($,this.config)}}class jY extends P1{static[I]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue($){if(typeof Buffer<"u"&&Buffer.from){let G=Buffer.isBuffer($)?$:$ instanceof ArrayBuffer?Buffer.from($):$.buffer?Buffer.from($.buffer,$.byteOffset,$.byteLength):Buffer.from($);return BigInt(G.toString("utf8"))}return BigInt(U8.decode($))}mapToDriverValue($){return Buffer.from($.toString())}}class TY extends O1{static[I]="SQLiteBlobJsonBuilder";constructor($){super($,"json","SQLiteBlobJson")}build($){return new CY($,this.config)}}class CY extends P1{static[I]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue($){if(typeof Buffer<"u"&&Buffer.from){let G=Buffer.isBuffer($)?$:$ instanceof ArrayBuffer?Buffer.from($):$.buffer?Buffer.from($.buffer,$.byteOffset,$.byteLength):Buffer.from($);return JSON.parse(G.toString("utf8"))}return JSON.parse(U8.decode($))}mapToDriverValue($){return Buffer.from(JSON.stringify($))}}class SY extends O1{static[I]="SQLiteBlobBufferBuilder";constructor($){super($,"buffer","SQLiteBlobBuffer")}build($){return new IY($,this.config)}}class IY extends P1{static[I]="SQLiteBlobBuffer";mapFromDriverValue($){if(Buffer.isBuffer($))return $;return Buffer.from($)}getSQLType(){return"blob"}}function xY($,G){let{name:X,config:Y}=D0($,G);if(Y?.mode==="json")return new TY(X);if(Y?.mode==="bigint")return new EY(X);return new SY(X)}class kY extends O1{static[I]="SQLiteCustomColumnBuilder";constructor($,G,X){super($,"custom","SQLiteCustomColumn");this.config.fieldConfig=G,this.config.customTypeParams=X}build($){return new bY($,this.config)}}class bY extends P1{static[I]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor($,G){super($,G);this.sqlName=G.customTypeParams.dataType(G.fieldConfig),this.mapTo=G.customTypeParams.toDriver,this.mapFrom=G.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue($){return typeof this.mapFrom==="function"?this.mapFrom($):$}mapToDriverValue($){return typeof this.mapTo==="function"?this.mapTo($):$}}function $5($){return(G,X)=>{let{name:Y,config:W}=D0(G,X);return new kY(Y,W,$)}}class G5 extends O1{static[I]="SQLiteBaseIntegerBuilder";constructor($,G,X){super($,G,X);this.config.autoIncrement=!1}primaryKey($){if($?.autoIncrement)this.config.autoIncrement=!0;return this.config.hasDefault=!0,super.primaryKey()}}class X5 extends P1{static[I]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}}class vY extends G5{static[I]="SQLiteIntegerBuilder";constructor($){super($,"number","SQLiteInteger")}build($){return new gY($,this.config)}}class gY extends X5{static[I]="SQLiteInteger"}class hY extends G5{static[I]="SQLiteTimestampBuilder";constructor($,G){super($,"date","SQLiteTimestamp");this.config.mode=G}defaultNow(){return this.default(w2`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build($){return new yY($,this.config)}}class yY extends X5{static[I]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue($){if(this.config.mode==="timestamp")return new Date($*1000);return new Date($)}mapToDriverValue($){let G=$.getTime();if(this.config.mode==="timestamp")return Math.floor(G/1000);return G}}class fY extends G5{static[I]="SQLiteBooleanBuilder";constructor($,G){super($,"boolean","SQLiteBoolean");this.config.mode=G}build($){return new mY($,this.config)}}class mY extends X5{static[I]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue($){return Number($)===1}mapToDriverValue($){return $?1:0}}function v1($,G){let{name:X,config:Y}=D0($,G);if(Y?.mode==="timestamp"||Y?.mode==="timestamp_ms")return new hY(X,Y.mode);if(Y?.mode==="boolean")return new fY(X,Y.mode);return new vY(X)}class uY extends O1{static[I]="SQLiteNumericBuilder";constructor($){super($,"string","SQLiteNumeric")}build($){return new pY($,this.config)}}class pY extends P1{static[I]="SQLiteNumeric";mapFromDriverValue($){if(typeof $==="string")return $;return String($)}getSQLType(){return"numeric"}}class lY extends O1{static[I]="SQLiteNumericNumberBuilder";constructor($){super($,"number","SQLiteNumericNumber")}build($){return new rY($,this.config)}}class rY extends P1{static[I]="SQLiteNumericNumber";mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}mapToDriverValue=String;getSQLType(){return"numeric"}}class dY extends O1{static[I]="SQLiteNumericBigIntBuilder";constructor($){super($,"bigint","SQLiteNumericBigInt")}build($){return new cY($,this.config)}}class cY extends P1{static[I]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}function iY($,G){let{name:X,config:Y}=D0($,G),W=Y?.mode;return W==="number"?new lY(X):W==="bigint"?new dY(X):new uY(X)}class nY extends O1{static[I]="SQLiteRealBuilder";constructor($){super($,"number","SQLiteReal")}build($){return new oY($,this.config)}}class oY extends P1{static[I]="SQLiteReal";getSQLType(){return"real"}}function sY($){return new nY($??"")}class aY extends O1{static[I]="SQLiteTextBuilder";constructor($,G){super($,"string","SQLiteText");this.config.enumValues=G.enum,this.config.length=G.length}build($){return new tY($,this.config)}}class tY extends P1{static[I]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor($,G){super($,G)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}}class eY extends O1{static[I]="SQLiteTextJsonBuilder";constructor($){super($,"json","SQLiteTextJson")}build($){return new $W($,this.config)}}class $W extends P1{static[I]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue($){return JSON.parse($)}mapToDriverValue($){return JSON.stringify($)}}function i($,G={}){let{name:X,config:Y}=D0($,G);if(Y.mode==="json")return new eY(X);return new aY(X,Y)}function GW(){return{blob:xY,customType:$5,integer:v1,numeric:iY,real:sY,text:i}}var D8=Symbol.for("drizzle:SQLiteInlineForeignKeys");class c4 extends M1{static[I]="SQLiteTable";static Symbol=Object.assign({},M1.Symbol,{InlineForeignKeys:D8});[M1.Symbol.Columns];[D8]=[];[M1.Symbol.ExtraConfigBuilder]=void 0}function iA($,G,X,Y,W=$){let V=new c4($,Y,W),q=typeof G==="function"?G(GW()):G,J=Object.fromEntries(Object.entries(q).map(([R,D])=>{let M=D;M.setName(R);let A=M.build(V);return V[D8].push(...M.buildForeignKeys(A,V)),[R,A]})),U=Object.assign(V,J);if(U[M1.Symbol.Columns]=J,U[M1.Symbol.ExtraConfigColumns]=J,X)U[c4.Symbol.ExtraConfigBuilder]=X;return U}var M0=($,G,X)=>{return iA($,G,X)};class XW{constructor($,G){this.name=$,this.value=G}static[I]="SQLiteCheckBuilder";brand;build($){return new YW($,this)}}class YW{constructor($,G){this.table=$,this.name=G.name,this.value=G.value}static[I]="SQLiteCheck";name;value}function WW($,G){return new XW($,G)}class VW{constructor($,G){this.name=$,this.unique=G}static[I]="SQLiteIndexBuilderOn";on(...$){return new qW(this.name,$,this.unique)}}class qW{static[I]="SQLiteIndexBuilder";config;constructor($,G,X){this.config={name:$,columns:G,unique:X,where:void 0}}where($){return this.config.where=$,this}build($){return new JW(this.config,$)}}class JW{static[I]="SQLiteIndex";config;constructor($,G){this.config={...$,table:G}}}function Y0($){return new VW($,!1)}function Y5(...$){if($[0].columns)return new M8($[0].columns,$[0].name);return new M8($)}class M8{static[I]="SQLitePrimaryKeyBuilder";columns;name;constructor($,G){this.columns=$,this.name=G}build($){return new HW($,this.columns,this.name)}}class HW{constructor($,G,X){this.table=$,this.columns=G,this.name=X}static[I]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[c4.Symbol.Name]}_${this.columns.map(($)=>$.name).join("_")}_pk`}}var UW=M0("job_queue",{id:i("id").primaryKey().$defaultFn(()=>g0()),type:i("type").notNull(),data:i("data").notNull(),result:i("result",{mode:"json"}),source:i("source"),metadata:i("metadata",{mode:"json"}).$type().notNull(),status:i("status",{enum:["pending","processing","completed","failed"]}).notNull().default("pending"),priority:v1("priority").notNull().default(0),retryCount:v1("retryCount").notNull().default(0),maxRetries:v1("maxRetries").notNull().default(3),lastError:i("lastError"),createdAt:v1("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:v1("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:v1("startedAt"),completedAt:v1("completedAt")},($)=>({queueReadyIdx:Y0("idx_job_queue_ready").on($.status,$.priority,$.scheduledFor),jobTypeIdx:Y0("idx_job_queue_type").on($.type,$.status),jobSourceIdx:Y0("idx_job_queue_source").on($.source)}));var nA=H.object({id:H.string(),type:H.string(),data:H.string(),status:H.enum(["pending","processing","completed","failed"]),source:H.string().nullable(),priority:H.number(),retryCount:H.number(),maxRetries:H.number(),lastError:H.string().nullable(),createdAt:H.number(),scheduledFor:H.number(),startedAt:H.number().nullable(),completedAt:H.number().nullable(),metadata:l4,result:H.unknown().nullable().optional()});function Q8($,G,X){return async(Y)=>{let{type:W,data:V,toolContext:q=null,options:J}=Y,{metadata:U,...R}=J??{},D={source:G,...J?.rootJobId&&{rootJobId:J.rootJobId},...R,metadata:{operationType:"data_processing",pluginId:G,...q&&{interfaceType:q.interfaceType,channelId:q.channelId},...U}},M=X&&!W.includes(":")?`${G}:${W}`:W;return $.enqueue({type:M,data:V,options:D})}}function K8($,G){return async(X,Y)=>{let W=g0(),V=X.map((J)=>({...J,type:J.type.includes(":")?J.type:`${G}:${J.type}`})),q={...Y,source:G,rootJobId:W,metadata:{...Y?.metadata,operationType:"batch_processing",pluginId:G}};return await $.enqueueBatch(V,q,W,G),W}}function F8($,G){return(X,Y)=>{let W=X.includes(":")?X:`${G}:${X}`;$.registerHandler(W,Y,G)}}var oA=H.object({name:H.string(),schema:H.custom(($)=>$ instanceof H.ZodType)});function RW($){return oA.safeParse($).success}function sA($){if(!$)return;return{status:$.status,message:$.message,lastCheck:$.lastCheck?.toISOString(),details:$.details}}function DW($){return{model:$.model,version:$.version,uptime:$.uptime,entities:$.entities,entityCounts:$.entityCounts,embeddings:$.embeddings,ai:$.ai,daemons:$.daemons.map((G)=>({name:G.name,pluginId:G.pluginId,status:G.status,health:sA(G.health)})),endpoints:$.endpoints,interactions:$.interactions}}var H4=H.record(H.unknown());var aA=H.object({id:H.string(),sessionId:H.string(),interfaceType:H.string(),channelId:H.string(),channelName:H.string().optional(),startedAt:H.string(),lastActiveAt:H.string(),createdAt:H.string(),updatedAt:H.string(),metadata:H4}),tA=H.object({id:H.string(),conversationId:H.string(),role:F2,content:H.string(),timestamp:H.string(),metadata:H4});function MW($){if(!$)return{};try{let G=JSON.parse($);if(G&&typeof G==="object"&&!Array.isArray(G))return G}catch{}return{}}function eA($){let G=F2.safeParse($);return G.success?G.data:"user"}function W5($){let G=MW($.metadata),X=typeof G.channelName==="string"?G.channelName:void 0;return{id:$.id,sessionId:$.sessionId,interfaceType:$.interfaceType,channelId:$.channelId,channelName:X,startedAt:$.started,lastActiveAt:$.lastActive,createdAt:$.created,updatedAt:$.updated,metadata:G}}function QW($){return{id:$.id,conversationId:$.conversationId,role:eA($.role),content:$.content,timestamp:$.timestamp,metadata:MW($.metadata)}}var A8=H.object({name:H.string(),role:H.string(),purpose:H.string(),values:H.array(H.string())}),w8=H.object({name:H.string(),kind:H.enum(["professional","team","collective"]),organization:H.string().optional(),description:H.string().optional(),avatar:H.string().optional(),website:H.string().optional(),email:H.string().optional(),socialLinks:H.array(H.object({platform:H.enum(["github","instagram","linkedin","email","website"]),url:H.string(),label:H.string().optional()})).optional()});function KW($){return A8.parse($)}function FW($){return w8.parse($)}function AW($){return async()=>{return DW(await $.getAppInfo())}}function wW($,G){return{get:()=>KW($.getIdentity()),getProfile:()=>FW($.getProfile()),getAppInfo:G}}function BW($,G,X){let Y=$.getMessageBus();return{send:async(V)=>{return Y.send({...V,sender:G})},subscribe:(V,q)=>{if(RW(V)){let J=V,U=q,R=async(D)=>{let M=J.schema.safeParse(D.payload);if(!M.success)return X.warn(`Invalid payload for channel ${J.name}`,{error:M.error.message}),{noop:!0};let{payload:A,...F}=D;return U(M.data,F)};return Y.subscribe(J.name,R)}return Y.subscribe(V,q)}}}function OW($,G){let X=$.getJobQueueService();return{...$.jobs,enqueue:Q8(X,G,!0),enqueueBatch:K8($.jobs,G),registerHandler:F8(X,G)}}function PW($){let G=$.getPermissionService();return{assertEntityActionAllowed:(X,Y,W)=>{G.assertEntityActionAllowed(X,Y,W.userPermissionLevel)}}}function NW($){return{get:async(G)=>{let Y=await $.getConversationService().getConversation(G);return Y?W5(Y):null},search:async(G)=>{return(await $.getConversationService().searchConversations(G)).map(W5)},list:async(G)=>{return(await $.getConversationService().listConversations(G)).map(W5)},getMessages:async(G,X)=>{return(await $.getConversationService().getMessages(G,X)).map(QW)},countMessages:async(G)=>{return $.getConversationService().countMessages(G)}}}function ZW($,G){return{registerHandler:(X,Y)=>{$.registerEvalHandler(G,X,Y)}}}function zW($){return{register:(G,X)=>{$.getInsightsRegistry().register(G,X)}}}function _W($,G){return{register:(X)=>{$.registerEndpoint({...X,pluginId:G})}}}function LW($,G){return{register:(X)=>{$.registerInteraction({...X,pluginId:G})}}}function U4($,G,X){let Y=$.getEntityService(),W=$.getLogger().child(G),V=$.getDomain(),q=$.getLocalSiteUrl(),J=$.shouldPreferLocalUrls(),U=$.getThemeCSS(),R=AW($),D=$.getAttachmentRegistry(),M=$.getRuntimeUploadRegistry(),A=$.getRuntimeState();return{pluginId:G,logger:W,entityService:Y,identity:wW($,R),appInfo:R,domain:V,siteUrl:V?`https://${V}`:void 0,localSiteUrl:q,previewUrl:V?`https://${e9(V)}`:void 0,preferLocalUrls:J,themeCSS:U,entityDisplay:X?.entityDisplay,spaces:$.getSpaces(),permissions:PW($),messaging:BW($,G,W),jobs:OW($,G),attachments:D,uploads:M,runtimeState:A,conversations:NW($),dataDir:$.getDataDir(),eval:ZW($,G),insights:zW($),endpoints:_W($,G),interactions:LW($,G)}}import{createClient as Jv}from"@libsql/client";var V5=M0("entities",{id:i("id").notNull(),entityType:i("entityType").notNull(),content:i("content").notNull(),contentHash:i("contentHash").notNull(),visibility:i("visibility",{enum:["public","shared","restricted"]}).notNull().default("public"),metadata:i("metadata",{mode:"json"}).$type().notNull().default(w2`'{}'`),created:v1("created").notNull().$defaultFn(()=>Date.now()),updated:v1("updated").notNull().$defaultFn(()=>Date.now())},($)=>{return{pk:Y5({columns:[$.id,$.entityType]}),visibilityCheck:WW("entities_visibility_check",w2`${$.visibility} IN ('public', 'shared', 'restricted')`)}});import{createClient as Av}from"@libsql/client";var EW=$5({dataType(){return"F32_BLOB(1536)"},toDriver($){return Buffer.from($.buffer)},fromDriver($){return new Float32Array($.buffer,$.byteOffset,$.byteLength/4)}});var q5=M0("embeddings",{entityId:i("entity_id").notNull(),entityType:i("entity_type").notNull(),embedding:EW("embedding").notNull(),contentHash:i("content_hash").notNull()},($)=>{return{pk:Y5({columns:[$.entityId,$.entityType]})}});var $w=H.enum(["public","shared","restricted"]),B2=H.union([$w,H.literal("private")]).optional().transform(($)=>{if($===void 0)return"public";if($==="private")return"restricted";return $});var O8=H.object({id:H.string(),entityType:H.string(),content:H.string(),created:H.string().datetime(),updated:H.string().datetime(),visibility:B2,metadata:H.record(H.string(),H.unknown()),contentHash:H.string()}),Ww=H.object({mediaType:H.string(),url:H.string(),downloadUrl:H.string().optional(),previewUrl:H.string().optional(),filename:H.string().optional(),sizeBytes:H.number().optional(),source:H.object({entityType:H.string().optional(),entityId:H.string().optional(),attachmentType:H.string().optional()}).optional()});var Sv=H.object({id:H.string().min(1,"Entity ID is required"),entityType:H.string().min(1,"Entity type is required"),contentHash:H.string().min(1,"Content hash is required"),operation:H.enum(["create","update"])});var vv=H.object({limit:H.number().int().positive().optional().default(20),offset:H.number().int().min(0).optional().default(0),types:H.array(H.string()).optional().default([]),excludeTypes:H.array(H.string()).optional().default([]),weight:H.record(H.string(),H.number()).optional(),visibilityScope:H.enum(["public","shared","restricted"]).optional(),includeUngenerated:H.boolean().optional().default(!1)});var N8=t4(y5(),1);function J5($,G){if(Object.keys(G).length===0)return $;let X=Object.fromEntries(Object.entries(G).filter(([,Y])=>Y!==void 0));return N8.default.stringify($,X)}function P8($){if($ instanceof Date)return $.toISOString();if(Array.isArray($))return $.map(P8);if($!==null&&typeof $==="object"){let G={};for(let[X,Y]of Object.entries($))G[X]=P8(Y);return G}return $}function n4($,G){let{content:X,data:Y}=N8.default($),W=P8(Y);return{content:X.trim(),metadata:G.parse(W)}}var fv=H.object({visibility:B2});var Hw=H.object({field:H.string(),direction:H.enum(["asc","desc"]),nullsFirst:H.boolean().optional()}),tv=H.object({limit:H.number().int().positive().optional(),offset:H.number().int().min(0).optional().default(0),sortFields:H.array(Hw).optional(),filter:H.object({metadata:H.record(H.string(),H.unknown()).optional(),visibilityScope:H.enum(["public","shared","restricted"]).optional()}).optional(),publishedOnly:H.boolean().optional()});var Ow=H.object({currentPage:H.number(),totalPages:H.number(),totalItems:H.number(),pageSize:H.number(),hasNextPage:H.boolean(),hasPrevPage:H.boolean()});function Pw($){return $.replace(/:/g,"-")}function Nw($){return $.split(/[:.-]/).map((G)=>G.charAt(0).toUpperCase()+G.slice(1)).join(" ")}var Z8=new Map;async function CW($,G,X){let Y=Z8.get(G);if(Y!==void 0)return Y;let W=Pw(G),V;try{V=await $.getEntity({entityType:"prompt",id:W})}catch{return X}if(V?.content){let q=n4(V.content,H.record(H.unknown())).content;return Z8.set(G,q),q}try{let q=Nw(G),J=J5(X,{title:q,target:G});await $.createEntity({entity:{id:W,entityType:"prompt",content:J,metadata:{title:q,target:G,slug:W}}})}catch{}return Z8.set(G,X),X}function H5($){let G=$.getEntityService(),X=$.getEntityRegistry(),Y=$.getDataSourceRegistry();return{register:(W,V,q,J)=>{X.registerEntityType(W,V,q,J)},getAdapter:(W)=>{try{return X.getAdapter(W)}catch{return}},extendFrontmatterSchema:(W,V)=>{X.extendFrontmatterSchema(W,V)},getEffectiveFrontmatterSchema:(W)=>{return X.getEffectiveFrontmatterSchema(W)},registerCreateInterceptor:(W,V)=>{X.registerCreateInterceptor(W,V)},registerUploadSaveHandler:(W)=>{X.registerUploadSaveHandler(W)},update:async(W)=>{return G.updateEntity({entity:W})},registerDataSource:(W)=>{Y.register(W)}}}function U5($){return{resolve:(G,X)=>{return CW($,G,X)}}}function SW($,G,X){let Y=U4($,G,X),W=$.getEntityService();return{...Y,entityService:W,entities:H5($),ai:{query:(V,q)=>$.query(V,q),generate:async(V)=>{return $.generateContent(V)},generateObject:async(V,q)=>{return $.generateObject(V,q)},generateImage:async(V,q)=>{return $.generateImage(V,q)},canGenerateImages:()=>{return $.canGenerateImages()}},prompts:U5(W),permissions:Y.permissions}}function xW($,G,X){let Y=!1,W=!1;if($.jobs.registerHandler(X.job.type,X.job.handler),X.initialSync){let V=X.initialSync;$.messaging.subscribe("sync:initial:completed",async()=>{if(Y)return{success:!0};if(Y=!0,!(await V.shouldEnqueue?.()??!0))return G.info("Skipping derived entity projection initial sync",{projectionId:X.id,targetType:X.targetType}),{success:!0};return W=await IW($,G,X,V.jobData,zw(V.jobOptions),"initial-sync"),{success:!0}})}if(X.sourceChange){let V=X.sourceChange,q=new Set(V.sourceTypes),J=V.events??["entity:created","entity:updated"],U=async(R)=>{if(V.requireInitialSync&&!Y)return{success:!0};let D=R.payload,M=Zw(V,D);if(!M||!q.has("*")&&!q.has(M))return{success:!0};if(!(await V.shouldEnqueue?.(D)??!0))return{success:!0};let F=await V.jobData(D);if(!F)return{success:!0};return await IW($,G,X,F,V.jobOptions?.(D),"source-change"),{success:!0}};for(let R of J)$.messaging.subscribe(R,U)}return{hasObservedInitialSync:()=>Y,hasQueuedInitialSync:()=>W}}function Zw($,G){if($.sourceType)return $.sourceType;if($.sourceKind&&$.sourceKind!=="entity")return $.sourceKind;return G.entityType}async function IW($,G,X,Y,W,V){try{return await $.jobs.enqueue({type:X.job.type,data:Y,...W?{options:W}:{}}),G.info("Queued derived entity projection",{projectionId:X.id,targetType:X.targetType,reason:V}),!0}catch(q){return G.error("Failed to queue derived entity projection",{projectionId:X.id,targetType:X.targetType,reason:V,error:R0(q)}),!1}}function zw($){return typeof $==="function"?$():$}var _w=H.object({});class R5 extends A2{type="entity";entityActionPolicy;derivedEntityProjectionControllers=new Map;constructor($,G,X={},Y=_w,W){super($,G,X,Y);if(W!==void 0)this.entityActionPolicy=W}async register($,G){let X=SW($,this.id,G);if(this.context=X,this.setupMessageHandlers(X),X.entities.register(this.entityType,this.schema,this.adapter,this.getEntityTypeConfig()),this.interceptCreate!==R5.prototype.interceptCreate)X.entities.registerCreateInterceptor(this.entityType,(U,R)=>this.interceptCreate(U,R,X));let Y=this.createGenerationHandler(X);if(Y)X.jobs.registerHandler(`${this.entityType}:generation`,Y);let W=this.getTemplates();if(W&&Object.keys(W).length>0)$.registerTemplates(W,this.id);let V=this.getDataSources();for(let U of V)X.entities.registerDataSource(U);let q=this.getDerivedEntityProjections(X);for(let U of q){let R=xW(X,this.logger,U);this.derivedEntityProjectionControllers.set(U.id,R)}await this.onRegister(this.context);let J=await this.getInstructions();return{tools:[],resources:[],...J&&{instructions:J}}}async interceptCreate($,G,X){return{kind:"continue",input:$}}createGenerationHandler($){return null}getTemplates(){return null}getDataSources(){return[]}getEntityTypeConfig(){return}getDerivedEntityProjections($){return[]}getDerivedEntityProjectionController($){return this.derivedEntityProjectionControllers.get($)}}class kW extends R5{hooks;constructor($,G,X,Y,W){super($,G,X,Y);this.hooks=W}get entityType(){return this.hooks.getEntityType()}get schema(){return this.hooks.getSchema()}get adapter(){return this.hooks.getAdapter()}onRegister($){return this.hooks.onRegister($)}onReady($){return this.hooks.onReady($)}onShutdown(){return this.hooks.onShutdown()}getEntityTypeConfig(){return this.hooks.getEntityTypeConfig()}getDataSources(){return this.hooks.getDataSources()}getInstructions(){return this.hooks.getInstructions()}interceptCreate($,G,X){return this.hooks.interceptCreate($,G,X)}}class z8{type="entity";id;version;packageName;description;delegate;constructor($,G,X,Y){if(this.id=$,this.version=G.version,this.packageName=G.name,G.description!==void 0)this.description=G.description;this.delegate=new kW($,G,X,Y,{getEntityType:()=>this.entityType,getSchema:()=>this.schema,getAdapter:()=>this.adapter,onRegister:(W)=>this.onRegister(W),onReady:(W)=>this.onReady(W),onShutdown:()=>this.onShutdown(),getEntityTypeConfig:()=>this.getEntityTypeConfig(),getDataSources:()=>this.getDataSources(),getInstructions:()=>this.getInstructions(),interceptCreate:(W,V,q)=>this.interceptCreate(W,V,q)})}register($,G){return this.delegate.register($,G)}async onRegister($){}async onReady($){}async onShutdown(){}async getInstructions(){return}getEntityTypeConfig(){return}getDataSources(){return[]}async interceptCreate($,G,X){return{kind:"continue",input:$}}ready(){return this.delegate.ready()}shutdown(){return this.delegate.shutdown?.()??Promise.resolve()}}import{createClient as rh}from"@libsql/client";var D5=M0("conversations",{id:i("id").primaryKey(),sessionId:i("session_id").notNull(),interfaceType:i("interface_type").notNull(),channelId:i("channel_id").notNull(),started:i("started").notNull(),lastActive:i("last_active").notNull(),metadata:i("metadata"),created:i("created").notNull(),updated:i("updated").notNull()},($)=>({sessionIdx:Y0("idx_conversations_session").on($.sessionId),channelIdx:Y0("idx_conversations_channel").on($.channelId),interfaceSessionIdx:Y0("idx_conversations_interface_session").on($.interfaceType,$.sessionId),interfaceChannelIdx:Y0("idx_conversations_interface_channel").on($.interfaceType,$.channelId)})),bW=M0("messages",{id:i("id").primaryKey(),conversationId:i("conversation_id").notNull().references(()=>D5.id,{onDelete:"cascade"}),role:i("role").notNull(),content:i("content").notNull(),timestamp:i("timestamp").notNull(),metadata:i("metadata")},($)=>({conversationIdx:Y0("idx_messages_conversation").on($.conversationId),timestampIdx:Y0("idx_messages_timestamp").on($.timestamp)})),vW=M0("summary_tracking",{conversationId:i("conversation_id").primaryKey().references(()=>D5.id,{onDelete:"cascade"}),lastSummarizedAt:i("last_summarized_at"),lastMessageId:i("last_message_id"),messagesSinceSummary:v1("messages_since_summary").default(0),updated:i("updated").notNull()});var nh=H.preprocess(($)=>{if(typeof $!=="string")return $;try{return JSON.parse($)}catch{return}},H.record(H.unknown())).catch({});var M5=H.object({actorId:H.string(),canonicalId:H.string().optional(),interfaceType:H.string(),role:F2,displayName:H.string().optional(),username:H.string().optional(),isBot:H.boolean().optional()}),Q5=H.object({messageId:H.string().optional(),channelId:H.string().optional(),channelName:H.string().optional(),threadId:H.string().optional(),metadata:H.record(H.unknown()).optional()}),Lw=H.object({actor:M5.optional(),source:Q5.optional()}).passthrough(),Ew=H.object({id:H.string(),conversationId:H.string(),role:H.string(),content:H.string(),timestamp:H.string(),metadata:H.string().nullable()}),jw=H.object({conversationId:H.string(),messageCount:H.number(),messages:H.array(Ew),windowStart:H.number(),windowEnd:H.number(),windowSize:H.number(),timestamp:H.string()});var gW=H.object({kind:H.string().min(1),id:H.string().min(1)}),Iw=H.object({kind:H.literal("text"),filename:H.string().min(1),mediaType:H.string().min(1),content:H.string(),sizeBytes:H.number().nonnegative().optional(),source:gW.optional()}),xw=H.instanceof(Uint8Array),kw=H.object({kind:H.literal("file"),filename:H.string().min(1),mediaType:H.string().min(1),data:xw,sizeBytes:H.number().nonnegative().optional(),source:gW.optional()}),bw=H.discriminatedUnion("kind",[Iw,kw]),vw=H.object({userPermissionLevel:p0.optional(),interfaceType:H.string().optional(),channelId:H.string().optional(),channelName:H.string().optional(),actor:M5.optional(),source:Q5.optional(),attachments:H.array(bw).optional()}),hW=H.object({id:H.string(),toolCallId:H.string().optional(),toolName:H.string(),summary:H.string(),preview:H.string().optional(),args:H.unknown()}),gw=H.enum(["approval-requested","approval-responded","output-available","output-denied","output-error"]),hw=H.object({kind:H.literal("tool-approval"),id:H.string(),toolCallId:H.string().optional(),toolName:H.string(),input:H.record(H.unknown()).optional(),summary:H.string(),preview:H.string().optional(),state:gw,output:H.unknown().optional(),error:H.string().optional()}),yw=H.object({entityType:H.string().optional(),entityId:H.string().optional(),attachmentType:H.string().optional()}),fw=H.object({mediaType:H.string().min(1),url:H.string().min(1),downloadUrl:H.string().min(1).optional(),previewUrl:H.string().min(1).optional(),filename:H.string().min(1).optional(),sizeBytes:H.number().nonnegative().optional(),source:yw.optional()}),mw=H.object({kind:H.literal("attachment"),id:H.string(),jobId:H.string().optional(),title:H.string(),description:H.string().optional(),attachment:fw}),uw=H.object({id:H.string().min(1),title:H.string().min(1).optional(),source:H.string().min(1),url:H.string().min(1).optional(),entityType:H.string().min(1).optional(),entityId:H.string().min(1).optional(),excerpt:H.string().min(1).optional(),provenance:H.record(H.unknown()).optional()}),pw=H.object({kind:H.literal("sources"),id:H.string().min(1),title:H.string().min(1).optional(),sources:H.array(uw).min(1)}),lw=H.object({type:H.literal("prompt"),id:H.string().min(1),label:H.string().min(1),prompt:H.string().min(1),description:H.string().min(1).optional()}),rw=H.object({type:H.literal("event"),id:H.string().min(1),label:H.string().min(1),event:H.string().min(1),description:H.string().min(1).optional()}),dw=H.discriminatedUnion("type",[lw,rw]),cw=H.object({kind:H.literal("actions"),id:H.string().min(1),title:H.string().min(1).optional(),defaultOpen:H.boolean().optional(),actions:H.array(dw).min(1)}),iw=H.discriminatedUnion("kind",[hw,mw,pw,cw]);function yW($){return{kind:"actions",id:$.id,...$.title!==void 0&&{title:$.title},...$.defaultOpen!==void 0&&{defaultOpen:$.defaultOpen},actions:$.actions.map((G)=>{if(G.type==="prompt")return{type:"prompt",id:G.id,label:G.label,prompt:G.prompt,...G.description!==void 0&&{description:G.description}};return{type:"event",id:G.id,label:G.label,event:G.event,...G.description!==void 0&&{description:G.description}}})}}function fW($){return{kind:"sources",id:$.id,...$.title!==void 0&&{title:$.title},sources:$.sources.map((G)=>({id:G.id,...G.title!==void 0&&{title:G.title},source:G.source,...G.url!==void 0&&{url:G.url},...G.entityType!==void 0&&{entityType:G.entityType},...G.entityId!==void 0&&{entityId:G.entityId},...G.excerpt!==void 0&&{excerpt:G.excerpt},...G.provenance!==void 0&&{provenance:G.provenance}}))}}function mW($){let{attachment:G}=$,{source:X}=G;return{kind:"attachment",id:$.id,...$.jobId!==void 0&&{jobId:$.jobId},title:$.title,...$.description!==void 0&&{description:$.description},attachment:{mediaType:G.mediaType,url:G.url,...G.downloadUrl!==void 0&&{downloadUrl:G.downloadUrl},...G.previewUrl!==void 0&&{previewUrl:G.previewUrl},...G.filename!==void 0&&{filename:G.filename},...G.sizeBytes!==void 0&&{sizeBytes:G.sizeBytes},...X!==void 0&&{source:{...X.entityType!==void 0&&{entityType:X.entityType},...X.entityId!==void 0&&{entityId:X.entityId},...X.attachmentType!==void 0&&{attachmentType:X.attachmentType}}}}}}var uW=H.object({toolName:H.string(),args:H.record(H.unknown()).optional(),jobId:H.string().optional(),data:H.unknown().optional()}),nw=H.object({text:H.string(),toolResults:H.array(uW).optional(),cards:H.array(iw).optional(),pendingConfirmations:H.array(hW).optional(),usage:H.object({promptTokens:H.number(),completionTokens:H.number(),totalTokens:H.number()})});function pW($){return{text:$.text,...$.toolResults&&{toolResults:$.toolResults.map((G)=>({toolName:G.toolName,...G.args&&{args:G.args},...G.jobId!==void 0&&{jobId:G.jobId},...G.data!==void 0&&{data:G.data}}))},...$.cards&&{cards:$.cards.map(ow)},...$.pendingConfirmations&&{pendingConfirmations:$.pendingConfirmations.map((G)=>sw(G))},usage:$.usage}}function ow($){if($.kind==="attachment")return mW($);if($.kind==="sources")return fW($);if($.kind==="actions")return yW($);return{kind:$.kind,id:$.id,...$.toolCallId!==void 0&&{toolCallId:$.toolCallId},toolName:$.toolName,...$.input!==void 0&&{input:$.input},summary:$.summary,...$.preview!==void 0&&{preview:$.preview},state:$.state,...$.output!==void 0&&{output:$.output},...$.error!==void 0&&{error:$.error}}}function sw($){return{id:$.id,...$.toolCallId!==void 0&&{toolCallId:$.toolCallId},toolName:$.toolName,summary:$.summary,...$.preview!==void 0&&{preview:$.preview},args:$.args}}function lW($){if(!$)return;return{...$.userPermissionLevel&&{userPermissionLevel:$.userPermissionLevel},...$.interfaceType&&{interfaceType:$.interfaceType},...$.channelId&&{channelId:$.channelId},...$.channelName&&{channelName:$.channelName},...$.actor&&{actor:$.actor},...$.source&&{source:$.source},...$.attachments&&{attachments:$.attachments}}}function rW($){return{chat:async(G,X,Y)=>{return pW(await $.chat(G,X,lW(Y)))},confirmPendingAction:async(G,X,Y,W)=>{let V=lW(W);if(!V)throw Error("Confirmation requires caller context.");return pW(await $.confirmPendingAction(G,X,Y,V))},invalidate:()=>{$.invalidateAgent()}}}function dW($,G,X){let Y=U4($,G,X),W=$.getMCPService(),V=$.getPermissionService(),q=rW($.getAgentService());return{...Y,mcpTransport:W,agent:q,permissions:{...Y.permissions,getUserLevel:(J,U,R)=>{return V.determineUserLevel(J,U,R)}},daemons:{register:(J,U)=>{let R=`${G}:${J}`;$.registerDaemon(R,U,G),Y.logger.debug(`Registered daemon: ${R}`)}},conversations:{...Y.conversations,start:async(J)=>{return $.getConversationService().startConversation(J)},addMessage:async(J)=>{await $.getConversationService().addMessage(J)},updateMetadata:async(J)=>{return $.getConversationService().updateConversationMetadata(J)},delete:async(J)=>{return $.getConversationService().deleteConversation(J)}},tools:{listForPermissionLevel:(J)=>{return $.listToolsForPermissionLevel(J)}},apiRoutes:{getRoutes:()=>{return $.getPluginApiRoutes()},getMessageBus:()=>{return $.getMessageBus()}},webRoutes:{getRoutes:()=>{return $.getPluginWebRoutes()}},plugins:{has:(J)=>$.hasPlugin(J)}}}var aw=3600000;class o4 extends A2{type="interface";daemon;jobTrackingEntries=new Map;jobTrackingTtlMs=aw;async register($,G){let X=dW($,this.id,G);if(this.context=X,this.initializeDaemon(),this.daemon)await this.registerDaemon(X);return this.setupMessageHandlers(X),await this.onRegister(X),this.getCapabilities()}async onRegister($){}async registerDaemon($){if(!this.daemon)return;$.daemons.register(this.id,this.daemon),$.logger.debug(`Registered daemon for interface: ${this.id}`)}createDaemon(){return}requiresDaemonStartup(){return!1}getWebRoutes(){return[]}initializeDaemon(){let $=this.createDaemon();if($)this.daemon=$}async handleProgressEvent($,G){}cleanupExpiredEntries(){let $=Date.now(),G=[];for(let[X,Y]of this.jobTrackingEntries)if($-Y.createdAt>this.jobTrackingTtlMs)G.push(X);for(let X of G)this.jobTrackingEntries.delete(X)}ownsJob($,G){return this.jobTrackingEntries.has($)||G!==void 0&&this.jobTrackingEntries.has(G)}getJobTracking($,G){let X=this.jobTrackingEntries.get($);if(X)return X.info;if(G){let Y=this.jobTrackingEntries.get(G);if(Y)return Y.info}return}setJobTracking($,G){this.cleanupExpiredEntries(),this.jobTrackingEntries.set($,{info:G,createdAt:Date.now()})}removeJobTracking($){this.jobTrackingEntries.delete($)}async createJobWithTracking($,G){let Y=await this.getContext().jobs.enqueue($);return this.setJobTracking(Y,G),Y}async createBatchWithTracking($,G,X){let W=await this.getContext().jobs.enqueueBatch($,X);return this.setJobTracking(W,G),W}}class cW extends o4{hooks;constructor($,G,X,Y,W){super($,G,X,Y);this.hooks=W}onRegister($){return this.hooks.onRegister($)}onReady($){return this.hooks.onReady($)}onShutdown(){return this.hooks.onShutdown()}getTools(){return this.hooks.getTools()}getResources(){return this.hooks.getResources()}getInstructions(){return this.hooks.getInstructions()}getWebRoutes(){return this.hooks.getWebRoutes()}requiresDaemonStartup(){return this.hooks.requiresDaemonStartup()}}class s4{type="interface";id;version;packageName;description;delegate;constructor($,G,X,Y){if(this.id=$,this.version=G.version,this.packageName=G.name,G.description!==void 0)this.description=G.description;this.delegate=new cW($,G,X,Y,{onRegister:(W)=>this.onRegister(W),onReady:(W)=>this.onReady(W),onShutdown:()=>this.onShutdown(),getTools:()=>this.getTools(),getResources:()=>this.getResources(),getInstructions:()=>this.getInstructions(),getWebRoutes:()=>this.getWebRoutes(),requiresDaemonStartup:()=>this.requiresDaemonStartup()})}register($,G){return this.delegate.register($,G)}async onRegister($){}async onReady($){}async onShutdown(){}async getTools(){return[]}async getResources(){return[]}async getInstructions(){return}getWebRoutes(){return[]}requiresDaemonStartup(){return!1}ready(){return this.delegate.ready()}shutdown(){return this.delegate.shutdown?.()??Promise.resolve()}}function iW($,G){$.messaging.subscribe("job-progress",async(X)=>{try{let Y=G8.safeParse(X.payload);if(!Y.success)return G.onInvalidSchema(),{success:!1};let W=Y.data;return await G.onProgress(W,W.metadata),{success:!0}}catch(Y){return G.onError(Y),{success:!1}}})}function nW($){let G=$.status==="completed"?"\u2705":"\u274C",X=$.status==="completed"?"completed":"failed",Y=$.metadata.operationType.replace(/_/g," "),W=$.metadata.operationTarget?`: ${$.metadata.operationTarget}`:"",V=`${G} **${Y}${W}** ${X}`;if($.message)V+=`
120
120
  ${$.message}`;return V}function _8($){let G=$.metadata.operationType.replace(/_/g," "),X=$.metadata.operationTarget?`: ${$.metadata.operationTarget}`:"",Y=`\uD83D\uDD04 **${G}${X}**`;if($.progress&&$.progress.total>0)Y+=` ${$.progress.current}/${$.progress.total} (${$.progress.percentage}%)`;if($.message)Y+=`
121
121
  ${$.message}`;return Y}var tw=H.enum(["tool:invoking","tool:completed","tool:failed"]),ew=H.object({toolName:H.string().min(1),conversationId:H.string().min(1),interfaceType:H.string().min(1),channelId:H.string().min(1).optional(),channelName:H.string().min(1).optional(),error:H.string().optional()}),$B=["tool:invoking","tool:completed","tool:failed"];function oW($,G){for(let X of $B)$.messaging.subscribe(X,async(Y)=>{try{let W=tw.safeParse(Y.type),V=ew.safeParse(Y.payload);if(!W.success||!V.success)return G.onInvalidSchema(),{success:!1};return await G.onToolActivity({type:W.data,...V.data}),{success:!0}}catch(W){return G.onError(W),{success:!1}}})}var L8=1e5,GB=[".md",".txt",".markdown"],XB=["text/plain","text/markdown","text/x-markdown"],YB=/https?:\/\/[^\s<>"{}|\\^`[\]]+?(?=[,;:\s]|$)/gi,WB=["meet.google.com","zoom.us","teams.microsoft.com","whereby.com","gather.town","calendly.com","cal.com","discord.com","discord.gg","cdn.discordapp.com","media.discordapp.net","giphy.com","tenor.com","wetransfer.com","file.io"],VB=H.object({captureUrls:H.boolean().default(!1),blockedUrlDomains:H.array(H.string()).default(WB)});function sW($,G){if(G&&XB.some((X)=>G.startsWith(X)))return!0;return GB.some((X)=>$.toLowerCase().endsWith(X))}function aW($){return $<=L8}function tW($){if($.includes(0))return!1;try{return new TextDecoder("utf-8",{fatal:!0}).decode($),!0}catch{return!1}}function eW($,G){return`User uploaded a file "${$}":
122
122
 
@@ -124,5 +124,5 @@ ${G}`}function $V($,G){let X=$.match(YB)??[];return[...new Set(X)].filter((Y)=>{
124
124
 
125
125
  ${G}`}extractCaptureableUrls($,G){let X=$.match(/https?:\/\/[^\s<>"{}|\\^`[\]]+?(?=[,;:\s]|$)/gi)??[];return[...new Set(X)].filter((Y)=>{try{let{hostname:W}=new URL(Y);return!G.some((V)=>W===V||W.endsWith(`.${V}`))}catch{return!1}})}captureUrlViaAgent($,G,X,Y,W){return this.messageDelegate.captureUrlViaAgentPublic($,G,X,Y,W)}trackAgentResponseForJob($,G,X){this.messageDelegate.trackAgentResponseForJobPublic($,G,X)}registerProgressCallback($){this.messageDelegate.registerProgressCallback($)}unregisterProgressCallback(){this.messageDelegate.unregisterProgressCallback()}getProgressEvents(){return this.messageDelegate.getProgressEvents()}getActiveProgressEvents(){return this.messageDelegate.getActiveProgressEvents()}startProcessingInput($=null){this.messageDelegate.startProcessingInput($)}endProcessingInput(){this.messageDelegate.endProcessingInput()}getCurrentChannelId(){return this.messageDelegate.getCurrentChannelIdPublic()}ready(){return this.messageDelegate.ready()}shutdown(){return this.messageDelegate.shutdown?.()??Promise.resolve()}}function YV($,G,X){let Y=U4($,G,X),W=$.getEntityService(),V=$.getRenderService(),q=$.getContentService();return{...Y,entityService:W,entities:H5($),templates:{register:(J,U)=>{$.registerTemplates(J,U??G)},format:(J,U)=>{return q.formatContent(J,U,{pluginId:G})},parse:(J,U)=>{return q.parseContent(J,U,G)},resolve:async(J,U)=>{return await q.resolveContent(J,U,G)},getCapabilities:(J)=>{let U=J.includes(":")?J:`${G}:${J}`,R=$.getTemplate(U);if(!R)return null;let D=p4.getCapabilities(R);return{canGenerate:D.canGenerate,canFetch:D.canFetch,canRender:D.canRender,isStaticOnly:D.isStaticOnly}}},views:{get:(J)=>{return V.get(J)??void 0},list:()=>{return V.list()},hasRenderer:(J,U="web")=>{return V.hasRenderer(J,U)},getRenderer:(J,U="web")=>{return V.getRenderer(J,U)},validate:(J,U)=>{return V.validate(J,U)}},prompts:U5(W),registerInstructions:(J)=>{$.registerInstructions(G,J)}}}class T8 extends A2{type="service";getApiRoutes(){return[]}getWebRoutes(){return[]}async register($,G){let X=YV($,this.id,G);return this.context=X,this.setupMessageHandlers(X),await this.onRegister(X),this.getCapabilities()}get entityService(){return this.getContext().entityService}registerEntityType($,G,X,Y){this.getContext().entities.register($,G,X,Y)}async enqueueJob($){return this.getContext().jobs.enqueue($)}async enqueueBatch($,G){return this.getContext().jobs.enqueueBatch($,G)}async registerEntityTypes($){}async registerJobHandlers($){}async onRegister($){await this.registerEntityTypes($),await this.registerJobHandlers($)}}class WV extends T8{hooks;constructor($,G,X,Y,W){super($,G,X,Y);this.hooks=W}onRegister($){return this.hooks.onRegister($)}onReady($){return this.hooks.onReady($)}onShutdown(){return this.hooks.onShutdown()}getTools(){return this.hooks.getTools()}getResources(){return this.hooks.getResources()}getInstructions(){return this.hooks.getInstructions()}}class C8{type="service";id;version;packageName;description;delegate;constructor($,G,X,Y){if(this.id=$,this.version=G.version,this.packageName=G.name,G.description!==void 0)this.description=G.description;this.delegate=new WV($,G,X,Y,{onRegister:(W)=>this.onRegister(W),onReady:(W)=>this.onReady(W),onShutdown:()=>this.onShutdown(),getTools:()=>this.getTools(),getResources:()=>this.getResources(),getInstructions:()=>this.getInstructions()})}register($,G){return this.delegate.register($,G)}async onRegister($){}async onReady($){}async onShutdown(){}async getTools(){return[]}async getResources(){return[]}async getInstructions(){return}ready(){return this.delegate.ready()}shutdown(){return this.delegate.shutdown?.()??Promise.resolve()}}var qB=H.object({status:H.enum(["healthy","warning","error","unknown"]),message:H.string().optional(),lastCheck:H.string().optional(),details:H.record(H.unknown()).optional()}),JB=H.object({name:H.string(),pluginId:H.string(),status:H.string(),health:qB.optional()}),HB=H.object({model:H.string(),version:H.string(),uptime:H.number(),entities:H.number(),entityCounts:H.array(t9),embeddings:H.number(),ai:H.object({model:H.string(),embeddingModel:H.string()}),daemons:H.array(JB),endpoints:H.array(s9),interactions:H.array(a9)});var UB=H.union([H.object({success:H.boolean(),data:H.unknown().optional(),error:H.string().optional()}),H.object({noop:H.literal(!0)})]),RB=H.object({id:H.string(),timestamp:H.string(),type:H.string(),source:H.string(),target:H.string().optional(),metadata:H4.optional()});export{VA as urlCaptureConfigSchema,YA as toolSuccess,WA as toolError,qA as defineChannel,GA as createTool,XA as createResource,uW as ToolResultDataSchema,C8 as ServicePlugin,hW as PendingConfirmationSchema,tA as MessageSchema,UB as MessageResponseSchema,j8 as MessageInterfacePlugin,s4 as InterfacePlugin,H4 as ExtensionMetadataSchema,z8 as EntityPlugin,aA as ConversationSchema,vw as ChatContextSchema,A8 as BrainCharacterSchema,RB as BaseMessageSchema,HB as AppInfoSchema,w8 as AnchorProfileSchema,nw as AgentResponseSchema};
126
126
 
127
- //# debugId=0E2C80A2C2A94EB664756E2164756E21
127
+ //# debugId=654A0D0F0808243A64756E2164756E21
128
128
  //# sourceMappingURL=plugins.js.map