@rockdog/directus-extension-vector-store
Version:
A Directus extension to integrate vector storage capabilities
1 lines • 3.82 MB
JavaScript
import e from"path";import t,{Readable as n}from"stream";import r,{EventEmitter as i}from"events";import s from"util";import*as a from"fs";import o from"fs";import c from"os";import l from"crypto";import u from"buffer";import{readFileSync as h,existsSync as d}from"node:fs";import{resolve as p,extname as f}from"node:path";import{cwd as m}from"node:process";import A from"url";import{createRequire as g}from"node:module";import{webcrypto as b}from"node:crypto";import"node:os";import"node:fs/promises";import y from"http";import v from"https";import E from"assert";import _ from"tty";import I from"zlib";import w from"net";import C from"tls";import S from"string_decoder";import T,{Transform as R}from"node:stream";import k from"node:assert";import B from"node:net";import x from"node:http";import N from"node:buffer";import O from"node:util";import D from"node:querystring";import M from"node:events";import L from"node:diagnostics_channel";import P from"node:tls";import Q from"node:zlib";import F from"node:perf_hooks";import U from"node:util/types";import j from"node:worker_threads";import"node:url";import G from"node:async_hooks";import"node:console";import"node:dns";var Y=["js","mjs","cjs"],H="object"==typeof global&&global&&global.Object===Object&&global,V="object"==typeof self&&self&&self.Object===Object&&self,q=(H||V||Function("return this")()).Symbol,W=Object.prototype,X=W.hasOwnProperty,K=W.toString,z=q?q.toStringTag:void 0;var J=Object.prototype.toString;var $=q?q.toStringTag:void 0;function Z(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":$&&$ in Object(e)?function(e){var t=X.call(e,z),n=e[z];try{e[z]=void 0;var r=!0}catch(e){}var i=K.call(e);return r&&(t?e[z]=n:delete e[z]),i}(e):function(e){return J.call(e)}(e)}function ee(e){return null!=e&&"object"==typeof e}function te(e){return"symbol"==typeof e||ee(e)&&"[object Symbol]"==Z(e)}var ne=Array.isArray,re=q?q.prototype:void 0,ie=re?re.toString:void 0;function se(e){if("string"==typeof e)return e;if(ne(e))return function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}(e,se)+"";if(te(e))return ie?ie.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}var ae=/\s/;var oe=/^\s+/;function ce(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&ae.test(e.charAt(t)););return t}(e)+1).replace(oe,""):e}function le(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var ue=/^[-+]0x[0-9a-f]+$/i,he=/^0b[01]+$/i,de=/^0o[0-7]+$/i,pe=parseInt;var fe,me,Ae=(fe=Object.getPrototypeOf,me=Object,function(e){return fe(me(e))}),ge=Function.prototype,be=Object.prototype,ye=ge.toString,ve=be.hasOwnProperty,Ee=ye.call(Object);function _e(e){if(!ee(e)||"[object Object]"!=Z(e))return!1;var t=Ae(e);if(null===t)return!0;var n=ve.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&ye.call(n)==Ee}var Ie=(0).constructor;Ie.isFinite,Ie.isInteger,[].constructor.isArray;var we=function(){function e(e){this.size=e,this.reset()}return e.prototype.reset=function(){this.oldestIndex=0,this.map={},this.cachedKeys=new Array(this.size)},e.prototype.get=function(e){return this.map[e]},e.prototype.set=function(e,t){this.map[e]=t;var n=this.cachedKeys[this.oldestIndex];void 0!==n&&delete this.map[n],this.cachedKeys[this.oldestIndex]=e,this.oldestIndex++,this.oldestIndex%=this.size},e}();new we(1e3);var Ce="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Se(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Te={exports:{}},Re=function(...e){try{return JSON.stringify(...e)}catch(e){return"[Cannot display object: "+e.message+"]"}};!function(e,t){const n=Re;Te.exports=class extends Error{constructor(e){super(e.filter((e=>""!==e)).map((e=>"string"==typeof e?e:e instanceof Error?e.message:n(e))).join(" ")||"Unknown error"),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t.assert)}}}(0,Te.exports);var ke=Te.exports;const Be=ke;var xe=function(e,...t){if(!e){if(1===t.length&&t[0]instanceof Error)throw t[0];throw new Be(t)}};const Ne=xe,Oe={};var De=function(e,t,n){if(!1===t||null==t)return e;"string"==typeof(n=n||{})&&(n={separator:n});const r=Array.isArray(t);Ne(!r||!n.separator,"Separator option is not valid for array-based chain");const i=r?t:t.split(n.separator||".");let s=e;for(let e=0;e<i.length;++e){let r=i[e];const a=n.iterables&&Oe.iterables(s);if(Array.isArray(s)||"set"===a){const e=Number(r);Number.isInteger(e)&&(r=e<0?s.length+e:e)}if(!s||"function"==typeof s&&!1===n.functions||!a&&void 0===s[r]){Ne(!n.strict||e+1===i.length,"Missing segment",r,"in reach path ",t),Ne("object"==typeof s||!0===n.functions||"function"!=typeof s,"Invalid segment",r,"in reach path ",t),s=n.default;break}s=a?"set"===a?[...s][r]:s.get(r):s[r]}return s};Oe.iterables=function(e){return e instanceof Set?"set":e instanceof Map?"map":void 0};var Me={exports:{}};!function(e,t){const n={};t=Me.exports={array:Array.prototype,buffer:Buffer&&Buffer.prototype,date:Date.prototype,error:Error.prototype,generic:Object.prototype,map:Map.prototype,promise:Promise.prototype,regex:RegExp.prototype,set:Set.prototype,weakMap:WeakMap.prototype,weakSet:WeakSet.prototype},n.typeMap=new Map([["[object Error]",t.error],["[object Map]",t.map],["[object Promise]",t.promise],["[object Set]",t.set],["[object WeakMap]",t.weakMap],["[object WeakSet]",t.weakSet]]),t.getInternalProto=function(e){if(Array.isArray(e))return t.array;if(Buffer&&e instanceof Buffer)return t.buffer;if(e instanceof Date)return t.date;if(e instanceof RegExp)return t.regex;if(e instanceof Error)return t.error;const r=Object.prototype.toString.call(e);return n.typeMap.get(r)||t.generic}}(0,Me.exports);var Le=Me.exports,Pe={keys:function(e,t={}){return!1!==t.symbols?Reflect.ownKeys(e):Object.getOwnPropertyNames(e)}};const Qe=De,Fe=Le,Ue=Pe,je={needsProtoHack:new Set([Fe.set,Fe.map,Fe.weakSet,Fe.weakMap])};var Ge=je.clone=function(e,t={},n=null){if("object"!=typeof e||null===e)return e;let r=je.clone,i=n;if(t.shallow){if(!0!==t.shallow)return je.cloneWithShallow(e,t);r=e=>e}else if(i){const t=i.get(e);if(t)return t}else i=new Map;const s=Fe.getInternalProto(e);if(s===Fe.buffer)return Buffer&&Buffer.from(e);if(s===Fe.date)return new Date(e.getTime());if(s===Fe.regex)return new RegExp(e);const a=je.base(e,s,t);if(a===e)return e;if(i&&i.set(e,a),s===Fe.set)for(const n of e)a.add(r(n,t,i));else if(s===Fe.map)for(const[n,s]of e)a.set(n,r(s,t,i));const o=Ue.keys(e,t);for(const n of o){if("__proto__"===n)continue;if(s===Fe.array&&"length"===n){a.length=e.length;continue}const o=Object.getOwnPropertyDescriptor(e,n);o?o.get||o.set?Object.defineProperty(a,n,o):o.enumerable?a[n]=r(e[n],t,i):Object.defineProperty(a,n,{enumerable:!1,writable:!0,configurable:!0,value:r(e[n],t,i)}):Object.defineProperty(a,n,{enumerable:!0,writable:!0,configurable:!0,value:r(e[n],t,i)})}return a};je.cloneWithShallow=function(e,t){const n=t.shallow;(t=Object.assign({},t)).shallow=!1;const r=new Map;for(const t of n){const n=Qe(e,t);"object"!=typeof n&&"function"!=typeof n||r.set(n,n)}return je.clone(e,t,r)},je.base=function(e,t,n){if(!1===n.prototype)return je.needsProtoHack.has(t)?new t.constructor:t===Fe.array?[]:{};const r=Object.getPrototypeOf(e);if(r&&r.isImmutable)return e;if(t===Fe.array){const e=[];return r!==t&&Object.setPrototypeOf(e,r),e}if(je.needsProtoHack.has(t)){const e=new r.constructor;return r!==t&&Object.setPrototypeOf(e,r),e}return Object.create(r)};var Ye,He={},Ve={},qe={name:"joi",description:"Object schema validation",version:"17.13.3",repository:"git://github.com/hapijs/joi",main:"lib/index.js",types:"lib/index.d.ts",browser:"dist/joi-browser.min.js",files:["lib/**/*","dist/*"],keywords:["schema","validation"],dependencies:{"@hapi/hoek":"^9.3.0","@hapi/topo":"^5.1.0","@sideway/address":"^4.1.5","@sideway/formula":"^3.0.1","@sideway/pinpoint":"^2.0.0"},devDependencies:{"@hapi/bourne":"2.x.x","@hapi/code":"8.x.x","@hapi/joi-legacy-test":"npm:@hapi/joi@15.x.x","@hapi/lab":"^25.1.3","@types/node":"^14.18.63",typescript:"4.3.x"},scripts:{prepublishOnly:"cd browser && npm install && npm run build",test:"lab -t 100 -a @hapi/code -L -Y","test-cov-html":"lab -r html -o coverage.html -a @hapi/code"},license:"BSD-3-Clause"},We={};function Xe(){if(Ye)return We;Ye=1;const e=ur(),t={};return t.wrap=e.string().min(1).max(2).allow(!1),We.preferences=e.object({allowUnknown:e.boolean(),abortEarly:e.boolean(),artifacts:e.boolean(),cache:e.boolean(),context:e.object(),convert:e.boolean(),dateFormat:e.valid("date","iso","string","time","utc"),debug:e.boolean(),errors:{escapeHtml:e.boolean(),label:e.valid("path","key",!1),language:[e.string(),e.object().ref()],render:e.boolean(),stack:e.boolean(),wrap:{label:t.wrap,array:t.wrap,string:t.wrap}},externals:e.boolean(),messages:e.object(),noDefaults:e.boolean(),nonEnumerables:e.boolean(),presence:e.valid("required","optional","forbidden"),skipFunctions:e.boolean(),stripUnknown:e.object({arrays:e.boolean(),objects:e.boolean()}).or("arrays","objects").allow(!0,!1),warnings:e.boolean()}).strict(),t.nameRx=/^[a-zA-Z0-9]\w*$/,t.rule=e.object({alias:e.array().items(e.string().pattern(t.nameRx)).single(),args:e.array().items(e.string(),e.object({name:e.string().pattern(t.nameRx).required(),ref:e.boolean(),assert:e.alternatives([e.function(),e.object().schema()]).conditional("ref",{is:!0,then:e.required()}),normalize:e.function(),message:e.string().when("assert",{is:e.function(),then:e.required()})})),convert:e.boolean(),manifest:e.boolean(),method:e.function().allow(!1),multi:e.boolean(),validate:e.function()}),We.extension=e.object({type:e.alternatives([e.string(),e.object().regex()]).required(),args:e.function(),cast:e.object().pattern(t.nameRx,e.object({from:e.function().maxArity(1).required(),to:e.function().minArity(1).maxArity(2).required()})),base:e.object().schema().when("type",{is:e.object().regex(),then:e.forbidden()}),coerce:[e.function().maxArity(3),e.object({method:e.function().maxArity(3).required(),from:e.array().items(e.string()).single()})],flags:e.object().pattern(t.nameRx,e.object({setter:e.string(),default:e.any()})),manifest:{build:e.function().arity(2)},messages:[e.object(),e.string()],modifiers:e.object().pattern(t.nameRx,e.function().minArity(1).maxArity(2)),overrides:e.object().pattern(t.nameRx,e.function()),prepare:e.function().maxArity(3),rebuild:e.function().arity(1),rules:e.object().pattern(t.nameRx,t.rule),terms:e.object().pattern(t.nameRx,e.object({init:e.array().allow(null).required(),manifest:e.object().pattern(/.+/,[e.valid("schema","single"),e.object({mapped:e.object({from:e.string().required(),to:e.string().required()}).required()})])})),validate:e.function().maxArity(3)}).strict(),We.extensions=e.array().items(e.object(),e.function().arity(1)).strict(),t.desc={buffer:e.object({buffer:e.string()}),func:e.object({function:e.function().required(),options:{literal:!0}}),override:e.object({override:!0}),ref:e.object({ref:e.object({type:e.valid("value","global","local"),path:e.array().required(),separator:e.string().length(1).allow(!1),ancestor:e.number().min(0).integer().allow("root"),map:e.array().items(e.array().length(2)).min(1),adjust:e.function(),iterables:e.boolean(),in:e.boolean(),render:e.boolean()}).required()}),regex:e.object({regex:e.string().min(3)}),special:e.object({special:e.valid("deep").required()}),template:e.object({template:e.string().required(),options:e.object()}),value:e.object({value:e.alternatives([e.object(),e.array()]).required()})},t.desc.entity=e.alternatives([e.array().items(e.link("...")),e.boolean(),e.function(),e.number(),e.string(),t.desc.buffer,t.desc.func,t.desc.ref,t.desc.regex,t.desc.special,t.desc.template,t.desc.value,e.link("/")]),t.desc.values=e.array().items(null,e.boolean(),e.function(),e.number().allow(1/0,-1/0),e.string().allow(""),e.symbol(),t.desc.buffer,t.desc.func,t.desc.override,t.desc.ref,t.desc.regex,t.desc.template,t.desc.value),t.desc.messages=e.object().pattern(/.+/,[e.string(),t.desc.template,e.object().pattern(/.+/,[e.string(),t.desc.template])]),We.description=e.object({type:e.string().required(),flags:e.object({cast:e.string(),default:e.any(),description:e.string(),empty:e.link("/"),failover:t.desc.entity,id:e.string(),label:e.string(),only:!0,presence:["optional","required","forbidden"],result:["raw","strip"],strip:e.boolean(),unit:e.string()}).unknown(),preferences:{allowUnknown:e.boolean(),abortEarly:e.boolean(),artifacts:e.boolean(),cache:e.boolean(),convert:e.boolean(),dateFormat:["date","iso","string","time","utc"],errors:{escapeHtml:e.boolean(),label:["path","key"],language:[e.string(),t.desc.ref],wrap:{label:t.wrap,array:t.wrap}},externals:e.boolean(),messages:t.desc.messages,noDefaults:e.boolean(),nonEnumerables:e.boolean(),presence:["required","optional","forbidden"],skipFunctions:e.boolean(),stripUnknown:e.object({arrays:e.boolean(),objects:e.boolean()}).or("arrays","objects").allow(!0,!1),warnings:e.boolean()},allow:t.desc.values,invalid:t.desc.values,rules:e.array().min(1).items({name:e.string().required(),args:e.object().min(1),keep:e.boolean(),message:[e.string(),t.desc.messages],warn:e.boolean()}),keys:e.object().pattern(/.*/,e.link("/")),link:t.desc.ref}).pattern(/^[a-z]\w*$/,e.any()),We}var Ke={},ze={exports:{}};const Je={};var $e=function(e){if(!e)return"";let t="";for(let n=0;n<e.length;++n){const r=e.charCodeAt(n);Je.isSafe(r)?t+=e[n]:t+=Je.escapeHtmlChar(r)}return t};Je.escapeHtmlChar=function(e){const t=Je.namedHtml.get(e);if(t)return t;if(e>=256)return"&#"+e+";";return`&#x${e.toString(16).padStart(2,"0")};`},Je.isSafe=function(e){return Je.safeCharCodes.has(e)},Je.namedHtml=new Map([[38,"&"],[60,"<"],[62,">"],[34,"""],[160," "],[162,"¢"],[163,"£"],[164,"¤"],[169,"©"],[174,"®"]]),Je.safeCharCodes=function(){const e=new Set;for(let t=32;t<123;++t)(t>=97||t>=65&&t<=90||t>=48&&t<=57||32===t||46===t||44===t||45===t||58===t||95===t)&&e.add(t);return e}();var Ze={};!function(e){const t={operators:["!","^","*","/","%","+","-","<","<=",">",">=","==","!=","&&","||","??"],operatorCharacters:["!","^","*","/","%","+","-","<","=",">","&","|","?"],operatorsOrder:[["^"],["*","/","%"],["+","-"],["<","<=",">",">="],["==","!="],["&&"],["||","??"]],operatorsPrefix:["!","n"],literals:{'"':'"',"`":"`","'":"'","[":"]"},numberRx:/^(?:[0-9]*(\.[0-9]*)?){1}$/,tokenRx:/^[\w\$\#\.\@\:\{\}]+$/,symbol:Symbol("formula"),settings:Symbol("settings")};e.Parser=class{constructor(e,n={}){if(!n[t.settings]&&n.constants)for(const e in n.constants){const t=n.constants[e];if(null!==t&&!["boolean","number","string"].includes(typeof t))throw new Error(`Formula constant ${e} contains invalid ${typeof t} value type`)}this.settings=n[t.settings]?n:Object.assign({[t.settings]:!0,constants:{},functions:{}},n),this.single=null,this._parts=null,this._parse(e)}_parse(n){let r=[],i="",s=0,a=!1;const o=n=>{if(s)throw new Error("Formula missing closing parenthesis");const o=r.length?r[r.length-1]:null;if(a||i||n){if(o&&"reference"===o.type&&")"===n)return o.type="function",o.value=this._subFormula(i,o.value),void(i="");if(")"===n){const t=new e.Parser(i,this.settings);r.push({type:"segment",value:t})}else if(a){if("]"===a)return r.push({type:"reference",value:i}),void(i="");r.push({type:"literal",value:i})}else if(t.operatorCharacters.includes(i))o&&"operator"===o.type&&t.operators.includes(o.value+i)?o.value+=i:r.push({type:"operator",value:i});else if(i.match(t.numberRx))r.push({type:"constant",value:parseFloat(i)});else if(void 0!==this.settings.constants[i])r.push({type:"constant",value:this.settings.constants[i]});else{if(!i.match(t.tokenRx))throw new Error(`Formula contains invalid token: ${i}`);r.push({type:"reference",value:i})}i=""}};for(const e of n)a?e===a?(o(),a=!1):i+=e:s?"("===e?(i+=e,++s):")"===e?(--s,s?i+=e:o(e)):i+=e:e in t.literals?a=t.literals[e]:"("===e?(o(),++s):t.operatorCharacters.includes(e)?(o(),i=e,o()):" "!==e?i+=e:o();o(),r=r.map(((e,t)=>"operator"!==e.type||"-"!==e.value||t&&"operator"!==r[t-1].type?e:{type:"operator",value:"n"}));let c=!1;for(const e of r){if("operator"===e.type){if(t.operatorsPrefix.includes(e.value))continue;if(!c)throw new Error("Formula contains an operator in invalid position");if(!t.operators.includes(e.value))throw new Error(`Formula contains an unknown operator ${e.value}`)}else if(c)throw new Error("Formula missing expected operator");c=!c}if(!c)throw new Error("Formula contains invalid trailing operator");1===r.length&&["reference","literal","constant"].includes(r[0].type)&&(this.single={type:"reference"===r[0].type?"reference":"value",value:r[0].value}),this._parts=r.map((e=>{if("operator"===e.type)return t.operatorsPrefix.includes(e.value)?e:e.value;if("reference"!==e.type)return e.value;if(this.settings.tokenRx&&!this.settings.tokenRx.test(e.value))throw new Error(`Formula contains invalid reference ${e.value}`);return this.settings.reference?this.settings.reference(e.value):t.reference(e.value)}))}_subFormula(n,r){const i=this.settings.functions[r];if("function"!=typeof i)throw new Error(`Formula contains unknown function ${r}`);let s=[];if(n){let e="",i=0,a=!1;const o=()=>{if(!e)throw new Error(`Formula contains function ${r} with invalid arguments ${n}`);s.push(e),e=""};for(let r=0;r<n.length;++r){const s=n[r];a?(e+=s,s===a&&(a=!1)):s in t.literals&&!i?(e+=s,a=t.literals[s]):","!==s||i?(e+=s,"("===s?++i:")"===s&&--i):o()}o()}return s=s.map((t=>new e.Parser(t,this.settings))),function(e){const t=[];for(const n of s)t.push(n.evaluate(e));return i.call(e,...t)}}evaluate(e){const n=this._parts.slice();for(let r=n.length-2;r>=0;--r){const i=n[r];if(i&&"operator"===i.type){const s=n[r+1];n.splice(r+1,1);const a=t.evaluate(s,e);n[r]=t.single(i.value,a)}}return t.operatorsOrder.forEach((r=>{for(let i=1;i<n.length-1;)if(r.includes(n[i])){const r=n[i],s=t.evaluate(n[i-1],e),a=t.evaluate(n[i+1],e);n.splice(i,2);const o=t.calculate(r,s,a);n[i-1]=0===o?0:o}else i+=2})),t.evaluate(n[0],e)}},e.Parser.prototype[t.symbol]=!0,t.reference=function(e){return function(t){return t&&void 0!==t[e]?t[e]:null}},t.evaluate=function(e,n){return null===e?null:"function"==typeof e?e(n):e[t.symbol]?e.evaluate(n):e},t.single=function(e,t){if("!"===e)return!t;const n=-t;return 0===n?0:n},t.calculate=function(e,n,r){if("??"===e)return t.exists(n)?n:r;if("string"==typeof n||"string"==typeof r){if("+"===e)return(n=t.exists(n)?n:"")+(r=t.exists(r)?r:"")}else switch(e){case"^":return Math.pow(n,r);case"*":return n*r;case"/":return n/r;case"%":return n%r;case"+":return n+r;case"-":return n-r}switch(e){case"<":return n<r;case"<=":return n<=r;case">":return n>r;case">=":return n>=r;case"==":return n===r;case"!=":return n!==r;case"&&":return n&&r;case"||":return n||r}return null},t.exists=function(e){return null!=e}}(Ze);var et,tt,nt={},rt={};function it(){if(et)return rt;et=1;const e=Ge,t=mt(),n={annotations:Symbol("annotations")};return rt.error=function(r){if(!this._original||"object"!=typeof this._original)return this.details[0].message;const i=r?"":"[31m",s=r?"":"[41m",a=r?"":"[0m",o=e(this._original);for(let e=this.details.length-1;e>=0;--e){const r=e+1,i=this.details[e],s=i.path;let a=o;for(let e=0;;++e){const o=s[e];if(t.isSchema(a)&&(a=a.clone()),!(e+1<s.length&&"string"!=typeof a[o])){const e=a[n.annotations]||{errors:{},missing:{}};a[n.annotations]=e;const t=o||i.context.key;void 0!==a[o]?(e.errors[t]=e.errors[t]||[],e.errors[t].push(r)):e.missing[t]=r;break}a=a[o]}}const c=/_\$key\$_([, \d]+)_\$end\$_"/g,l=/"_\$miss\$_([^|]+)\|(\d+)_\$end\$_": "__missing__"/g,u=/\s*"_\$idx\$_([, \d]+)_\$end\$_",?\n(.*)/g,h=/"\[(NaN|Symbol.*|-?Infinity|function.*|\(.*)]"/g;let d=n.safeStringify(o,2).replace(c,((e,t)=>`" ${i}[${t}]${a}`)).replace(l,((e,t,n)=>`${s}"${t}"${a}${i} [${n}]: -- missing --${a}`)).replace(u,((e,t,n)=>`\n${n} ${i}[${t}]${a}`)).replace(h,((e,t)=>t));d=`${d}\n${i}`;for(let e=0;e<this.details.length;++e){d=`${d}\n[${e+1}] ${this.details[e].message}`}return d+=a,d},n.safeStringify=function(e,t){return JSON.stringify(e,n.serializer(),t)},n.serializer=function(){const e=[],t=[],r=(n,r)=>t[0]===r?"[Circular ~]":"[Circular ~."+e.slice(0,t.indexOf(r)).join(".")+"]";return function(i,s){if(t.length>0){const n=t.indexOf(this);~n?(t.length=n+1,e.length=n+1,e[n]=i):(t.push(this),e.push(i)),~t.indexOf(s)&&(s=r.call(this,i,s))}else t.push(s);if(s){const e=s[n.annotations];if(e){if(Array.isArray(s)){const t=[];for(let n=0;n<s.length;++n)e.errors[n]&&t.push(`_$idx$_${e.errors[n].sort().join(", ")}_$end$_`),t.push(s[n]);s=t}else{for(const t in e.errors)s[`${t}_$key$_${e.errors[t].sort().join(", ")}_$end$_`]=s[t],s[t]=void 0;for(const t in e.missing)s[`_$miss$_${t}|${e.missing[t]}_$end$_`]="__missing__"}return s}}return s===1/0||s===-1/0||Number.isNaN(s)||"function"==typeof s||"symbol"==typeof s?"["+s.toString()+"]":s}},rt}function st(){return tt||(tt=1,function(e){const t=it(),n=mt(),r=pt();e.Report=class{constructor(t,n,r,i,s,a,o){if(this.code=t,this.flags=i,this.messages=s,this.path=a.path,this.prefs=o,this.state=a,this.value=n,this.message=null,this.template=null,this.local=r||{},this.local.label=e.label(this.flags,this.state,this.prefs,this.messages),void 0===this.value||this.local.hasOwnProperty("value")||(this.local.value=this.value),this.path.length){const e=this.path[this.path.length-1];"object"!=typeof e&&(this.local.key=e)}}_setTemplate(e){if(this.template=e,!this.flags.label&&0===this.path.length){const e=this._template(this.template,"root");e&&(this.local.label=e)}}toString(){if(this.message)return this.message;const e=this.code;if(!this.prefs.errors.render)return this.code;const t=this._template(this.template)||this._template(this.prefs.messages)||this._template(this.messages);return void 0===t?`Error code "${e}" is not defined, your custom type is missing the correct messages definition`:(this.message=t.render(this.value,this.state,this.prefs,this.local,{errors:this.prefs.errors,messages:[this.prefs.messages,this.messages]}),this.prefs.errors.label||(this.message=this.message.replace(/^"" /,"").trim()),this.message)}_template(t,n){return e.template(this.value,t,n||this.code,this.state,this.prefs)}},e.path=function(e){let t="";for(const n of e)"object"!=typeof n&&("string"==typeof n?(t&&(t+="."),t+=n):t+=`[${n}]`);return t},e.template=function(e,t,i,s,a){if(!t)return;if(r.isTemplate(t))return"root"!==i?t:null;let o=a.errors.language;if(n.isResolvable(o)&&(o=o.resolve(e,s,a)),o&&t[o]){if(void 0!==t[o][i])return t[o][i];if(void 0!==t[o]["*"])return t[o]["*"]}return t[i]?t[i]:t["*"]},e.label=function(t,n,r,i){if(!r.errors.label)return"";if(t.label)return t.label;let s=n.path;"key"===r.errors.label&&n.path.length>1&&(s=n.path.slice(-1));const a=e.path(s);return a||(e.template(null,r.messages,"root",n,r)||i&&e.template(null,i,"root",n,r)||"value")},e.process=function(t,n,r){if(!t)return null;const{override:i,message:s,details:a}=e.details(t);if(i)return i;if(r.errors.stack)return new e.ValidationError(s,a,n);const o=Error.stackTraceLimit;Error.stackTraceLimit=0;const c=new e.ValidationError(s,a,n);return Error.stackTraceLimit=o,c},e.details=function(e,t={}){let n=[];const r=[];for(const i of e){if(i instanceof Error){if(!1!==t.override)return{override:i};const e=i.toString();n.push(e),r.push({message:e,type:"override",context:{error:i}});continue}const e=i.toString();n.push(e),r.push({message:e,path:i.path.filter((e=>"object"!=typeof e)),type:i.code,context:i.local})}return n.length>1&&(n=[...new Set(n)]),{message:n.join(". "),details:r}},e.ValidationError=class extends Error{constructor(e,t,n){super(e),this._original=n,this.details=t}static isError(t){return t instanceof e.ValidationError}},e.ValidationError.prototype.isJoi=!0,e.ValidationError.prototype.name="ValidationError",e.ValidationError.prototype.annotate=t.error}(nt)),nt}var at,ot,ct,lt,ut,ht={};function dt(){return at||(at=1,function(e){const t=xe,n=Ge,r=De,i=mt();let s;const a={symbol:Symbol("ref"),defaults:{adjust:null,in:!1,iterables:null,map:null,separator:".",type:"value"}};e.create=function(e,n={}){t("string"==typeof e,"Invalid reference key:",e),i.assertOptions(n,["adjust","ancestor","in","iterables","map","prefix","render","separator"]),t(!n.prefix||"object"==typeof n.prefix,"options.prefix must be of type object");const r=Object.assign({},a.defaults,n);delete r.prefix;const s=r.separator,o=a.context(e,s,n.prefix);if(r.type=o.type,e=o.key,"value"===r.type)if(o.root&&(t(!s||e[0]!==s,"Cannot specify relative path with root prefix"),r.ancestor="root",e||(e=null)),s&&s===e)e=null,r.ancestor=0;else if(void 0!==r.ancestor)t(!s||!e||e[0]!==s,"Cannot combine prefix with ancestor option");else{const[t,n]=a.ancestor(e,s);n&&""===(e=e.slice(n))&&(e=null),r.ancestor=t}return r.path=s?null===e?[]:e.split(s):[e],new a.Ref(r)},e.in=function(t,n={}){return e.create(t,{...n,in:!0})},e.isRef=function(e){return!!e&&!!e[i.symbols.ref]},a.Ref=class{constructor(e){t("object"==typeof e,"Invalid reference construction"),i.assertOptions(e,["adjust","ancestor","in","iterables","map","path","render","separator","type","depth","key","root","display"]),t([!1,void 0].includes(e.separator)||"string"==typeof e.separator&&1===e.separator.length,"Invalid separator"),t(!e.adjust||"function"==typeof e.adjust,"options.adjust must be a function"),t(!e.map||Array.isArray(e.map),"options.map must be an array"),t(!e.map||!e.adjust,"Cannot set both map and adjust options"),Object.assign(this,a.defaults,e),t("value"===this.type||void 0===this.ancestor,"Non-value references cannot reference ancestors"),Array.isArray(this.map)&&(this.map=new Map(this.map)),this.depth=this.path.length,this.key=this.path.length?this.path.join(this.separator):null,this.root=this.path[0],this.updateDisplay()}resolve(e,n,r,i,s={}){return t(!this.in||s.in,"Invalid in() reference usage"),"global"===this.type?this._resolve(r.context,n,s):"local"===this.type?this._resolve(i,n,s):this.ancestor?"root"===this.ancestor?this._resolve(n.ancestors[n.ancestors.length-1],n,s):(t(this.ancestor<=n.ancestors.length,"Invalid reference exceeds the schema root:",this.display),this._resolve(n.ancestors[this.ancestor-1],n,s)):this._resolve(e,n,s)}_resolve(e,t,n){let i;if("value"===this.type&&t.mainstay.shadow&&!1!==n.shadow&&(i=t.mainstay.shadow.get(this.absolute(t))),void 0===i&&(i=r(e,this.path,{iterables:this.iterables,functions:!0})),this.adjust&&(i=this.adjust(i)),this.map){const e=this.map.get(i);void 0!==e&&(i=e)}return t.mainstay&&t.mainstay.tracer.resolve(t,this,i),i}toString(){return this.display}absolute(e){return[...e.path.slice(0,-this.ancestor),...this.path]}clone(){return new a.Ref(this)}describe(){const e={path:this.path};"value"!==this.type&&(e.type=this.type),"."!==this.separator&&(e.separator=this.separator),"value"===this.type&&1!==this.ancestor&&(e.ancestor=this.ancestor),this.map&&(e.map=[...this.map]);for(const t of["adjust","iterables","render"])null!==this[t]&&void 0!==this[t]&&(e[t]=this[t]);return!1!==this.in&&(e.in=!0),{ref:e}}updateDisplay(){const e=null!==this.key?this.key:"";if("value"!==this.type)return void(this.display=`ref:${this.type}:${e}`);if(!this.separator)return void(this.display=`ref:${e}`);if(!this.ancestor)return void(this.display=`ref:${this.separator}${e}`);if("root"===this.ancestor)return void(this.display=`ref:root:${e}`);if(1===this.ancestor)return void(this.display=`ref:${e||".."}`);const t=new Array(this.ancestor+1).fill(this.separator).join("");this.display=`ref:${t}${e||""}`}},a.Ref.prototype[i.symbols.ref]=!0,e.build=function(e){return"value"===(e=Object.assign({},a.defaults,e)).type&&void 0===e.ancestor&&(e.ancestor=1),new a.Ref(e)},a.context=function(e,t,n={}){if(e=e.trim(),n){const r=void 0===n.global?"$":n.global;if(r!==t&&e.startsWith(r))return{key:e.slice(r.length),type:"global"};const i=void 0===n.local?"#":n.local;if(i!==t&&e.startsWith(i))return{key:e.slice(i.length),type:"local"};const s=void 0===n.root?"/":n.root;if(s!==t&&e.startsWith(s))return{key:e.slice(s.length),type:"value",root:!0}}return{key:e,type:"value"}},a.ancestor=function(e,t){if(!t)return[1,0];if(e[0]!==t)return[1,0];if(e[1]!==t)return[0,1];let n=2;for(;e[n]===t;)++n;return[n-1,n]},e.toSibling=0,e.toParent=1,e.Manager=class{constructor(){this.refs=[]}register(t,n){if(t)if(n=void 0===n?e.toParent:n,Array.isArray(t))for(const e of t)this.register(e,n);else if(i.isSchema(t))for(const e of t._refs.refs)e.ancestor-n>=0&&this.refs.push({ancestor:e.ancestor-n,root:e.root});else e.isRef(t)&&"value"===t.type&&t.ancestor-n>=0&&this.refs.push({ancestor:t.ancestor-n,root:t.root}),s=s||pt(),s.isTemplate(t)&&this.register(t.refs(),n)}get length(){return this.refs.length}clone(){const t=new e.Manager;return t.refs=n(this.refs),t}reset(){this.refs=[]}roots(){return this.refs.filter((e=>!e.ancestor)).map((e=>e.root))}}}(ht)),ht}function pt(){return ot||(ot=1,function(e){const t=xe,n=Ge,r=$e,i=Ze,s=mt(),a=st(),o=dt(),c={symbol:Symbol("template"),opens:new Array(1e3).join("\0"),closes:new Array(1e3).join(""),dateFormat:{date:Date.prototype.toDateString,iso:Date.prototype.toISOString,string:Date.prototype.toString,time:Date.prototype.toTimeString,utc:Date.prototype.toUTCString}};e.exports=c.Template=class{constructor(e,r){if(t("string"==typeof e,"Template source must be a string"),t(!e.includes("\0")&&!e.includes(""),"Template source cannot contain reserved control characters"),this.source=e,this.rendered=e,this._template=null,r){const{functions:e,...i}=r;this._settings=Object.keys(i).length?n(i):void 0,this._functions=e,this._functions&&(t(Object.keys(this._functions).every((e=>"string"==typeof e)),"Functions keys must be strings"),t(Object.values(this._functions).every((e=>"function"==typeof e)),"Functions values must be functions"))}else this._settings=void 0,this._functions=void 0;this._parse()}_parse(){if(!this.source.includes("{"))return;const e=c.encode(this.source),t=c.split(e);let n=!1;const r=[],i=t.shift();i&&r.push(i);for(const e of t){const t="{"!==e[0],i=t?"}":"}}",s=e.indexOf(i);if(-1===s||"{"===e[1]){r.push(`{${c.decode(e)}`);continue}let a=e.slice(t?0:1,s);const o=":"===a[0];o&&(a=a.slice(1));const l=this._ref(c.decode(a),{raw:t,wrapped:o});r.push(l),"string"!=typeof l&&(n=!0);const u=e.slice(s+i.length);u&&r.push(c.decode(u))}n?this._template=r:this.rendered=r.join("")}static date(e,t){return c.dateFormat[t.dateFormat].call(e)}describe(e={}){if(!this._settings&&e.compact)return this.source;const t={template:this.source};return this._settings&&(t.options=this._settings),this._functions&&(t.functions=this._functions),t}static build(e){return new c.Template(e.template,e.options||e.functions?{...e.options,functions:e.functions}:void 0)}isDynamic(){return!!this._template}static isTemplate(e){return!!e&&!!e[s.symbols.template]}refs(){if(!this._template)return;const e=[];for(const t of this._template)"string"!=typeof t&&e.push(...t.refs);return e}resolve(e,t,n,r){return this._template&&1===this._template.length?this._part(this._template[0],e,t,n,r,{}):this.render(e,t,n,r)}_part(e,...t){return e.ref?e.ref.resolve(...t):e.formula.evaluate(t)}render(e,t,n,i,s={}){if(!this.isDynamic())return this.rendered;const a=[];for(const o of this._template)if("string"==typeof o)a.push(o);else{const l=this._part(o,e,t,n,i,s),u=c.stringify(l,e,t,n,i,s);if(void 0!==u){const e=o.raw||!1===(s.errors&&s.errors.escapeHtml)?u:r(u);a.push(c.wrap(e,o.wrapped&&n.errors.wrap.label))}}return a.join("")}_ref(e,{raw:t,wrapped:n}){const r=[],s=e=>{const t=o.create(e,this._settings);return r.push(t),e=>{const n=t.resolve(...e);return void 0!==n?n:null}};try{const t=this._functions?{...c.functions,...this._functions}:c.functions;var a=new i.Parser(e,{reference:s,functions:t,constants:c.constants})}catch(t){throw t.message=`Invalid template variable "${e}" fails due to: ${t.message}`,t}if(a.single){if("reference"===a.single.type){const e=r[0];return{ref:e,raw:t,refs:r,wrapped:n||"local"===e.type&&"label"===e.key}}return c.stringify(a.single.value)}return{formula:a,raw:t,refs:r}}toString(){return this.source}},c.Template.prototype[s.symbols.template]=!0,c.Template.prototype.isImmutable=!0,c.encode=function(e){return e.replace(/\\(\{+)/g,((e,t)=>c.opens.slice(0,t.length))).replace(/\\(\}+)/g,((e,t)=>c.closes.slice(0,t.length)))},c.decode=function(e){return e.replace(/\u0000/g,"{").replace(/\u0001/g,"}")},c.split=function(e){const t=[];let n="";for(let r=0;r<e.length;++r){const i=e[r];if("{"===i){let i="";for(;r+1<e.length&&"{"===e[r+1];)i+="{",++r;t.push(n),n=i}else n+=i}return t.push(n),t},c.wrap=function(e,t){return t?1===t.length?`${t}${e}${t}`:`${t[0]}${e}${t[1]}`:e},c.stringify=function(e,t,n,r,i,s={}){const a=typeof e,l=r&&r.errors&&r.errors.wrap||{};let u=!1;if(o.isRef(e)&&e.render&&(u=e.in,e=e.resolve(t,n,r,i,{in:e.in,...s})),null===e)return"null";if("string"===a)return c.wrap(e,s.arrayItems&&l.string);if("number"===a||"function"===a||"symbol"===a)return e.toString();if("object"!==a)return JSON.stringify(e);if(e instanceof Date)return c.Template.date(e,r);if(e instanceof Map){const t=[];for(const[n,r]of e.entries())t.push(`${n.toString()} -> ${r.toString()}`);e=t}if(!Array.isArray(e))return e.toString();const h=[];for(const a of e)h.push(c.stringify(a,t,n,r,i,{arrayItems:!0,...s}));return c.wrap(h.join(", "),!u&&l.array)},c.constants={true:!0,false:!1,null:null,second:1e3,minute:6e4,hour:36e5,day:864e5},c.functions={if:(e,t,n)=>e?t:n,length:e=>"string"==typeof e?e.length:e&&"object"==typeof e?Array.isArray(e)?e.length:Object.keys(e).length:null,msg(e){const[t,n,r,i,s]=this,o=s.messages;if(!o)return"";const c=a.template(t,o[0],e,n,r)||a.template(t,o[1],e,n,r);return c?c.render(t,n,r,i,s):""},number:e=>"number"==typeof e?e:"string"==typeof e?parseFloat(e):"boolean"==typeof e?e?1:0:e instanceof Date?e.getTime():null}}(ze)),ze.exports}function ft(){return ct||(ct=1,function(e){const t=xe,n=Ge,r=pt();e.compile=function(e,i){if("string"==typeof e)return t(!i,"Cannot set single message string"),new r(e);if(r.isTemplate(e))return t(!i,"Cannot set single message template"),e;t("object"==typeof e&&!Array.isArray(e),"Invalid message options"),i=i?n(i):{};for(let n in e){const s=e[n];if("root"===n||r.isTemplate(s)){i[n]=s;continue}if("string"==typeof s){i[n]=new r(s);continue}t("object"==typeof s&&!Array.isArray(s),"Invalid message for",n);const a=n;for(n in i[a]=i[a]||{},s){const e=s[n];"root"===n||r.isTemplate(e)?i[a][n]=e:(t("string"==typeof e,"Invalid message for",n,"in",a),i[a][n]=new r(e))}}return i},e.decompile=function(e){const t={};for(let n in e){const i=e[n];if("root"===n){t.root=i;continue}if(r.isTemplate(i)){t[n]=i.describe({compact:!0});continue}const s=n;for(n in t[s]={},i){const e=i[n];"root"!==n?t[s][n]=e.describe({compact:!0}):t[s].root=e}}return t},e.merge=function(i,s){if(!i)return e.compile(s);if(!s)return i;if("string"==typeof s)return new r(s);if(r.isTemplate(s))return s;const a=n(i);for(let e in s){const n=s[e];if("root"===e||r.isTemplate(n)){a[e]=n;continue}if("string"==typeof n){a[e]=new r(n);continue}t("object"==typeof n&&!Array.isArray(n),"Invalid message for",e);const i=e;for(e in a[i]=a[i]||{},n){const s=n[e];"root"===e||r.isTemplate(s)?a[i][e]=s:(t("string"==typeof s,"Invalid message for",e,"in",i),a[i][e]=new r(s))}}return a}}(Ke)),Ke}function mt(){return lt||(lt=1,function(e){const t=xe,n=ke,r=qe;let i,s;const a={isoDate:/^(?:[-+]\d{2})?(?:\d{4}(?!\d{2}\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\1(?:[12]\d|0[1-9]|3[01]))?|W(?:[0-4]\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\d|[12]\d{2}|3(?:[0-5]\d|6[1-6])))(?![T]$|[T][\d]+Z$)(?:[T\s](?:(?:(?:[01]\d|2[0-3])(?:(:?)[0-5]\d)?|24\:?00)(?:[.,]\d+(?!:))?)(?:\2[0-5]\d(?:[.,]\d+)?)?(?:[Z]|(?:[+-])(?:[01]\d|2[0-3])(?::?[0-5]\d)?)?)?)?$/};e.version=r.version,e.defaults={abortEarly:!0,allowUnknown:!1,artifacts:!1,cache:!0,context:null,convert:!0,dateFormat:"iso",errors:{escapeHtml:!1,label:"path",language:null,render:!0,stack:!1,wrap:{label:'"',array:"[]"}},externals:!0,messages:{},nonEnumerables:!1,noDefaults:!1,presence:"optional",skipFunctions:!1,stripUnknown:!1,warnings:!1},e.symbols={any:Symbol.for("@hapi/joi/schema"),arraySingle:Symbol("arraySingle"),deepDefault:Symbol("deepDefault"),errors:Symbol("errors"),literal:Symbol("literal"),override:Symbol("override"),parent:Symbol("parent"),prefs:Symbol("prefs"),ref:Symbol("ref"),template:Symbol("template"),values:Symbol("values")},e.assertOptions=function(e,n,r="Options"){t(e&&"object"==typeof e&&!Array.isArray(e),"Options must be of type object");const i=Object.keys(e).filter((e=>!n.includes(e)));t(0===i.length,`${r} contain unknown keys: ${i}`)},e.checkPreferences=function(e){s=s||Xe();const t=s.preferences.validate(e);if(t.error)throw new n([t.error.details[0].message])},e.compare=function(e,t,n){switch(n){case"=":return e===t;case">":return e>t;case"<":return e<t;case">=":return e>=t;case"<=":return e<=t}},e.default=function(e,t){return void 0===e?t:e},e.isIsoDate=function(e){return a.isoDate.test(e)},e.isNumber=function(e){return"number"==typeof e&&!isNaN(e)},e.isResolvable=function(t){return!!t&&(t[e.symbols.ref]||t[e.symbols.template])},e.isSchema=function(n,r={}){const i=n&&n[e.symbols.any];return!!i&&(t(r.legacy||i.version===e.version,"Cannot mix different versions of joi schemas"),!0)},e.isValues=function(t){return t[e.symbols.values]},e.limit=function(e){return Number.isSafeInteger(e)&&e>=0},e.preferences=function(t,n){i=i||ft(),t=t||{},n=n||{};const r=Object.assign({},t,n);return n.errors&&t.errors&&(r.errors=Object.assign({},t.errors,n.errors),r.errors.wrap=Object.assign({},t.errors.wrap,n.errors.wrap)),n.messages&&(r.messages=i.compile(n.messages,t.messages)),delete r[e.symbols.prefs],r},e.tryWithPath=function(e,t,n={}){try{return e()}catch(e){throw void 0!==e.path?e.path=t+"."+e.path:e.path=t,n.append&&(e.message=`${e.message} (${e.path})`),e}},e.validateArg=function(t,n,{assert:r,message:i}){if(e.isSchema(r)){const e=r.validate(t);if(!e.error)return;return e.error.message}if(!r(t))return n?`${n} ${i}`:i},e.verifyFlat=function(e,n){for(const r of e)t(!Array.isArray(r),"Method no longer accepts array arguments:",n)}}(Ve)),Ve}function At(){if(ut)return He;ut=1;const e=xe,t=Ge,n=mt(),r={max:1e3,supported:new Set(["undefined","boolean","number","string"])};return He.provider={provision:e=>new r.Cache(e)},r.Cache=class{constructor(t={}){n.assertOptions(t,["max"]),e(void 0===t.max||t.max&&t.max>0&&isFinite(t.max),"Invalid max cache size"),this._max=t.max||r.max,this._map=new Map,this._list=new r.List}get length(){return this._map.size}set(e,t){if(null!==e&&!r.supported.has(typeof e))return;let n=this._map.get(e);if(n)return n.value=t,void this._list.first(n);n=this._list.unshift({key:e,value:t}),this._map.set(e,n),this._compact()}get(e){const n=this._map.get(e);if(n)return this._list.first(n),t(n.value)}_compact(){if(this._map.size>this._max){const e=this._list.pop();this._map.delete(e.key)}}},r.List=class{constructor(){this.tail=null,this.head=null}unshift(e){return e.next=null,e.prev=this.head,this.head&&(this.head.next=e),this.head=e,this.tail||(this.tail=e),e}first(e){e!==this.head&&(this._remove(e),this.unshift(e))}pop(){return this._remove(this.tail)}_remove(e){const{next:t,prev:n}=e;return t.prev=n,n&&(n.next=t),e===this.tail&&(this.tail=t),e.prev=null,e.next=null,e}},He}var gt,bt={};function yt(){return gt||(gt=1,function(e){const t=xe,n=mt(),r=dt(),i={};e.schema=function(e,t,r={}){n.assertOptions(r,["appendPath","override"]);try{return i.schema(e,t,r)}catch(e){throw r.appendPath&&void 0!==e.path&&(e.message=`${e.message} (${e.path})`),e}},i.schema=function(e,r,s){t(void 0!==r,"Invalid undefined schema"),Array.isArray(r)&&(t(r.length,"Invalid empty array schema"),1===r.length&&(r=r[0]));const a=(t,...n)=>!1!==s.override?t.valid(e.override,...n):t.valid(...n);if(i.simple(r))return a(e,r);if("function"==typeof r)return e.custom(r);if(t("object"==typeof r,"Invalid schema content:",typeof r),n.isResolvable(r))return a(e,r);if(n.isSchema(r))return r;if(Array.isArray(r)){for(const t of r)if(!i.simple(t))return e.alternatives().try(...r);return a(e,...r)}return r instanceof RegExp?e.string().regex(r):r instanceof Date?a(e.date(),r):(t(Object.getPrototypeOf(r)===Object.getPrototypeOf({}),"Schema can only contain plain objects"),e.object().keys(r))},e.ref=function(e,t){return r.isRef(e)?e:r.create(e,t)},e.compile=function(r,s,a={}){n.assertOptions(a,["legacy"]);const o=s&&s[n.symbols.any];if(o)return t(a.legacy||o.version===n.version,"Cannot mix different versions of joi schemas:",o.version,n.version),s;if("object"!=typeof s||!a.legacy)return e.schema(r,s,{appendPath:!0});const c=i.walk(s);return c?c.compile(c.root,s):e.schema(r,s,{appendPath:!0})},i.walk=function(e){if("object"!=typeof e)return null;if(Array.isArray(e)){for(const t of e){const e=i.walk(t);if(e)return e}return null}const r=e[n.symbols.any];if(r)return{root:e[r.root],compile:r.compile};t(Object.getPrototypeOf(e)===Object.getPrototypeOf({}),"Schema can only contain plain objects");for(const t in e){const n=i.walk(e[t]);if(n)return n}return null},i.simple=function(e){return null===e||["boolean","string","number"].includes(typeof e)},e.when=function(s,a,o){if(void 0===o&&(t(a&&"object"==typeof a,"Missing options"),o=a,a=r.create(".")),Array.isArray(o)&&(o={switch:o}),n.assertOptions(o,["is","not","then","otherwise","switch","break"]),n.isSchema(a))return t(void 0===o.is,'"is" can not be used with a schema condition'),t(void 0===o.not,'"not" can not be used with a schema condition'),t(void 0===o.switch,'"switch" can not be used with a schema condition'),i.condition(s,{is:a,then:o.then,otherwise:o.otherwise,break:o.break});if(t(r.isRef(a)||"string"==typeof a,"Invalid condition:",a),t(void 0===o.not||void 0===o.is,'Cannot combine "is" with "not"'),void 0===o.switch){let c=o;void 0!==o.not&&(c={is:o.not,then:o.otherwise,otherwise:o.then,break:o.break});let l=void 0!==c.is?s.$_compile(c.is):s.$_root.invalid(null,!1,0,"").required();return t(void 0!==c.then||void 0!==c.otherwise,'options must have at least one of "then", "otherwise", or "switch"'),t(void 0===c.break||void 0===c.then||void 0===c.otherwise,"Cannot specify then, otherwise, and break all together"),void 0===o.is||r.isRef(o.is)||n.isSchema(o.is)||(l=l.required()),i.condition(s,{ref:e.ref(a),is:l,then:c.then,otherwise:c.otherwise,break:c.break})}t(Array.isArray(o.switch),'"switch" must be an array'),t(void 0===o.is,'Cannot combine "switch" with "is"'),t(void 0===o.not,'Cannot combine "switch" with "not"'),t(void 0===o.then,'Cannot combine "switch" with "then"');const c={ref:e.ref(a),switch:[],break:o.break};for(let e=0;e<o.switch.length;++e){const i=o.switch[e],a=e===o.switch.length-1;n.assertOptions(i,a?["is","then","otherwise"]:["is","then"]),t(void 0!==i.is,'Switch statement missing "is"'),t(void 0!==i.then,'Switch statement missing "then"');const l={is:s.$_compile(i.is),then:s.$_compile(i.then)};if(r.isRef(i.is)||n.isSchema(i.is)||(l.is=l.is.required()),a){t(void 0===o.otherwise||void 0===i.otherwise,'Cannot specify "otherwise" inside and outside a "switch"');const e=void 0!==o.otherwise?o.otherwise:i.otherwise;void 0!==e&&(t(void 0===c.break,"Cannot specify both otherwise and break"),l.otherwise=s.$_compile(e))}c.switch.push(l)}return c},i.condition=function(e,t){for(const n of["then","otherwise"])void 0===t[n]?delete t[n]:t[n]=e.$_compile(t[n]);return t}}(bt)),bt}var vt,Et={};function _t(){if(vt)return Et;vt=1;const e=xe,t=Ge,n=mt(),r=ft(),i={};return Et.type=function(s,a){const o=Object.getPrototypeOf(s),c=t(o),l=s._assign(Object.create(c)),u=Object.assign({},a);delete u.base,c._definition=u;const h=o._definition||{};u.messages=r.merge(h.messages,u.messages),u.properties=Object.assign({},h.properties,u.properties),l.type=u.type,u.flags=Object.assign({},h.flags,u.flags);const d=Object.assign({},h.terms);if(u.terms)for(const t in u.terms){const n=u.terms[t];e(void 0===l.$_terms[t],"Invalid term override for",u.type,t),l.$_terms[t]=n.init,d[t]=n}u.terms=d,u.args||(u.args=h.args),u.prepare=i.prepare(u.prepare,h.prepare),u.coerce&&("function"==typeof u.coerce&&(u.coerce={method:u.coerce}),u.coerce.from&&!Array.isArray(u.coerce.from)&&(u.coerce={method:u.coerce.method,from:[].concat(u.coerce.from)})),u.coerce=i.coerce(u.coerce,h.coerce),u.validate=i.validate(u.validate,h.validate);const p=Object.assign({},h.rules);if(u.rules)for(const t in u.rules){const r=u.rules[t];e("object"==typeof r,"Invalid rule definition for",u.type,t);let i=r.method;if(void 0===i&&(i=function(){return this.$_addRule(t)}),i&&(e(!c[t],"Rule conflict in",u.type,t),c[t]=i),e(!p[t],"Rule conflict in",u.type,t),p[t]=r,r.alias){const e=[].concat(r.alias);for(const t of e)c[t]=r.method}r.args&&(r.argsByName=new Map,r.args=r.args.map((t=>("string"==typeof t&&(t={name:t}),e(!r.argsByName.has(t.name),"Duplicated argument name",t.name),n.isSchema(t.assert)&&(t.assert=t.assert.strict().label(t.name)),r.argsByName.set(t.name,t),t))))}u.rules=p;const f=Object.assign({},h.modifiers);if(u.modifiers)for(const t in u.modifiers){e(!c[t],"Rule conflict in",u.type,t);const n=u.modifiers[t];e("function"==typeof n,"Invalid modifier definition for",u.type,t);const r=function(e){return this.rule({[t]:e})};c[t]=r,f[t]=n}if(u.modifiers=f,u.overrides){c._super=o,l.$_super={};for(const t in u.overrides)e(o[t],"Cannot override missing",t),u.overrides[t][n.symbols.parent]=o[t],l.$_super[t]=o[t].bind(l);Object.assign(c,u.overrides)}u.cast=Object.assign({},h.cast,u.cast);const m=Object.assign({},h.manifest,u.manifest);return m.build=i.build(u.manifest&&u.manifest.build,h.manifest&&h.manifest.build),u.manifest=m,u.rebuild=i.rebuild(u.rebuild,h.rebuild),l},i.build=function(e,t){return e&&t?function(n,r){return t(e(n,r),r)}:e||t},i.coerce=function(e,t){return e&&t?{from:e.from&&t.from?[...new Set([...e.from,...t.from])]:null,method(n,r){let i;if((!t.from||t.from.includes(typeof n))&&(i=t.method(n,r),i)){if(i.errors||void 0===i.value)return i;n=i.value}if(!e.from||e.from.includes(typeof n)){const t=e.method(n,r);if(t)return t}return i}}:e||t},i.prepare=function(e,t){return e&&t?function(n,r){const i=e(n,r);if(i){if(i.errors||void 0===i.value)return i;n=i.value}return t(n,r)||i}:e||t},i.rebuild=function(e,t){return e&&t?function(n){t(n),e(n)}:e||t},i.validate=function(e,t){return e&&t?function(n,r){const i=t(n,r);if(i){if(i.errors&&(!Array.isArray(i.errors)||i.errors.length))return i;n=i.value}return e(n,r)||i}:e||t},Et}var It,wt={};function Ct(){if(It)return wt;It=1;const e=xe,t=Ge,n=mt(),r=ft(),i=dt(),s=pt();let a;const o={};return wt.describe=function(i){const s=i._definition,a={type:i.type,flags:{},rules:[]};for(const e in i._flags)"_"!==e[0]&&(a.flags[e]=o.describe(i._flags[e]));Object.keys(a.flags).length||delete a.flags,i._preferences&&(a.preferences=t(i._preferences,{shallow:["messages"]}),delete a.preferences[n.symbols.prefs],a.preferences.messages&&(a.preferences.messages=r.decompile(a.preferences.messages))),i._valids&&(a.allow=i._valids.describe()),i._invalids&&(a.invalid=i._invalids.describe());for(const e of i._rules){if(!1===s.rules[e.name].manifest)continue;const t={name:e.name};for(const n in s.modifiers)void 0!==e[n]&&(t[n]=o.describe(e[n]));if(e.args){t.args={};for(const n in e.args){const r=e.args[n];("options"!==n||Object.keys(r).length)&&(t.args[n]=o.describe(r,{assign:n}))}Object.keys(t.args).length||delete t.args}a.rules.push(t)}a.rules.length||delete a.rules;for(const t in i.$_terms){if("_"===t[0])continue;e(!a[t],"Cannot describe schema due to internal name conflict with",t);const r=i.$_terms[t];if(!r)continue;if(r instanceof Map){r.size&&(a[t]=[...r.entries()]);continue}if(n.isValues(r)){a[t]=r.describe();continue}e(s.terms[t],"Term",t,"missing configuration");const c=s.terms[t].manifest,l="object"==typeof c;if(!r.length&&!l)continue;const u=[];for(const e of r)u.push(o.describe(e));if(l){const{from:e,to:n}=c.mapped;a[t]={};for(const r of u)a[t][r[n]]=r[e]}else"single"!==c?a[t]=u:(e(1===u.length,"Term",t,"contains more than one item"),a[t]=u[0])}return o.validate(i.$_root,a),a},o.describe=function(e,r={}){if(Array.isArray(e))return e.map(o.describe);if(e===n.symbols.deepDefault)return{special:"deep"};if("object"!=typeof e||null===e)return e;if("options"===r.assign)return t(e);if(Buffer&&Buffer.isBuffer(e))return{buffer:e.toString("binary")};if(e instanceof Date)return e.toISOString();if(e instanceof Error)return e;if(e instanceof RegExp)return"regex"===r.assign?e.toString():{regex:e.toString()};if(e[n.symbols.literal])return{function:e.literal};if("function"==typeof e.describe)return"ref"===r.assign?e.describe().ref:e.describe();const i={};for(const t in e){const n=e[t];void 0!==n&&(i[t]=o.describe(n,{assign:t}))}return i},wt.build=function(e,t){return new o.Builder(e).parse(t)},o.Builder=class{constructor(e){this.joi=e}parse(t){o.validate(this.joi,t);let n=this.joi[t.type]()._bare();const r=n._definition;if(t.flags)for(const i in t.flags){const s=r.flags[i]&&r.flags[i].setter||i;e("function"==typeof n[s],"Invalid flag",i,"for type",t.type),n=n[s](this.build(t.flags[i]))}if(t.preferences&&(n=n.preferences(this.build(t.preferences))),t.allow&&(n=n.allow(...this.build(t.allow))),t.invalid&&(n=n.invalid(...this.build(t.invalid))),t.rules)for(const i of t.rules){e("function"==typeof n[i.name],"Invalid rule",i.name,"for type",t.type);const s=[];if(i.args){const n={};for(const e in i.args)n[e]=this.build(i.args[e],{assign:e});const a=Object.keys(n),o=r.rules[i.name].args;if(o){e(a.length<=o.length,"Invalid number of arguments for",t.type,i.name,"(expected up to",o.length,", found",a.length,")");for(const{name:e}of o)s.push(n[e])}else e(1===a.length,"Invalid number of arguments for",t.type,i.name,"(expected up to 1, found",a.length,")"),s.push(n[a[0]])}n=n[i.name](...s);const a={};for(const e in r.modifiers)void 0!==i[e]&&(a[e]=this.build(i[e]));Object.keys(a).length&&(n=n.rule(a))}const i={};for(const n in t){if(["allow","flags","in