@botpress/sdk 4.12.0 → 4.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -76,7 +76,7 @@ ${v}`.trim();case M.ZodFirstPartyTypeKind.ZodEnum:return s.values.map(se).join("
76
76
  `,a+=`}
77
77
  `,a+=`}
78
78
  `),a+=`}
79
- `,a+="})"}let o=n?a?n+a:r?r==="z.never()"?n+".strict()":n+`.catchall(${r})`:n:a||(r?`z.record(${r})`:"z.record(z.any())");return Xe.an.anyOf(t)&&(o+=`.and(${zg(N(b({},t),{anyOf:t.anyOf.map(i=>typeof i=="object"&&!i.type&&(i.properties||i.additionalProperties||i.patternProperties)?N(b({},i),{type:"object"}):i)}),e)})`),Xe.a.oneOf(t)&&(o+=`.and(${ts(N(b({},t),{oneOf:t.oneOf.map(i=>typeof i=="object"&&!i.type&&(i.properties||i.additionalProperties||i.patternProperties)?N(b({},i),{type:"object"}):i)}),e)})`),Xe.an.allOf(t)&&(o+=`.and(${zr(N(b({},t),{allOf:t.allOf.map(i=>typeof i=="object"&&!i.type&&(i.properties||i.additionalProperties||i.patternProperties)?N(b({},i),{type:"object"}):i)}),e)})`),o}d(qg,"parseObject");var qP=d(t=>{var e;let n="z.string()";if((e=t[le])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";n="z.coerce.string()"}return n+=ut(t,"format",({value:r})=>{switch(r){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime(",")"]}}),n+=ut(t,"pattern",({json:r})=>[`.regex(new RegExp(${r})`,", ",")"]),n+=ut(t,"minLength",({json:r})=>[`.min(${r}`,", ",")"]),n+=ut(t,"maxLength",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseString"),GP=d((t,e)=>`${it($P(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),VP=d(t=>`z.ref('${t.$ref}')`,"parseRef"),JP=d((t,e)=>{var n,r;if(t.oneOf.length<=1||!((n=t.discriminator)!=null&&n.propertyName))return ts(t,e);let a=t.oneOf.map((o,i)=>it(o,N(b({},e),{path:[...e.path,"oneOf",i]})));return`z.discriminatedUnion("${(r=t.discriminator)==null?void 0:r.propertyName}", [${a.join(", ")}])`},"parseDiscriminator"),it=d((t,e={seen:new Map,path:[]},n)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let o=e.parserOverride(t,e);if(typeof o=="string")return o}let r=e.seen.get(t);if(r){if(r.r!==void 0)return r.r;if(e.depth===void 0||r.n>=e.depth)return"z.any()";r.n+=1}else r={r:void 0,n:0},e.seen.set(t,r);let a=QP(t,e);return n||(a=XP(t,a),e.withoutDefaults||(a=YP(t,a))),r.r=a,a},"parseSchema"),XP=d((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),YP=d((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),QP=d((t,e)=>Xe.a.nullable(t)?GP(t,e):Xe.an.object(t)?qg(t,e):Xe.an.array(t)?KP(t,e):Xe.an.anyOf(t)?zg(t,e):Xe.an.allOf(t)?zr(t,e):Xe.a.discriminator(t)?JP(t,e):Xe.a.oneOf(t)?ts(t,e):Xe.a.not(t)?HP(t,e):Xe.an.enum(t)?FP(t):Xe.a.const(t)?LP(t):Xe.a.multipleType(t)?DP(t,e):Xe.a.primitive(t,"string")?qP(t):Xe.a.primitive(t,"number")||Xe.a.primitive(t,"integer")?zP(t):Xe.a.primitive(t,"boolean")?MP(t):Xe.a.primitive(t,"null")?UP(t):Xe.a.conditional(t)?WP(t,e):Xe.a.ref(t)?VP(t):NP(t),"selectParser"),Xe={an:{object:d(t=>t.type==="object","object"),array:d(t=>t.type==="array","array"),anyOf:d(t=>t.anyOf!==void 0,"anyOf"),allOf:d(t=>t.allOf!==void 0,"allOf"),enum:d(t=>t.enum!==void 0,"enum")},a:{nullable:d(t=>t.nullable===!0,"nullable"),multipleType:d(t=>Array.isArray(t.type),"multipleType"),not:d(t=>t.not!==void 0,"not"),const:d(t=>t.const!==void 0,"const"),primitive:d((t,e)=>t.type===e,"primitive"),conditional:d(t=>Boolean("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),"conditional"),discriminator:d(t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},"discriminator"),oneOf:d(t=>t.oneOf!==void 0,"oneOf"),ref:d(t=>t.$ref!==void 0,"ref")}},eB=d(t=>{let e;try{e=new Function("z",`return ${t}`)(M)}catch(n){return{sucess:!1,error:`Failed to evaluate schema: ${(n instanceof Error?n:new Error(String(n))).message}`}}return e instanceof M.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),tB=d(t=>it(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),nB=d(t=>{let e=tB(t);e=e.replaceAll("errors: z.ZodError[]","errors");let n=eB(e);if(!n.sucess)throw new sa(n.error);return n.value},"jsonSchemaToZod"),Nr=d((t,e)=>{var n,r;if(e[le]&&t._def&&(t._def[le]=e[le]),((n=t._def)==null?void 0:n.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([a,o])=>{let i=typeof t._def.shape=="function"?t._def.shape():t._def.shape;i[a]&&Nr(i[a],o)}),((r=t._def)==null?void 0:r.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Nr(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let a=e.items;if(typeof a=="object"&&!Array.isArray(a)){let o=t._def.type;o&&Nr(o,a)}else Array.isArray(a)&&a.forEach((o,i)=>{let s=t._def;s.typeName===Y.ZodFirstPartyTypeKind.ZodTuple&&Nr(s.items[i],o)})}},"applyZuiPropsRecursively"),rB=d(t=>{let e=nB(t);return Nr(e,t),e},"fromJSONSchemaLegacy"),iB=d(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&Gg(r))&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===M.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),aB=d(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&r.type==="null")&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===M.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),Gg=d(t=>{var e,n;return t.not===!0&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===M.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),oB=d(t=>{var e,n;return!t.not&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===M.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),sB=d(({type:t,minimum:e,exclusiveMinimum:n,maximum:r,exclusiveMaximum:a,multipleOf:o,format:i})=>{let s=M.number();return t==="integer"&&(s=s.int()),i==="finite"&&(s=s.finite()),n!==void 0?s=s.gt(n):e!==void 0&&(s=s.gte(e)),a!==void 0?s=s.lt(a):r!==void 0&&(s=s.lte(r)),o!==void 0&&(s=s.multipleOf(o)),s},"numberJSONSchemaToZuiNumber"),lB=d(({format:t,pattern:e,minLength:n,maxLength:r})=>{let a=M.string();if(n&&r&&n===r?a=a.length(n):(n&&(a=a.min(n)),r&&(a=a.max(r))),t==="cuid"||e===Ye.cuid)a=a.cuid();else if(t==="cuid2"||e===Ye.cuid2)a=a.cuid2();else if(t==="emoji"||e===Ye.emoji)a=a.emoji();else if(t==="ulid"||e===Ye.ulid)a=a.ulid();else if(t==="date-time"){let{precision:o,offset:i}=e?bx(e):{};a=a.datetime({precision:o,offset:i})}else t==="email"||e===Ye.email?a=a.email():t==="ipv4"||e===Ye.ipv4?a=a.ip():t==="ipv6"||e===Ye.ipv6?a=a.ip("v6"):t==="uri"?a=a.url():t==="uuid"||e===Ye.uuid?a=a.uuid():e&&(a=a.regex(new RegExp(e)));return a},"stringJSONSchemaToZuiString"),xr=d((t,e)=>{let n=[];e.enum!==void 0&&n.push(...e.enum),e.const!==void 0&&n.push(e.const);let r=n.filter(i=>typeof i===t),[a]=r;if(!a){if(t==="string"&&e.type==="string")return lB(e);if(t==="number"&&(e.type==="number"||e.type==="integer"))return sB(e);if(t==="boolean")return M.boolean();if(t==="null")return M.null();throw new sa(`Unknown primitive type: "${t}"`)}if(r.length===1)return M.literal(a);let o=r.map(i=>M.literal(i));return M.union(o)},"toZuiPrimitive"),uB=d((t,e)=>cB(t)?dB(t,e):fB(t)?pB(t,e):gB(t,e),"arrayJSONSchemaToZuiArray"),cB=d(t=>Array.isArray(t.items),"_isTuple"),fB=d(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),dB=d(({items:t,additionalItems:e},n)=>{let r=t.map(n),a=M.tuple(r);return e!==void 0&&(a=a.rest(n(e))),a},"_handleTuple"),pB=d(({items:t,minItems:e,maxItems:n},r)=>{let a=M.set(r(t));return e&&(a=a.min(e)),n&&(a=a.max(n)),a},"_handleSet"),gB=d(({minItems:t,maxItems:e,items:n},r)=>{let a=M.array(r(n));return t&&t===e?a.length(t):(t&&(a=a.min(t)),e&&(a=a.max(e)),a)},"_handleArray"),qn=M.any();function Vg(t){return rt(t)}d(Vg,"fromJSONSchema");function rt(t){var e;if(t===void 0)return qn;if(t===!0)return M.any();if(t===!1)return M.never();if(t.default!==void 0)return rt(N(b({},t),{default:void 0})).default(t.default);if(t.readOnly)return rt(N(b({},t),{readOnly:void 0})).readonly();if(t.oneOf!==void 0)throw new nn({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new nn({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new nn({propertyNames:t.propertyNames});if(t.if!==void 0)throw new nn({if:t.if});if(t.then!==void 0)throw new nn({then:t.then});if(t.else!==void 0)throw new nn({else:t.else});if(t.$ref!==void 0)return M.ref(t.$ref);if(t.not!==void 0){if(Gg(t))return M.undefined();if(t.not===!0)return M.never();throw new nn({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return qn;if(t.type.length===1)return rt(N(b({},t),{type:t.type[0]}));let n=t,{type:r}=n,a=Qc(n,["type"]),o=t.type.map(i=>rt(N(b({},a),{type:i})));return M.union(o)}if(t.type==="string")return t.enum&&t.enum.length>0?M.enum(t.enum):xr("string",t);if(t.type==="integer"){let n=xr("number",t);return n instanceof M.ZodNumber?n.int():n}if(t.type==="number")return xr("number",t);if(t.type==="boolean")return xr("boolean",t);if(t.type==="null")return xr("null",t);if(t.type==="array")return uB(t,rt);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let n=rt(t.additionalProperties);return rt(N(b({},t),{additionalProperties:void 0})).catchall(n)}if(t.properties!==void 0){let n={};for(let[r,a]of Object.entries(t.properties)){let o=rt(a),i=(e=t.required)!=null?e:[];n[r]=i.includes(r)?o:o.optional()}return M.object(n)}if(t.additionalProperties!==void 0){let n=rt(t.additionalProperties);return M.record(n)}return M.record(qn)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return qn;if(t.anyOf.length===1)return rt(t.anyOf[0]);if(iB(t))return rt(t.anyOf[0]).optional();if(aB(t))return rt(t.anyOf[0]).nullable();let n=t.anyOf.map(rt);return M.union(n)}if(t.allOf!==void 0){if(t.allOf.length===0)return qn;if(t.allOf.length===1)return rt(t.allOf[0]);let[n,...r]=t.allOf,a=rt(n),o=rt({allOf:r});return M.intersection(a,o)}return oB(t)?M.unknown():qn}d(rt,"_fromJSONSchema");var yB=/^\d{4}-\d{2}-\d{2}(T|\s)?((\d{2}:\d{2}:\d{2}(\.\d{1,3})?)|(\d{2}:\d{2}))?(\s?([+-]\d{2}:\d{2}|Z))?$/,xo=d((t,e,n=!0)=>{if(typeof t!="object")throw new co("Input must be an object");let r=d(i=>{let s=i;return e?.nullable&&(s=s.nullable()),e?.optional&&(s=s.optional()),e?.passtrough&&typeof s.passthrough=="function"&&(s=s.passthrough()),s},"applyOptions"),a=Object.entries(t).reduce((i,[s,l])=>{if(l===null)i[s]=r(Y.null());else switch(typeof l){case"string":i[s]=yB.test(l)?r(Y.string().datetime()):r(Y.string());break;case"number":i[s]=r(Y.number());break;case"boolean":i[s]=r(Y.boolean());break;case"object":Array.isArray(l)?l.length===0?i[s]=r(Y.array(Y.unknown())):typeof l[0]=="object"?i[s]=r(Y.array(xo(l[0],e,!1))):["string","number","boolean"].includes(typeof l[0])&&(i[s]=r(Y.array(Y[typeof l[0]]()))):i[s]=r(xo(l,e,!1));break;default:throw new co(`Unsupported type for key ${s}`)}return i},{}),o=Object.keys(a).length>0;return e?.passtrough||!n&&!o?Y.object(a).passthrough():Y.object(a)},"fromObject");function Jg(){return{}}d(Jg,"parseAnyDef");function Xg(t,e){var n,r;let a={type:"array"};return((r=(n=t.type)==null?void 0:n._def)==null?void 0:r.typeName)!=="ZodAny"&&(a.items=Ie(t.type._def,N(b({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&Re(a,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&Re(a,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(Re(a,"minItems",t.exactLength.value,t.exactLength.message,e),Re(a,"maxItems",t.exactLength.value,t.exactLength.message,e)),a}d(Xg,"parseArrayDef");function Yg(t,e){let n=b({type:"integer",format:"int64"},t.coerce?{[le]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"?r.inclusive?Re(n,"minimum",r.value,r.message,e):Re(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),Re(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?Re(n,"maximum",r.value,r.message,e):Re(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),Re(n,"maximum",r.value,r.message,e));break;case"multipleOf":Re(n,"multipleOf",r.value,r.message,e);break}return n}d(Yg,"parseBigintDef");function Qg(t){return b({type:"boolean"},t.coerce?{[le]:{coerce:t.coerce||void 0}}:{})}d(Qg,"parseBooleanDef");function ey(t,e){return Ie(t.type._def,e)}d(ey,"parseBrandedDef");var mB=d((t,e)=>Ie(t.innerType._def,e),"parseCatchDef");function ty(t,e){return e.dateStrategy=="integer"?hB(t,e):b({type:"string",format:"date-time"},t.coerce?{[le]:{coerce:t.coerce||void 0}}:{})}d(ty,"parseDateDef");var hB=d((t,e)=>{let n=b({type:"integer",format:"unix-time"},t.coerce?{[le]:{coerce:t.coerce||void 0}}:{});for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"&&Re(n,"minimum",r.value,r.message,e);break;case"max":e.target==="jsonSchema7"&&Re(n,"maximum",r.value,r.message,e);break}return n},"integerDateParser");function ny(t,e){return N(b({},Ie(t.innerType._def,e)),{default:t.defaultValue()})}d(ny,"parseDefaultDef");function ry(t,e){return e.effectStrategy==="input"?Ie(t.schema._def,e):{}}d(ry,"parseEffectsDef");function iy(t){return{type:"string",enum:t.values}}d(iy,"parseEnumDef");var vB=d(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function ay(t,e){let n=[Ie(t.left._def,N(b({},e),{currentPath:[...e.currentPath,"allOf","0"]})),Ie(t.right._def,N(b({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(o=>!!o),r=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,a=[];return n.forEach(o=>{if(vB(o))a.push(...o.allOf),o.unevaluatedProperties===void 0&&(r=void 0);else{let i=o;if("additionalProperties"in o&&o.additionalProperties===!1){let s=o,{additionalProperties:l}=s;i=Qc(s,["additionalProperties"])}else r=void 0;a.push(i)}}),a.length?b({allOf:a},r):void 0}d(ay,"parseIntersectionDef");function oy(t,e){let n=typeof t.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:n==="bigint"?"integer":n,enum:[t.value]}:{type:n==="bigint"?"integer":n,const:t.value}}d(oy,"parseLiteralDef");function ns(t,e){var n,r,a,o,i;if(e.target==="openApi3"&&((n=t.keyType)==null?void 0:n._def.typeName)==="ZodEnum")return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((l,f)=>{var p;return N(b({},l),{[f]:(p=Ie(t.valueType._def,N(b({},e),{currentPath:[...e.currentPath,"properties",f]})))!=null?p:{}})},{}),additionalProperties:!1};let s={type:"object",additionalProperties:(r=Ie(t.valueType._def,N(b({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:{}};if(e.target==="openApi3")return s;if(((a=t.keyType)==null?void 0:a._def.typeName)==="ZodString"&&((o=t.keyType._def.checks)!=null&&o.length)){let l=Object.entries(Zo(t.keyType._def,e)).reduce((f,[p,y])=>p==="type"?f:N(b({},f),{[p]:y}),{});return N(b({},s),{propertyNames:l})}else if(((i=t.keyType)==null?void 0:i._def.typeName)==="ZodEnum")return N(b({},s),{propertyNames:{enum:t.keyType._def.values}});return s}d(ns,"parseRecordDef");function sy(t,e){if(e.mapStrategy==="record")return ns(t,e);let n=Ie(t.keyType._def,N(b({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},r=Ie(t.valueType._def,N(b({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}d(sy,"parseMapDef");function ly(t){let e=t.values,r=Object.keys(t.values).filter(o=>typeof e[e[o]]!="number").map(o=>e[o]),a=Array.from(new Set(r.map(o=>typeof o)));return{type:a.length===1?a[0]==="string"?"string":"number":["string","number"],enum:r.filter(o=>typeof o=="string"||typeof o=="number")}}d(ly,"parseNativeEnumDef");function uy(){return{not:{}}}d(uy,"parseNeverDef");function cy(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}d(cy,"parseNullDef");var aa={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function fy(t,e){if(e.target==="openApi3")return Vc(t,e);let n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in aa&&(!r._def.checks||!r._def.checks.length))){let r=n.reduce((a,o)=>{let i=aa[o._def.typeName];return i&&!a.includes(i)?[...a,i]:a},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){let r=n.reduce((a,o)=>{let i=typeof o._def.value;switch(i){case"string":case"number":case"boolean":return[...a,i];case"bigint":return[...a,"integer"];case"object":if(o._def.value===null)return[...a,"null"];case"symbol":case"undefined":case"function":default:return a}},[]);if(r.length===n.length){let a=r.filter((o,i,s)=>s.indexOf(o)===i);return{type:a.length>1?a:a[0],enum:n.reduce((o,i)=>o.includes(i._def.value)?o:[...o,i._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,a)=>[...r,...a._def.values.filter(o=>!r.includes(o))],[])};return Vc(t,e)}d(fy,"parseUnionDef");var Vc=d((t,e)=>{let n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((a,o)=>Ie(a._def,N(b({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${o}`]}))).filter(a=>!!a&&(!e.strictUnions||typeof a=="object"&&Object.keys(a).length>0)),r=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(n.length)return e.unionStrategy==="anyOf"?b({anyOf:n},r):b({oneOf:n},r)},"asUnionOf");function dy(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length)){let r=t.innerType;if(e.target==="openApi3"){let o={type:aa[r._def.typeName],nullable:!0};return Po(r._def,e,o)}let a={type:[aa[r._def.typeName],"null"]};return Po(r._def,e,a)}if(e.target==="openApi3"){let r=Ie(t.innerType._def,N(b({},e),{currentPath:[...e.currentPath]}));return r&&N(b({},r),{nullable:!0})}let n=Ie(t.innerType._def,N(b({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return n&&{anyOf:[n,{type:"null"}]}}d(dy,"parseNullableDef");function py(t,e){let n=b({type:"number"},t.coerce?{[le]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"int":n.type="integer",Uo(n,"type",r.message,e);break;case"min":e.target==="jsonSchema7"?r.inclusive?Re(n,"minimum",r.value,r.message,e):Re(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),Re(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?Re(n,"maximum",r.value,r.message,e):Re(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),Re(n,"maximum",r.value,r.message,e));break;case"multipleOf":Re(n,"multipleOf",r.value,r.message,e);break}return n}d(py,"parseNumberDef");var TB=d((t,e)=>{var n;return t.unknownKeys instanceof he?(n=Ie(t.unknownKeys._def,N(b({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function gy(t,e){let n=N(b({type:"object"},Object.entries(t.shape()).reduce((r,[a,o])=>{if(o===void 0||o._def===void 0)return r;let i=Ie(o._def,N(b({},e),{currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]}));return i===void 0?r:{properties:N(b({},r.properties),{[a]:i}),required:o.isOptional()?r.required:[...r.required,a]}},{properties:{},required:[]})),{additionalProperties:TB(t,e)});return n.required.length||delete n.required,n}d(gy,"parseObjectDef");var _B=d((t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return Ie(t.innerType._def,e);let r=Ie(t.innerType._def,N(b({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return r?{anyOf:[{not:{}},r]}:{}},"parseOptionalDef"),bB=d((t,e)=>{if(e.pipeStrategy==="input")return Ie(t.in._def,e);if(e.pipeStrategy==="output")return Ie(t.out._def,e);let n=Ie(t.in._def,N(b({},e),{currentPath:[...e.currentPath,"allOf","0"]})),r=Ie(t.out._def,N(b({},e),{currentPath:[...e.currentPath,"allOf",n?"1":"0"]}));return{allOf:[n,r].filter(a=>a!==void 0)}},"parsePipelineDef");function yy(t,e){return Ie(t.type._def,e)}d(yy,"parsePromiseDef");function my(t,e){let r={type:"array",uniqueItems:!0,items:Ie(t.valueType._def,N(b({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&Re(r,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&Re(r,"maxItems",t.maxSize.value,t.maxSize.message,e),r}d(my,"parseSetDef");function hy(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>Ie(n._def,N(b({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Ie(t.rest._def,N(b({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>Ie(n._def,N(b({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[])}}d(hy,"parseTupleDef");function vy(){return{not:{}}}d(vy,"parseUndefinedDef");function Ty(){return{}}d(Ty,"parseUnknownDef");var wB=d((t,e)=>Ie(t.innerType._def,e),"parseReadonlyDef");function _y(t){return{$ref:t.uri}}d(_y,"parseRefDef");function Ie(t,e,n=!1){let r=e.seen.get(t);if(r&&!n){let i=xB(r,e);if(i!==void 0)return i}let a={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,a);let o=BB(t,t.typeName,e);return o&&Po(t,e,o),a.jsonSchema=o,o}d(Ie,"parseDef");var xB=d((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:PB(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((n,r)=>e.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),PB=d((t,e)=>{let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];n++);return[(t.length-n).toString(),...e.slice(n)].join("/")},"getRelativePath"),BB=d((t,e,n)=>{switch(e){case"ZodString":return Zo(t,n);case"ZodNumber":return py(t,n);case"ZodObject":return gy(t,n);case"ZodBigInt":return Yg(t,n);case"ZodBoolean":return Qg(t);case"ZodDate":return ty(t,n);case"ZodUndefined":return vy();case"ZodNull":return cy(n);case"ZodArray":return Xg(t,n);case"ZodUnion":case"ZodDiscriminatedUnion":return fy(t,n);case"ZodIntersection":return ay(t,n);case"ZodTuple":return hy(t,n);case"ZodRecord":return ns(t,n);case"ZodRef":return _y(t);case"ZodLiteral":return oy(t,n);case"ZodEnum":return iy(t);case"ZodNativeEnum":return ly(t);case"ZodNullable":return dy(t,n);case"ZodOptional":return _B(t,n);case"ZodMap":return sy(t,n);case"ZodSet":return my(t,n);case"ZodLazy":return Ie(t.getter()._def,n);case"ZodPromise":return yy(t,n);case"ZodNaN":case"ZodNever":return uy();case"ZodEffects":return ry(t,n);case"ZodAny":return Jg();case"ZodUnknown":return Ty();case"ZodDefault":return ny(t,n);case"ZodBranded":return ey(t,n);case"ZodReadonly":return wB(t,n);case"ZodCatch":return mB(t,n);case"ZodPipeline":return bB(t,n);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(r=>{})(e)}},"selectParser"),Po=d((t,e,n)=>(t.description&&(n.description=t.description,e.markdownDescription&&(n.markdownDescription=t.description)),Object.assign(n,{[le]:b(b({},t[le]),n[le])}),n),"addMeta"),Jc={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"string",mapStrategy:"entries",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",emailStrategy:"format:email",discriminator:!1,unionStrategy:"anyOf"},SB=d(t=>typeof t=="string"?N(b({},Jc),{name:t}):b(b({},Jc),t),"getDefaultOptions"),EB=d(t=>{let e=SB(t),n=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return N(b({},e),{currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([r,a])=>[a._def,{def:a._def,path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))})},"getRefs"),kB=d((t,e)=>{var n;let r=EB(e),a=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((l,[f,p])=>{var y;return N(b({},l),{[f]:(y=Ie(p._def,N(b({},r),{currentPath:[...r.basePath,r.definitionPath,f]}),!0))!=null?y:{}})},{}):void 0,o=typeof e=="string"?e:e?.name,i=(n=Ie(t._def,o===void 0?r:N(b({},r),{currentPath:[...r.basePath,r.definitionPath,o]}),!1))!=null?n:{},s=o===void 0?a?N(b({},i),{[r.definitionPath]:a}):i:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,o].join("/"),[r.definitionPath]:N(b({},a),{[o]:i})};return r.target==="jsonSchema7"?s.$schema="http://json-schema.org/draft-07/schema#":r.target==="jsonSchema2019-09"&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),s},"zodToJsonSchema"),IB=d((t,e={target:"openApi3"})=>{let n=kB(t,e);return e.$schemaUrl===!1?delete n.$schema:typeof e.$schemaUrl=="string"&&(n.$schema=e.$schemaUrl),n},"toJSONSchemaLegacy");var Vr=(t,e)=>{let n=t._def,r=e._def;if(n.typeName===Y.ZodFirstPartyTypeKind.ZodObject&&r.typeName===Y.ZodFirstPartyTypeKind.ZodObject){let a=n.shape(),o=r.shape();return Y.object({...a,...o})}if(n.typeName===Y.ZodFirstPartyTypeKind.ZodRecord&&r.typeName===Y.ZodFirstPartyTypeKind.ZodRecord)return Y.record(Y.intersection(n.valueType,r.valueType));throw new Error("Cannot merge object schemas with record schemas")},by=Y;var yt=Y.string().min(1),xy=Y.object({text:yt}),Py=Y.object({markdown:yt}),By=Y.object({imageUrl:yt}),Sy=Y.object({audioUrl:yt}),Ey=Y.object({videoUrl:yt}),ky=Y.object({fileUrl:yt,title:yt.optional()}),Iy=Y.object({latitude:Y.number(),longitude:Y.number(),address:Y.string().optional(),title:Y.string().optional()}),Ay=Y.object({title:yt,subtitle:yt.optional(),imageUrl:yt.optional(),actions:Y.array(Y.object({action:Y.enum(["postback","url","say"]),label:yt,value:yt}))}),wy=Y.object({text:yt,options:Y.array(Y.object({label:yt,value:yt}))}),AB=Y.object({items:Y.array(Ay)}),CB=Y.union([Y.object({type:Y.literal("text"),payload:xy}),Y.object({type:Y.literal("markdown"),payload:Py}),Y.object({type:Y.literal("image"),payload:By}),Y.object({type:Y.literal("audio"),payload:Sy}),Y.object({type:Y.literal("video"),payload:Ey}),Y.object({type:Y.literal("file"),payload:ky}),Y.object({type:Y.literal("location"),payload:Iy})]),OB=Y.object({items:Y.array(CB)}),RB={schema:Py},MB={text:{schema:xy},image:{schema:By},audio:{schema:Sy},video:{schema:Ey},file:{schema:ky},location:{schema:Iy},carousel:{schema:AB},card:{schema:Ay},dropdown:{schema:wy},choice:{schema:wy},bloc:{schema:OB}};C();R();O();var wa="x-bot-id",Oy="x-bot-user-id",Ry="x-integration-id",My="x-webhook-id",Ny="x-bp-configuration-type",xa="x-bp-configuration",Pa="x-bp-operation",Dy="x-bp-type",QA={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};C();R();O();import{isNode as Nk}from"browser-or-node";C();R();O();var rs=console;function Ct(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function za(t,e=8072,n=Zk){if(!Nk)throw new Error("This function can only be called in Node.js");let a=(Mh(),$v(Rh)).createServer(async(o,i)=>{try{let s=await Dk(o);if(s.path==="/health"){i.writeHead(200).end("ok");return}let l=await t(s);i.writeHead(l?.status??200,l?.headers??{}).end(l?.body??"{}")}catch(s){rs.error("Error while handling request",{error:s?.message??"Internal error occured"}),i.writeHead(500).end(JSON.stringify({error:s?.message??"Internal error occured"}))}});return a.listen(e,()=>n(e)),a}async function Dk(t){let e=await Uk(t),n={};for(let a=0;a<t.rawHeaders.length;a+=2){let o=t.rawHeaders[a].toLowerCase(),i=t.rawHeaders[a+1];n[o]=i}let r=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:r.pathname,query:Hk(r.search,"?"),headers:n,method:t.method?.toUpperCase()??"GET"}}function Hk(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function Uk(t){return new Promise((e,n)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let r="";t.on("data",a=>r+=a.toString()),t.on("error",a=>n(a)),t.on("end",()=>e(r))})}function Zk(t){rs.info(`Listening on port ${t}`)}import{isApiError as rU,RuntimeError as iU}from"@botpress/client";C();R();O();C();R();O();C();R();O();C();R();O();var Le={};Wn(Le,{mapKeys:()=>Kk,mapValues:()=>jk,mergeRecords:()=>Fk,pairs:()=>qa,stripUndefinedProps:()=>Lk,values:()=>$k});C();R();O();var qa=t=>Object.entries(t),$k=t=>Object.values(t),jk=(t,e)=>Object.fromEntries(qa(t).map(([n,r])=>[n,e(r,n)])),Kk=(t,e)=>Object.fromEntries(qa(t).map(([n,r])=>[e(n),r])),Lk=t=>Object.fromEntries(qa(t).filter(([,e])=>e!==void 0)),Fk=(t,e,n)=>{let r=[...Object.keys(t),...Object.keys(e)],a=[...new Set(r)],o={};for(let i of a){let s=t[i],l=e[i];s&&l?o[i]=n(s,l):s?o[i]=s:l&&(o[i]=l)}return o};var ye={};Wn(ye,{safePush:()=>Wk,unique:()=>zk});C();R();O();var Wk=(t,...e)=>t?[...t,...e]:[...e],zk=t=>Array.from(new Set(t));C();R();O();var Qt={};Wn(Qt,{setName:()=>qk});C();R();O();var qk=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var Nh=t=>{let{name:e,version:n}=t,r={actions:{},events:{},channels:{}},a={name:e,version:n,entities:Le.mapValues(t.entities,i=>({name:i.name})),actions:{},events:{},channels:{}},o=Le.mapValues(t.entities,i=>i.schema);for(let[i,s]of Object.entries(t.definition.actions??{})){let l=s.input.schema.dereference(o),f=s.output.schema.dereference(o),p=t.actions?.[i]?.name??i;r.actions[p]={...s,...t.actions?.[i]??{},input:{schema:l},output:{schema:f}},a.actions[i]={name:p}}for(let[i,s]of Object.entries(t.definition.events??{})){let l=s.schema.dereference(o),f=t.events?.[i]?.name??i;r.events[f]={...s,...t.events?.[i]??{},schema:l},a.events[i]={name:f}}for(let[i,s]of Object.entries(t.definition.channels??{})){let l={};for(let[p,y]of Object.entries(s.messages)){let g=y.schema.dereference(o);l[p]={...y,schema:g}}let f=t.channels?.[i]?.name??i;r.channels[f]={...s,...t.channels?.[i]??{},message:{...s.message??{},tags:{...s.message?.tags??{},...t.channels?.[i]?.message?.tags??{}}},conversation:{...s.conversation??{},tags:{...s.conversation?.tags??{},...t.channels?.[i]?.conversation?.tags??{}}},messages:l},a.channels[i]={name:f}}return{resolved:r,statement:a}};C();R();O();var Ga=Symbol("schemaName"),Dh=t=>t?Le.mapValues(t,(n,r)=>({...n,[Ga]:r})):{},Hh=t=>Ga in t&&t[Ga]!==void 0,Uh=t=>t[Ga];C();R();O();var el=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.identifier=e.identifier,this.description=e.description,this.configuration=e.configuration,this.configurations=e.configurations,this.events=e.events,this.actions=e.actions,this.channels=e.channels,this.states=e.states,this.user=e.user,this.secrets=e.secrets,this.entities=e.entities,this.interfaces=e.interfaces,this.__advanced=e.__advanced,this.attributes=e.attributes}name;version;title;description;icon;readme;configuration;configurations;events;actions;channels;states;user;secrets;identifier;entities;interfaces;__advanced;attributes;extend(e,n){let{entities:r,actions:a,events:o,channels:i}=this._callBuilder(e,n),s=this;s.interfaces??={};let l=Object.values(r).map(g=>g.name),f=l.length===0?e.name:`${e.name}<${l.join(",")}>`,{resolved:p,statement:y}=Nh({...e,entities:r,actions:Le.stripUndefinedProps(a),events:Le.stripUndefinedProps(o),channels:Le.stripUndefinedProps(i)});return s.actions=Le.mergeRecords(s.actions??{},p.actions,this._mergeActions),s.channels=Le.mergeRecords(s.channels??{},p.channels,this._mergeChannels),s.events=Le.mergeRecords(s.events??{},p.events,this._mergeEvents),s.interfaces[f]={id:e.id,...y},this}_callBuilder(e,n){let a={entities:Dh(this.entities)},o=n(a),i=Le.pairs(o.entities).find(([l,f])=>!Hh(f));if(i)throw new Error(`Cannot extend interface "${e.name}" with entity "${i[0]}"; the provided schema is not part of the integration's entities.`);return{entities:Le.mapValues(o.entities,l=>({name:Uh(l),schema:l.schema})),actions:o.actions??{},events:o.events??{},channels:o.channels??{}}}_mergeActions=(e,n)=>({...e,...n,input:{schema:Vr(e.input.schema,n.input.schema)},output:{schema:Vr(e.output.schema,n.output.schema)}});_mergeEvents=(e,n)=>({...e,...n,schema:Vr(e.schema,n.schema)});_mergeChannels=(e,n)=>{let r=Le.mergeRecords(e.messages,n.messages,this._mergeMessage),a;(e.conversation||n.conversation)&&(a={tags:{...e.conversation?.tags,...n.conversation?.tags}});let o;return(e.message||n.message)&&(o={tags:{...e.message?.tags,...n.message?.tags}}),{...e,...n,messages:r,conversation:a,message:o}};_mergeMessage=(e,n)=>({schema:Vr(e.schema,n.schema)})};C();R();O();C();R();O();import{isApiError as xI,Client as PI,RuntimeError as wv,InvalidPayloadError as BI}from"@botpress/client";C();R();O();import*as Zh from"@botpress/client";var Va={retries:3,retryCondition:t=>Zh.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Gk(e.response?.headers??{})??t)*1e3},Gk=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let n of e){let r=t[n];if(r!==void 0)return Vk(String(r))}},Vk=t=>{let e=Jk(t)?Xk(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},Jk=t=>t.includes(" "),Xk=t=>{let e=Yk(t);if(!e)return;let n=new Date;return Math.max(0,Math.floor((e.getTime()-n.getTime())/1e3))},Yk=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};C();R();O();C();R();O();var ii=class{constructor(e){this._client=e}createConversation=e=>this._client.createConversation(e);getConversation=e=>this._client.getConversation(e);listConversations=e=>this._client.listConversations(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);updateConversation=e=>this._client.updateConversation(e);deleteConversation=e=>this._client.deleteConversation(e);listParticipants=e=>this._client.listParticipants(e);addParticipant=e=>this._client.addParticipant(e);getParticipant=e=>this._client.getParticipant(e);removeParticipant=e=>this._client.removeParticipant(e);createEvent=e=>this._client.createEvent(e);getEvent=e=>this._client.getEvent(e);listEvents=e=>this._client.listEvents(e);createMessage=e=>this._client.createMessage(e);getOrCreateMessage=e=>this._client.getOrCreateMessage(e);getMessage=e=>this._client.getMessage(e);updateMessage=e=>this._client.updateMessage(e);listMessages=e=>this._client.listMessages(e);deleteMessage=e=>this._client.deleteMessage(e);createUser=e=>this._client.createUser(e);getUser=e=>this._client.getUser(e);listUsers=e=>this._client.listUsers(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);updateUser=e=>this._client.updateUser(e);deleteUser=e=>this._client.deleteUser(e);getState=e=>this._client.getState(e);setState=e=>this._client.setState(e);getOrSetState=e=>this._client.getOrSetState(e);patchState=e=>this._client.patchState(e);configureIntegration=e=>this._client.configureIntegration(e);uploadFile=e=>this._client.uploadFile(e);upsertFile=e=>this._client.upsertFile(e);deleteFile=e=>this._client.deleteFile(e);listFiles=e=>this._client.listFiles(e);getFile=e=>this._client.getFile(e);updateFileMetadata=e=>this._client.updateFileMetadata(e);trackAnalytics=e=>this._client.trackAnalytics(e)};C();R();O();var Ja=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};C();R();O();C();R();O();var fn="#";var ER=Y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),$h=t=>{let e=t[wa],n=t[Oy],r=t[Ry],a=t[My],o=t[Ny],i=t[xa],s=t[Pa];if(!e)throw new Error("Missing bot headers");if(!n)throw new Error("Missing bot user headers");if(!r)throw new Error("Missing integration headers");if(!a)throw new Error("Missing webhook headers");if(!i)throw new Error("Missing configuration headers");if(!s)throw new Error("Missing operation headers");return{botId:e,botUserId:n,integrationId:r,webhookId:a,operation:s,configurationType:o??null,configuration:i?JSON.parse(q.from(i,"base64").toString("utf-8")):{}}};C();R();O();C();R();O();C();R();O();C();R();O();var nl={},jh=!1;function wl(){return jh||(jh=!0,nl=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},n=Symbol("test"),r=Object(n);if(typeof n=="string"||Object.prototype.toString.call(n)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var a=42;e[n]=a;for(n in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==n||!Object.prototype.propertyIsEnumerable.call(e,n))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var i=Object.getOwnPropertyDescriptor(e,n);if(i.value!==a||i.enumerable!==!0)return!1}return!0}),nl}var rl={},Kh=!1;function Qk(){return Kh||(Kh=!0,rl=Error),rl}var il={},Lh=!1;function eI(){return Lh||(Lh=!0,il=EvalError),il}var al={},Fh=!1;function tI(){return Fh||(Fh=!0,al=RangeError),al}var ol={},Wh=!1;function nI(){return Wh||(Wh=!0,ol=ReferenceError),ol}var sl={},zh=!1;function lv(){return zh||(zh=!0,sl=SyntaxError),sl}var ll={},qh=!1;function Xa(){return qh||(qh=!0,ll=TypeError),ll}var ul={},Gh=!1;function rI(){return Gh||(Gh=!0,ul=URIError),ul}var cl={},Vh=!1;function iI(){if(Vh)return cl;Vh=!0;var t=typeof Symbol<"u"&&Symbol,e=wl();return cl=function(){return typeof t!="function"||typeof Symbol!="function"||typeof t("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},cl}var fl={},Jh=!1;function aI(){if(Jh)return fl;Jh=!0;var t={__proto__:null,foo:{}},e=Object;return fl=function(){return{__proto__:t}.foo===t.foo&&!(t instanceof e)},fl}var dl={},Xh=!1;function oI(){if(Xh)return dl;Xh=!0;var t="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,n=Math.max,r="[object Function]",a=function(l,f){for(var p=[],y=0;y<l.length;y+=1)p[y]=l[y];for(var g=0;g<f.length;g+=1)p[g+l.length]=f[g];return p},o=function(l,f){for(var p=[],y=f,g=0;y<l.length;y+=1,g+=1)p[g]=l[y];return p},i=function(s,l){for(var f="",p=0;p<s.length;p+=1)f+=s[p],p+1<s.length&&(f+=l);return f};return dl=function(l){var f=this;if(typeof f!="function"||e.apply(f)!==r)throw new TypeError(t+f);for(var p=o(arguments,1),y,g=function(){if(this instanceof y){var v=f.apply(this,a(p,arguments));return Object(v)===v?v:this}return f.apply(l,a(p,arguments))},h=n(0,f.length-p.length),w=[],P=0;P<h;P++)w[P]="$"+P;if(y=Function("binder","return function ("+i(w,",")+"){ return binder.apply(this,arguments); }")(g),f.prototype){var B=function(){};B.prototype=f.prototype,y.prototype=new B,B.prototype=null}return y},dl}var pl={},Yh=!1;function xl(){if(Yh)return pl;Yh=!0;var t=oI();return pl=Function.prototype.bind||t,pl}var gl={},Qh=!1;function sI(){if(Qh)return gl;Qh=!0;var t=Function.prototype.call,e=Object.prototype.hasOwnProperty,n=xl();return gl=n.call(t,e),gl}var yl={},ev=!1;function oi(){if(ev)return yl;ev=!0;var t,e=Qk(),n=eI(),r=tI(),a=nI(),o=lv(),i=Xa(),s=rI(),l=Function,f=function(Ue){try{return l('"use strict"; return ('+Ue+").constructor;")()}catch{}},p=Object.getOwnPropertyDescriptor;if(p)try{p({},"")}catch{p=null}var y=function(){throw new i},g=p?function(){try{return arguments.callee,y}catch{try{return p(arguments,"callee").get}catch{return y}}}():y,h=iI()(),w=aI()(),P=Object.getPrototypeOf||(w?function(Ue){return Ue.__proto__}:null),B={},v=typeof Uint8Array>"u"||!P?t:P(Uint8Array),E={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?t:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?t:ArrayBuffer,"%ArrayIteratorPrototype%":h&&P?P([][Symbol.iterator]()):t,"%AsyncFromSyncIteratorPrototype%":t,"%AsyncFunction%":B,"%AsyncGenerator%":B,"%AsyncGeneratorFunction%":B,"%AsyncIteratorPrototype%":B,"%Atomics%":typeof Atomics>"u"?t:Atomics,"%BigInt%":typeof BigInt>"u"?t:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?t:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?t:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?t:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":e,"%eval%":eval,"%EvalError%":n,"%Float32Array%":typeof Float32Array>"u"?t:Float32Array,"%Float64Array%":typeof Float64Array>"u"?t:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?t:FinalizationRegistry,"%Function%":l,"%GeneratorFunction%":B,"%Int8Array%":typeof Int8Array>"u"?t:Int8Array,"%Int16Array%":typeof Int16Array>"u"?t:Int16Array,"%Int32Array%":typeof Int32Array>"u"?t:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":h&&P?P(P([][Symbol.iterator]())):t,"%JSON%":typeof JSON=="object"?JSON:t,"%Map%":typeof Map>"u"?t:Map,"%MapIteratorPrototype%":typeof Map>"u"||!h||!P?t:P(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?t:Promise,"%Proxy%":typeof Proxy>"u"?t:Proxy,"%RangeError%":r,"%ReferenceError%":a,"%Reflect%":typeof Reflect>"u"?t:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?t:Set,"%SetIteratorPrototype%":typeof Set>"u"||!h||!P?t:P(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?t:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":h&&P?P(""[Symbol.iterator]()):t,"%Symbol%":h?Symbol:t,"%SyntaxError%":o,"%ThrowTypeError%":g,"%TypedArray%":v,"%TypeError%":i,"%Uint8Array%":typeof Uint8Array>"u"?t:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?t:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?t:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?t:Uint32Array,"%URIError%":s,"%WeakMap%":typeof WeakMap>"u"?t:WeakMap,"%WeakRef%":typeof WeakRef>"u"?t:WeakRef,"%WeakSet%":typeof WeakSet>"u"?t:WeakSet};if(P)try{null.error}catch(Ue){var S=P(P(Ue));E["%Error.prototype%"]=S}var H=function Ue(Pe){var Ee;if(Pe==="%AsyncFunction%")Ee=f("async function () {}");else if(Pe==="%GeneratorFunction%")Ee=f("function* () {}");else if(Pe==="%AsyncGeneratorFunction%")Ee=f("async function* () {}");else if(Pe==="%AsyncGenerator%"){var fe=Ue("%AsyncGeneratorFunction%");fe&&(Ee=fe.prototype)}else if(Pe==="%AsyncIteratorPrototype%"){var ve=Ue("%AsyncGenerator%");ve&&P&&(Ee=P(ve.prototype))}return E[Pe]=Ee,Ee},K={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ae=xl(),ee=sI(),ge=ae.call(Function.call,Array.prototype.concat),oe=ae.call(Function.apply,Array.prototype.splice),re=ae.call(Function.call,String.prototype.replace),Oe=ae.call(Function.call,String.prototype.slice),ze=ae.call(Function.call,RegExp.prototype.exec),tt=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Ve=/\\(\\)?/g,Je=function(Pe){var Ee=Oe(Pe,0,1),fe=Oe(Pe,-1);if(Ee==="%"&&fe!=="%")throw new o("invalid intrinsic syntax, expected closing `%`");if(fe==="%"&&Ee!=="%")throw new o("invalid intrinsic syntax, expected opening `%`");var ve=[];return re(Pe,tt,function(D,j,F,de){ve[ve.length]=F?re(de,Ve,"$1"):j||D}),ve},mt=function(Pe,Ee){var fe=Pe,ve;if(ee(K,fe)&&(ve=K[fe],fe="%"+ve[0]+"%"),ee(E,fe)){var D=E[fe];if(D===B&&(D=H(fe)),typeof D>"u"&&!Ee)throw new i("intrinsic "+Pe+" exists, but is not available. Please file an issue!");return{alias:ve,name:fe,value:D}}throw new o("intrinsic "+Pe+" does not exist!")};return yl=function(Pe,Ee){if(typeof Pe!="string"||Pe.length===0)throw new i("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof Ee!="boolean")throw new i('"allowMissing" argument must be a boolean');if(ze(/^%?[^%]*%?$/,Pe)===null)throw new o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var fe=Je(Pe),ve=fe.length>0?fe[0]:"",D=mt("%"+ve+"%",Ee),j=D.name,F=D.value,de=!1,Te=D.alias;Te&&(ve=Te[0],oe(fe,ge([0,1],Te)));for(var A=1,k=!0;A<fe.length;A+=1){var $=fe[A],X=Oe($,0,1),ie=Oe($,-1);if((X==='"'||X==="'"||X==="`"||ie==='"'||ie==="'"||ie==="`")&&X!==ie)throw new o("property names with quotes must have matching quotes");if(($==="constructor"||!k)&&(de=!0),ve+="."+$,j="%"+ve+"%",ee(E,j))F=E[j];else if(F!=null){if(!($ in F)){if(!Ee)throw new i("base intrinsic for "+Pe+" exists, but the property is not available.");return}if(p&&A+1>=fe.length){var _=p(F,$);k=!!_,k&&"get"in _&&!("originalValue"in _.get)?F=_.get:F=F[$]}else k=ee(F,$),F=F[$];k&&!de&&(E[j]=F)}}return F},yl}var ml={},tv=!1;function Pl(){if(tv)return ml;tv=!0;var t=oi(),e=t("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch{e=!1}return ml=e,ml}var hl={},nv=!1;function Ya(){if(nv)return hl;nv=!0;var t=oi(),e=t("%Object.getOwnPropertyDescriptor%",!0);if(e)try{e([],"length")}catch{e=null}return hl=e,hl}var vl={},rv=!1;function lI(){if(rv)return vl;rv=!0;var t=Pl(),e=lv(),n=Xa(),r=Ya();return vl=function(o,i,s){if(!o||typeof o!="object"&&typeof o!="function")throw new n("`obj` must be an object or a function`");if(typeof i!="string"&&typeof i!="symbol")throw new n("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new n("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new n("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new n("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new n("`loose`, if provided, must be a boolean");var l=arguments.length>3?arguments[3]:null,f=arguments.length>4?arguments[4]:null,p=arguments.length>5?arguments[5]:null,y=arguments.length>6?arguments[6]:!1,g=!!r&&r(o,i);if(t)t(o,i,{configurable:p===null&&g?g.configurable:!p,enumerable:l===null&&g?g.enumerable:!l,value:s,writable:f===null&&g?g.writable:!f});else if(y||!l&&!f&&!p)o[i]=s;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},vl}var Tl={},iv=!1;function uI(){if(iv)return Tl;iv=!0;var t=Pl(),e=function(){return!!t};return e.hasArrayLengthDefineBug=function(){if(!t)return null;try{return t([],"length",{value:1}).length!==1}catch{return!0}},Tl=e,Tl}var _l={},av=!1;function cI(){if(av)return _l;av=!0;var t=oi(),e=lI(),n=uI()(),r=Ya(),a=Xa(),o=t("%Math.floor%");return _l=function(s,l){if(typeof s!="function")throw new a("`fn` is not a function");if(typeof l!="number"||l<0||l>4294967295||o(l)!==l)throw new a("`length` must be a positive 32-bit integer");var f=arguments.length>2&&!!arguments[2],p=!0,y=!0;if("length"in s&&r){var g=r(s,"length");g&&!g.configurable&&(p=!1),g&&!g.writable&&(y=!1)}return(p||y||!f)&&(n?e(s,"length",l,!0,!0):e(s,"length",l)),s},_l}var ai={},ov=!1;function Bl(){if(ov)return ai;ov=!0;var t=xl(),e=oi(),n=cI(),r=Xa(),a=e("%Function.prototype.apply%"),o=e("%Function.prototype.call%"),i=e("%Reflect.apply%",!0)||t.call(o,a),s=Pl(),l=e("%Math.max%");ai=function(y){if(typeof y!="function")throw new r("a function is required");var g=i(t,o,arguments);return n(g,1+l(0,y.length-(arguments.length-1)),!0)};var f=function(){return i(t,a,arguments)};return s?s(ai,"apply",{value:f}):ai.apply=f,ai}var bl={},sv=!1;function Sl(){if(sv)return bl;sv=!0;var t=oi(),e=Bl(),n=e(t("String.prototype.indexOf"));return bl=function(a,o){var i=t(a,!!o);return typeof i=="function"&&n(a,".prototype.")>-1?e(i):i},bl}is();bs();var El={},uv=!1;function Hl(){if(uv)return El;uv=!0;var t=wl();return El=function(){return t()&&!!Symbol.toStringTag},El}var kl={},cv=!1;function fI(){if(cv)return kl;cv=!0;var t=Hl()(),e=Sl(),n=e("Object.prototype.toString"),r=function(s){return t&&s&&typeof s=="object"&&Symbol.toStringTag in s?!1:n(s)==="[object Arguments]"},a=function(s){return r(s)?!0:s!==null&&typeof s=="object"&&typeof s.length=="number"&&s.length>=0&&n(s)!=="[object Array]"&&n(s.callee)==="[object Function]"},o=function(){return r(arguments)}();return r.isLegacyArguments=a,kl=o?r:a,kl}var Il={},fv=!1;function dI(){if(fv)return Il;fv=!0;var t=Object.prototype.toString,e=Function.prototype.toString,n=/^\s*(?:function)?\*/,r=Hl()(),a=Object.getPrototypeOf,o=function(){if(!r)return!1;try{return Function("return function*() {}")()}catch{}},i;return Il=function(l){if(typeof l!="function")return!1;if(n.test(e.call(l)))return!0;if(!r){var f=t.call(l);return f==="[object GeneratorFunction]"}if(!a)return!1;if(typeof i>"u"){var p=o();i=p?a(p):!1}return a(l)===i},Il}var Al={},dv=!1;function pI(){if(dv)return Al;dv=!0;var t=Function.prototype.toString,e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,n,r;if(typeof e=="function"&&typeof Object.defineProperty=="function")try{n=Object.defineProperty({},"length",{get:function(){throw r}}),r={},e(function(){throw 42},null,n)}catch(E){E!==r&&(e=null)}else e=null;var a=/^\s*class\b/,o=function(S){try{var H=t.call(S);return a.test(H)}catch{return!1}},i=function(S){try{return o(S)?!1:(t.call(S),!0)}catch{return!1}},s=Object.prototype.toString,l="[object Object]",f="[object Function]",p="[object GeneratorFunction]",y="[object HTMLAllCollection]",g="[object HTML document.all class]",h="[object HTMLCollection]",w=typeof Symbol=="function"&&!!Symbol.toStringTag,P=!(0 in[,]),B=function(){return!1};if(typeof document=="object"){var v=document.all;s.call(v)===s.call(document.all)&&(B=function(S){if((P||!S)&&(typeof S>"u"||typeof S=="object"))try{var H=s.call(S);return(H===y||H===g||H===h||H===l)&&S("")==null}catch{}return!1})}return Al=e?function(S){if(B(S))return!0;if(!S||typeof S!="function"&&typeof S!="object")return!1;try{e(S,null,n)}catch(H){if(H!==r)return!1}return!o(S)&&i(S)}:function(S){if(B(S))return!0;if(!S||typeof S!="function"&&typeof S!="object")return!1;if(w)return i(S);if(o(S))return!1;var H=s.call(S);return H!==f&&H!==p&&!/^\[object HTML/.test(H)?!1:i(S)},Al}var Cl={},pv=!1;function gI(){if(pv)return Cl;pv=!0;var t=pI(),e=Object.prototype.toString,n=Object.prototype.hasOwnProperty,r=function(l,f,p){for(var y=0,g=l.length;y<g;y++)n.call(l,y)&&(p==null?f(l[y],y,l):f.call(p,l[y],y,l))},a=function(l,f,p){for(var y=0,g=l.length;y<g;y++)p==null?f(l.charAt(y),y,l):f.call(p,l.charAt(y),y,l)},o=function(l,f,p){for(var y in l)n.call(l,y)&&(p==null?f(l[y],y,l):f.call(p,l[y],y,l))},i=function(l,f,p){if(!t(f))throw new TypeError("iterator must be a function");var y;arguments.length>=3&&(y=p),e.call(l)==="[object Array]"?r(l,f,y):typeof l=="string"?a(l,f,y):o(l,f,y)};return Cl=i,Cl}var Ol={},gv=!1;function yI(){return gv||(gv=!0,Ol=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),Ol}var Rl={},yv=!1,mI=typeof globalThis<"u"?globalThis:typeof self<"u"?self:global;function hI(){if(yv)return Rl;yv=!0;var t=yI(),e=typeof globalThis>"u"?mI:globalThis;return Rl=function(){for(var r=[],a=0;a<t.length;a++)typeof e[t[a]]=="function"&&(r[r.length]=t[a]);return r},Rl}var Ml={},mv=!1,vI=typeof globalThis<"u"?globalThis:typeof self<"u"?self:global;function bv(){if(mv)return Ml;mv=!0;var t=gI(),e=hI(),n=Bl(),r=Sl(),a=Ya(),o=r("Object.prototype.toString"),i=Hl()(),s=typeof globalThis>"u"?vI:globalThis,l=e(),f=r("String.prototype.slice"),p=Object.getPrototypeOf,y=r("Array.prototype.indexOf",!0)||function(B,v){for(var E=0;E<B.length;E+=1)if(B[E]===v)return E;return-1},g={__proto__:null};i&&a&&p?t(l,function(P){var B=new s[P];if(Symbol.toStringTag in B){var v=p(B),E=a(v,Symbol.toStringTag);if(!E){var S=p(v);E=a(S,Symbol.toStringTag)}g["$"+P]=n(E.get)}}):t(l,function(P){var B=new s[P],v=B.slice||B.set;v&&(g["$"+P]=n(v))});var h=function(B){var v=!1;return t(g,function(E,S){if(!v)try{"$"+E(B)===S&&(v=f(S,1))}catch{}}),v},w=function(B){var v=!1;return t(g,function(E,S){if(!v)try{E(B),v=f(S,1)}catch{}}),v};return Ml=function(B){if(!B||typeof B!="object")return!1;if(!i){var v=f(o(B),8,-1);return y(l,v)>-1?v:v!=="Object"?!1:w(B)}return a?h(B):null},Ml}var Nl={},hv=!1;function TI(){if(hv)return Nl;hv=!0;var t=bv();return Nl=function(n){return!!t(n)},Nl}var we={},vv=!1;function _I(){if(vv)return we;vv=!0;var t=fI(),e=dI(),n=bv(),r=TI();function a(Z){return Z.call.bind(Z)}var o=typeof BigInt<"u",i=typeof Symbol<"u",s=a(Object.prototype.toString),l=a(Number.prototype.valueOf),f=a(String.prototype.valueOf),p=a(Boolean.prototype.valueOf);if(o)var y=a(BigInt.prototype.valueOf);if(i)var g=a(Symbol.prototype.valueOf);function h(Z,kt){if(typeof Z!="object")return!1;try{return kt(Z),!0}catch{return!1}}we.isArgumentsObject=t,we.isGeneratorFunction=e,we.isTypedArray=r;function w(Z){return typeof Promise<"u"&&Z instanceof Promise||Z!==null&&typeof Z=="object"&&typeof Z.then=="function"&&typeof Z.catch=="function"}we.isPromise=w;function P(Z){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(Z):r(Z)||D(Z)}we.isArrayBufferView=P;function B(Z){return n(Z)==="Uint8Array"}we.isUint8Array=B;function v(Z){return n(Z)==="Uint8ClampedArray"}we.isUint8ClampedArray=v;function E(Z){return n(Z)==="Uint16Array"}we.isUint16Array=E;function S(Z){return n(Z)==="Uint32Array"}we.isUint32Array=S;function H(Z){return n(Z)==="Int8Array"}we.isInt8Array=H;function K(Z){return n(Z)==="Int16Array"}we.isInt16Array=K;function ae(Z){return n(Z)==="Int32Array"}we.isInt32Array=ae;function ee(Z){return n(Z)==="Float32Array"}we.isFloat32Array=ee;function ge(Z){return n(Z)==="Float64Array"}we.isFloat64Array=ge;function oe(Z){return n(Z)==="BigInt64Array"}we.isBigInt64Array=oe;function re(Z){return n(Z)==="BigUint64Array"}we.isBigUint64Array=re;function Oe(Z){return s(Z)==="[object Map]"}Oe.working=typeof Map<"u"&&Oe(new Map);function ze(Z){return typeof Map>"u"?!1:Oe.working?Oe(Z):Z instanceof Map}we.isMap=ze;function tt(Z){return s(Z)==="[object Set]"}tt.working=typeof Set<"u"&&tt(new Set);function Ve(Z){return typeof Set>"u"?!1:tt.working?tt(Z):Z instanceof Set}we.isSet=Ve;function Je(Z){return s(Z)==="[object WeakMap]"}Je.working=typeof WeakMap<"u"&&Je(new WeakMap);function mt(Z){return typeof WeakMap>"u"?!1:Je.working?Je(Z):Z instanceof WeakMap}we.isWeakMap=mt;function Ue(Z){return s(Z)==="[object WeakSet]"}Ue.working=typeof WeakSet<"u"&&Ue(new WeakSet);function Pe(Z){return Ue(Z)}we.isWeakSet=Pe;function Ee(Z){return s(Z)==="[object ArrayBuffer]"}Ee.working=typeof ArrayBuffer<"u"&&Ee(new ArrayBuffer);function fe(Z){return typeof ArrayBuffer>"u"?!1:Ee.working?Ee(Z):Z instanceof ArrayBuffer}we.isArrayBuffer=fe;function ve(Z){return s(Z)==="[object DataView]"}ve.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&ve(new DataView(new ArrayBuffer(1),0,1));function D(Z){return typeof DataView>"u"?!1:ve.working?ve(Z):Z instanceof DataView}we.isDataView=D;var j=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function F(Z){return s(Z)==="[object SharedArrayBuffer]"}function de(Z){return typeof j>"u"?!1:(typeof F.working>"u"&&(F.working=F(new j)),F.working?F(Z):Z instanceof j)}we.isSharedArrayBuffer=de;function Te(Z){return s(Z)==="[object AsyncFunction]"}we.isAsyncFunction=Te;function A(Z){return s(Z)==="[object Map Iterator]"}we.isMapIterator=A;function k(Z){return s(Z)==="[object Set Iterator]"}we.isSetIterator=k;function $(Z){return s(Z)==="[object Generator]"}we.isGeneratorObject=$;function X(Z){return s(Z)==="[object WebAssembly.Module]"}we.isWebAssemblyCompiledModule=X;function ie(Z){return h(Z,l)}we.isNumberObject=ie;function _(Z){return h(Z,f)}we.isStringObject=_;function x(Z){return h(Z,p)}we.isBooleanObject=x;function z(Z){return o&&h(Z,y)}we.isBigIntObject=z;function Q(Z){return i&&h(Z,g)}we.isSymbolObject=Q;function Me(Z){return ie(Z)||_(Z)||x(Z)||z(Z)||Q(Z)}we.isBoxedPrimitive=Me;function _e(Z){return typeof Uint8Array<"u"&&(fe(Z)||de(Z))}return we.isAnyArrayBuffer=_e,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(Z){Object.defineProperty(we,Z,{enumerable:!1,value:function(){throw new Error(Z+" is not supported in userland")}})}),we}var Dl={},Tv=!1;function bI(){return Tv||(Tv=!0,Dl=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"}),Dl}var xe={},_v=!1,si=typeof globalThis<"u"?globalThis:typeof self<"u"?self:global;function wI(){if(_v)return xe;_v=!0;var t=At,e=Object.getOwnPropertyDescriptors||function(j){for(var F=Object.keys(j),de={},Te=0;Te<F.length;Te++)de[F[Te]]=Object.getOwnPropertyDescriptor(j,F[Te]);return de},n=/%[sdj%]/g;xe.format=function(D){if(!K(D)){for(var j=[],F=0;F<arguments.length;F++)j.push(i(arguments[F]));return j.join(" ")}for(var F=1,de=arguments,Te=de.length,A=String(D).replace(n,function($){if($==="%%")return"%";if(F>=Te)return $;switch($){case"%s":return String(de[F++]);case"%d":return Number(de[F++]);case"%j":try{return JSON.stringify(de[F++])}catch{return"[Circular]"}default:return $}}),k=de[F];F<Te;k=de[++F])E(k)||!oe(k)?A+=" "+k:A+=" "+i(k);return A},xe.deprecate=function(D,j){if(typeof t<"u"&&t.noDeprecation===!0)return D;if(typeof t>"u")return function(){return xe.deprecate(D,j).apply(this||si,arguments)};var F=!1;function de(){if(!F){if(t.throwDeprecation)throw new Error(j);t.traceDeprecation?console.trace(j):console.error(j),F=!0}return D.apply(this||si,arguments)}return de};var r={},a=/^$/;if(t.env.NODE_DEBUG){var o=t.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),a=new RegExp("^"+o+"$","i")}xe.debuglog=function(D){if(D=D.toUpperCase(),!r[D])if(a.test(D)){var j=t.pid;r[D]=function(){var F=xe.format.apply(xe,arguments);console.error("%s %d: %s",D,j,F)}}else r[D]=function(){};return r[D]};function i(D,j){var F={seen:[],stylize:l};return arguments.length>=3&&(F.depth=arguments[2]),arguments.length>=4&&(F.colors=arguments[3]),v(j)?F.showHidden=j:j&&xe._extend(F,j),ee(F.showHidden)&&(F.showHidden=!1),ee(F.depth)&&(F.depth=2),ee(F.colors)&&(F.colors=!1),ee(F.customInspect)&&(F.customInspect=!0),F.colors&&(F.stylize=s),p(F,D,F.depth)}xe.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function s(D,j){var F=i.styles[j];return F?"\x1B["+i.colors[F][0]+"m"+D+"\x1B["+i.colors[F][1]+"m":D}function l(D,j){return D}function f(D){var j={};return D.forEach(function(F,de){j[F]=!0}),j}function p(D,j,F){if(D.customInspect&&j&&ze(j.inspect)&&j.inspect!==xe.inspect&&!(j.constructor&&j.constructor.prototype===j)){var de=j.inspect(F,D);return K(de)||(de=p(D,de,F)),de}var Te=y(D,j);if(Te)return Te;var A=Object.keys(j),k=f(A);if(D.showHidden&&(A=Object.getOwnPropertyNames(j)),Oe(j)&&(A.indexOf("message")>=0||A.indexOf("description")>=0))return g(j);if(A.length===0){if(ze(j)){var $=j.name?": "+j.name:"";return D.stylize("[Function"+$+"]","special")}if(ge(j))return D.stylize(RegExp.prototype.toString.call(j),"regexp");if(re(j))return D.stylize(Date.prototype.toString.call(j),"date");if(Oe(j))return g(j)}var X="",ie=!1,_=["{","}"];if(B(j)&&(ie=!0,_=["[","]"]),ze(j)){var x=j.name?": "+j.name:"";X=" [Function"+x+"]"}if(ge(j)&&(X=" "+RegExp.prototype.toString.call(j)),re(j)&&(X=" "+Date.prototype.toUTCString.call(j)),Oe(j)&&(X=" "+g(j)),A.length===0&&(!ie||j.length==0))return _[0]+X+_[1];if(F<0)return ge(j)?D.stylize(RegExp.prototype.toString.call(j),"regexp"):D.stylize("[Object]","special");D.seen.push(j);var z;return ie?z=h(D,j,F,k,A):z=A.map(function(Q){return w(D,j,F,k,Q,ie)}),D.seen.pop(),P(z,X,_)}function y(D,j){if(ee(j))return D.stylize("undefined","undefined");if(K(j)){var F="'"+JSON.stringify(j).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return D.stylize(F,"string")}if(H(j))return D.stylize(""+j,"number");if(v(j))return D.stylize(""+j,"boolean");if(E(j))return D.stylize("null","null")}function g(D){return"["+Error.prototype.toString.call(D)+"]"}function h(D,j,F,de,Te){for(var A=[],k=0,$=j.length;k<$;++k)Pe(j,String(k))?A.push(w(D,j,F,de,String(k),!0)):A.push("");return Te.forEach(function(X){X.match(/^\d+$/)||A.push(w(D,j,F,de,X,!0))}),A}function w(D,j,F,de,Te,A){var k,$,X;if(X=Object.getOwnPropertyDescriptor(j,Te)||{value:j[Te]},X.get?X.set?$=D.stylize("[Getter/Setter]","special"):$=D.stylize("[Getter]","special"):X.set&&($=D.stylize("[Setter]","special")),Pe(de,Te)||(k="["+Te+"]"),$||(D.seen.indexOf(X.value)<0?(E(F)?$=p(D,X.value,null):$=p(D,X.value,F-1),$.indexOf(`
79
+ `,a+="})"}let o=n?a?n+a:r?r==="z.never()"?n+".strict()":n+`.catchall(${r})`:n:a||(r?`z.record(${r})`:"z.record(z.any())");return Xe.an.anyOf(t)&&(o+=`.and(${zg(N(b({},t),{anyOf:t.anyOf.map(i=>typeof i=="object"&&!i.type&&(i.properties||i.additionalProperties||i.patternProperties)?N(b({},i),{type:"object"}):i)}),e)})`),Xe.a.oneOf(t)&&(o+=`.and(${ts(N(b({},t),{oneOf:t.oneOf.map(i=>typeof i=="object"&&!i.type&&(i.properties||i.additionalProperties||i.patternProperties)?N(b({},i),{type:"object"}):i)}),e)})`),Xe.an.allOf(t)&&(o+=`.and(${zr(N(b({},t),{allOf:t.allOf.map(i=>typeof i=="object"&&!i.type&&(i.properties||i.additionalProperties||i.patternProperties)?N(b({},i),{type:"object"}):i)}),e)})`),o}d(qg,"parseObject");var qP=d(t=>{var e;let n="z.string()";if((e=t[le])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";n="z.coerce.string()"}return n+=ut(t,"format",({value:r})=>{switch(r){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime(",")"]}}),n+=ut(t,"pattern",({json:r})=>[`.regex(new RegExp(${r})`,", ",")"]),n+=ut(t,"minLength",({json:r})=>[`.min(${r}`,", ",")"]),n+=ut(t,"maxLength",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseString"),GP=d((t,e)=>`${it($P(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),VP=d(t=>`z.ref('${t.$ref}')`,"parseRef"),JP=d((t,e)=>{var n,r;if(t.oneOf.length<=1||!((n=t.discriminator)!=null&&n.propertyName))return ts(t,e);let a=t.oneOf.map((o,i)=>it(o,N(b({},e),{path:[...e.path,"oneOf",i]})));return`z.discriminatedUnion("${(r=t.discriminator)==null?void 0:r.propertyName}", [${a.join(", ")}])`},"parseDiscriminator"),it=d((t,e={seen:new Map,path:[]},n)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let o=e.parserOverride(t,e);if(typeof o=="string")return o}let r=e.seen.get(t);if(r){if(r.r!==void 0)return r.r;if(e.depth===void 0||r.n>=e.depth)return"z.any()";r.n+=1}else r={r:void 0,n:0},e.seen.set(t,r);let a=QP(t,e);return n||(a=XP(t,a),e.withoutDefaults||(a=YP(t,a))),r.r=a,a},"parseSchema"),XP=d((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),YP=d((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),QP=d((t,e)=>Xe.a.nullable(t)?GP(t,e):Xe.an.object(t)?qg(t,e):Xe.an.array(t)?KP(t,e):Xe.an.anyOf(t)?zg(t,e):Xe.an.allOf(t)?zr(t,e):Xe.a.discriminator(t)?JP(t,e):Xe.a.oneOf(t)?ts(t,e):Xe.a.not(t)?HP(t,e):Xe.an.enum(t)?FP(t):Xe.a.const(t)?LP(t):Xe.a.multipleType(t)?DP(t,e):Xe.a.primitive(t,"string")?qP(t):Xe.a.primitive(t,"number")||Xe.a.primitive(t,"integer")?zP(t):Xe.a.primitive(t,"boolean")?MP(t):Xe.a.primitive(t,"null")?UP(t):Xe.a.conditional(t)?WP(t,e):Xe.a.ref(t)?VP(t):NP(t),"selectParser"),Xe={an:{object:d(t=>t.type==="object","object"),array:d(t=>t.type==="array","array"),anyOf:d(t=>t.anyOf!==void 0,"anyOf"),allOf:d(t=>t.allOf!==void 0,"allOf"),enum:d(t=>t.enum!==void 0,"enum")},a:{nullable:d(t=>t.nullable===!0,"nullable"),multipleType:d(t=>Array.isArray(t.type),"multipleType"),not:d(t=>t.not!==void 0,"not"),const:d(t=>t.const!==void 0,"const"),primitive:d((t,e)=>t.type===e,"primitive"),conditional:d(t=>Boolean("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),"conditional"),discriminator:d(t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},"discriminator"),oneOf:d(t=>t.oneOf!==void 0,"oneOf"),ref:d(t=>t.$ref!==void 0,"ref")}},eB=d(t=>{let e;try{e=new Function("z",`return ${t}`)(M)}catch(n){return{sucess:!1,error:`Failed to evaluate schema: ${(n instanceof Error?n:new Error(String(n))).message}`}}return e instanceof M.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),tB=d(t=>it(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),nB=d(t=>{let e=tB(t);e=e.replaceAll("errors: z.ZodError[]","errors");let n=eB(e);if(!n.sucess)throw new sa(n.error);return n.value},"jsonSchemaToZod"),Nr=d((t,e)=>{var n,r;if(e[le]&&t._def&&(t._def[le]=e[le]),((n=t._def)==null?void 0:n.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([a,o])=>{let i=typeof t._def.shape=="function"?t._def.shape():t._def.shape;i[a]&&Nr(i[a],o)}),((r=t._def)==null?void 0:r.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Nr(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let a=e.items;if(typeof a=="object"&&!Array.isArray(a)){let o=t._def.type;o&&Nr(o,a)}else Array.isArray(a)&&a.forEach((o,i)=>{let s=t._def;s.typeName===Y.ZodFirstPartyTypeKind.ZodTuple&&Nr(s.items[i],o)})}},"applyZuiPropsRecursively"),rB=d(t=>{let e=nB(t);return Nr(e,t),e},"fromJSONSchemaLegacy"),iB=d(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&Gg(r))&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===M.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),aB=d(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&r.type==="null")&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===M.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),Gg=d(t=>{var e,n;return t.not===!0&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===M.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),oB=d(t=>{var e,n;return!t.not&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===M.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),sB=d(({type:t,minimum:e,exclusiveMinimum:n,maximum:r,exclusiveMaximum:a,multipleOf:o,format:i})=>{let s=M.number();return t==="integer"&&(s=s.int()),i==="finite"&&(s=s.finite()),n!==void 0?s=s.gt(n):e!==void 0&&(s=s.gte(e)),a!==void 0?s=s.lt(a):r!==void 0&&(s=s.lte(r)),o!==void 0&&(s=s.multipleOf(o)),s},"numberJSONSchemaToZuiNumber"),lB=d(({format:t,pattern:e,minLength:n,maxLength:r})=>{let a=M.string();if(n&&r&&n===r?a=a.length(n):(n&&(a=a.min(n)),r&&(a=a.max(r))),t==="cuid"||e===Ye.cuid)a=a.cuid();else if(t==="cuid2"||e===Ye.cuid2)a=a.cuid2();else if(t==="emoji"||e===Ye.emoji)a=a.emoji();else if(t==="ulid"||e===Ye.ulid)a=a.ulid();else if(t==="date-time"){let{precision:o,offset:i}=e?bx(e):{};a=a.datetime({precision:o,offset:i})}else t==="email"||e===Ye.email?a=a.email():t==="ipv4"||e===Ye.ipv4?a=a.ip():t==="ipv6"||e===Ye.ipv6?a=a.ip("v6"):t==="uri"?a=a.url():t==="uuid"||e===Ye.uuid?a=a.uuid():e&&(a=a.regex(new RegExp(e)));return a},"stringJSONSchemaToZuiString"),xr=d((t,e)=>{let n=[];e.enum!==void 0&&n.push(...e.enum),e.const!==void 0&&n.push(e.const);let r=n.filter(i=>typeof i===t),[a]=r;if(!a){if(t==="string"&&e.type==="string")return lB(e);if(t==="number"&&(e.type==="number"||e.type==="integer"))return sB(e);if(t==="boolean")return M.boolean();if(t==="null")return M.null();throw new sa(`Unknown primitive type: "${t}"`)}if(r.length===1)return M.literal(a);let o=r.map(i=>M.literal(i));return M.union(o)},"toZuiPrimitive"),uB=d((t,e)=>cB(t)?dB(t,e):fB(t)?pB(t,e):gB(t,e),"arrayJSONSchemaToZuiArray"),cB=d(t=>Array.isArray(t.items),"_isTuple"),fB=d(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),dB=d(({items:t,additionalItems:e},n)=>{let r=t.map(n),a=M.tuple(r);return e!==void 0&&(a=a.rest(n(e))),a},"_handleTuple"),pB=d(({items:t,minItems:e,maxItems:n},r)=>{let a=M.set(r(t));return e&&(a=a.min(e)),n&&(a=a.max(n)),a},"_handleSet"),gB=d(({minItems:t,maxItems:e,items:n},r)=>{let a=M.array(r(n));return t&&t===e?a.length(t):(t&&(a=a.min(t)),e&&(a=a.max(e)),a)},"_handleArray"),qn=M.any();function Vg(t){return rt(t)}d(Vg,"fromJSONSchema");function rt(t){var e;if(t===void 0)return qn;if(t===!0)return M.any();if(t===!1)return M.never();if(t.default!==void 0)return rt(N(b({},t),{default:void 0})).default(t.default);if(t.readOnly)return rt(N(b({},t),{readOnly:void 0})).readonly();if(t.oneOf!==void 0)throw new nn({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new nn({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new nn({propertyNames:t.propertyNames});if(t.if!==void 0)throw new nn({if:t.if});if(t.then!==void 0)throw new nn({then:t.then});if(t.else!==void 0)throw new nn({else:t.else});if(t.$ref!==void 0)return M.ref(t.$ref);if(t.not!==void 0){if(Gg(t))return M.undefined();if(t.not===!0)return M.never();throw new nn({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return qn;if(t.type.length===1)return rt(N(b({},t),{type:t.type[0]}));let n=t,{type:r}=n,a=Qc(n,["type"]),o=t.type.map(i=>rt(N(b({},a),{type:i})));return M.union(o)}if(t.type==="string")return t.enum&&t.enum.length>0?M.enum(t.enum):xr("string",t);if(t.type==="integer"){let n=xr("number",t);return n instanceof M.ZodNumber?n.int():n}if(t.type==="number")return xr("number",t);if(t.type==="boolean")return xr("boolean",t);if(t.type==="null")return xr("null",t);if(t.type==="array")return uB(t,rt);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let n=rt(t.additionalProperties);return rt(N(b({},t),{additionalProperties:void 0})).catchall(n)}if(t.properties!==void 0){let n={};for(let[r,a]of Object.entries(t.properties)){let o=rt(a),i=(e=t.required)!=null?e:[];n[r]=i.includes(r)?o:o.optional()}return M.object(n)}if(t.additionalProperties!==void 0){let n=rt(t.additionalProperties);return M.record(n)}return M.record(qn)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return qn;if(t.anyOf.length===1)return rt(t.anyOf[0]);if(iB(t))return rt(t.anyOf[0]).optional();if(aB(t))return rt(t.anyOf[0]).nullable();let n=t.anyOf.map(rt);return M.union(n)}if(t.allOf!==void 0){if(t.allOf.length===0)return qn;if(t.allOf.length===1)return rt(t.allOf[0]);let[n,...r]=t.allOf,a=rt(n),o=rt({allOf:r});return M.intersection(a,o)}return oB(t)?M.unknown():qn}d(rt,"_fromJSONSchema");var yB=/^\d{4}-\d{2}-\d{2}(T|\s)?((\d{2}:\d{2}:\d{2}(\.\d{1,3})?)|(\d{2}:\d{2}))?(\s?([+-]\d{2}:\d{2}|Z))?$/,xo=d((t,e,n=!0)=>{if(typeof t!="object")throw new co("Input must be an object");let r=d(i=>{let s=i;return e?.nullable&&(s=s.nullable()),e?.optional&&(s=s.optional()),e?.passtrough&&typeof s.passthrough=="function"&&(s=s.passthrough()),s},"applyOptions"),a=Object.entries(t).reduce((i,[s,l])=>{if(l===null)i[s]=r(Y.null());else switch(typeof l){case"string":i[s]=yB.test(l)?r(Y.string().datetime()):r(Y.string());break;case"number":i[s]=r(Y.number());break;case"boolean":i[s]=r(Y.boolean());break;case"object":Array.isArray(l)?l.length===0?i[s]=r(Y.array(Y.unknown())):typeof l[0]=="object"?i[s]=r(Y.array(xo(l[0],e,!1))):["string","number","boolean"].includes(typeof l[0])&&(i[s]=r(Y.array(Y[typeof l[0]]()))):i[s]=r(xo(l,e,!1));break;default:throw new co(`Unsupported type for key ${s}`)}return i},{}),o=Object.keys(a).length>0;return e?.passtrough||!n&&!o?Y.object(a).passthrough():Y.object(a)},"fromObject");function Jg(){return{}}d(Jg,"parseAnyDef");function Xg(t,e){var n,r;let a={type:"array"};return((r=(n=t.type)==null?void 0:n._def)==null?void 0:r.typeName)!=="ZodAny"&&(a.items=Ie(t.type._def,N(b({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&Re(a,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&Re(a,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(Re(a,"minItems",t.exactLength.value,t.exactLength.message,e),Re(a,"maxItems",t.exactLength.value,t.exactLength.message,e)),a}d(Xg,"parseArrayDef");function Yg(t,e){let n=b({type:"integer",format:"int64"},t.coerce?{[le]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"?r.inclusive?Re(n,"minimum",r.value,r.message,e):Re(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),Re(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?Re(n,"maximum",r.value,r.message,e):Re(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),Re(n,"maximum",r.value,r.message,e));break;case"multipleOf":Re(n,"multipleOf",r.value,r.message,e);break}return n}d(Yg,"parseBigintDef");function Qg(t){return b({type:"boolean"},t.coerce?{[le]:{coerce:t.coerce||void 0}}:{})}d(Qg,"parseBooleanDef");function ey(t,e){return Ie(t.type._def,e)}d(ey,"parseBrandedDef");var mB=d((t,e)=>Ie(t.innerType._def,e),"parseCatchDef");function ty(t,e){return e.dateStrategy=="integer"?hB(t,e):b({type:"string",format:"date-time"},t.coerce?{[le]:{coerce:t.coerce||void 0}}:{})}d(ty,"parseDateDef");var hB=d((t,e)=>{let n=b({type:"integer",format:"unix-time"},t.coerce?{[le]:{coerce:t.coerce||void 0}}:{});for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"&&Re(n,"minimum",r.value,r.message,e);break;case"max":e.target==="jsonSchema7"&&Re(n,"maximum",r.value,r.message,e);break}return n},"integerDateParser");function ny(t,e){return N(b({},Ie(t.innerType._def,e)),{default:t.defaultValue()})}d(ny,"parseDefaultDef");function ry(t,e){return e.effectStrategy==="input"?Ie(t.schema._def,e):{}}d(ry,"parseEffectsDef");function iy(t){return{type:"string",enum:t.values}}d(iy,"parseEnumDef");var vB=d(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function ay(t,e){let n=[Ie(t.left._def,N(b({},e),{currentPath:[...e.currentPath,"allOf","0"]})),Ie(t.right._def,N(b({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(o=>!!o),r=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,a=[];return n.forEach(o=>{if(vB(o))a.push(...o.allOf),o.unevaluatedProperties===void 0&&(r=void 0);else{let i=o;if("additionalProperties"in o&&o.additionalProperties===!1){let s=o,{additionalProperties:l}=s;i=Qc(s,["additionalProperties"])}else r=void 0;a.push(i)}}),a.length?b({allOf:a},r):void 0}d(ay,"parseIntersectionDef");function oy(t,e){let n=typeof t.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:n==="bigint"?"integer":n,enum:[t.value]}:{type:n==="bigint"?"integer":n,const:t.value}}d(oy,"parseLiteralDef");function ns(t,e){var n,r,a,o,i;if(e.target==="openApi3"&&((n=t.keyType)==null?void 0:n._def.typeName)==="ZodEnum")return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((l,f)=>{var p;return N(b({},l),{[f]:(p=Ie(t.valueType._def,N(b({},e),{currentPath:[...e.currentPath,"properties",f]})))!=null?p:{}})},{}),additionalProperties:!1};let s={type:"object",additionalProperties:(r=Ie(t.valueType._def,N(b({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:{}};if(e.target==="openApi3")return s;if(((a=t.keyType)==null?void 0:a._def.typeName)==="ZodString"&&((o=t.keyType._def.checks)!=null&&o.length)){let l=Object.entries(Zo(t.keyType._def,e)).reduce((f,[p,y])=>p==="type"?f:N(b({},f),{[p]:y}),{});return N(b({},s),{propertyNames:l})}else if(((i=t.keyType)==null?void 0:i._def.typeName)==="ZodEnum")return N(b({},s),{propertyNames:{enum:t.keyType._def.values}});return s}d(ns,"parseRecordDef");function sy(t,e){if(e.mapStrategy==="record")return ns(t,e);let n=Ie(t.keyType._def,N(b({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},r=Ie(t.valueType._def,N(b({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}d(sy,"parseMapDef");function ly(t){let e=t.values,r=Object.keys(t.values).filter(o=>typeof e[e[o]]!="number").map(o=>e[o]),a=Array.from(new Set(r.map(o=>typeof o)));return{type:a.length===1?a[0]==="string"?"string":"number":["string","number"],enum:r.filter(o=>typeof o=="string"||typeof o=="number")}}d(ly,"parseNativeEnumDef");function uy(){return{not:{}}}d(uy,"parseNeverDef");function cy(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}d(cy,"parseNullDef");var aa={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function fy(t,e){if(e.target==="openApi3")return Vc(t,e);let n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in aa&&(!r._def.checks||!r._def.checks.length))){let r=n.reduce((a,o)=>{let i=aa[o._def.typeName];return i&&!a.includes(i)?[...a,i]:a},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){let r=n.reduce((a,o)=>{let i=typeof o._def.value;switch(i){case"string":case"number":case"boolean":return[...a,i];case"bigint":return[...a,"integer"];case"object":if(o._def.value===null)return[...a,"null"];case"symbol":case"undefined":case"function":default:return a}},[]);if(r.length===n.length){let a=r.filter((o,i,s)=>s.indexOf(o)===i);return{type:a.length>1?a:a[0],enum:n.reduce((o,i)=>o.includes(i._def.value)?o:[...o,i._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,a)=>[...r,...a._def.values.filter(o=>!r.includes(o))],[])};return Vc(t,e)}d(fy,"parseUnionDef");var Vc=d((t,e)=>{let n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((a,o)=>Ie(a._def,N(b({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${o}`]}))).filter(a=>!!a&&(!e.strictUnions||typeof a=="object"&&Object.keys(a).length>0)),r=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(n.length)return e.unionStrategy==="anyOf"?b({anyOf:n},r):b({oneOf:n},r)},"asUnionOf");function dy(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length)){let r=t.innerType;if(e.target==="openApi3"){let o={type:aa[r._def.typeName],nullable:!0};return Po(r._def,e,o)}let a={type:[aa[r._def.typeName],"null"]};return Po(r._def,e,a)}if(e.target==="openApi3"){let r=Ie(t.innerType._def,N(b({},e),{currentPath:[...e.currentPath]}));return r&&N(b({},r),{nullable:!0})}let n=Ie(t.innerType._def,N(b({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return n&&{anyOf:[n,{type:"null"}]}}d(dy,"parseNullableDef");function py(t,e){let n=b({type:"number"},t.coerce?{[le]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"int":n.type="integer",Uo(n,"type",r.message,e);break;case"min":e.target==="jsonSchema7"?r.inclusive?Re(n,"minimum",r.value,r.message,e):Re(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),Re(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?Re(n,"maximum",r.value,r.message,e):Re(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),Re(n,"maximum",r.value,r.message,e));break;case"multipleOf":Re(n,"multipleOf",r.value,r.message,e);break}return n}d(py,"parseNumberDef");var TB=d((t,e)=>{var n;return t.unknownKeys instanceof he?(n=Ie(t.unknownKeys._def,N(b({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function gy(t,e){let n=N(b({type:"object"},Object.entries(t.shape()).reduce((r,[a,o])=>{if(o===void 0||o._def===void 0)return r;let i=Ie(o._def,N(b({},e),{currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]}));return i===void 0?r:{properties:N(b({},r.properties),{[a]:i}),required:o.isOptional()?r.required:[...r.required,a]}},{properties:{},required:[]})),{additionalProperties:TB(t,e)});return n.required.length||delete n.required,n}d(gy,"parseObjectDef");var _B=d((t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return Ie(t.innerType._def,e);let r=Ie(t.innerType._def,N(b({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return r?{anyOf:[{not:{}},r]}:{}},"parseOptionalDef"),bB=d((t,e)=>{if(e.pipeStrategy==="input")return Ie(t.in._def,e);if(e.pipeStrategy==="output")return Ie(t.out._def,e);let n=Ie(t.in._def,N(b({},e),{currentPath:[...e.currentPath,"allOf","0"]})),r=Ie(t.out._def,N(b({},e),{currentPath:[...e.currentPath,"allOf",n?"1":"0"]}));return{allOf:[n,r].filter(a=>a!==void 0)}},"parsePipelineDef");function yy(t,e){return Ie(t.type._def,e)}d(yy,"parsePromiseDef");function my(t,e){let r={type:"array",uniqueItems:!0,items:Ie(t.valueType._def,N(b({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&Re(r,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&Re(r,"maxItems",t.maxSize.value,t.maxSize.message,e),r}d(my,"parseSetDef");function hy(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>Ie(n._def,N(b({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Ie(t.rest._def,N(b({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>Ie(n._def,N(b({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[])}}d(hy,"parseTupleDef");function vy(){return{not:{}}}d(vy,"parseUndefinedDef");function Ty(){return{}}d(Ty,"parseUnknownDef");var wB=d((t,e)=>Ie(t.innerType._def,e),"parseReadonlyDef");function _y(t){return{$ref:t.uri}}d(_y,"parseRefDef");function Ie(t,e,n=!1){let r=e.seen.get(t);if(r&&!n){let i=xB(r,e);if(i!==void 0)return i}let a={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,a);let o=BB(t,t.typeName,e);return o&&Po(t,e,o),a.jsonSchema=o,o}d(Ie,"parseDef");var xB=d((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:PB(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((n,r)=>e.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),PB=d((t,e)=>{let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];n++);return[(t.length-n).toString(),...e.slice(n)].join("/")},"getRelativePath"),BB=d((t,e,n)=>{switch(e){case"ZodString":return Zo(t,n);case"ZodNumber":return py(t,n);case"ZodObject":return gy(t,n);case"ZodBigInt":return Yg(t,n);case"ZodBoolean":return Qg(t);case"ZodDate":return ty(t,n);case"ZodUndefined":return vy();case"ZodNull":return cy(n);case"ZodArray":return Xg(t,n);case"ZodUnion":case"ZodDiscriminatedUnion":return fy(t,n);case"ZodIntersection":return ay(t,n);case"ZodTuple":return hy(t,n);case"ZodRecord":return ns(t,n);case"ZodRef":return _y(t);case"ZodLiteral":return oy(t,n);case"ZodEnum":return iy(t);case"ZodNativeEnum":return ly(t);case"ZodNullable":return dy(t,n);case"ZodOptional":return _B(t,n);case"ZodMap":return sy(t,n);case"ZodSet":return my(t,n);case"ZodLazy":return Ie(t.getter()._def,n);case"ZodPromise":return yy(t,n);case"ZodNaN":case"ZodNever":return uy();case"ZodEffects":return ry(t,n);case"ZodAny":return Jg();case"ZodUnknown":return Ty();case"ZodDefault":return ny(t,n);case"ZodBranded":return ey(t,n);case"ZodReadonly":return wB(t,n);case"ZodCatch":return mB(t,n);case"ZodPipeline":return bB(t,n);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(r=>{})(e)}},"selectParser"),Po=d((t,e,n)=>(t.description&&(n.description=t.description,e.markdownDescription&&(n.markdownDescription=t.description)),Object.assign(n,{[le]:b(b({},t[le]),n[le])}),n),"addMeta"),Jc={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"string",mapStrategy:"entries",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",emailStrategy:"format:email",discriminator:!1,unionStrategy:"anyOf"},SB=d(t=>typeof t=="string"?N(b({},Jc),{name:t}):b(b({},Jc),t),"getDefaultOptions"),EB=d(t=>{let e=SB(t),n=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return N(b({},e),{currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([r,a])=>[a._def,{def:a._def,path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))})},"getRefs"),kB=d((t,e)=>{var n;let r=EB(e),a=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((l,[f,p])=>{var y;return N(b({},l),{[f]:(y=Ie(p._def,N(b({},r),{currentPath:[...r.basePath,r.definitionPath,f]}),!0))!=null?y:{}})},{}):void 0,o=typeof e=="string"?e:e?.name,i=(n=Ie(t._def,o===void 0?r:N(b({},r),{currentPath:[...r.basePath,r.definitionPath,o]}),!1))!=null?n:{},s=o===void 0?a?N(b({},i),{[r.definitionPath]:a}):i:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,o].join("/"),[r.definitionPath]:N(b({},a),{[o]:i})};return r.target==="jsonSchema7"?s.$schema="http://json-schema.org/draft-07/schema#":r.target==="jsonSchema2019-09"&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),s},"zodToJsonSchema"),IB=d((t,e={target:"openApi3"})=>{let n=kB(t,e);return e.$schemaUrl===!1?delete n.$schema:typeof e.$schemaUrl=="string"&&(n.$schema=e.$schemaUrl),n},"toJSONSchemaLegacy");var Vr=(t,e)=>{let n=t._def,r=e._def;if(n.typeName===Y.ZodFirstPartyTypeKind.ZodObject&&r.typeName===Y.ZodFirstPartyTypeKind.ZodObject){let a=n.shape(),o=r.shape();return Y.object({...a,...o})}if(n.typeName===Y.ZodFirstPartyTypeKind.ZodRecord&&r.typeName===Y.ZodFirstPartyTypeKind.ZodRecord)return Y.record(Y.intersection(n.valueType,r.valueType));throw new Error("Cannot merge object schemas with record schemas")},by=Y;var yt=Y.string().min(1),xy=Y.object({text:yt}),Py=Y.object({markdown:yt}),By=Y.object({imageUrl:yt}),Sy=Y.object({audioUrl:yt}),Ey=Y.object({videoUrl:yt}),ky=Y.object({fileUrl:yt,title:yt.optional()}),Iy=Y.object({latitude:Y.number(),longitude:Y.number(),address:Y.string().optional(),title:Y.string().optional()}),Ay=Y.object({title:yt,subtitle:yt.optional(),imageUrl:yt.optional(),actions:Y.array(Y.object({action:Y.enum(["postback","url","say"]),label:yt,value:yt}))}),wy=Y.object({text:yt,options:Y.array(Y.object({label:yt,value:yt}))}),AB=Y.object({items:Y.array(Ay)}),CB=Y.union([Y.object({type:Y.literal("text"),payload:xy}),Y.object({type:Y.literal("markdown"),payload:Py}),Y.object({type:Y.literal("image"),payload:By}),Y.object({type:Y.literal("audio"),payload:Sy}),Y.object({type:Y.literal("video"),payload:Ey}),Y.object({type:Y.literal("file"),payload:ky}),Y.object({type:Y.literal("location"),payload:Iy})]),OB=Y.object({items:Y.array(CB)}),RB={schema:Py},MB={text:{schema:xy},image:{schema:By},audio:{schema:Sy},video:{schema:Ey},file:{schema:ky},location:{schema:Iy},carousel:{schema:AB},card:{schema:Ay},dropdown:{schema:wy},choice:{schema:wy},bloc:{schema:OB}};C();R();O();var wa="x-bot-id",Oy="x-bot-user-id",Ry="x-integration-id",My="x-webhook-id",Ny="x-bp-configuration-type",xa="x-bp-configuration",Pa="x-bp-operation",Dy="x-bp-type",QA={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};C();R();O();import{isNode as Nk}from"browser-or-node";C();R();O();var rs=console;function Ct(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function za(t,e=8072,n=Zk){if(!Nk)throw new Error("This function can only be called in Node.js");let a=(Mh(),$v(Rh)).createServer(async(o,i)=>{try{let s=await Dk(o);if(s.path==="/health"){i.writeHead(200).end("ok");return}let l=await t(s);i.writeHead(l?.status??200,l?.headers??{}).end(l?.body??"{}")}catch(s){rs.error("Error while handling request",{error:s?.message??"Internal error occured"}),i.writeHead(500).end(JSON.stringify({error:s?.message??"Internal error occured"}))}});return a.listen(e,()=>n(e)),a}async function Dk(t){let e=await Uk(t),n={};for(let a=0;a<t.rawHeaders.length;a+=2){let o=t.rawHeaders[a].toLowerCase(),i=t.rawHeaders[a+1];n[o]=i}let r=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:r.pathname,query:Hk(r.search,"?"),headers:n,method:t.method?.toUpperCase()??"GET"}}function Hk(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function Uk(t){return new Promise((e,n)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let r="";t.on("data",a=>r+=a.toString()),t.on("error",a=>n(a)),t.on("end",()=>e(r))})}function Zk(t){rs.info(`Listening on port ${t}`)}import{isApiError as rU,RuntimeError as iU}from"@botpress/client";C();R();O();C();R();O();C();R();O();C();R();O();var Le={};Wn(Le,{mapKeys:()=>Kk,mapValues:()=>jk,mergeRecords:()=>Fk,pairs:()=>qa,stripUndefinedProps:()=>Lk,values:()=>$k});C();R();O();var qa=t=>Object.entries(t),$k=t=>Object.values(t),jk=(t,e)=>Object.fromEntries(qa(t).map(([n,r])=>[n,e(r,n)])),Kk=(t,e)=>Object.fromEntries(qa(t).map(([n,r])=>[e(n),r])),Lk=t=>Object.fromEntries(qa(t).filter(([,e])=>e!==void 0)),Fk=(t,e,n)=>{let r=[...Object.keys(t),...Object.keys(e)],a=[...new Set(r)],o={};for(let i of a){let s=t[i],l=e[i];s&&l?o[i]=n(s,l):s?o[i]=s:l&&(o[i]=l)}return o};var ye={};Wn(ye,{safePush:()=>Wk,unique:()=>zk});C();R();O();var Wk=(t,...e)=>t?[...t,...e]:[...e],zk=t=>Array.from(new Set(t));C();R();O();var Qt={};Wn(Qt,{setName:()=>qk});C();R();O();var qk=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var Nh=t=>{let{name:e,version:n}=t,r={actions:{},events:{},channels:{}},a={name:e,version:n,entities:Le.mapValues(t.entities,i=>({name:i.name})),actions:{},events:{},channels:{}},o=Le.mapValues(t.entities,i=>i.schema);for(let[i,s]of Object.entries(t.definition.actions??{})){let l=s.input.schema.dereference(o),f=s.output.schema.dereference(o),p=t.actions?.[i]?.name??i;r.actions[p]={...s,...t.actions?.[i]??{},input:{schema:l},output:{schema:f}},a.actions[i]={name:p}}for(let[i,s]of Object.entries(t.definition.events??{})){let l=s.schema.dereference(o),f=t.events?.[i]?.name??i;r.events[f]={...s,...t.events?.[i]??{},schema:l},a.events[i]={name:f}}for(let[i,s]of Object.entries(t.definition.channels??{})){let l={};for(let[p,y]of Object.entries(s.messages)){let g=y.schema.dereference(o);l[p]={...y,schema:g}}let f=t.channels?.[i]?.name??i;r.channels[f]={...s,...t.channels?.[i]??{},message:{...s.message??{},tags:{...s.message?.tags??{},...t.channels?.[i]?.message?.tags??{}}},conversation:{...s.conversation??{},tags:{...s.conversation?.tags??{},...t.channels?.[i]?.conversation?.tags??{}}},messages:l},a.channels[i]={name:f}}return{resolved:r,statement:a}};C();R();O();var Ga=Symbol("schemaName"),Dh=t=>t?Le.mapValues(t,(n,r)=>({...n,[Ga]:r})):{},Hh=t=>Ga in t&&t[Ga]!==void 0,Uh=t=>t[Ga];C();R();O();var el=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.identifier=e.identifier,this.description=e.description,this.configuration=e.configuration,this.configurations=e.configurations,this.events=e.events,this.actions=e.actions,this.channels=e.channels,this.states=e.states,this.user=e.user,this.secrets=e.secrets,this.entities=e.entities,this.interfaces=e.interfaces,this.__advanced=e.__advanced,this.attributes=e.attributes}name;version;title;description;icon;readme;configuration;configurations;events;actions;channels;states;user;secrets;identifier;entities;interfaces;__advanced;attributes;extend(e,n){let{entities:r,actions:a,events:o,channels:i}=this._callBuilder(e,n),s=this;s.interfaces??={};let l=Object.values(r).map(g=>g.name),f=l.length===0?e.name:`${e.name}<${l.join(",")}>`,{resolved:p,statement:y}=Nh({...e,entities:r,actions:Le.stripUndefinedProps(a),events:Le.stripUndefinedProps(o),channels:Le.stripUndefinedProps(i)});return s.actions=Le.mergeRecords(s.actions??{},p.actions,this._mergeActions),s.channels=Le.mergeRecords(s.channels??{},p.channels,this._mergeChannels),s.events=Le.mergeRecords(s.events??{},p.events,this._mergeEvents),s.interfaces[f]={id:e.id,...y},this}_callBuilder(e,n){let a={entities:Dh(this.entities)},o=n(a),i=Le.pairs(o.entities).find(([l,f])=>!Hh(f));if(i)throw new Error(`Cannot extend interface "${e.name}" with entity "${i[0]}"; the provided schema is not part of the integration's entities.`);return{entities:Le.mapValues(o.entities,l=>({name:Uh(l),schema:l.schema})),actions:o.actions??{},events:o.events??{},channels:o.channels??{}}}_mergeActions=(e,n)=>({...e,...n,input:{schema:Vr(e.input.schema,n.input.schema)},output:{schema:Vr(e.output.schema,n.output.schema)}});_mergeEvents=(e,n)=>({...e,...n,schema:Vr(e.schema,n.schema)});_mergeChannels=(e,n)=>{let r=Le.mergeRecords(e.messages,n.messages,this._mergeMessage),a;(e.conversation||n.conversation)&&(a={tags:{...e.conversation?.tags,...n.conversation?.tags}});let o;return(e.message||n.message)&&(o={tags:{...e.message?.tags,...n.message?.tags}}),{...e,...n,messages:r,conversation:a,message:o}};_mergeMessage=(e,n)=>({schema:Vr(e.schema,n.schema)})};C();R();O();C();R();O();import{isApiError as xI,Client as PI,RuntimeError as wv,InvalidPayloadError as BI}from"@botpress/client";C();R();O();import*as Zh from"@botpress/client";var Va={retries:3,retryCondition:t=>Zh.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Gk(e.response?.headers??{})??t)*1e3},Gk=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let n of e){let r=t[n];if(r!==void 0)return Vk(String(r))}},Vk=t=>{let e=Jk(t)?Xk(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},Jk=t=>t.includes(" "),Xk=t=>{let e=Yk(t);if(!e)return;let n=new Date;return Math.max(0,Math.floor((e.getTime()-n.getTime())/1e3))},Yk=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};C();R();O();C();R();O();var ii=class{constructor(e){this._client=e}get _inner(){return this._client}createConversation=e=>this._client.createConversation(e);getConversation=e=>this._client.getConversation(e);listConversations=e=>this._client.listConversations(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);updateConversation=e=>this._client.updateConversation(e);deleteConversation=e=>this._client.deleteConversation(e);listParticipants=e=>this._client.listParticipants(e);addParticipant=e=>this._client.addParticipant(e);getParticipant=e=>this._client.getParticipant(e);removeParticipant=e=>this._client.removeParticipant(e);createEvent=e=>this._client.createEvent(e);getEvent=e=>this._client.getEvent(e);listEvents=e=>this._client.listEvents(e);createMessage=e=>this._client.createMessage(e);getOrCreateMessage=e=>this._client.getOrCreateMessage(e);getMessage=e=>this._client.getMessage(e);updateMessage=e=>this._client.updateMessage(e);listMessages=e=>this._client.listMessages(e);deleteMessage=e=>this._client.deleteMessage(e);createUser=e=>this._client.createUser(e);getUser=e=>this._client.getUser(e);listUsers=e=>this._client.listUsers(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);updateUser=e=>this._client.updateUser(e);deleteUser=e=>this._client.deleteUser(e);getState=e=>this._client.getState(e);setState=e=>this._client.setState(e);getOrSetState=e=>this._client.getOrSetState(e);patchState=e=>this._client.patchState(e);configureIntegration=e=>this._client.configureIntegration(e);uploadFile=e=>this._client.uploadFile(e);upsertFile=e=>this._client.upsertFile(e);deleteFile=e=>this._client.deleteFile(e);listFiles=e=>this._client.listFiles(e);getFile=e=>this._client.getFile(e);updateFileMetadata=e=>this._client.updateFileMetadata(e);trackAnalytics=e=>this._client.trackAnalytics(e)};C();R();O();var Ja=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};C();R();O();C();R();O();var fn="#";var ER=Y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),$h=t=>{let e=t[wa],n=t[Oy],r=t[Ry],a=t[My],o=t[Ny],i=t[xa],s=t[Pa];if(!e)throw new Error("Missing bot headers");if(!n)throw new Error("Missing bot user headers");if(!r)throw new Error("Missing integration headers");if(!a)throw new Error("Missing webhook headers");if(!i)throw new Error("Missing configuration headers");if(!s)throw new Error("Missing operation headers");return{botId:e,botUserId:n,integrationId:r,webhookId:a,operation:s,configurationType:o??null,configuration:i?JSON.parse(q.from(i,"base64").toString("utf-8")):{}}};C();R();O();C();R();O();C();R();O();C();R();O();var nl={},jh=!1;function wl(){return jh||(jh=!0,nl=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},n=Symbol("test"),r=Object(n);if(typeof n=="string"||Object.prototype.toString.call(n)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var a=42;e[n]=a;for(n in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==n||!Object.prototype.propertyIsEnumerable.call(e,n))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var i=Object.getOwnPropertyDescriptor(e,n);if(i.value!==a||i.enumerable!==!0)return!1}return!0}),nl}var rl={},Kh=!1;function Qk(){return Kh||(Kh=!0,rl=Error),rl}var il={},Lh=!1;function eI(){return Lh||(Lh=!0,il=EvalError),il}var al={},Fh=!1;function tI(){return Fh||(Fh=!0,al=RangeError),al}var ol={},Wh=!1;function nI(){return Wh||(Wh=!0,ol=ReferenceError),ol}var sl={},zh=!1;function lv(){return zh||(zh=!0,sl=SyntaxError),sl}var ll={},qh=!1;function Xa(){return qh||(qh=!0,ll=TypeError),ll}var ul={},Gh=!1;function rI(){return Gh||(Gh=!0,ul=URIError),ul}var cl={},Vh=!1;function iI(){if(Vh)return cl;Vh=!0;var t=typeof Symbol<"u"&&Symbol,e=wl();return cl=function(){return typeof t!="function"||typeof Symbol!="function"||typeof t("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},cl}var fl={},Jh=!1;function aI(){if(Jh)return fl;Jh=!0;var t={__proto__:null,foo:{}},e=Object;return fl=function(){return{__proto__:t}.foo===t.foo&&!(t instanceof e)},fl}var dl={},Xh=!1;function oI(){if(Xh)return dl;Xh=!0;var t="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,n=Math.max,r="[object Function]",a=function(l,f){for(var p=[],y=0;y<l.length;y+=1)p[y]=l[y];for(var g=0;g<f.length;g+=1)p[g+l.length]=f[g];return p},o=function(l,f){for(var p=[],y=f,g=0;y<l.length;y+=1,g+=1)p[g]=l[y];return p},i=function(s,l){for(var f="",p=0;p<s.length;p+=1)f+=s[p],p+1<s.length&&(f+=l);return f};return dl=function(l){var f=this;if(typeof f!="function"||e.apply(f)!==r)throw new TypeError(t+f);for(var p=o(arguments,1),y,g=function(){if(this instanceof y){var v=f.apply(this,a(p,arguments));return Object(v)===v?v:this}return f.apply(l,a(p,arguments))},h=n(0,f.length-p.length),w=[],P=0;P<h;P++)w[P]="$"+P;if(y=Function("binder","return function ("+i(w,",")+"){ return binder.apply(this,arguments); }")(g),f.prototype){var B=function(){};B.prototype=f.prototype,y.prototype=new B,B.prototype=null}return y},dl}var pl={},Yh=!1;function xl(){if(Yh)return pl;Yh=!0;var t=oI();return pl=Function.prototype.bind||t,pl}var gl={},Qh=!1;function sI(){if(Qh)return gl;Qh=!0;var t=Function.prototype.call,e=Object.prototype.hasOwnProperty,n=xl();return gl=n.call(t,e),gl}var yl={},ev=!1;function oi(){if(ev)return yl;ev=!0;var t,e=Qk(),n=eI(),r=tI(),a=nI(),o=lv(),i=Xa(),s=rI(),l=Function,f=function(Ue){try{return l('"use strict"; return ('+Ue+").constructor;")()}catch{}},p=Object.getOwnPropertyDescriptor;if(p)try{p({},"")}catch{p=null}var y=function(){throw new i},g=p?function(){try{return arguments.callee,y}catch{try{return p(arguments,"callee").get}catch{return y}}}():y,h=iI()(),w=aI()(),P=Object.getPrototypeOf||(w?function(Ue){return Ue.__proto__}:null),B={},v=typeof Uint8Array>"u"||!P?t:P(Uint8Array),E={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?t:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?t:ArrayBuffer,"%ArrayIteratorPrototype%":h&&P?P([][Symbol.iterator]()):t,"%AsyncFromSyncIteratorPrototype%":t,"%AsyncFunction%":B,"%AsyncGenerator%":B,"%AsyncGeneratorFunction%":B,"%AsyncIteratorPrototype%":B,"%Atomics%":typeof Atomics>"u"?t:Atomics,"%BigInt%":typeof BigInt>"u"?t:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?t:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?t:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?t:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":e,"%eval%":eval,"%EvalError%":n,"%Float32Array%":typeof Float32Array>"u"?t:Float32Array,"%Float64Array%":typeof Float64Array>"u"?t:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?t:FinalizationRegistry,"%Function%":l,"%GeneratorFunction%":B,"%Int8Array%":typeof Int8Array>"u"?t:Int8Array,"%Int16Array%":typeof Int16Array>"u"?t:Int16Array,"%Int32Array%":typeof Int32Array>"u"?t:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":h&&P?P(P([][Symbol.iterator]())):t,"%JSON%":typeof JSON=="object"?JSON:t,"%Map%":typeof Map>"u"?t:Map,"%MapIteratorPrototype%":typeof Map>"u"||!h||!P?t:P(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?t:Promise,"%Proxy%":typeof Proxy>"u"?t:Proxy,"%RangeError%":r,"%ReferenceError%":a,"%Reflect%":typeof Reflect>"u"?t:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?t:Set,"%SetIteratorPrototype%":typeof Set>"u"||!h||!P?t:P(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?t:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":h&&P?P(""[Symbol.iterator]()):t,"%Symbol%":h?Symbol:t,"%SyntaxError%":o,"%ThrowTypeError%":g,"%TypedArray%":v,"%TypeError%":i,"%Uint8Array%":typeof Uint8Array>"u"?t:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?t:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?t:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?t:Uint32Array,"%URIError%":s,"%WeakMap%":typeof WeakMap>"u"?t:WeakMap,"%WeakRef%":typeof WeakRef>"u"?t:WeakRef,"%WeakSet%":typeof WeakSet>"u"?t:WeakSet};if(P)try{null.error}catch(Ue){var S=P(P(Ue));E["%Error.prototype%"]=S}var H=function Ue(Pe){var Ee;if(Pe==="%AsyncFunction%")Ee=f("async function () {}");else if(Pe==="%GeneratorFunction%")Ee=f("function* () {}");else if(Pe==="%AsyncGeneratorFunction%")Ee=f("async function* () {}");else if(Pe==="%AsyncGenerator%"){var fe=Ue("%AsyncGeneratorFunction%");fe&&(Ee=fe.prototype)}else if(Pe==="%AsyncIteratorPrototype%"){var ve=Ue("%AsyncGenerator%");ve&&P&&(Ee=P(ve.prototype))}return E[Pe]=Ee,Ee},K={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ae=xl(),ee=sI(),ge=ae.call(Function.call,Array.prototype.concat),oe=ae.call(Function.apply,Array.prototype.splice),re=ae.call(Function.call,String.prototype.replace),Oe=ae.call(Function.call,String.prototype.slice),ze=ae.call(Function.call,RegExp.prototype.exec),tt=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Ve=/\\(\\)?/g,Je=function(Pe){var Ee=Oe(Pe,0,1),fe=Oe(Pe,-1);if(Ee==="%"&&fe!=="%")throw new o("invalid intrinsic syntax, expected closing `%`");if(fe==="%"&&Ee!=="%")throw new o("invalid intrinsic syntax, expected opening `%`");var ve=[];return re(Pe,tt,function(D,j,F,de){ve[ve.length]=F?re(de,Ve,"$1"):j||D}),ve},mt=function(Pe,Ee){var fe=Pe,ve;if(ee(K,fe)&&(ve=K[fe],fe="%"+ve[0]+"%"),ee(E,fe)){var D=E[fe];if(D===B&&(D=H(fe)),typeof D>"u"&&!Ee)throw new i("intrinsic "+Pe+" exists, but is not available. Please file an issue!");return{alias:ve,name:fe,value:D}}throw new o("intrinsic "+Pe+" does not exist!")};return yl=function(Pe,Ee){if(typeof Pe!="string"||Pe.length===0)throw new i("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof Ee!="boolean")throw new i('"allowMissing" argument must be a boolean');if(ze(/^%?[^%]*%?$/,Pe)===null)throw new o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var fe=Je(Pe),ve=fe.length>0?fe[0]:"",D=mt("%"+ve+"%",Ee),j=D.name,F=D.value,de=!1,Te=D.alias;Te&&(ve=Te[0],oe(fe,ge([0,1],Te)));for(var A=1,k=!0;A<fe.length;A+=1){var $=fe[A],X=Oe($,0,1),ie=Oe($,-1);if((X==='"'||X==="'"||X==="`"||ie==='"'||ie==="'"||ie==="`")&&X!==ie)throw new o("property names with quotes must have matching quotes");if(($==="constructor"||!k)&&(de=!0),ve+="."+$,j="%"+ve+"%",ee(E,j))F=E[j];else if(F!=null){if(!($ in F)){if(!Ee)throw new i("base intrinsic for "+Pe+" exists, but the property is not available.");return}if(p&&A+1>=fe.length){var _=p(F,$);k=!!_,k&&"get"in _&&!("originalValue"in _.get)?F=_.get:F=F[$]}else k=ee(F,$),F=F[$];k&&!de&&(E[j]=F)}}return F},yl}var ml={},tv=!1;function Pl(){if(tv)return ml;tv=!0;var t=oi(),e=t("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch{e=!1}return ml=e,ml}var hl={},nv=!1;function Ya(){if(nv)return hl;nv=!0;var t=oi(),e=t("%Object.getOwnPropertyDescriptor%",!0);if(e)try{e([],"length")}catch{e=null}return hl=e,hl}var vl={},rv=!1;function lI(){if(rv)return vl;rv=!0;var t=Pl(),e=lv(),n=Xa(),r=Ya();return vl=function(o,i,s){if(!o||typeof o!="object"&&typeof o!="function")throw new n("`obj` must be an object or a function`");if(typeof i!="string"&&typeof i!="symbol")throw new n("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new n("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new n("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new n("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new n("`loose`, if provided, must be a boolean");var l=arguments.length>3?arguments[3]:null,f=arguments.length>4?arguments[4]:null,p=arguments.length>5?arguments[5]:null,y=arguments.length>6?arguments[6]:!1,g=!!r&&r(o,i);if(t)t(o,i,{configurable:p===null&&g?g.configurable:!p,enumerable:l===null&&g?g.enumerable:!l,value:s,writable:f===null&&g?g.writable:!f});else if(y||!l&&!f&&!p)o[i]=s;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},vl}var Tl={},iv=!1;function uI(){if(iv)return Tl;iv=!0;var t=Pl(),e=function(){return!!t};return e.hasArrayLengthDefineBug=function(){if(!t)return null;try{return t([],"length",{value:1}).length!==1}catch{return!0}},Tl=e,Tl}var _l={},av=!1;function cI(){if(av)return _l;av=!0;var t=oi(),e=lI(),n=uI()(),r=Ya(),a=Xa(),o=t("%Math.floor%");return _l=function(s,l){if(typeof s!="function")throw new a("`fn` is not a function");if(typeof l!="number"||l<0||l>4294967295||o(l)!==l)throw new a("`length` must be a positive 32-bit integer");var f=arguments.length>2&&!!arguments[2],p=!0,y=!0;if("length"in s&&r){var g=r(s,"length");g&&!g.configurable&&(p=!1),g&&!g.writable&&(y=!1)}return(p||y||!f)&&(n?e(s,"length",l,!0,!0):e(s,"length",l)),s},_l}var ai={},ov=!1;function Bl(){if(ov)return ai;ov=!0;var t=xl(),e=oi(),n=cI(),r=Xa(),a=e("%Function.prototype.apply%"),o=e("%Function.prototype.call%"),i=e("%Reflect.apply%",!0)||t.call(o,a),s=Pl(),l=e("%Math.max%");ai=function(y){if(typeof y!="function")throw new r("a function is required");var g=i(t,o,arguments);return n(g,1+l(0,y.length-(arguments.length-1)),!0)};var f=function(){return i(t,a,arguments)};return s?s(ai,"apply",{value:f}):ai.apply=f,ai}var bl={},sv=!1;function Sl(){if(sv)return bl;sv=!0;var t=oi(),e=Bl(),n=e(t("String.prototype.indexOf"));return bl=function(a,o){var i=t(a,!!o);return typeof i=="function"&&n(a,".prototype.")>-1?e(i):i},bl}is();bs();var El={},uv=!1;function Hl(){if(uv)return El;uv=!0;var t=wl();return El=function(){return t()&&!!Symbol.toStringTag},El}var kl={},cv=!1;function fI(){if(cv)return kl;cv=!0;var t=Hl()(),e=Sl(),n=e("Object.prototype.toString"),r=function(s){return t&&s&&typeof s=="object"&&Symbol.toStringTag in s?!1:n(s)==="[object Arguments]"},a=function(s){return r(s)?!0:s!==null&&typeof s=="object"&&typeof s.length=="number"&&s.length>=0&&n(s)!=="[object Array]"&&n(s.callee)==="[object Function]"},o=function(){return r(arguments)}();return r.isLegacyArguments=a,kl=o?r:a,kl}var Il={},fv=!1;function dI(){if(fv)return Il;fv=!0;var t=Object.prototype.toString,e=Function.prototype.toString,n=/^\s*(?:function)?\*/,r=Hl()(),a=Object.getPrototypeOf,o=function(){if(!r)return!1;try{return Function("return function*() {}")()}catch{}},i;return Il=function(l){if(typeof l!="function")return!1;if(n.test(e.call(l)))return!0;if(!r){var f=t.call(l);return f==="[object GeneratorFunction]"}if(!a)return!1;if(typeof i>"u"){var p=o();i=p?a(p):!1}return a(l)===i},Il}var Al={},dv=!1;function pI(){if(dv)return Al;dv=!0;var t=Function.prototype.toString,e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,n,r;if(typeof e=="function"&&typeof Object.defineProperty=="function")try{n=Object.defineProperty({},"length",{get:function(){throw r}}),r={},e(function(){throw 42},null,n)}catch(E){E!==r&&(e=null)}else e=null;var a=/^\s*class\b/,o=function(S){try{var H=t.call(S);return a.test(H)}catch{return!1}},i=function(S){try{return o(S)?!1:(t.call(S),!0)}catch{return!1}},s=Object.prototype.toString,l="[object Object]",f="[object Function]",p="[object GeneratorFunction]",y="[object HTMLAllCollection]",g="[object HTML document.all class]",h="[object HTMLCollection]",w=typeof Symbol=="function"&&!!Symbol.toStringTag,P=!(0 in[,]),B=function(){return!1};if(typeof document=="object"){var v=document.all;s.call(v)===s.call(document.all)&&(B=function(S){if((P||!S)&&(typeof S>"u"||typeof S=="object"))try{var H=s.call(S);return(H===y||H===g||H===h||H===l)&&S("")==null}catch{}return!1})}return Al=e?function(S){if(B(S))return!0;if(!S||typeof S!="function"&&typeof S!="object")return!1;try{e(S,null,n)}catch(H){if(H!==r)return!1}return!o(S)&&i(S)}:function(S){if(B(S))return!0;if(!S||typeof S!="function"&&typeof S!="object")return!1;if(w)return i(S);if(o(S))return!1;var H=s.call(S);return H!==f&&H!==p&&!/^\[object HTML/.test(H)?!1:i(S)},Al}var Cl={},pv=!1;function gI(){if(pv)return Cl;pv=!0;var t=pI(),e=Object.prototype.toString,n=Object.prototype.hasOwnProperty,r=function(l,f,p){for(var y=0,g=l.length;y<g;y++)n.call(l,y)&&(p==null?f(l[y],y,l):f.call(p,l[y],y,l))},a=function(l,f,p){for(var y=0,g=l.length;y<g;y++)p==null?f(l.charAt(y),y,l):f.call(p,l.charAt(y),y,l)},o=function(l,f,p){for(var y in l)n.call(l,y)&&(p==null?f(l[y],y,l):f.call(p,l[y],y,l))},i=function(l,f,p){if(!t(f))throw new TypeError("iterator must be a function");var y;arguments.length>=3&&(y=p),e.call(l)==="[object Array]"?r(l,f,y):typeof l=="string"?a(l,f,y):o(l,f,y)};return Cl=i,Cl}var Ol={},gv=!1;function yI(){return gv||(gv=!0,Ol=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),Ol}var Rl={},yv=!1,mI=typeof globalThis<"u"?globalThis:typeof self<"u"?self:global;function hI(){if(yv)return Rl;yv=!0;var t=yI(),e=typeof globalThis>"u"?mI:globalThis;return Rl=function(){for(var r=[],a=0;a<t.length;a++)typeof e[t[a]]=="function"&&(r[r.length]=t[a]);return r},Rl}var Ml={},mv=!1,vI=typeof globalThis<"u"?globalThis:typeof self<"u"?self:global;function bv(){if(mv)return Ml;mv=!0;var t=gI(),e=hI(),n=Bl(),r=Sl(),a=Ya(),o=r("Object.prototype.toString"),i=Hl()(),s=typeof globalThis>"u"?vI:globalThis,l=e(),f=r("String.prototype.slice"),p=Object.getPrototypeOf,y=r("Array.prototype.indexOf",!0)||function(B,v){for(var E=0;E<B.length;E+=1)if(B[E]===v)return E;return-1},g={__proto__:null};i&&a&&p?t(l,function(P){var B=new s[P];if(Symbol.toStringTag in B){var v=p(B),E=a(v,Symbol.toStringTag);if(!E){var S=p(v);E=a(S,Symbol.toStringTag)}g["$"+P]=n(E.get)}}):t(l,function(P){var B=new s[P],v=B.slice||B.set;v&&(g["$"+P]=n(v))});var h=function(B){var v=!1;return t(g,function(E,S){if(!v)try{"$"+E(B)===S&&(v=f(S,1))}catch{}}),v},w=function(B){var v=!1;return t(g,function(E,S){if(!v)try{E(B),v=f(S,1)}catch{}}),v};return Ml=function(B){if(!B||typeof B!="object")return!1;if(!i){var v=f(o(B),8,-1);return y(l,v)>-1?v:v!=="Object"?!1:w(B)}return a?h(B):null},Ml}var Nl={},hv=!1;function TI(){if(hv)return Nl;hv=!0;var t=bv();return Nl=function(n){return!!t(n)},Nl}var we={},vv=!1;function _I(){if(vv)return we;vv=!0;var t=fI(),e=dI(),n=bv(),r=TI();function a(Z){return Z.call.bind(Z)}var o=typeof BigInt<"u",i=typeof Symbol<"u",s=a(Object.prototype.toString),l=a(Number.prototype.valueOf),f=a(String.prototype.valueOf),p=a(Boolean.prototype.valueOf);if(o)var y=a(BigInt.prototype.valueOf);if(i)var g=a(Symbol.prototype.valueOf);function h(Z,kt){if(typeof Z!="object")return!1;try{return kt(Z),!0}catch{return!1}}we.isArgumentsObject=t,we.isGeneratorFunction=e,we.isTypedArray=r;function w(Z){return typeof Promise<"u"&&Z instanceof Promise||Z!==null&&typeof Z=="object"&&typeof Z.then=="function"&&typeof Z.catch=="function"}we.isPromise=w;function P(Z){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(Z):r(Z)||D(Z)}we.isArrayBufferView=P;function B(Z){return n(Z)==="Uint8Array"}we.isUint8Array=B;function v(Z){return n(Z)==="Uint8ClampedArray"}we.isUint8ClampedArray=v;function E(Z){return n(Z)==="Uint16Array"}we.isUint16Array=E;function S(Z){return n(Z)==="Uint32Array"}we.isUint32Array=S;function H(Z){return n(Z)==="Int8Array"}we.isInt8Array=H;function K(Z){return n(Z)==="Int16Array"}we.isInt16Array=K;function ae(Z){return n(Z)==="Int32Array"}we.isInt32Array=ae;function ee(Z){return n(Z)==="Float32Array"}we.isFloat32Array=ee;function ge(Z){return n(Z)==="Float64Array"}we.isFloat64Array=ge;function oe(Z){return n(Z)==="BigInt64Array"}we.isBigInt64Array=oe;function re(Z){return n(Z)==="BigUint64Array"}we.isBigUint64Array=re;function Oe(Z){return s(Z)==="[object Map]"}Oe.working=typeof Map<"u"&&Oe(new Map);function ze(Z){return typeof Map>"u"?!1:Oe.working?Oe(Z):Z instanceof Map}we.isMap=ze;function tt(Z){return s(Z)==="[object Set]"}tt.working=typeof Set<"u"&&tt(new Set);function Ve(Z){return typeof Set>"u"?!1:tt.working?tt(Z):Z instanceof Set}we.isSet=Ve;function Je(Z){return s(Z)==="[object WeakMap]"}Je.working=typeof WeakMap<"u"&&Je(new WeakMap);function mt(Z){return typeof WeakMap>"u"?!1:Je.working?Je(Z):Z instanceof WeakMap}we.isWeakMap=mt;function Ue(Z){return s(Z)==="[object WeakSet]"}Ue.working=typeof WeakSet<"u"&&Ue(new WeakSet);function Pe(Z){return Ue(Z)}we.isWeakSet=Pe;function Ee(Z){return s(Z)==="[object ArrayBuffer]"}Ee.working=typeof ArrayBuffer<"u"&&Ee(new ArrayBuffer);function fe(Z){return typeof ArrayBuffer>"u"?!1:Ee.working?Ee(Z):Z instanceof ArrayBuffer}we.isArrayBuffer=fe;function ve(Z){return s(Z)==="[object DataView]"}ve.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&ve(new DataView(new ArrayBuffer(1),0,1));function D(Z){return typeof DataView>"u"?!1:ve.working?ve(Z):Z instanceof DataView}we.isDataView=D;var j=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function F(Z){return s(Z)==="[object SharedArrayBuffer]"}function de(Z){return typeof j>"u"?!1:(typeof F.working>"u"&&(F.working=F(new j)),F.working?F(Z):Z instanceof j)}we.isSharedArrayBuffer=de;function Te(Z){return s(Z)==="[object AsyncFunction]"}we.isAsyncFunction=Te;function A(Z){return s(Z)==="[object Map Iterator]"}we.isMapIterator=A;function k(Z){return s(Z)==="[object Set Iterator]"}we.isSetIterator=k;function $(Z){return s(Z)==="[object Generator]"}we.isGeneratorObject=$;function X(Z){return s(Z)==="[object WebAssembly.Module]"}we.isWebAssemblyCompiledModule=X;function ie(Z){return h(Z,l)}we.isNumberObject=ie;function _(Z){return h(Z,f)}we.isStringObject=_;function x(Z){return h(Z,p)}we.isBooleanObject=x;function z(Z){return o&&h(Z,y)}we.isBigIntObject=z;function Q(Z){return i&&h(Z,g)}we.isSymbolObject=Q;function Me(Z){return ie(Z)||_(Z)||x(Z)||z(Z)||Q(Z)}we.isBoxedPrimitive=Me;function _e(Z){return typeof Uint8Array<"u"&&(fe(Z)||de(Z))}return we.isAnyArrayBuffer=_e,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(Z){Object.defineProperty(we,Z,{enumerable:!1,value:function(){throw new Error(Z+" is not supported in userland")}})}),we}var Dl={},Tv=!1;function bI(){return Tv||(Tv=!0,Dl=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"}),Dl}var xe={},_v=!1,si=typeof globalThis<"u"?globalThis:typeof self<"u"?self:global;function wI(){if(_v)return xe;_v=!0;var t=At,e=Object.getOwnPropertyDescriptors||function(j){for(var F=Object.keys(j),de={},Te=0;Te<F.length;Te++)de[F[Te]]=Object.getOwnPropertyDescriptor(j,F[Te]);return de},n=/%[sdj%]/g;xe.format=function(D){if(!K(D)){for(var j=[],F=0;F<arguments.length;F++)j.push(i(arguments[F]));return j.join(" ")}for(var F=1,de=arguments,Te=de.length,A=String(D).replace(n,function($){if($==="%%")return"%";if(F>=Te)return $;switch($){case"%s":return String(de[F++]);case"%d":return Number(de[F++]);case"%j":try{return JSON.stringify(de[F++])}catch{return"[Circular]"}default:return $}}),k=de[F];F<Te;k=de[++F])E(k)||!oe(k)?A+=" "+k:A+=" "+i(k);return A},xe.deprecate=function(D,j){if(typeof t<"u"&&t.noDeprecation===!0)return D;if(typeof t>"u")return function(){return xe.deprecate(D,j).apply(this||si,arguments)};var F=!1;function de(){if(!F){if(t.throwDeprecation)throw new Error(j);t.traceDeprecation?console.trace(j):console.error(j),F=!0}return D.apply(this||si,arguments)}return de};var r={},a=/^$/;if(t.env.NODE_DEBUG){var o=t.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),a=new RegExp("^"+o+"$","i")}xe.debuglog=function(D){if(D=D.toUpperCase(),!r[D])if(a.test(D)){var j=t.pid;r[D]=function(){var F=xe.format.apply(xe,arguments);console.error("%s %d: %s",D,j,F)}}else r[D]=function(){};return r[D]};function i(D,j){var F={seen:[],stylize:l};return arguments.length>=3&&(F.depth=arguments[2]),arguments.length>=4&&(F.colors=arguments[3]),v(j)?F.showHidden=j:j&&xe._extend(F,j),ee(F.showHidden)&&(F.showHidden=!1),ee(F.depth)&&(F.depth=2),ee(F.colors)&&(F.colors=!1),ee(F.customInspect)&&(F.customInspect=!0),F.colors&&(F.stylize=s),p(F,D,F.depth)}xe.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function s(D,j){var F=i.styles[j];return F?"\x1B["+i.colors[F][0]+"m"+D+"\x1B["+i.colors[F][1]+"m":D}function l(D,j){return D}function f(D){var j={};return D.forEach(function(F,de){j[F]=!0}),j}function p(D,j,F){if(D.customInspect&&j&&ze(j.inspect)&&j.inspect!==xe.inspect&&!(j.constructor&&j.constructor.prototype===j)){var de=j.inspect(F,D);return K(de)||(de=p(D,de,F)),de}var Te=y(D,j);if(Te)return Te;var A=Object.keys(j),k=f(A);if(D.showHidden&&(A=Object.getOwnPropertyNames(j)),Oe(j)&&(A.indexOf("message")>=0||A.indexOf("description")>=0))return g(j);if(A.length===0){if(ze(j)){var $=j.name?": "+j.name:"";return D.stylize("[Function"+$+"]","special")}if(ge(j))return D.stylize(RegExp.prototype.toString.call(j),"regexp");if(re(j))return D.stylize(Date.prototype.toString.call(j),"date");if(Oe(j))return g(j)}var X="",ie=!1,_=["{","}"];if(B(j)&&(ie=!0,_=["[","]"]),ze(j)){var x=j.name?": "+j.name:"";X=" [Function"+x+"]"}if(ge(j)&&(X=" "+RegExp.prototype.toString.call(j)),re(j)&&(X=" "+Date.prototype.toUTCString.call(j)),Oe(j)&&(X=" "+g(j)),A.length===0&&(!ie||j.length==0))return _[0]+X+_[1];if(F<0)return ge(j)?D.stylize(RegExp.prototype.toString.call(j),"regexp"):D.stylize("[Object]","special");D.seen.push(j);var z;return ie?z=h(D,j,F,k,A):z=A.map(function(Q){return w(D,j,F,k,Q,ie)}),D.seen.pop(),P(z,X,_)}function y(D,j){if(ee(j))return D.stylize("undefined","undefined");if(K(j)){var F="'"+JSON.stringify(j).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return D.stylize(F,"string")}if(H(j))return D.stylize(""+j,"number");if(v(j))return D.stylize(""+j,"boolean");if(E(j))return D.stylize("null","null")}function g(D){return"["+Error.prototype.toString.call(D)+"]"}function h(D,j,F,de,Te){for(var A=[],k=0,$=j.length;k<$;++k)Pe(j,String(k))?A.push(w(D,j,F,de,String(k),!0)):A.push("");return Te.forEach(function(X){X.match(/^\d+$/)||A.push(w(D,j,F,de,X,!0))}),A}function w(D,j,F,de,Te,A){var k,$,X;if(X=Object.getOwnPropertyDescriptor(j,Te)||{value:j[Te]},X.get?X.set?$=D.stylize("[Getter/Setter]","special"):$=D.stylize("[Getter]","special"):X.set&&($=D.stylize("[Setter]","special")),Pe(de,Te)||(k="["+Te+"]"),$||(D.seen.indexOf(X.value)<0?(E(F)?$=p(D,X.value,null):$=p(D,X.value,F-1),$.indexOf(`
80
80
  `)>-1&&(A?$=$.split(`
81
81
  `).map(function(ie){return" "+ie}).join(`
82
82
  `).slice(2):$=`
@@ -85,7 +85,7 @@ ${v}`.trim();case M.ZodFirstPartyTypeKind.ZodEnum:return s.values.map(se).join("
85
85
  `))):$=D.stylize("[Circular]","special")),ee(k)){if(A&&Te.match(/^\d+$/))return $;k=JSON.stringify(""+Te),k.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(k=k.slice(1,-1),k=D.stylize(k,"name")):(k=k.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),k=D.stylize(k,"string"))}return k+": "+$}function P(D,j,F){var de=D.reduce(function(Te,A){return A.indexOf(`
86
86
  `)>=0,Te+A.replace(/\u001b\[\d\d?m/g,"").length+1},0);return de>60?F[0]+(j===""?"":j+`
87
87
  `)+" "+D.join(`,
88
- `)+" "+F[1]:F[0]+j+" "+D.join(", ")+" "+F[1]}xe.types=_I();function B(D){return Array.isArray(D)}xe.isArray=B;function v(D){return typeof D=="boolean"}xe.isBoolean=v;function E(D){return D===null}xe.isNull=E;function S(D){return D==null}xe.isNullOrUndefined=S;function H(D){return typeof D=="number"}xe.isNumber=H;function K(D){return typeof D=="string"}xe.isString=K;function ae(D){return typeof D=="symbol"}xe.isSymbol=ae;function ee(D){return D===void 0}xe.isUndefined=ee;function ge(D){return oe(D)&&Ve(D)==="[object RegExp]"}xe.isRegExp=ge,xe.types.isRegExp=ge;function oe(D){return typeof D=="object"&&D!==null}xe.isObject=oe;function re(D){return oe(D)&&Ve(D)==="[object Date]"}xe.isDate=re,xe.types.isDate=re;function Oe(D){return oe(D)&&(Ve(D)==="[object Error]"||D instanceof Error)}xe.isError=Oe,xe.types.isNativeError=Oe;function ze(D){return typeof D=="function"}xe.isFunction=ze;function tt(D){return D===null||typeof D=="boolean"||typeof D=="number"||typeof D=="string"||typeof D=="symbol"||typeof D>"u"}xe.isPrimitive=tt,xe.isBuffer=bI();function Ve(D){return Object.prototype.toString.call(D)}function Je(D){return D<10?"0"+D.toString(10):D.toString(10)}var mt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ue(){var D=new Date,j=[Je(D.getHours()),Je(D.getMinutes()),Je(D.getSeconds())].join(":");return[D.getDate(),mt[D.getMonth()],j].join(" ")}xe.log=function(){console.log("%s - %s",Ue(),xe.format.apply(xe,arguments))},xe.inherits=Mt(),xe._extend=function(D,j){if(!j||!oe(j))return D;for(var F=Object.keys(j),de=F.length;de--;)D[F[de]]=j[F[de]];return D};function Pe(D,j){return Object.prototype.hasOwnProperty.call(D,j)}var Ee=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;xe.promisify=function(j){if(typeof j!="function")throw new TypeError('The "original" argument must be of type Function');if(Ee&&j[Ee]){if(F=j[Ee],typeof F!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(F,Ee,{value:F,enumerable:!1,writable:!1,configurable:!0}),F}function F(){for(var de,Te,A=new Promise(function(X,ie){de=X,Te=ie}),k=[],$=0;$<arguments.length;$++)k.push(arguments[$]);k.push(function(X,ie){X?Te(X):de(ie)});try{j.apply(this||si,k)}catch(X){Te(X)}return A}return Object.setPrototypeOf(F,Object.getPrototypeOf(j)),Ee&&Object.defineProperty(F,Ee,{value:F,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(F,e(j))},xe.promisify.custom=Ee;function fe(D,j){if(!D){var F=new Error("Promise was rejected with a falsy value");F.reason=D,D=F}return j(D)}function ve(D){if(typeof D!="function")throw new TypeError('The "original" argument must be of type Function');function j(){for(var F=[],de=0;de<arguments.length;de++)F.push(arguments[de]);var Te=F.pop();if(typeof Te!="function")throw new TypeError("The last argument must be of type Function");var A=this||si,k=function(){return Te.apply(A,arguments)};D.apply(this||si,F).then(function($){t.nextTick(k.bind(null,null,$))},function($){t.nextTick(fe.bind(null,$,k))})}return Object.setPrototypeOf(j,Object.getPrototypeOf(D)),Object.defineProperties(j,e(D)),j}return xe.callbackify=ve,xe}var ce=wI();ce.format;ce.deprecate;ce.debuglog;ce.inspect;ce.types;ce.isArray;ce.isBoolean;ce.isNull;ce.isNullOrUndefined;ce.isNumber;ce.isString;ce.isSymbol;ce.isUndefined;ce.isRegExp;ce.isObject;ce.isDate;ce.isError;ce.isFunction;ce.isPrimitive;ce.isBuffer;ce.log;ce.inherits;ce._extend;ce.promisify;ce.callbackify;var ZR=ce._extend,$R=ce.callbackify,jR=ce.debuglog,KR=ce.deprecate,LR=ce.format,FR=ce.inherits,WR=ce.inspect,zR=ce.isArray,qR=ce.isBoolean,GR=ce.isBuffer,VR=ce.isDate,JR=ce.isError,XR=ce.isFunction,YR=ce.isNull,QR=ce.isNullOrUndefined,e0=ce.isNumber,t0=ce.isObject,n0=ce.isPrimitive,r0=ce.isRegExp,i0=ce.isString,a0=ce.isSymbol,o0=ce.isUndefined,s0=ce.log,l0=ce.promisify,u0=ce.types,c0=ce.TextEncoder=globalThis.TextEncoder,f0=ce.TextDecoder=globalThis.TextDecoder;var hr=class{defaultOptions;constructor(e){this.defaultOptions=e}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}_log(e,n){this._getConsoleMethod(e)(this._serializeMessage(n))}_serializeMessage(e){let n=ce.format(...e);return J.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(n):n}getJsonMessage(e){return JSON.stringify({msg:e,options:this.defaultOptions})}_getConsoleMethod(e){switch(e){case"debug":return console.debug;case"warn":return console.warn;case"error":return console.error;default:return console.info}}};var Kn=class extends hr{constructor(e){super({visibleToBotOwners:!0,...e})}with(e){return new Kn({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withVisibleToBotOwners(e){return this.with({visibleToBotOwners:e})}forBot(){return this.withVisibleToBotOwners(!0)}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,options:this.defaultOptions})}};C();R();O();var SI=t=>["traceparent","tracestate","sentry-trace"].reduce((e,n)=>(t[n]&&(e[n]=t[n]),e),{}),EI=(t,e,n)=>{let[,r]=(e.headers.traceparent||"").split("-"),a=new PI({botId:t.botId,integrationId:t.integrationId,retry:Va,headers:SI(e.headers)}),o=new ii(a),i=new Kn({traceId:r});return{ctx:t,req:e,client:o,logger:i,instance:n}},kI=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await AI(t);case"register":return await CI(t);case"unregister":return await OI(t);case"message_created":return await NI(t);case"action_triggered":return await DI(t);case"ping":return await II(t);case"create_user":return await RI(t);case"create_conversation":return await MI(t);default:throw new BI(`Unknown operation ${e.operation}`)}},xv=t=>async e=>{let n=$h(e.headers),r=EI(n,e,t),{logger:a}=r;try{let o;return o=await HI(r),o?{...o,status:o.status??200}:(o=await kI(r),o?{...o,status:o.status??200}:{status:200})}catch(o){if(xI(o)){let s=o.type==="Runtime"?o:new wv(o.message,o);return a.forBot().error(s.message),{status:s.code,body:JSON.stringify(s.toJSON())}}console.error(o);let i=new wv("An unexpected error occurred in the integration. Bot owners: Check logs for more informations. Integration owners: throw a RuntimeError to return a custom error message instead.");return a.forBot().error(i.message),{status:i.code,body:JSON.stringify(i.toJSON())}}},II=async t=>{},AI=async({client:t,ctx:e,req:n,logger:r,instance:a})=>{let{req:o}=Ct(n);return a.webhook({client:t,ctx:e,req:o,logger:r})},CI=async({client:t,ctx:e,req:n,logger:r,instance:a})=>{if(!a.register)return;let{webhookUrl:o}=Ct(n);await a.register({client:t,ctx:e,webhookUrl:o,logger:r})},OI=async({client:t,ctx:e,req:n,logger:r,instance:a})=>{if(!a.unregister)return;let{webhookUrl:o}=Ct(n);await a.unregister({ctx:e,webhookUrl:o,client:t,logger:r})},RI=async({client:t,ctx:e,req:n,logger:r,instance:a})=>{if(!a.createUser)return;let{tags:o}=Ct(n);return await a.createUser({ctx:e,client:t,tags:o,logger:r})},MI=async({client:t,ctx:e,req:n,logger:r,instance:a})=>{if(!a.createConversation)return;let{channel:o,tags:i}=Ct(n);return await a.createConversation({ctx:e,client:t,channel:o,tags:i,logger:r})},NI=async({ctx:t,req:e,client:n,logger:r,instance:a})=>{let{conversation:o,user:i,type:s,payload:l,message:f}=Ct(e),p=a.channels[o.channel];if(!p)throw new Error(`Channel ${o.channel} not found`);let y=p.messages[s];if(!y)throw new Error(`Message of type ${s} not found in channel ${o.channel}`);await y({ctx:t,conversation:o,message:f,user:i,type:s,client:n,payload:l,ack:async({tags:h})=>{await n.updateMessage({id:f.id,tags:h})},logger:r})},DI=async({req:t,ctx:e,client:n,logger:r,instance:a})=>{let{input:o,type:i}=Ct(t);if(!i)throw new Error("Missing action type");let s=a.actions[i];if(!s)throw new Error(`Action ${i} not found`);let l=new Ja,p={output:await s({ctx:e,input:o,client:n,type:i,logger:r,metadata:l}),meta:l.toJSON()};return{body:JSON.stringify(p)}},HI=async({instance:t,client:e,ctx:n,logger:r,req:a})=>{let o=t.unknownOperationHandler;if(o)return await o({client:e,ctx:n,logger:r,req:a})};var Ul=class{constructor(e){this.props=e;this.actions=e.actions,this.channels=e.channels,this.register=e.register,this.unregister=e.unregister,this.createUser=e.createUser,this.createConversation=e.createConversation,this.webhook=e.handler,this.unknownOperationHandler=e.__advanced?.unknownOperationHandler}actions;channels;register;unregister;createUser;createConversation;webhook;unknownOperationHandler;handler=xv(this);start=e=>za(this.handler,e)};C();R();O();C();R();O();C();R();O();C();R();O();C();R();O();var Zl=class{constructor(e){this.props=e;this.integrations=e.integrations,this.plugins=e.plugins,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.states=e.states,this.configuration=e.configuration,this.events=e.events,this.recurringEvents=e.recurringEvents,this.actions=e.actions,this.tables=e.tables,this.workflows=e.workflows,this.attributes=e.attributes,this.withPlugins={user:e.user,conversation:e.conversation,message:e.message,states:e.states,events:e.events,recurringEvents:e.recurringEvents,actions:e.actions,tables:e.tables,workflows:e.workflows}}integrations;plugins;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;attributes;withPlugins;addIntegration(e,n){let r=this;return r.integrations||(r.integrations={}),r.integrations[e.name]={enabled:n.enabled,...e,configurationType:n.configurationType,configuration:n.configuration,disabledChannels:n.disabledChannels},this}addPlugin(e,n){let r=this;r.plugins||(r.plugins={});let a=n.alias??e.name.replace("/","-");return r.plugins[a]={...e,alias:a,configuration:n.configuration,interfaces:n.interfaces},r.withPlugins.user=this._mergeUser(r.withPlugins.user,e.definition.user),r.withPlugins.conversation=this._mergeConversation(r.withPlugins.conversation,e.definition.conversation),r.withPlugins.message=this._mergeMessage(r.withPlugins.message,e.definition.message),r.withPlugins.recurringEvents=this._mergeRecurringEvents(r.withPlugins.recurringEvents,e.definition.recurringEvents),r.withPlugins.tables=this._mergeTables(r.withPlugins.tables,e.definition.tables),r.withPlugins.workflows=this._mergeWorkflows(r.withPlugins.workflows,e.definition.workflows),r.withPlugins.states=this._mergeStates(r.withPlugins.states,this._prefixKeysWithPluginAlias(e.definition.states,a)),r.withPlugins.events=this._mergeEvents(r.withPlugins.events,this._prefixKeysWithPluginAlias(e.definition.events,a)),r.withPlugins.actions=this._mergeActions(r.withPlugins.actions,this._prefixKeysWithPluginAlias(e.definition.actions,a)),this}_mergeUser=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeConversation=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeMessage=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeStates=(e,n)=>({...e,...n});_mergeEvents=(e,n)=>({...e,...n});_mergeRecurringEvents=(e,n)=>({...e,...n});_mergeActions=(e,n)=>({...e,...n});_mergeTables=(e,n)=>({...e,...n});_mergeWorkflows=(e,n)=>({...e,...n});_prefixKeysWithPluginAlias=(e,n)=>Le.mapKeys(e??{},r=>`${n}${fn}${r}`);dereferencePluginEntities(){let e=this._buildZuiReferenceMap();return{...this,withPlugins:{...this.withPlugins,events:this._dereferenceDefinitionSchemas(this.withPlugins.events,e),states:this._dereferenceDefinitionSchemas(this.withPlugins.states,e),tables:this._dereferenceDefinitionSchemas(this.withPlugins.tables,e),actions:this._dereferenceActionDefinitionSchemas(this.withPlugins.actions,e)},plugins:Object.fromEntries(Object.entries(this.plugins??{}).map(([n,r])=>[n,{...r,definition:{...r.definition,events:this._dereferenceDefinitionSchemas(r.definition.events,e),states:this._dereferenceDefinitionSchemas(r.definition.states,e),tables:this._dereferenceDefinitionSchemas(r.definition.tables,e),actions:this._dereferenceActionDefinitionSchemas(r.definition.actions,e)}}]))}}_buildZuiReferenceMap(){let e={},n=Object.entries(this.plugins??{});for(let[r,a]of n){let o=Object.entries(a.interfaces??{});for(let[i,s]of o){let l=this.integrations?.[s.name];if(!l)throw new Error(`Interface with alias "${i}" of plugin with alias "${r}" references integration "${s.name}" which is not installed`);let f=Object.entries(s.entities??{});for(let[p,{name:y}]of f){let g=l.definition.entities?.[y]?.schema;if(!g)throw new Error(`Interface entity "${y}" does not exist in integration "${l.name}"`);e[`interface:${i}/entities/${p}`]=g}}}return e}_dereferenceZuiSchema(e,n){return e.dereference(n)}_dereferenceDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,a])=>[r,{...a,schema:this._dereferenceZuiSchema(a.schema,n)}]))}_dereferenceActionDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,a])=>[r,{...a,input:{schema:this._dereferenceZuiSchema(a.input.schema,n)},output:{schema:this._dereferenceZuiSchema(a.output.schema,n)}}]))}};C();R();O();C();R();O();import{isApiError as FI,Client as WI,RuntimeError as Sv}from"@botpress/client";C();R();O();var Ln=class extends hr{constructor(e){super({...e})}with(e){return new Ln({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withWorkflowId(e){return this.with({workflowId:e})}withEventId(e){return this.with({eventId:e})}withMessageId(e){return this.with({messageId:e})}};C();R();O();C();R();O();var en=class{constructor(e,n={before:{},after:{}}){this._client=e;this._hooks=n}getConversation=e=>this._run("getConversation",e);listConversations=e=>this._run("listConversations",e);updateConversation=e=>this._run("updateConversation",e);deleteConversation=e=>this._run("deleteConversation",e);listParticipants=e=>this._run("listParticipants",e);addParticipant=e=>this._run("addParticipant",e);getParticipant=e=>this._run("getParticipant",e);removeParticipant=e=>this._run("removeParticipant",e);createEvent=e=>this._run("createEvent",e);getEvent=e=>this._run("getEvent",e);listEvents=e=>this._run("listEvents",e);createMessage=e=>this._run("createMessage",e);getOrCreateMessage=e=>this._run("getOrCreateMessage",e);getMessage=e=>this._run("getMessage",e);updateMessage=e=>this._run("updateMessage",e);listMessages=e=>this._run("listMessages",e);deleteMessage=e=>this._run("deleteMessage",e);getUser=e=>this._run("getUser",e);listUsers=e=>this._run("listUsers",e);updateUser=e=>this._run("updateUser",e);deleteUser=e=>this._run("deleteUser",e);getState=e=>this._run("getState",e);setState=e=>this._run("setState",e);getOrSetState=e=>this._run("getOrSetState",e);patchState=e=>this._run("patchState",e);callAction=e=>this._run("callAction",e);uploadFile=e=>this._run("uploadFile",e);upsertFile=e=>this._run("upsertFile",e);deleteFile=e=>this._run("deleteFile",e);listFiles=e=>this._run("listFiles",e);getFile=e=>this._run("getFile",e);updateFileMetadata=e=>this._run("updateFileMetadata",e);searchFiles=e=>this._run("searchFiles",e);trackAnalytics=e=>this._run("trackAnalytics",e);getTableRow=e=>this._run("getTableRow",e);createTableRows=e=>this._run("createTableRows",e);findTableRows=e=>this._run("findTableRows",e);deleteTableRows=e=>this._run("deleteTableRows",e);updateTableRows=e=>this._run("updateTableRows",e);upsertTableRows=e=>this._run("upsertTableRows",e);createWorkflow=e=>this._run("createWorkflow",e);getWorkflow=e=>this._run("getWorkflow",e);updateWorkflow=e=>this._run("updateWorkflow",e);deleteWorkflow=e=>this._run("deleteWorkflow",e);listWorkflows=e=>this._run("listWorkflows",e);createConversation=e=>this._client.createConversation(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);createUser=e=>this._client.createUser(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);_run=async(e,n)=>{let r=this._hooks.before[e];r&&(n=await r(n));let a=await this._client[e](n),o=this._hooks.after[e];return o&&(a=await o(a,n)),a}};C();R();O();C();R();O();var vr=t=>new Proxy({},{get:(e,n)=>({listInstances:{all:r=>dn({workflowName:n,client:t,input:r}),running:r=>dn({workflowName:n,client:t,input:r,statuses:["in_progress"]}),scheduled:r=>dn({workflowName:n,client:t,input:r,statuses:["pending","listening"]}),allFinished:r=>dn({workflowName:n,client:t,input:r,statuses:["completed","cancelled","failed","timedout"]}),cancelled:r=>dn({workflowName:n,client:t,input:r,statuses:["cancelled"]}),failed:r=>dn({workflowName:n,client:t,input:r,statuses:["failed"]}),succeeded:r=>dn({workflowName:n,client:t,input:r,statuses:["completed"]}),timedOut:r=>dn({workflowName:n,client:t,input:r,statuses:["timedout"]})},startNewInstance:async r=>{let{workflow:a}=await t.createWorkflow({name:n,status:"pending",...r});return{workflow:pn({client:t,workflow:a})}}})}),dn=async t=>{let e=await t.client.listWorkflows({name:t.workflowName,statuses:t.statuses,...t.input});return{...e,workflows:e.workflows.map(n=>pn({client:t.client,workflow:n}))}},pn=t=>({...t.workflow,async update(e){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,...e});return{workflow:pn({client:t.client,workflow:n})}},async setFailed({failureReason:e}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:e});return{workflow:pn({client:t.client,workflow:n})}},async setCompleted({output:e}={}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:e});return{workflow:pn({client:t.client,workflow:n})}},async cancel(){let{workflow:e}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return{workflow:pn({client:t.client,workflow:e})}}});C();R();O();C();R();O();var UI=Y.enum(["event_received","register","unregister","ping","action_triggered"]),Pv=t=>{let e=t[wa],n=t[xa],r=t[Dy],a=UI.parse(t[Pa]);if(!e)throw new Error("Missing bot headers");if(!r)throw new Error("Missing type headers");if(!n)throw new Error("Missing configuration headers");if(!a)throw new Error("Missing operation headers");return{botId:e,operation:a,type:r,configuration:n?JSON.parse(q.from(n,"base64").toString("utf-8")):{}}};C();R();O();var ft={status:200};C();R();O();C();R();O();var $l=t=>{switch(t){case"workflow_continued":return"continued";case"workflow_started":return"started";case"workflow_timedout":return"timed_out";default:throw new Error(`Unsupported workflow update type: ${t}`)}};var ZI=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],Bv=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!ZI.includes(e.payload.type))throw new Error("Unexpected event type");let n={...t,logger:$I(t,e)};if(!e.payload.workflow.name)return n.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),ft;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":n.logger.info(`Received child workflow event "${e.payload.type}", but child workflows are not yet supported`);break;case"workflow_timedout":case"workflow_started":case"workflow_continued":return await jI(n,e);default:e.payload.type}return ft},$I=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),jI=async(t,e)=>{let n=$l(e.payload.type),r=t.self.workflowHandlers[n]?.[e.payload.workflow.name];return!r||r.length===0?(t.logger.warn(`No ${n} handler found for workflow "${e.payload.workflow.name}"`),ft):(await KI(t,e),await LI(t,e),ft)},KI=async(t,e)=>{e.payload.workflow.status==="pending"&&await t.client.updateWorkflow({id:e.payload.workflow.id,status:"in_progress",eventId:e.id})},LI=async(t,e)=>{let n=$l(e.payload.type),r=t.self.workflowHandlers[n]?.[e.payload.workflow.name];for(let a of r)await a({...t,conversation:e.payload.conversation,user:e.payload.user,workflow:pn({...t,workflow:e.payload.workflow}),workflows:vr(t.client)})};C();R();O();var Ev=t=>async e=>{let n=Pv(e.headers),r=new Ln,a=new WI({botId:n.botId,retry:Va}),o=new en(a,{before:{createMessage:async s=>{let l=t.hookHandlers.before_outgoing_message[s.type]??[];for(let f of l){let p=new en(a);s=(await f({client:p,ctx:n,logger:r.with({conversationId:s.conversationId,userId:s.userId}),data:s,...gn({client:p})}))?.data??s}return s},callAction:async s=>{let l=t.hookHandlers.before_outgoing_call_action[s.type]??[];for(let f of l){let p=new en(a);s=(await f({client:p,ctx:n,logger:r,data:s,...gn({client:p})}))?.data??s}return s}},after:{createMessage:async s=>{let l=t.hookHandlers.after_outgoing_message[s.message.type]??[];for(let f of l){let p=new en(a);s=(await f({client:p,ctx:n,logger:r.with({messageId:s.message.id,conversationId:s.message.conversationId,userId:s.message.userId}),data:s,...gn({client:p})}))?.data??s}return s},callAction:async(s,l)=>{let{type:f}=l,p=t.hookHandlers.after_outgoing_call_action[f]??[];for(let y of p){let g=new en(a);s=(await y({client:g,ctx:n,logger:r,data:{type:f,...s},...gn({client:g})}))?.data??s}return s}}}),i={req:e,ctx:n,logger:r,client:o,self:t};try{switch(n.operation){case"action_triggered":return await JI(i);case"event_received":return await VI(i);case"register":return await qI(i);case"unregister":return await GI(i);case"ping":return await zI(i);default:throw new Error(`Unknown operation ${n.operation}`)}}catch(s){let l=s instanceof Error?s:new Error(String(s));if(FI(l)){let p=l.type==="Runtime"?l:new Sv(l.message,l);return r.error(p.message),{status:p.code,body:JSON.stringify(p.toJSON())}}let f=new Sv("An unexpected error occurred in the bot.",l);return r.error(f.message,l),{status:f.code,body:JSON.stringify(f.toJSON())}}},zI=async t=>ft,qI=async t=>ft,GI=async t=>ft,VI=async t=>{let{ctx:e,logger:n,req:r,client:a,self:o}=t,i={client:a,ctx:e,logger:n,...gn({client:a})},s=Ct(r);if(i.logger=i.logger.with({eventId:s.event.id,messageId:s.event.messageId,conversationId:s.event.conversationId,userId:s.event.userId}),e.type==="workflow_update")return await Bv(t,s.event);if(e.type==="message_created"){let h=s.event,w=h.payload.message;i.logger=i.logger.with({messageId:w.id,conversationId:w.conversationId,userId:w.userId});let P=o.hookHandlers.before_incoming_message[w.type]??[];for(let S of P){let H=await S({...i,data:w});if(w=H?.data??w,H?.stop)return ft}let B={...i,user:h.payload.user,conversation:h.payload.conversation,message:w,event:h},v=o.messageHandlers[w.type]??[];for(let S of v)await S(B);let E=o.hookHandlers.after_incoming_message[w.type]??[];for(let S of E){let H=await S({...i,data:w});if(w=H?.data??w,H?.stop)return ft}return ft}if(e.type==="state_expired"){let w=s.event.payload.state,P={...i,state:w},B=o.stateExpiredHandlers["*"]??[];for(let v of B)await v(P);return ft}let l=s.event,f=o.hookHandlers.before_incoming_event[l.type]??[];for(let h of f){let w=await h({...i,data:l});if(l=w?.data??l,w?.stop)return ft}let p={...i,event:l},y=o.eventHandlers[l.type]??[];for(let h of y)await h(p);let g=o.hookHandlers.after_incoming_event[l.type]??[];for(let h of g){let w=await h({...i,data:l});if(l=w?.data??l,w?.stop)return ft}return ft},JI=async({ctx:t,logger:e,req:n,client:r,self:a})=>{let{input:o,type:i}=Ct(n);if(!i)throw new Error("Missing action type");let s=a.hookHandlers.before_incoming_call_action[i]??[];for(let g of s){let h=await g({ctx:t,logger:e,client:r,data:{type:i,input:o},...gn({client:r})});o=h?.data?.input??o,i=h?.data?.type??i}let l=a.actionHandlers[i];if(!l)throw new Error(`Action ${i} not found`);let f=await l({ctx:t,logger:e,input:o,client:r,type:i,...gn({client:r})}),p=a.hookHandlers.after_incoming_call_action[i]??[];for(let g of p){let h=await g({ctx:t,logger:e,client:r,data:{type:i,output:f},...gn({client:r})});i=h?.data?.type??i,f=h?.data?.output??f}return{status:200,body:JSON.stringify({output:f})}},gn=t=>({workflows:vr(t.client)});var jl=class{constructor(e){this.props=e;this._actionHandlers=e.actions,this._plugins=e.plugins}_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_plugins={};_registerOrder=0;get actionHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._actionHandlers[n];if(r)return r;for(let[a,o]of Object.entries(this._plugins)){let[i,s]=n.split(fn);if(!(i!==a||!s)&&(r=o.actionHandlers[s],r))return r}}})}get messageHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(s=>s.messageHandlers[n]??[]),a=this._messageHandlers[n]??[],o=this._messageHandlers["*"]??[],i=[...a,...o].sort((s,l)=>s.order-l.order).map(({handler:s})=>s);return ye.unique([...r,...i])}})}get eventHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(s=>s.eventHandlers[n]??[]),a=this._eventHandlers[n]??[],o=this._eventHandlers["*"]??[],i=[...a,...o].sort((s,l)=>s.order-l.order).map(({handler:s})=>s);return ye.unique([...r,...i])}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(s=>s.stateExpiredHandlers[n]??[]),a=this._stateExpiredHandlers[n]??[],o=this._stateExpiredHandlers["*"]??[],i=[...a,...o].sort((s,l)=>s.order-l.order).map(({handler:s})=>s);return ye.unique([...r,...i])}})}get hookHandlers(){return new Proxy({},{get:(e,n)=>{if(this._hookHandlers[n])return new Proxy({},{get:(a,o)=>{let i=Object.values(this._plugins).flatMap(y=>y.hookHandlers[n]?.[o]??[]),s=this._hookHandlers[n]??{},l=s[o]??[],f=s["*"]??[],p=[...l,...f].sort((y,g)=>y.order-g.order).map(({handler:y})=>y);return ye.unique([...i,...p])}})}})}get workflowHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._workflowHandlers[n];if(r)return new Proxy({},{get:(a,o)=>{let i=r[o]?.sort((l,f)=>l.order-f.order).map(({handler:l})=>l)??[],s=Object.values(this._plugins).flatMap(l=>l.workflowHandlers[n]?.[o]??[]);return ye.unique([...i,...s])}})}})}on={message:(e,n)=>{this._messageHandlers[e]=ye.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=ye.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=ye.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=ye.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=ye.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=ye.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=ye.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=ye.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=ye.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=ye.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=ye.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=ye.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=ye.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=ye.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=ye.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=ye.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};handler=Ev(this);start=e=>za(this.handler,e)};C();R();O();C();R();O();C();R();O();C();R();O();C();R();O();var Kl=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.title=e.title,this.description=e.description,this.readme=e.readme,this.entities=e.entities??{},this.attributes=e.attributes;let n=this._getEntityReference(this.entities),r=e.events===void 0?{}:Le.mapValues(e.events,i=>({...i,schema:i.schema(n)})),a=e.actions===void 0?{}:Le.mapValues(e.actions,i=>({...i,input:{...i.input,schema:i.input.schema(n)},output:{...i.output,schema:i.output.schema(n)}})),o=e.channels===void 0?{}:Le.mapValues(e.channels,i=>({...i,messages:Le.mapValues(i.messages,s=>({...s,schema:s.schema(n)}))}));this.events=r,this.actions=a,this.channels=o}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;_getEntityReference=e=>{let n={};for(let[r,a]of Object.entries(e)){let o=a.schema._def["x-zui"]?.title,i=a.schema._def.description,s=by.ref(r);o&&s.title(o),i&&s.describe(i),n[r]=s}return n}};C();R();O();C();R();O();C();R();O();C();R();O();var Ll=class{constructor(e){this.props=e;let n=Object.fromEntries(Object.entries(e.interfaces??{}).map(([r,a])=>[r,Object.fromEntries(Object.entries(a.definition.entities??{}).map(([o])=>[o,Y.ref(`interface:${r}/entities/${o}`)]))]));this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.description=e.description,this.integrations=e.integrations,this.interfaces=e.interfaces,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.recurringEvents=e.recurringEvents,this.workflows=e.workflows,this.attributes=e.attributes,this.configuration=e.configuration,this.states=Object.fromEntries(Object.entries(e.states??{}).map(([r,a])=>[r,{...a,schema:typeof a.schema=="object"?a.schema:a.schema({entities:n})}])),this.events=Object.fromEntries(Object.entries(e.events??{}).map(([r,a])=>[r,{...a,schema:typeof a.schema=="object"?a.schema:a.schema({entities:n})}])),this.actions=Object.fromEntries(Object.entries(e.actions??{}).map(([r,a])=>[r,{...a,input:{...a.input,schema:typeof a.input.schema=="object"?a.input.schema:a.input.schema({entities:n})},output:{...a.output,schema:typeof a.output.schema=="object"?a.output.schema:a.output.schema({entities:n})}}])),this.tables=Object.fromEntries(Object.entries(e.tables??{}).map(([r,a])=>[r,{...a,schema:typeof a.schema=="object"?a.schema:a.schema({entities:n})}]))}name;version;title;description;icon;readme;attributes;integrations;interfaces;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;dereferenceEntities({intersectWithUnknownRecord:e}={intersectWithUnknownRecord:!0}){let n=this._buildZuiReferenceMap(e);return{...this,events:this._dereferenceDefinitionSchemas(this.events,n),states:this._dereferenceDefinitionSchemas(this.states,n),tables:this._dereferenceDefinitionSchemas(this.tables,n),actions:this._dereferenceActionDefinitionSchemas(this.actions,n)}}_buildZuiReferenceMap(e){return Object.fromEntries(Object.entries(this.interfaces??{}).flatMap(([n,r])=>Object.entries(r.definition.entities??{}).map(([a,o])=>[`interface:${n}/entities/${a}`,e?o.schema.and(Y.record(Y.string(),Y.unknown())):o.schema])))}_dereferenceZuiSchema(e,n){return e.dereference(n)}_dereferenceDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,a])=>[r,{...a,schema:this._dereferenceZuiSchema(a.schema,n)}]))}_dereferenceActionDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,a])=>[r,{...a,input:{schema:this._dereferenceZuiSchema(a.input.schema,n)},output:{schema:this._dereferenceZuiSchema(a.output.schema,n)}}]))}};C();R();O();C();R();O();C();R();O();C();R();O();var Fl=":";var kv=t=>{let[e,n]=t.split(Fl);return!e||!n?null:{namespace:e,eventName:n}},Iv=t=>`${t.namespace}${Fl}${t.actionName}`,Av=t=>`${t.namespace}${Fl}${t.eventName}`,Cv=(t,e)=>{let n=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},r=n.name,a=n.actions[t.actionName]?.name??t.actionName;return{namespace:r,actionName:a}},Ov=(t,e)=>{let n=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},r=n.name,a=n.events[t.eventName]?.name??t.eventName;return{namespace:r,eventName:a}};var Rv=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(a,o)=>i=>XI({client:t,interfaces:e.interfaces,integrationOrInterfaceName:r,methodName:o,input:i})})}),XI=async({client:t,interfaces:e,integrationOrInterfaceName:n,methodName:r,input:a})=>{let o=Cv({namespace:n,actionName:r},e),i=Iv(o);return(await t.callAction({type:i,input:a})).output};C();R();O();C();R();O();C();R();O();var Fn=class{constructor(e){this._props=e}async emit(e){let{conversationId:n,userId:r,messageId:a}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:n,userId:r,messageId:a})}async schedule(e,n){let{conversationId:r,userId:a,messageId:o}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:r,userId:a,messageId:o,schedule:n})}withConversationId(e){return new Fn({...this._props,conversationId:e})}withUserId(e){return new Fn({...this._props,userId:e})}withMessageId(e){return new Fn({...this._props,messageId:e})}},Mv=(t,e)=>new Proxy({},{get:(n,r)=>{let a=e.alias!==void 0?`${e.alias}${fn}${r}`:r;return new Fn({client:t,eventName:a})}});C();R();O();C();R();O();C();R();O();var Wl=class{constructor(e,n,r){this._client=e;this._stateType=n;this._stateName=r}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(n=>n.state.payload)}async set(e,n){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:n})}async getOrSet(e,n){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:n}).then(r=>r.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,n){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:n})}},Nv=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(a,o)=>{let i=e.alias!==void 0?`${e.alias}${fn}${o}`:o;return new Wl(t,r,i)}})});C();R();O();var zl=class{constructor(e){this.props=e;this._actionHandlers=e.actions}_runtimeProps;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_registerOrder=0;initialize(e){return this._runtimeProps=e,this}get _runtime(){if(!this._runtimeProps)throw new Error("Plugin not correctly initialized. This is likely because you access your plugin config outside of an handler.");return this._runtimeProps}_getTools(e){let{configuration:n,interfaces:r,alias:a}=this._runtime,o=Rv(e,this._runtime),i=Nv(e,this._runtime),s=vr(e),l=Mv(e,this._runtime);return{configuration:n,interfaces:r,actions:o,states:i,alias:a,workflows:s,events:l}}get actionHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=this._actionHandlers[n];if(r)return Qt.setName(a=>r({...a,...this._getTools(a.client)}),r.name)}})}get messageHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=this._messageHandlers[n]??[],a=this._messageHandlers["*"]??[];return ye.unique([...r,...a]).sort((i,s)=>i.order-s.order).map(({handler:i})=>Qt.setName(s=>i({...s,...this._getTools(s.client)}),i.name))}})}get eventHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=this._eventHandlers[n]??[],a=Object.entries(this._eventHandlers).filter(([s])=>this._eventResolvesTo(s,n)).flatMap(([,s])=>s??[]),o=this._eventHandlers["*"]??[];return ye.unique([...r,...a,...o]).sort((s,l)=>s.order-l.order).map(({handler:s})=>Qt.setName(l=>s({...l,...this._getTools(l.client)}),s.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=this._stateExpiredHandlers[n]??[],a=this._stateExpiredHandlers["*"]??[];return ye.unique([...r,...a]).sort((i,s)=>i.order-s.order).map(({handler:i})=>Qt.setName(s=>i({...s,...this._getTools(s.client)}),i.name))}})}get hookHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._hookHandlers[n];if(r)return new Proxy({},{get:(a,o)=>{o=this._stripAliasPrefix(o);let i=r[o]??[],s=Object.entries(r).filter(([p])=>this._eventResolvesTo(p,o)).flatMap(([,p])=>p??[]),l=r["*"]??[];return ye.unique([...i,...s,...l]).sort((p,y)=>p.order-y.order).map(({handler:p})=>Qt.setName(y=>p({...y,...this._getTools(y.client)}),p.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._workflowHandlers[n];if(r)return new Proxy({},{get:(a,o)=>(r[o]?.sort((s,l)=>s.order-l.order)??[]).map(({handler:s})=>Qt.setName(l=>s({...l,...this._getTools(l.client)}),s.name))})}})}on={message:(e,n)=>{this._messageHandlers[e]=ye.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=ye.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=ye.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=ye.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=ye.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=ye.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=ye.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=ye.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=ye.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=ye.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=ye.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=ye.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=ye.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=ye.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=ye.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=ye.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};_eventResolvesTo=(e,n)=>{let r=kv(e);if(!r)return!1;let a=Ov(r,this._runtime.interfaces);return Av(a)===n};_stripAliasPrefix=e=>{let{alias:n}=this._runtime;if(!n)return e;let r=`${n}:`;return e.startsWith(r)?e.slice(r.length):e}};C();R();O();C();R();O();C();R();O();C();R();O();C();R();O();C();R();O();export{Rx as BRAND,jl as Bot,Zl as BotDefinition,Ln as BotLogger,en as BotSpecificClient,Xn as DIRTY,Ix as EMPTY_PATH,pe as INVALID,Ul as Integration,el as IntegrationDefinition,Kn as IntegrationLogger,ii as IntegrationSpecificClient,Kl as InterfaceDefinition,RP as NEVER,pt as OK,It as ParseInputLazyPath,vt as ParseStatus,zl as Plugin,Ll as PluginDefinition,iU as RuntimeError,he as Schema,QA as WELL_KNOWN_ATTRIBUTES,Fr as ZodAny,Wr as ZodArray,jo as ZodBigInt,Ko as ZodBoolean,Lo as ZodBranded,Fo as ZodCatch,Wo as ZodDate,ha as ZodDefault,fg as ZodDiscriminatedUnion,Sn as ZodEffects,or as ZodEnum,Kt as ZodError,Yp as ZodFirstPartyTypeKind,pg as ZodFunction,qo as ZodIntersection,G as ZodIssueCode,Go as ZodLazy,Vo as ZodLiteral,yg as ZodMap,hg as ZodNaN,Jo as ZodNativeEnum,Gr as ZodNever,Xo as ZodNull,tr as ZodNullable,Yo as ZodNumber,nr as ZodObject,an as ZodOptional,ne as ZodParsedType,Qo as ZodPipeline,Ta as ZodPromise,_a as ZodReadonly,Pg as ZodRecord,Sg as ZodRef,he as ZodSchema,Eg as ZodSet,gt as ZodString,Ug as ZodSymbol,Sn as ZodTransformer,ir as ZodTuple,he as ZodType,ba as ZodUndefined,es as ZodUnion,Ur as ZodUnknown,Kg as ZodVoid,te as addIssueToContext,$x as agent,Wx as aimodel,nP as any,oP as array,Xx as bigint,Wg as boolean,wa as botIdHeader,Oy as botUserIdHeader,OP as coerce,xa as configurationHeader,Ny as configurationTypeHeader,Hx as conversation,va as createZodEnum,Ig as cuid2Regex,kg as cuidRegex,ug as custom,zx as datasource,Yx as date,cP as discriminatedUnion,Gc as effect,Og as emailRegex,bP as enum,ue as errorUtil,jx as event,vP as function,Kr as getErrorMap,rn as getParsedType,Vx as instanceof,Ry as integrationIdHeader,Fx as intent,fP as intersection,Mg as ipv4Regex,Ng as ipv6Regex,_o as isAborted,rU as isApiError,ki as isAsync,bo as isDirty,Mx as isEmojiRegex,Lr as isValid,qx as knowledgebase,Gx as late,TP as lazy,_P as literal,Ei as makeIssue,mP as map,Vr as mergeObjectSchemas,Zx as message,Cy as messages,Jx as nan,wP as nativeEnum,iP as never,tP as null,BP as nullable,Fg as number,sP as object,To as objectUtil,CP as oboolean,AP as onumber,Pa as operationHeader,PP as optional,IP as ostring,Ct as parseBody,kP as pipeline,EP as preprocess,me as processCreateParams,xP as promise,kx as quotelessJson,yP as readonly,pP as record,gP as ref,za as serve,hP as set,tg as setErrorMap,lP as strictObject,Lg as string,Qx as symbol,Kx as table,Lx as tablerow,Gc as transformer,zv as transforms,dP as tuple,Dy as typeHeader,Ag as ulidRegex,eP as undefined,uP as union,rP as unknown,Ux as user,be as util,Cg as uuidRegex,Dx as variable,aP as void,My as webhookIdHeader,Y as z};
88
+ `)+" "+F[1]:F[0]+j+" "+D.join(", ")+" "+F[1]}xe.types=_I();function B(D){return Array.isArray(D)}xe.isArray=B;function v(D){return typeof D=="boolean"}xe.isBoolean=v;function E(D){return D===null}xe.isNull=E;function S(D){return D==null}xe.isNullOrUndefined=S;function H(D){return typeof D=="number"}xe.isNumber=H;function K(D){return typeof D=="string"}xe.isString=K;function ae(D){return typeof D=="symbol"}xe.isSymbol=ae;function ee(D){return D===void 0}xe.isUndefined=ee;function ge(D){return oe(D)&&Ve(D)==="[object RegExp]"}xe.isRegExp=ge,xe.types.isRegExp=ge;function oe(D){return typeof D=="object"&&D!==null}xe.isObject=oe;function re(D){return oe(D)&&Ve(D)==="[object Date]"}xe.isDate=re,xe.types.isDate=re;function Oe(D){return oe(D)&&(Ve(D)==="[object Error]"||D instanceof Error)}xe.isError=Oe,xe.types.isNativeError=Oe;function ze(D){return typeof D=="function"}xe.isFunction=ze;function tt(D){return D===null||typeof D=="boolean"||typeof D=="number"||typeof D=="string"||typeof D=="symbol"||typeof D>"u"}xe.isPrimitive=tt,xe.isBuffer=bI();function Ve(D){return Object.prototype.toString.call(D)}function Je(D){return D<10?"0"+D.toString(10):D.toString(10)}var mt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ue(){var D=new Date,j=[Je(D.getHours()),Je(D.getMinutes()),Je(D.getSeconds())].join(":");return[D.getDate(),mt[D.getMonth()],j].join(" ")}xe.log=function(){console.log("%s - %s",Ue(),xe.format.apply(xe,arguments))},xe.inherits=Mt(),xe._extend=function(D,j){if(!j||!oe(j))return D;for(var F=Object.keys(j),de=F.length;de--;)D[F[de]]=j[F[de]];return D};function Pe(D,j){return Object.prototype.hasOwnProperty.call(D,j)}var Ee=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;xe.promisify=function(j){if(typeof j!="function")throw new TypeError('The "original" argument must be of type Function');if(Ee&&j[Ee]){if(F=j[Ee],typeof F!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(F,Ee,{value:F,enumerable:!1,writable:!1,configurable:!0}),F}function F(){for(var de,Te,A=new Promise(function(X,ie){de=X,Te=ie}),k=[],$=0;$<arguments.length;$++)k.push(arguments[$]);k.push(function(X,ie){X?Te(X):de(ie)});try{j.apply(this||si,k)}catch(X){Te(X)}return A}return Object.setPrototypeOf(F,Object.getPrototypeOf(j)),Ee&&Object.defineProperty(F,Ee,{value:F,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(F,e(j))},xe.promisify.custom=Ee;function fe(D,j){if(!D){var F=new Error("Promise was rejected with a falsy value");F.reason=D,D=F}return j(D)}function ve(D){if(typeof D!="function")throw new TypeError('The "original" argument must be of type Function');function j(){for(var F=[],de=0;de<arguments.length;de++)F.push(arguments[de]);var Te=F.pop();if(typeof Te!="function")throw new TypeError("The last argument must be of type Function");var A=this||si,k=function(){return Te.apply(A,arguments)};D.apply(this||si,F).then(function($){t.nextTick(k.bind(null,null,$))},function($){t.nextTick(fe.bind(null,$,k))})}return Object.setPrototypeOf(j,Object.getPrototypeOf(D)),Object.defineProperties(j,e(D)),j}return xe.callbackify=ve,xe}var ce=wI();ce.format;ce.deprecate;ce.debuglog;ce.inspect;ce.types;ce.isArray;ce.isBoolean;ce.isNull;ce.isNullOrUndefined;ce.isNumber;ce.isString;ce.isSymbol;ce.isUndefined;ce.isRegExp;ce.isObject;ce.isDate;ce.isError;ce.isFunction;ce.isPrimitive;ce.isBuffer;ce.log;ce.inherits;ce._extend;ce.promisify;ce.callbackify;var ZR=ce._extend,$R=ce.callbackify,jR=ce.debuglog,KR=ce.deprecate,LR=ce.format,FR=ce.inherits,WR=ce.inspect,zR=ce.isArray,qR=ce.isBoolean,GR=ce.isBuffer,VR=ce.isDate,JR=ce.isError,XR=ce.isFunction,YR=ce.isNull,QR=ce.isNullOrUndefined,e0=ce.isNumber,t0=ce.isObject,n0=ce.isPrimitive,r0=ce.isRegExp,i0=ce.isString,a0=ce.isSymbol,o0=ce.isUndefined,s0=ce.log,l0=ce.promisify,u0=ce.types,c0=ce.TextEncoder=globalThis.TextEncoder,f0=ce.TextDecoder=globalThis.TextDecoder;var hr=class{defaultOptions;constructor(e){this.defaultOptions=e}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}_log(e,n){this._getConsoleMethod(e)(this._serializeMessage(n))}_serializeMessage(e){let n=ce.format(...e);return J.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(n):n}getJsonMessage(e){return JSON.stringify({msg:e,options:this.defaultOptions})}_getConsoleMethod(e){switch(e){case"debug":return console.debug;case"warn":return console.warn;case"error":return console.error;default:return console.info}}};var Kn=class extends hr{constructor(e){super({visibleToBotOwners:!0,...e})}with(e){return new Kn({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withVisibleToBotOwners(e){return this.with({visibleToBotOwners:e})}forBot(){return this.withVisibleToBotOwners(!0)}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,options:this.defaultOptions})}};C();R();O();var SI=t=>["traceparent","tracestate","sentry-trace"].reduce((e,n)=>(t[n]&&(e[n]=t[n]),e),{}),EI=(t,e,n)=>{let[,r]=(e.headers.traceparent||"").split("-"),a=new PI({botId:t.botId,integrationId:t.integrationId,retry:Va,headers:SI(e.headers)}),o=new ii(a),i=new Kn({traceId:r});return{ctx:t,req:e,client:o,logger:i,instance:n}},kI=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await AI(t);case"register":return await CI(t);case"unregister":return await OI(t);case"message_created":return await NI(t);case"action_triggered":return await DI(t);case"ping":return await II(t);case"create_user":return await RI(t);case"create_conversation":return await MI(t);default:throw new BI(`Unknown operation ${e.operation}`)}},xv=t=>async e=>{let n=$h(e.headers),r=EI(n,e,t),{logger:a}=r;try{let o;return o=await HI(r),o?{...o,status:o.status??200}:(o=await kI(r),o?{...o,status:o.status??200}:{status:200})}catch(o){if(xI(o)){let s=o.type==="Runtime"?o:new wv(o.message,o);return a.forBot().error(s.message),{status:s.code,body:JSON.stringify(s.toJSON())}}console.error(o);let i=new wv("An unexpected error occurred in the integration. Bot owners: Check logs for more informations. Integration owners: throw a RuntimeError to return a custom error message instead.");return a.forBot().error(i.message),{status:i.code,body:JSON.stringify(i.toJSON())}}},II=async t=>{},AI=async({client:t,ctx:e,req:n,logger:r,instance:a})=>{let{req:o}=Ct(n);return a.webhook({client:t,ctx:e,req:o,logger:r})},CI=async({client:t,ctx:e,req:n,logger:r,instance:a})=>{if(!a.register)return;let{webhookUrl:o}=Ct(n);await a.register({client:t,ctx:e,webhookUrl:o,logger:r})},OI=async({client:t,ctx:e,req:n,logger:r,instance:a})=>{if(!a.unregister)return;let{webhookUrl:o}=Ct(n);await a.unregister({ctx:e,webhookUrl:o,client:t,logger:r})},RI=async({client:t,ctx:e,req:n,logger:r,instance:a})=>{if(!a.createUser)return;let{tags:o}=Ct(n);return await a.createUser({ctx:e,client:t,tags:o,logger:r})},MI=async({client:t,ctx:e,req:n,logger:r,instance:a})=>{if(!a.createConversation)return;let{channel:o,tags:i}=Ct(n);return await a.createConversation({ctx:e,client:t,channel:o,tags:i,logger:r})},NI=async({ctx:t,req:e,client:n,logger:r,instance:a})=>{let{conversation:o,user:i,type:s,payload:l,message:f}=Ct(e),p=a.channels[o.channel];if(!p)throw new Error(`Channel ${o.channel} not found`);let y=p.messages[s];if(!y)throw new Error(`Message of type ${s} not found in channel ${o.channel}`);await y({ctx:t,conversation:o,message:f,user:i,type:s,client:n,payload:l,ack:async({tags:h})=>{await n.updateMessage({id:f.id,tags:h})},logger:r})},DI=async({req:t,ctx:e,client:n,logger:r,instance:a})=>{let{input:o,type:i}=Ct(t);if(!i)throw new Error("Missing action type");let s=a.actions[i];if(!s)throw new Error(`Action ${i} not found`);let l=new Ja,p={output:await s({ctx:e,input:o,client:n,type:i,logger:r,metadata:l}),meta:l.toJSON()};return{body:JSON.stringify(p)}},HI=async({instance:t,client:e,ctx:n,logger:r,req:a})=>{let o=t.unknownOperationHandler;if(o)return await o({client:e,ctx:n,logger:r,req:a})};var Ul=class{constructor(e){this.props=e;this.actions=e.actions,this.channels=e.channels,this.register=e.register,this.unregister=e.unregister,this.createUser=e.createUser,this.createConversation=e.createConversation,this.webhook=e.handler,this.unknownOperationHandler=e.__advanced?.unknownOperationHandler}actions;channels;register;unregister;createUser;createConversation;webhook;unknownOperationHandler;handler=xv(this);start=e=>za(this.handler,e)};C();R();O();C();R();O();C();R();O();C();R();O();C();R();O();var Zl=class{constructor(e){this.props=e;this.integrations=e.integrations,this.plugins=e.plugins,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.states=e.states,this.configuration=e.configuration,this.events=e.events,this.recurringEvents=e.recurringEvents,this.actions=e.actions,this.tables=e.tables,this.workflows=e.workflows,this.attributes=e.attributes,this.withPlugins={user:e.user,conversation:e.conversation,message:e.message,states:e.states,events:e.events,recurringEvents:e.recurringEvents,actions:e.actions,tables:e.tables,workflows:e.workflows}}integrations;plugins;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;attributes;withPlugins;addIntegration(e,n){let r=this;return r.integrations||(r.integrations={}),r.integrations[e.name]={enabled:n.enabled,...e,configurationType:n.configurationType,configuration:n.configuration,disabledChannels:n.disabledChannels},this}addPlugin(e,n){let r=this;r.plugins||(r.plugins={});let a=n.alias??e.name.replace("/","-");return r.plugins[a]={...e,alias:a,configuration:n.configuration,interfaces:n.interfaces},r.withPlugins.user=this._mergeUser(r.withPlugins.user,e.definition.user),r.withPlugins.conversation=this._mergeConversation(r.withPlugins.conversation,e.definition.conversation),r.withPlugins.message=this._mergeMessage(r.withPlugins.message,e.definition.message),r.withPlugins.recurringEvents=this._mergeRecurringEvents(r.withPlugins.recurringEvents,e.definition.recurringEvents),r.withPlugins.tables=this._mergeTables(r.withPlugins.tables,e.definition.tables),r.withPlugins.workflows=this._mergeWorkflows(r.withPlugins.workflows,e.definition.workflows),r.withPlugins.states=this._mergeStates(r.withPlugins.states,this._prefixKeysWithPluginAlias(e.definition.states,a)),r.withPlugins.events=this._mergeEvents(r.withPlugins.events,this._prefixKeysWithPluginAlias(e.definition.events,a)),r.withPlugins.actions=this._mergeActions(r.withPlugins.actions,this._prefixKeysWithPluginAlias(e.definition.actions,a)),this}_mergeUser=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeConversation=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeMessage=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeStates=(e,n)=>({...e,...n});_mergeEvents=(e,n)=>({...e,...n});_mergeRecurringEvents=(e,n)=>({...e,...n});_mergeActions=(e,n)=>({...e,...n});_mergeTables=(e,n)=>({...e,...n});_mergeWorkflows=(e,n)=>({...e,...n});_prefixKeysWithPluginAlias=(e,n)=>Le.mapKeys(e??{},r=>`${n}${fn}${r}`);dereferencePluginEntities(){let e=this._buildZuiReferenceMap();return{...this,withPlugins:{...this.withPlugins,events:this._dereferenceDefinitionSchemas(this.withPlugins.events,e),states:this._dereferenceDefinitionSchemas(this.withPlugins.states,e),tables:this._dereferenceDefinitionSchemas(this.withPlugins.tables,e),actions:this._dereferenceActionDefinitionSchemas(this.withPlugins.actions,e)},plugins:Object.fromEntries(Object.entries(this.plugins??{}).map(([n,r])=>[n,{...r,definition:{...r.definition,events:this._dereferenceDefinitionSchemas(r.definition.events,e),states:this._dereferenceDefinitionSchemas(r.definition.states,e),tables:this._dereferenceDefinitionSchemas(r.definition.tables,e),actions:this._dereferenceActionDefinitionSchemas(r.definition.actions,e)}}]))}}_buildZuiReferenceMap(){let e={},n=Object.entries(this.plugins??{});for(let[r,a]of n){let o=Object.entries(a.interfaces??{});for(let[i,s]of o){let l=this.integrations?.[s.name];if(!l)throw new Error(`Interface with alias "${i}" of plugin with alias "${r}" references integration "${s.name}" which is not installed`);let f=Object.entries(s.entities??{});for(let[p,{name:y}]of f){let g=l.definition.entities?.[y]?.schema;if(!g)throw new Error(`Interface entity "${y}" does not exist in integration "${l.name}"`);e[`interface:${i}/entities/${p}`]=g}}}return e}_dereferenceZuiSchema(e,n){return e.dereference(n)}_dereferenceDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,a])=>[r,{...a,schema:this._dereferenceZuiSchema(a.schema,n)}]))}_dereferenceActionDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,a])=>[r,{...a,input:{schema:this._dereferenceZuiSchema(a.input.schema,n)},output:{schema:this._dereferenceZuiSchema(a.output.schema,n)}}]))}};C();R();O();C();R();O();import{isApiError as FI,Client as WI,RuntimeError as Sv}from"@botpress/client";C();R();O();var Ln=class extends hr{constructor(e){super({...e})}with(e){return new Ln({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withWorkflowId(e){return this.with({workflowId:e})}withEventId(e){return this.with({eventId:e})}withMessageId(e){return this.with({messageId:e})}};C();R();O();C();R();O();var en=class{constructor(e,n={before:{},after:{}}){this._client=e;this._hooks=n}get _inner(){return this._client}getConversation=e=>this._run("getConversation",e);listConversations=e=>this._run("listConversations",e);updateConversation=e=>this._run("updateConversation",e);deleteConversation=e=>this._run("deleteConversation",e);listParticipants=e=>this._run("listParticipants",e);addParticipant=e=>this._run("addParticipant",e);getParticipant=e=>this._run("getParticipant",e);removeParticipant=e=>this._run("removeParticipant",e);createEvent=e=>this._run("createEvent",e);getEvent=e=>this._run("getEvent",e);listEvents=e=>this._run("listEvents",e);createMessage=e=>this._run("createMessage",e);getOrCreateMessage=e=>this._run("getOrCreateMessage",e);getMessage=e=>this._run("getMessage",e);updateMessage=e=>this._run("updateMessage",e);listMessages=e=>this._run("listMessages",e);deleteMessage=e=>this._run("deleteMessage",e);getUser=e=>this._run("getUser",e);listUsers=e=>this._run("listUsers",e);updateUser=e=>this._run("updateUser",e);deleteUser=e=>this._run("deleteUser",e);getState=e=>this._run("getState",e);setState=e=>this._run("setState",e);getOrSetState=e=>this._run("getOrSetState",e);patchState=e=>this._run("patchState",e);callAction=e=>this._run("callAction",e);uploadFile=e=>this._run("uploadFile",e);upsertFile=e=>this._run("upsertFile",e);deleteFile=e=>this._run("deleteFile",e);listFiles=e=>this._run("listFiles",e);getFile=e=>this._run("getFile",e);updateFileMetadata=e=>this._run("updateFileMetadata",e);searchFiles=e=>this._run("searchFiles",e);trackAnalytics=e=>this._run("trackAnalytics",e);getTableRow=e=>this._run("getTableRow",e);createTableRows=e=>this._run("createTableRows",e);findTableRows=e=>this._run("findTableRows",e);deleteTableRows=e=>this._run("deleteTableRows",e);updateTableRows=e=>this._run("updateTableRows",e);upsertTableRows=e=>this._run("upsertTableRows",e);createWorkflow=e=>this._run("createWorkflow",e);getWorkflow=e=>this._run("getWorkflow",e);updateWorkflow=e=>this._run("updateWorkflow",e);deleteWorkflow=e=>this._run("deleteWorkflow",e);listWorkflows=e=>this._run("listWorkflows",e);createConversation=e=>this._client.createConversation(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);createUser=e=>this._client.createUser(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);_run=async(e,n)=>{let r=this._hooks.before[e];r&&(n=await r(n));let a=await this._client[e](n),o=this._hooks.after[e];return o&&(a=await o(a,n)),a}};C();R();O();C();R();O();var vr=t=>new Proxy({},{get:(e,n)=>({listInstances:{all:r=>dn({workflowName:n,client:t,input:r}),running:r=>dn({workflowName:n,client:t,input:r,statuses:["in_progress"]}),scheduled:r=>dn({workflowName:n,client:t,input:r,statuses:["pending","listening"]}),allFinished:r=>dn({workflowName:n,client:t,input:r,statuses:["completed","cancelled","failed","timedout"]}),cancelled:r=>dn({workflowName:n,client:t,input:r,statuses:["cancelled"]}),failed:r=>dn({workflowName:n,client:t,input:r,statuses:["failed"]}),succeeded:r=>dn({workflowName:n,client:t,input:r,statuses:["completed"]}),timedOut:r=>dn({workflowName:n,client:t,input:r,statuses:["timedout"]})},startNewInstance:async r=>{let{workflow:a}=await t.createWorkflow({name:n,status:"pending",...r});return{workflow:pn({client:t,workflow:a})}}})}),dn=async t=>{let e=await t.client.listWorkflows({name:t.workflowName,statuses:t.statuses,...t.input});return{...e,workflows:e.workflows.map(n=>pn({client:t.client,workflow:n}))}},pn=t=>({...t.workflow,async update(e){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,...e});return{workflow:pn({client:t.client,workflow:n})}},async setFailed({failureReason:e}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:e});return{workflow:pn({client:t.client,workflow:n})}},async setCompleted({output:e}={}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:e});return{workflow:pn({client:t.client,workflow:n})}},async cancel(){let{workflow:e}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return{workflow:pn({client:t.client,workflow:e})}}});C();R();O();C();R();O();var UI=Y.enum(["event_received","register","unregister","ping","action_triggered"]),Pv=t=>{let e=t[wa],n=t[xa],r=t[Dy],a=UI.parse(t[Pa]);if(!e)throw new Error("Missing bot headers");if(!r)throw new Error("Missing type headers");if(!n)throw new Error("Missing configuration headers");if(!a)throw new Error("Missing operation headers");return{botId:e,operation:a,type:r,configuration:n?JSON.parse(q.from(n,"base64").toString("utf-8")):{}}};C();R();O();var ft={status:200};C();R();O();C();R();O();var $l=t=>{switch(t){case"workflow_continued":return"continued";case"workflow_started":return"started";case"workflow_timedout":return"timed_out";default:throw new Error(`Unsupported workflow update type: ${t}`)}};var ZI=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],Bv=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!ZI.includes(e.payload.type))throw new Error("Unexpected event type");let n={...t,logger:$I(t,e)};if(!e.payload.workflow.name)return n.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),ft;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":n.logger.info(`Received child workflow event "${e.payload.type}", but child workflows are not yet supported`);break;case"workflow_timedout":case"workflow_started":case"workflow_continued":return await jI(n,e);default:e.payload.type}return ft},$I=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),jI=async(t,e)=>{let n=$l(e.payload.type),r=t.self.workflowHandlers[n]?.[e.payload.workflow.name];return!r||r.length===0?(t.logger.warn(`No ${n} handler found for workflow "${e.payload.workflow.name}"`),ft):(await KI(t,e),await LI(t,e),ft)},KI=async(t,e)=>{e.payload.workflow.status==="pending"&&await t.client.updateWorkflow({id:e.payload.workflow.id,status:"in_progress",eventId:e.id})},LI=async(t,e)=>{let n=$l(e.payload.type),r=t.self.workflowHandlers[n]?.[e.payload.workflow.name];for(let a of r)await a({...t,conversation:e.payload.conversation,user:e.payload.user,workflow:pn({...t,workflow:e.payload.workflow}),workflows:vr(t.client)})};C();R();O();var Ev=t=>async e=>{let n=Pv(e.headers),r=new Ln,a=new WI({botId:n.botId,retry:Va}),o=new en(a,{before:{createMessage:async s=>{let l=t.hookHandlers.before_outgoing_message[s.type]??[];for(let f of l){let p=new en(a);s=(await f({client:p,ctx:n,logger:r.with({conversationId:s.conversationId,userId:s.userId}),data:s,...gn({client:p})}))?.data??s}return s},callAction:async s=>{let l=t.hookHandlers.before_outgoing_call_action[s.type]??[];for(let f of l){let p=new en(a);s=(await f({client:p,ctx:n,logger:r,data:s,...gn({client:p})}))?.data??s}return s}},after:{createMessage:async s=>{let l=t.hookHandlers.after_outgoing_message[s.message.type]??[];for(let f of l){let p=new en(a);s=(await f({client:p,ctx:n,logger:r.with({messageId:s.message.id,conversationId:s.message.conversationId,userId:s.message.userId}),data:s,...gn({client:p})}))?.data??s}return s},callAction:async(s,l)=>{let{type:f}=l,p=t.hookHandlers.after_outgoing_call_action[f]??[];for(let y of p){let g=new en(a);s=(await y({client:g,ctx:n,logger:r,data:{type:f,...s},...gn({client:g})}))?.data??s}return s}}}),i={req:e,ctx:n,logger:r,client:o,self:t};try{switch(n.operation){case"action_triggered":return await JI(i);case"event_received":return await VI(i);case"register":return await qI(i);case"unregister":return await GI(i);case"ping":return await zI(i);default:throw new Error(`Unknown operation ${n.operation}`)}}catch(s){let l=s instanceof Error?s:new Error(String(s));if(FI(l)){let p=l.type==="Runtime"?l:new Sv(l.message,l);return r.error(p.message),{status:p.code,body:JSON.stringify(p.toJSON())}}let f=new Sv("An unexpected error occurred in the bot.",l);return r.error(f.message,l),{status:f.code,body:JSON.stringify(f.toJSON())}}},zI=async t=>ft,qI=async t=>ft,GI=async t=>ft,VI=async t=>{let{ctx:e,logger:n,req:r,client:a,self:o}=t,i={client:a,ctx:e,logger:n,...gn({client:a})},s=Ct(r);if(i.logger=i.logger.with({eventId:s.event.id,messageId:s.event.messageId,conversationId:s.event.conversationId,userId:s.event.userId}),e.type==="workflow_update")return await Bv(t,s.event);if(e.type==="message_created"){let h=s.event,w=h.payload.message;i.logger=i.logger.with({messageId:w.id,conversationId:w.conversationId,userId:w.userId});let P=o.hookHandlers.before_incoming_message[w.type]??[];for(let S of P){let H=await S({...i,data:w});if(w=H?.data??w,H?.stop)return ft}let B={...i,user:h.payload.user,conversation:h.payload.conversation,message:w,event:h},v=o.messageHandlers[w.type]??[];for(let S of v)await S(B);let E=o.hookHandlers.after_incoming_message[w.type]??[];for(let S of E){let H=await S({...i,data:w});if(w=H?.data??w,H?.stop)return ft}return ft}if(e.type==="state_expired"){let w=s.event.payload.state,P={...i,state:w},B=o.stateExpiredHandlers["*"]??[];for(let v of B)await v(P);return ft}let l=s.event,f=o.hookHandlers.before_incoming_event[l.type]??[];for(let h of f){let w=await h({...i,data:l});if(l=w?.data??l,w?.stop)return ft}let p={...i,event:l},y=o.eventHandlers[l.type]??[];for(let h of y)await h(p);let g=o.hookHandlers.after_incoming_event[l.type]??[];for(let h of g){let w=await h({...i,data:l});if(l=w?.data??l,w?.stop)return ft}return ft},JI=async({ctx:t,logger:e,req:n,client:r,self:a})=>{let{input:o,type:i}=Ct(n);if(!i)throw new Error("Missing action type");let s=a.hookHandlers.before_incoming_call_action[i]??[];for(let g of s){let h=await g({ctx:t,logger:e,client:r,data:{type:i,input:o},...gn({client:r})});o=h?.data?.input??o,i=h?.data?.type??i}let l=a.actionHandlers[i];if(!l)throw new Error(`Action ${i} not found`);let f=await l({ctx:t,logger:e,input:o,client:r,type:i,...gn({client:r})}),p=a.hookHandlers.after_incoming_call_action[i]??[];for(let g of p){let h=await g({ctx:t,logger:e,client:r,data:{type:i,output:f},...gn({client:r})});i=h?.data?.type??i,f=h?.data?.output??f}return{status:200,body:JSON.stringify({output:f})}},gn=t=>({workflows:vr(t.client)});var jl=class{constructor(e){this.props=e;this._actionHandlers=e.actions,this._plugins=e.plugins}_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_plugins={};_registerOrder=0;get actionHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._actionHandlers[n];if(r)return r;for(let[a,o]of Object.entries(this._plugins)){let[i,s]=n.split(fn);if(!(i!==a||!s)&&(r=o.actionHandlers[s],r))return r}}})}get messageHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(s=>s.messageHandlers[n]??[]),a=this._messageHandlers[n]??[],o=this._messageHandlers["*"]??[],i=[...a,...o].sort((s,l)=>s.order-l.order).map(({handler:s})=>s);return ye.unique([...r,...i])}})}get eventHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(s=>s.eventHandlers[n]??[]),a=this._eventHandlers[n]??[],o=this._eventHandlers["*"]??[],i=[...a,...o].sort((s,l)=>s.order-l.order).map(({handler:s})=>s);return ye.unique([...r,...i])}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(s=>s.stateExpiredHandlers[n]??[]),a=this._stateExpiredHandlers[n]??[],o=this._stateExpiredHandlers["*"]??[],i=[...a,...o].sort((s,l)=>s.order-l.order).map(({handler:s})=>s);return ye.unique([...r,...i])}})}get hookHandlers(){return new Proxy({},{get:(e,n)=>{if(this._hookHandlers[n])return new Proxy({},{get:(a,o)=>{let i=Object.values(this._plugins).flatMap(y=>y.hookHandlers[n]?.[o]??[]),s=this._hookHandlers[n]??{},l=s[o]??[],f=s["*"]??[],p=[...l,...f].sort((y,g)=>y.order-g.order).map(({handler:y})=>y);return ye.unique([...i,...p])}})}})}get workflowHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._workflowHandlers[n];if(r)return new Proxy({},{get:(a,o)=>{let i=r[o]?.sort((l,f)=>l.order-f.order).map(({handler:l})=>l)??[],s=Object.values(this._plugins).flatMap(l=>l.workflowHandlers[n]?.[o]??[]);return ye.unique([...i,...s])}})}})}on={message:(e,n)=>{this._messageHandlers[e]=ye.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=ye.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=ye.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=ye.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=ye.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=ye.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=ye.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=ye.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=ye.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=ye.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=ye.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=ye.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=ye.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=ye.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=ye.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=ye.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};handler=Ev(this);start=e=>za(this.handler,e)};C();R();O();C();R();O();C();R();O();C();R();O();C();R();O();var Kl=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.title=e.title,this.description=e.description,this.readme=e.readme,this.entities=e.entities??{},this.attributes=e.attributes;let n=this._getEntityReference(this.entities),r=e.events===void 0?{}:Le.mapValues(e.events,i=>({...i,schema:i.schema(n)})),a=e.actions===void 0?{}:Le.mapValues(e.actions,i=>({...i,input:{...i.input,schema:i.input.schema(n)},output:{...i.output,schema:i.output.schema(n)}})),o=e.channels===void 0?{}:Le.mapValues(e.channels,i=>({...i,messages:Le.mapValues(i.messages,s=>({...s,schema:s.schema(n)}))}));this.events=r,this.actions=a,this.channels=o}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;_getEntityReference=e=>{let n={};for(let[r,a]of Object.entries(e)){let o=a.schema._def["x-zui"]?.title,i=a.schema._def.description,s=by.ref(r);o&&s.title(o),i&&s.describe(i),n[r]=s}return n}};C();R();O();C();R();O();C();R();O();C();R();O();var Ll=class{constructor(e){this.props=e;let n=Object.fromEntries(Object.entries(e.interfaces??{}).map(([r,a])=>[r,Object.fromEntries(Object.entries(a.definition.entities??{}).map(([o])=>[o,Y.ref(`interface:${r}/entities/${o}`)]))]));this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.description=e.description,this.integrations=e.integrations,this.interfaces=e.interfaces,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.recurringEvents=e.recurringEvents,this.workflows=e.workflows,this.attributes=e.attributes,this.configuration=e.configuration,this.states=Object.fromEntries(Object.entries(e.states??{}).map(([r,a])=>[r,{...a,schema:typeof a.schema=="object"?a.schema:a.schema({entities:n})}])),this.events=Object.fromEntries(Object.entries(e.events??{}).map(([r,a])=>[r,{...a,schema:typeof a.schema=="object"?a.schema:a.schema({entities:n})}])),this.actions=Object.fromEntries(Object.entries(e.actions??{}).map(([r,a])=>[r,{...a,input:{...a.input,schema:typeof a.input.schema=="object"?a.input.schema:a.input.schema({entities:n})},output:{...a.output,schema:typeof a.output.schema=="object"?a.output.schema:a.output.schema({entities:n})}}])),this.tables=Object.fromEntries(Object.entries(e.tables??{}).map(([r,a])=>[r,{...a,schema:typeof a.schema=="object"?a.schema:a.schema({entities:n})}]))}name;version;title;description;icon;readme;attributes;integrations;interfaces;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;dereferenceEntities({intersectWithUnknownRecord:e}={intersectWithUnknownRecord:!0}){let n=this._buildZuiReferenceMap(e);return{...this,events:this._dereferenceDefinitionSchemas(this.events,n),states:this._dereferenceDefinitionSchemas(this.states,n),tables:this._dereferenceDefinitionSchemas(this.tables,n),actions:this._dereferenceActionDefinitionSchemas(this.actions,n)}}_buildZuiReferenceMap(e){return Object.fromEntries(Object.entries(this.interfaces??{}).flatMap(([n,r])=>Object.entries(r.definition.entities??{}).map(([a,o])=>[`interface:${n}/entities/${a}`,e?o.schema.and(Y.record(Y.string(),Y.unknown())):o.schema])))}_dereferenceZuiSchema(e,n){return e.dereference(n)}_dereferenceDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,a])=>[r,{...a,schema:this._dereferenceZuiSchema(a.schema,n)}]))}_dereferenceActionDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,a])=>[r,{...a,input:{schema:this._dereferenceZuiSchema(a.input.schema,n)},output:{schema:this._dereferenceZuiSchema(a.output.schema,n)}}]))}};C();R();O();C();R();O();C();R();O();C();R();O();var Fl=":";var kv=t=>{let[e,n]=t.split(Fl);return!e||!n?null:{namespace:e,eventName:n}},Iv=t=>`${t.namespace}${Fl}${t.actionName}`,Av=t=>`${t.namespace}${Fl}${t.eventName}`,Cv=(t,e)=>{let n=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},r=n.name,a=n.actions[t.actionName]?.name??t.actionName;return{namespace:r,actionName:a}},Ov=(t,e)=>{let n=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},r=n.name,a=n.events[t.eventName]?.name??t.eventName;return{namespace:r,eventName:a}};var Rv=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(a,o)=>i=>XI({client:t,interfaces:e.interfaces,integrationOrInterfaceName:r,methodName:o,input:i})})}),XI=async({client:t,interfaces:e,integrationOrInterfaceName:n,methodName:r,input:a})=>{let o=Cv({namespace:n,actionName:r},e),i=Iv(o);return(await t.callAction({type:i,input:a})).output};C();R();O();C();R();O();C();R();O();var Fn=class{constructor(e){this._props=e}async emit(e){let{conversationId:n,userId:r,messageId:a}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:n,userId:r,messageId:a})}async schedule(e,n){let{conversationId:r,userId:a,messageId:o}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:r,userId:a,messageId:o,schedule:n})}withConversationId(e){return new Fn({...this._props,conversationId:e})}withUserId(e){return new Fn({...this._props,userId:e})}withMessageId(e){return new Fn({...this._props,messageId:e})}},Mv=(t,e)=>new Proxy({},{get:(n,r)=>{let a=e.alias!==void 0?`${e.alias}${fn}${r}`:r;return new Fn({client:t,eventName:a})}});C();R();O();C();R();O();C();R();O();var Wl=class{constructor(e,n,r){this._client=e;this._stateType=n;this._stateName=r}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(n=>n.state.payload)}async set(e,n){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:n})}async getOrSet(e,n){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:n}).then(r=>r.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,n){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:n})}},Nv=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(a,o)=>{let i=e.alias!==void 0?`${e.alias}${fn}${o}`:o;return new Wl(t,r,i)}})});C();R();O();var zl=class{constructor(e){this.props=e;this._actionHandlers=e.actions}_runtimeProps;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_registerOrder=0;initialize(e){return this._runtimeProps=e,this}get _runtime(){if(!this._runtimeProps)throw new Error("Plugin not correctly initialized. This is likely because you access your plugin config outside of an handler.");return this._runtimeProps}_getTools(e){let{configuration:n,interfaces:r,alias:a}=this._runtime,o=Rv(e,this._runtime),i=Nv(e,this._runtime),s=vr(e),l=Mv(e,this._runtime);return{configuration:n,interfaces:r,actions:o,states:i,alias:a,workflows:s,events:l}}get actionHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=this._actionHandlers[n];if(r)return Qt.setName(a=>r({...a,...this._getTools(a.client)}),r.name)}})}get messageHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=this._messageHandlers[n]??[],a=this._messageHandlers["*"]??[];return ye.unique([...r,...a]).sort((i,s)=>i.order-s.order).map(({handler:i})=>Qt.setName(s=>i({...s,...this._getTools(s.client)}),i.name))}})}get eventHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=this._eventHandlers[n]??[],a=Object.entries(this._eventHandlers).filter(([s])=>this._eventResolvesTo(s,n)).flatMap(([,s])=>s??[]),o=this._eventHandlers["*"]??[];return ye.unique([...r,...a,...o]).sort((s,l)=>s.order-l.order).map(({handler:s})=>Qt.setName(l=>s({...l,...this._getTools(l.client)}),s.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=this._stateExpiredHandlers[n]??[],a=this._stateExpiredHandlers["*"]??[];return ye.unique([...r,...a]).sort((i,s)=>i.order-s.order).map(({handler:i})=>Qt.setName(s=>i({...s,...this._getTools(s.client)}),i.name))}})}get hookHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._hookHandlers[n];if(r)return new Proxy({},{get:(a,o)=>{o=this._stripAliasPrefix(o);let i=r[o]??[],s=Object.entries(r).filter(([p])=>this._eventResolvesTo(p,o)).flatMap(([,p])=>p??[]),l=r["*"]??[];return ye.unique([...i,...s,...l]).sort((p,y)=>p.order-y.order).map(({handler:p})=>Qt.setName(y=>p({...y,...this._getTools(y.client)}),p.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._workflowHandlers[n];if(r)return new Proxy({},{get:(a,o)=>(r[o]?.sort((s,l)=>s.order-l.order)??[]).map(({handler:s})=>Qt.setName(l=>s({...l,...this._getTools(l.client)}),s.name))})}})}on={message:(e,n)=>{this._messageHandlers[e]=ye.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=ye.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=ye.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=ye.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=ye.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=ye.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=ye.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=ye.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=ye.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=ye.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=ye.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=ye.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=ye.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=ye.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=ye.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=ye.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};_eventResolvesTo=(e,n)=>{let r=kv(e);if(!r)return!1;let a=Ov(r,this._runtime.interfaces);return Av(a)===n};_stripAliasPrefix=e=>{let{alias:n}=this._runtime;if(!n)return e;let r=`${n}:`;return e.startsWith(r)?e.slice(r.length):e}};C();R();O();C();R();O();C();R();O();C();R();O();C();R();O();C();R();O();export{Rx as BRAND,jl as Bot,Zl as BotDefinition,Ln as BotLogger,en as BotSpecificClient,Xn as DIRTY,Ix as EMPTY_PATH,pe as INVALID,Ul as Integration,el as IntegrationDefinition,Kn as IntegrationLogger,ii as IntegrationSpecificClient,Kl as InterfaceDefinition,RP as NEVER,pt as OK,It as ParseInputLazyPath,vt as ParseStatus,zl as Plugin,Ll as PluginDefinition,iU as RuntimeError,he as Schema,QA as WELL_KNOWN_ATTRIBUTES,Fr as ZodAny,Wr as ZodArray,jo as ZodBigInt,Ko as ZodBoolean,Lo as ZodBranded,Fo as ZodCatch,Wo as ZodDate,ha as ZodDefault,fg as ZodDiscriminatedUnion,Sn as ZodEffects,or as ZodEnum,Kt as ZodError,Yp as ZodFirstPartyTypeKind,pg as ZodFunction,qo as ZodIntersection,G as ZodIssueCode,Go as ZodLazy,Vo as ZodLiteral,yg as ZodMap,hg as ZodNaN,Jo as ZodNativeEnum,Gr as ZodNever,Xo as ZodNull,tr as ZodNullable,Yo as ZodNumber,nr as ZodObject,an as ZodOptional,ne as ZodParsedType,Qo as ZodPipeline,Ta as ZodPromise,_a as ZodReadonly,Pg as ZodRecord,Sg as ZodRef,he as ZodSchema,Eg as ZodSet,gt as ZodString,Ug as ZodSymbol,Sn as ZodTransformer,ir as ZodTuple,he as ZodType,ba as ZodUndefined,es as ZodUnion,Ur as ZodUnknown,Kg as ZodVoid,te as addIssueToContext,$x as agent,Wx as aimodel,nP as any,oP as array,Xx as bigint,Wg as boolean,wa as botIdHeader,Oy as botUserIdHeader,OP as coerce,xa as configurationHeader,Ny as configurationTypeHeader,Hx as conversation,va as createZodEnum,Ig as cuid2Regex,kg as cuidRegex,ug as custom,zx as datasource,Yx as date,cP as discriminatedUnion,Gc as effect,Og as emailRegex,bP as enum,ue as errorUtil,jx as event,vP as function,Kr as getErrorMap,rn as getParsedType,Vx as instanceof,Ry as integrationIdHeader,Fx as intent,fP as intersection,Mg as ipv4Regex,Ng as ipv6Regex,_o as isAborted,rU as isApiError,ki as isAsync,bo as isDirty,Mx as isEmojiRegex,Lr as isValid,qx as knowledgebase,Gx as late,TP as lazy,_P as literal,Ei as makeIssue,mP as map,Vr as mergeObjectSchemas,Zx as message,Cy as messages,Jx as nan,wP as nativeEnum,iP as never,tP as null,BP as nullable,Fg as number,sP as object,To as objectUtil,CP as oboolean,AP as onumber,Pa as operationHeader,PP as optional,IP as ostring,Ct as parseBody,kP as pipeline,EP as preprocess,me as processCreateParams,xP as promise,kx as quotelessJson,yP as readonly,pP as record,gP as ref,za as serve,hP as set,tg as setErrorMap,lP as strictObject,Lg as string,Qx as symbol,Kx as table,Lx as tablerow,Gc as transformer,zv as transforms,dP as tuple,Dy as typeHeader,Ag as ulidRegex,eP as undefined,uP as union,rP as unknown,Ux as user,be as util,Cg as uuidRegex,Dx as variable,aP as void,My as webhookIdHeader,Y as z};
89
89
  /*! Bundled license information:
90
90
 
91
91
  @jspm/core/nodelibs/browser/chunk-DtuTasat.js: