UNPKG

@netcentric/cm-notify

Version:

Adobe Cloud Manager Pipeline Notifications to Slack, Teams and Email

6 lines 243 kB
var p=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Wn=p((_d,Dl)=>{Dl.exports={name:"dotenv",version:"16.5.0",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard",pretest:"npm run lint && npm run dts-check",test:"tap run --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run --show-full-coverage --timeout=60000 --coverage-report=lcov",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},homepage:"https://github.com/motdotla/dotenv#readme",funding:"https://dotenvx.com",keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@types/node":"^18.11.3",decache:"^4.6.2",sinon:"^14.0.1",standard:"^17.0.0","standard-version":"^9.5.0",tap:"^19.2.0",typescript:"^4.8.4"},engines:{node:">=12"},browser:{fs:!1}}});var es=p((Ad,Me)=>{var Ar=require("fs"),Er=require("path"),Ll=require("os"),Ml=require("crypto"),Pl=Wn(),Jn=Pl.version,ql=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function Bl(e){let t={},r=e.toString();r=r.replace(/\r\n?/mg,` `);let n;for(;(n=ql.exec(r))!=null;){let s=n[1],i=n[2]||"";i=i.trim();let o=i[0];i=i.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),o==='"'&&(i=i.replace(/\\n/g,` `),i=i.replace(/\\r/g,"\r")),t[s]=i}return t}function jl(e){let t=Qn(e),r=H.configDotenv({path:t});if(!r.parsed){let o=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw o.code="MISSING_DATA",o}let n=Zn(e).split(","),s=n.length,i;for(let o=0;o<s;o++)try{let a=n[o].trim(),l=Ul(r,a);i=H.decrypt(l.ciphertext,l.key);break}catch(a){if(o+1>=s)throw a}return H.parse(i)}function Fl(e){console.log(`[dotenv@${Jn}][WARN] ${e}`)}function St(e){console.log(`[dotenv@${Jn}][DEBUG] ${e}`)}function Zn(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function Ul(e,t){let r;try{r=new URL(t)}catch(a){if(a.code==="ERR_INVALID_URL"){let l=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw l.code="INVALID_DOTENV_KEY",l}throw a}let n=r.password;if(!n){let a=new Error("INVALID_DOTENV_KEY: Missing key part");throw a.code="INVALID_DOTENV_KEY",a}let s=r.searchParams.get("environment");if(!s){let a=new Error("INVALID_DOTENV_KEY: Missing environment part");throw a.code="INVALID_DOTENV_KEY",a}let i=`DOTENV_VAULT_${s.toUpperCase()}`,o=e.parsed[i];if(!o){let a=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${i} in your .env.vault file.`);throw a.code="NOT_FOUND_DOTENV_ENVIRONMENT",a}return{ciphertext:o,key:n}}function Qn(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let r of e.path)Ar.existsSync(r)&&(t=r.endsWith(".vault")?r:`${r}.vault`);else t=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else t=Er.resolve(process.cwd(),".env.vault");return Ar.existsSync(t)?t:null}function Yn(e){return e[0]==="~"?Er.join(Ll.homedir(),e.slice(1)):e}function Gl(e){!!(e&&e.debug)&&St("Loading env from encrypted .env.vault");let r=H._parseVault(e),n=process.env;return e&&e.processEnv!=null&&(n=e.processEnv),H.populate(n,r,e),{parsed:r}}function Hl(e){let t=Er.resolve(process.cwd(),".env"),r="utf8",n=!!(e&&e.debug);e&&e.encoding?r=e.encoding:n&&St("No encoding is specified. UTF-8 is used by default");let s=[t];if(e&&e.path)if(!Array.isArray(e.path))s=[Yn(e.path)];else{s=[];for(let l of e.path)s.push(Yn(l))}let i,o={};for(let l of s)try{let c=H.parse(Ar.readFileSync(l,{encoding:r}));H.populate(o,c,e)}catch(c){n&&St(`Failed to load ${l} ${c.message}`),i=c}let a=process.env;return e&&e.processEnv!=null&&(a=e.processEnv),H.populate(a,o,e),i?{parsed:o,error:i}:{parsed:o}}function Xl(e){if(Zn(e).length===0)return H.configDotenv(e);let t=Qn(e);return t?H._configVault(e):(Fl(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`),H.configDotenv(e))}function Vl(e,t){let r=Buffer.from(t.slice(-64),"hex"),n=Buffer.from(e,"base64"),s=n.subarray(0,12),i=n.subarray(-16);n=n.subarray(12,-16);try{let o=Ml.createDecipheriv("aes-256-gcm",r,s);return o.setAuthTag(i),`${o.update(n)}${o.final()}`}catch(o){let a=o instanceof RangeError,l=o.message==="Invalid key length",c=o.message==="Unsupported state or unable to authenticate data";if(a||l){let f=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw f.code="INVALID_DOTENV_KEY",f}else if(c){let f=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw f.code="DECRYPTION_FAILED",f}else throw o}}function Kl(e,t,r={}){let n=!!(r&&r.debug),s=!!(r&&r.override);if(typeof t!="object"){let i=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw i.code="OBJECT_REQUIRED",i}for(let i of Object.keys(t))Object.prototype.hasOwnProperty.call(e,i)?(s===!0&&(e[i]=t[i]),n&&St(s===!0?`"${i}" is already defined and WAS overwritten`:`"${i}" is already defined and was NOT overwritten`)):e[i]=t[i]}var H={configDotenv:Hl,_configVault:Gl,_parseVault:jl,config:Xl,decrypt:Vl,parse:Bl,populate:Kl};Me.exports.configDotenv=H.configDotenv;Me.exports._configVault=H._configVault;Me.exports._parseVault=H._parseVault;Me.exports.config=H.config;Me.exports.decrypt=H.decrypt;Me.exports.parse=H.parse;Me.exports.populate=H.populate;Me.exports=H});var rs=p((Ed,ts)=>{var zl={slackWebhook:process.env.SLACK_WEBHOOK,teamsWebhook:process.env.TEAMS_WEBHOOK,teamsEmail:process.env.TEAMS_EMAIL,orgName:process.env.ORGANIZATION_NAME,clientId:process.env.CLIENT_ID,title:process.env.TITLE||"Cloud Manager Pipeline Notification",fromEmail:process.env.EMAIL_FROM,dataPath:process.env.DATA_PATH||".data",secret:process.env.SECRET};ts.exports={DEFAULT_CONFIG:zl}});var ft=p((wd,is)=>{var{join:ns,resolve:wr}=require("node:path"),{existsSync:ss,writeFileSync:Wl}=require("node:fs"),{DEFAULT_CONFIG:Yl}=rs(),Or=class{static getJsonDataFilePath(t,r){let n=r||ns(process.cwd(),".data");return wr(n,t)}static getValidPath(t){try{let r=wr(t);return ss(r)?r:!1}catch{return!1}}static getFilePath(t,r){let n=this.getValidPath(t);if(n)return n;let s=r||ns(process.cwd(),".data"),i=wr(s,t);return this.getValidPath(i)}static getJsonData(t,r){let n=this.getJsonDataFilePath(t,r);return ss(n)?require(n):null}static saveJsonData(t,r,n){let s=this.getJsonDataFilePath(t,n);Wl(s,JSON.stringify(r,null,2)),console.log("File created: ",s)}static convertUTCToTimezone(t,r="cet"){let n={cet:{timeZone:"Europe/Berlin",locale:"de-DE"},ist:{timeZone:"Asia/Kolkata",locale:"en-IN"},est:{timeZone:"America/New_York",locale:"en-US"}},s=r.toLowerCase(),i=n[s];if(!i)throw new Error("Unsupported timezone. Use cet, ist, or est.");let o=new Date(t);return`${new Intl.DateTimeFormat(i.locale,{timeZone:i.timeZone,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(o)} ${s.toUpperCase()}`}static convertUTCToDateWithOffset(t,r="+00:00"){let n=/^([+-])(\d{2}):(\d{2})$/,s=r.match(n);if(!s)throw new Error("Invalid UTC offset format. Use format like +05:30 or -04:00.");let i=s[1]==="+"?1:-1,o=parseInt(s[2],10),a=parseInt(s[3],10),l=i*(o*60*60*1e3+a*60*1e3);return`${new Date(t+l).toISOString().replace("T"," ").substring(0,19)} UTC${r}`}static isBase64(t){return!t||typeof t!="string"?!1:/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}static getDefaultConfig(){return Yl}};is.exports={CMUtils:Or}});var as=p((Od,os)=>{"use strict";os.exports=function(...e){try{return JSON.stringify(...e)}catch(t){return"[Cannot display object: "+t.message+"]"}}});var Sr=p((ls,cs)=>{"use strict";var Jl=as();cs.exports=class extends Error{constructor(e){let t=e.filter(r=>r!=="").map(r=>typeof r=="string"?r:r instanceof Error?r.message:Jl(r));super(t.join(" ")||"Unknown error"),typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ls.assert)}}});var $=p((Rd,us)=>{"use strict";var Zl=Sr();us.exports=function(e,...t){if(!e)throw t.length===1&&t[0]instanceof Error?t[0]:new Zl(t)}});var Qe=p((Cd,ds)=>{"use strict";var Rr=$(),fs={};ds.exports=function(e,t,r){if(t===!1||t===null||t===void 0)return e;r=r||{},typeof r=="string"&&(r={separator:r});let n=Array.isArray(t);Rr(!n||!r.separator,"Separator option is not valid for array-based chain");let s=n?t:t.split(r.separator||"."),i=e;for(let o=0;o<s.length;++o){let a=s[o],l=r.iterables&&fs.iterables(i);if(Array.isArray(i)||l==="set"){let c=Number(a);Number.isInteger(c)&&(a=c<0?i.length+c:c)}if(!i||typeof i=="function"&&r.functions===!1||!l&&i[a]===void 0){Rr(!r.strict||o+1===s.length,"Missing segment",a,"in reach path ",t),Rr(typeof i=="object"||r.functions===!0||typeof i!="function","Invalid segment",a,"in reach path ",t),i=r.default;break}l?l==="set"?i=[...i][a]:i=i.get(a):i=i[a]}return i};fs.iterables=function(e){if(e instanceof Set)return"set";if(e instanceof Map)return"map"}});var Cr=p((ie,ms)=>{"use strict";var hs={};ie=ms.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};hs.typeMap=new Map([["[object Error]",ie.error],["[object Map]",ie.map],["[object Promise]",ie.promise],["[object Set]",ie.set],["[object WeakMap]",ie.weakMap],["[object WeakSet]",ie.weakSet]]);ie.getInternalProto=function(e){if(Array.isArray(e))return ie.array;if(Buffer&&e instanceof Buffer)return ie.buffer;if(e instanceof Date)return ie.date;if(e instanceof RegExp)return ie.regex;if(e instanceof Error)return ie.error;let t=Object.prototype.toString.call(e);return hs.typeMap.get(t)||ie.generic}});var Nr=p(ps=>{"use strict";ps.keys=function(e,t={}){return t.symbols!==!1?Reflect.ownKeys(e):Object.getOwnPropertyNames(e)}});var oe=p((vd,gs)=>{"use strict";var Ql=Qe(),fe=Cr(),ec=Nr(),Pe={needsProtoHack:new Set([fe.set,fe.map,fe.weakSet,fe.weakMap])};gs.exports=Pe.clone=function(e,t={},r=null){if(typeof e!="object"||e===null)return e;let n=Pe.clone,s=r;if(t.shallow){if(t.shallow!==!0)return Pe.cloneWithShallow(e,t);n=l=>l}else if(s){let l=s.get(e);if(l)return l}else s=new Map;let i=fe.getInternalProto(e);if(i===fe.buffer)return Buffer&&Buffer.from(e);if(i===fe.date)return new Date(e.getTime());if(i===fe.regex)return new RegExp(e);let o=Pe.base(e,i,t);if(o===e)return e;if(s&&s.set(e,o),i===fe.set)for(let l of e)o.add(n(l,t,s));else if(i===fe.map)for(let[l,c]of e)o.set(l,n(c,t,s));let a=ec.keys(e,t);for(let l of a){if(l==="__proto__")continue;if(i===fe.array&&l==="length"){o.length=e.length;continue}let c=Object.getOwnPropertyDescriptor(e,l);c?c.get||c.set?Object.defineProperty(o,l,c):c.enumerable?o[l]=n(e[l],t,s):Object.defineProperty(o,l,{enumerable:!1,writable:!0,configurable:!0,value:n(e[l],t,s)}):Object.defineProperty(o,l,{enumerable:!0,writable:!0,configurable:!0,value:n(e[l],t,s)})}return o};Pe.cloneWithShallow=function(e,t){let r=t.shallow;t=Object.assign({},t),t.shallow=!1;let n=new Map;for(let s of r){let i=Ql(e,s);(typeof i=="object"||typeof i=="function")&&n.set(i,i)}return Pe.clone(e,t,n)};Pe.base=function(e,t,r){if(r.prototype===!1)return Pe.needsProtoHack.has(t)?new t.constructor:t===fe.array?[]:{};let n=Object.getPrototypeOf(e);if(n&&n.isImmutable)return e;if(t===fe.array){let s=[];return n!==t&&Object.setPrototypeOf(s,n),s}if(Pe.needsProtoHack.has(t)){let s=new n.constructor;return n!==t&&Object.setPrototypeOf(s,n),s}return Object.create(n)}});var ys=p((Id,tc)=>{tc.exports={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"}});var Bt=p(Rt=>{"use strict";var h=jt(),S={};S.wrap=h.string().min(1).max(2).allow(!1);Rt.preferences=h.object({allowUnknown:h.boolean(),abortEarly:h.boolean(),artifacts:h.boolean(),cache:h.boolean(),context:h.object(),convert:h.boolean(),dateFormat:h.valid("date","iso","string","time","utc"),debug:h.boolean(),errors:{escapeHtml:h.boolean(),label:h.valid("path","key",!1),language:[h.string(),h.object().ref()],render:h.boolean(),stack:h.boolean(),wrap:{label:S.wrap,array:S.wrap,string:S.wrap}},externals:h.boolean(),messages:h.object(),noDefaults:h.boolean(),nonEnumerables:h.boolean(),presence:h.valid("required","optional","forbidden"),skipFunctions:h.boolean(),stripUnknown:h.object({arrays:h.boolean(),objects:h.boolean()}).or("arrays","objects").allow(!0,!1),warnings:h.boolean()}).strict();S.nameRx=/^[a-zA-Z0-9]\w*$/;S.rule=h.object({alias:h.array().items(h.string().pattern(S.nameRx)).single(),args:h.array().items(h.string(),h.object({name:h.string().pattern(S.nameRx).required(),ref:h.boolean(),assert:h.alternatives([h.function(),h.object().schema()]).conditional("ref",{is:!0,then:h.required()}),normalize:h.function(),message:h.string().when("assert",{is:h.function(),then:h.required()})})),convert:h.boolean(),manifest:h.boolean(),method:h.function().allow(!1),multi:h.boolean(),validate:h.function()});Rt.extension=h.object({type:h.alternatives([h.string(),h.object().regex()]).required(),args:h.function(),cast:h.object().pattern(S.nameRx,h.object({from:h.function().maxArity(1).required(),to:h.function().minArity(1).maxArity(2).required()})),base:h.object().schema().when("type",{is:h.object().regex(),then:h.forbidden()}),coerce:[h.function().maxArity(3),h.object({method:h.function().maxArity(3).required(),from:h.array().items(h.string()).single()})],flags:h.object().pattern(S.nameRx,h.object({setter:h.string(),default:h.any()})),manifest:{build:h.function().arity(2)},messages:[h.object(),h.string()],modifiers:h.object().pattern(S.nameRx,h.function().minArity(1).maxArity(2)),overrides:h.object().pattern(S.nameRx,h.function()),prepare:h.function().maxArity(3),rebuild:h.function().arity(1),rules:h.object().pattern(S.nameRx,S.rule),terms:h.object().pattern(S.nameRx,h.object({init:h.array().allow(null).required(),manifest:h.object().pattern(/.+/,[h.valid("schema","single"),h.object({mapped:h.object({from:h.string().required(),to:h.string().required()}).required()})])})),validate:h.function().maxArity(3)}).strict();Rt.extensions=h.array().items(h.object(),h.function().arity(1)).strict();S.desc={buffer:h.object({buffer:h.string()}),func:h.object({function:h.function().required(),options:{literal:!0}}),override:h.object({override:!0}),ref:h.object({ref:h.object({type:h.valid("value","global","local"),path:h.array().required(),separator:h.string().length(1).allow(!1),ancestor:h.number().min(0).integer().allow("root"),map:h.array().items(h.array().length(2)).min(1),adjust:h.function(),iterables:h.boolean(),in:h.boolean(),render:h.boolean()}).required()}),regex:h.object({regex:h.string().min(3)}),special:h.object({special:h.valid("deep").required()}),template:h.object({template:h.string().required(),options:h.object()}),value:h.object({value:h.alternatives([h.object(),h.array()]).required()})};S.desc.entity=h.alternatives([h.array().items(h.link("...")),h.boolean(),h.function(),h.number(),h.string(),S.desc.buffer,S.desc.func,S.desc.ref,S.desc.regex,S.desc.special,S.desc.template,S.desc.value,h.link("/")]);S.desc.values=h.array().items(null,h.boolean(),h.function(),h.number().allow(1/0,-1/0),h.string().allow(""),h.symbol(),S.desc.buffer,S.desc.func,S.desc.override,S.desc.ref,S.desc.regex,S.desc.template,S.desc.value);S.desc.messages=h.object().pattern(/.+/,[h.string(),S.desc.template,h.object().pattern(/.+/,[h.string(),S.desc.template])]);Rt.description=h.object({type:h.string().required(),flags:h.object({cast:h.string(),default:h.any(),description:h.string(),empty:h.link("/"),failover:S.desc.entity,id:h.string(),label:h.string(),only:!0,presence:["optional","required","forbidden"],result:["raw","strip"],strip:h.boolean(),unit:h.string()}).unknown(),preferences:{allowUnknown:h.boolean(),abortEarly:h.boolean(),artifacts:h.boolean(),cache:h.boolean(),convert:h.boolean(),dateFormat:["date","iso","string","time","utc"],errors:{escapeHtml:h.boolean(),label:["path","key"],language:[h.string(),S.desc.ref],wrap:{label:S.wrap,array:S.wrap}},externals:h.boolean(),messages:S.desc.messages,noDefaults:h.boolean(),nonEnumerables:h.boolean(),presence:["required","optional","forbidden"],skipFunctions:h.boolean(),stripUnknown:h.object({arrays:h.boolean(),objects:h.boolean()}).or("arrays","objects").allow(!0,!1),warnings:h.boolean()},allow:S.desc.values,invalid:S.desc.values,rules:h.array().min(1).items({name:h.string().required(),args:h.object().min(1),keep:h.boolean(),message:[h.string(),S.desc.messages],warn:h.boolean()}),keys:h.object().pattern(/.*/,h.link("/")),link:S.desc.ref}).pattern(/^[a-z]\w*$/,h.any())});var _s=p((xd,bs)=>{"use strict";var Ve={};bs.exports=function(e){if(!e)return"";let t="";for(let r=0;r<e.length;++r){let n=e.charCodeAt(r);Ve.isSafe(n)?t+=e[r]:t+=Ve.escapeHtmlChar(n)}return t};Ve.escapeHtmlChar=function(e){let t=Ve.namedHtml.get(e);return t||(e>=256?"&#"+e+";":`&#x${e.toString(16).padStart(2,"0")};`)};Ve.isSafe=function(e){return Ve.safeCharCodes.has(e)};Ve.namedHtml=new Map([[38,"&amp;"],[60,"&lt;"],[62,"&gt;"],[34,"&quot;"],[160,"&nbsp;"],[162,"&cent;"],[163,"&pound;"],[164,"&curren;"],[169,"&copy;"],[174,"&reg;"]]);Ve.safeCharCodes=function(){let e=new Set;for(let t=32;t<123;++t)(t>=97||t>=65&&t<=90||t>=48&&t<=57||t===32||t===46||t===44||t===45||t===58||t===95)&&e.add(t);return e}()});var As=p(Ct=>{"use strict";var v={operators:["!","^","*","/","%","+","-","<","<=",">",">=","==","!=","&&","||","??"],operatorCharacters:["!","^","*","/","%","+","-","<","=",">","&","|","?"],operatorsOrder:[["^"],["*","/","%"],["+","-"],["<","<=",">",">="],["==","!="],["&&"],["||","??"]],operatorsPrefix:["!","n"],literals:{'"':'"',"`":"`","'":"'","[":"]"},numberRx:/^(?:[0-9]*(\.[0-9]*)?){1}$/,tokenRx:/^[\w\$\#\.\@\:\{\}]+$/,symbol:Symbol("formula"),settings:Symbol("settings")};Ct.Parser=class{constructor(e,t={}){if(!t[v.settings]&&t.constants)for(let r in t.constants){let n=t.constants[r];if(n!==null&&!["boolean","number","string"].includes(typeof n))throw new Error(`Formula constant ${r} contains invalid ${typeof n} value type`)}this.settings=t[v.settings]?t:Object.assign({[v.settings]:!0,constants:{},functions:{}},t),this.single=null,this._parts=null,this._parse(e)}_parse(e){let t=[],r="",n=0,s=!1,i=a=>{if(n)throw new Error("Formula missing closing parenthesis");let l=t.length?t[t.length-1]:null;if(!(!s&&!r&&!a)){if(l&&l.type==="reference"&&a===")"){l.type="function",l.value=this._subFormula(r,l.value),r="";return}if(a===")"){let c=new Ct.Parser(r,this.settings);t.push({type:"segment",value:c})}else if(s){if(s==="]"){t.push({type:"reference",value:r}),r="";return}t.push({type:"literal",value:r})}else if(v.operatorCharacters.includes(r))l&&l.type==="operator"&&v.operators.includes(l.value+r)?l.value+=r:t.push({type:"operator",value:r});else if(r.match(v.numberRx))t.push({type:"constant",value:parseFloat(r)});else if(this.settings.constants[r]!==void 0)t.push({type:"constant",value:this.settings.constants[r]});else{if(!r.match(v.tokenRx))throw new Error(`Formula contains invalid token: ${r}`);t.push({type:"reference",value:r})}r=""}};for(let a of e)s?a===s?(i(),s=!1):r+=a:n?a==="("?(r+=a,++n):a===")"?(--n,n?r+=a:i(a)):r+=a:a in v.literals?s=v.literals[a]:a==="("?(i(),++n):v.operatorCharacters.includes(a)?(i(),r=a,i()):a!==" "?r+=a:i();i(),t=t.map((a,l)=>a.type!=="operator"||a.value!=="-"||l&&t[l-1].type!=="operator"?a:{type:"operator",value:"n"});let o=!1;for(let a of t){if(a.type==="operator"){if(v.operatorsPrefix.includes(a.value))continue;if(!o)throw new Error("Formula contains an operator in invalid position");if(!v.operators.includes(a.value))throw new Error(`Formula contains an unknown operator ${a.value}`)}else if(o)throw new Error("Formula missing expected operator");o=!o}if(!o)throw new Error("Formula contains invalid trailing operator");t.length===1&&["reference","literal","constant"].includes(t[0].type)&&(this.single={type:t[0].type==="reference"?"reference":"value",value:t[0].value}),this._parts=t.map(a=>{if(a.type==="operator")return v.operatorsPrefix.includes(a.value)?a:a.value;if(a.type!=="reference")return a.value;if(this.settings.tokenRx&&!this.settings.tokenRx.test(a.value))throw new Error(`Formula contains invalid reference ${a.value}`);return this.settings.reference?this.settings.reference(a.value):v.reference(a.value)})}_subFormula(e,t){let r=this.settings.functions[t];if(typeof r!="function")throw new Error(`Formula contains unknown function ${t}`);let n=[];if(e){let s="",i=0,o=!1,a=()=>{if(!s)throw new Error(`Formula contains function ${t} with invalid arguments ${e}`);n.push(s),s=""};for(let l=0;l<e.length;++l){let c=e[l];o?(s+=c,c===o&&(o=!1)):c in v.literals&&!i?(s+=c,o=v.literals[c]):c===","&&!i?a():(s+=c,c==="("?++i:c===")"&&--i)}a()}return n=n.map(s=>new Ct.Parser(s,this.settings)),function(s){let i=[];for(let o of n)i.push(o.evaluate(s));return r.call(s,...i)}}evaluate(e){let t=this._parts.slice();for(let r=t.length-2;r>=0;--r){let n=t[r];if(n&&n.type==="operator"){let s=t[r+1];t.splice(r+1,1);let i=v.evaluate(s,e);t[r]=v.single(n.value,i)}}return v.operatorsOrder.forEach(r=>{for(let n=1;n<t.length-1;)if(r.includes(t[n])){let s=t[n],i=v.evaluate(t[n-1],e),o=v.evaluate(t[n+1],e);t.splice(n,2);let a=v.calculate(s,i,o);t[n-1]=a===0?0:a}else n+=2}),v.evaluate(t[0],e)}};Ct.Parser.prototype[v.symbol]=!0;v.reference=function(e){return function(t){return t&&t[e]!==void 0?t[e]:null}};v.evaluate=function(e,t){return e===null?null:typeof e=="function"?e(t):e[v.symbol]?e.evaluate(t):e};v.single=function(e,t){if(e==="!")return!t;let r=-t;return r===0?0:r};v.calculate=function(e,t,r){if(e==="??")return v.exists(t)?t:r;if(typeof t=="string"||typeof r=="string"){if(e==="+")return t=v.exists(t)?t:"",r=v.exists(r)?r:"",t+r}else switch(e){case"^":return Math.pow(t,r);case"*":return t*r;case"/":return t/r;case"%":return t%r;case"+":return t+r;case"-":return t-r}switch(e){case"<":return t<r;case"<=":return t<=r;case">":return t>r;case">=":return t>=r;case"==":return t===r;case"!=":return t!==r;case"&&":return t&&r;case"||":return t||r}return null};v.exists=function(e){return e!=null}});var ws=p(Es=>{"use strict";var rc=oe(),nc=M(),et={annotations:Symbol("annotations")};Es.error=function(e){if(!this._original||typeof this._original!="object")return this.details[0].message;let t=e?"":"\x1B[31m",r=e?"":"\x1B[41m",n=e?"":"\x1B[0m",s=rc(this._original);for(let a=this.details.length-1;a>=0;--a){let l=a+1,c=this.details[a],f=c.path,u=s;for(let d=0;;++d){let g=f[d];if(nc.isSchema(u)&&(u=u.clone()),d+1<f.length&&typeof u[g]!="string")u=u[g];else{let m=u[et.annotations]||{errors:{},missing:{}};u[et.annotations]=m;let b=g||c.context.key;u[g]!==void 0?(m.errors[b]=m.errors[b]||[],m.errors[b].push(l)):m.missing[b]=l;break}}}let i={key:/_\$key\$_([, \d]+)_\$end\$_"/g,missing:/"_\$miss\$_([^|]+)\|(\d+)_\$end\$_": "__missing__"/g,arrayIndex:/\s*"_\$idx\$_([, \d]+)_\$end\$_",?\n(.*)/g,specials:/"\[(NaN|Symbol.*|-?Infinity|function.*|\(.*)]"/g},o=et.safeStringify(s,2).replace(i.key,(a,l)=>`" ${t}[${l}]${n}`).replace(i.missing,(a,l,c)=>`${r}"${l}"${n}${t} [${c}]: -- missing --${n}`).replace(i.arrayIndex,(a,l,c)=>` ${c} ${t}[${l}]${n}`).replace(i.specials,(a,l)=>l);o=`${o} ${t}`;for(let a=0;a<this.details.length;++a){let l=a+1;o=`${o} [${l}] ${this.details[a].message}`}return o=o+n,o};et.safeStringify=function(e,t){return JSON.stringify(e,et.serializer(),t)};et.serializer=function(){let e=[],t=[],r=(n,s)=>t[0]===s?"[Circular ~]":"[Circular ~."+e.slice(0,t.indexOf(s)).join(".")+"]";return function(n,s){if(t.length>0){let i=t.indexOf(this);~i?(t.length=i+1,e.length=i+1,e[i]=n):(t.push(this),e.push(n)),~t.indexOf(s)&&(s=r.call(this,n,s))}else t.push(s);if(s){let i=s[et.annotations];if(i){if(Array.isArray(s)){let o=[];for(let a=0;a<s.length;++a)i.errors[a]&&o.push(`_$idx$_${i.errors[a].sort().join(", ")}_$end$_`),o.push(s[a]);s=o}else{for(let o in i.errors)s[`${o}_$key$_${i.errors[o].sort().join(", ")}_$end$_`]=s[o],s[o]=void 0;for(let o in i.missing)s[`_$miss$_${o}|${i.missing[o]}_$end$_`]="__missing__"}return s}}return s===1/0||s===-1/0||Number.isNaN(s)||typeof s=="function"||typeof s=="symbol"?"["+s.toString()+"]":s}}});var qe=p(G=>{"use strict";var sc=ws(),ic=M(),oc=Ke();G.Report=class{constructor(e,t,r,n,s,i,o){if(this.code=e,this.flags=n,this.messages=s,this.path=i.path,this.prefs=o,this.state=i,this.value=t,this.message=null,this.template=null,this.local=r||{},this.local.label=G.label(this.flags,this.state,this.prefs,this.messages),this.value!==void 0&&!this.local.hasOwnProperty("value")&&(this.local.value=this.value),this.path.length){let a=this.path[this.path.length-1];typeof a!="object"&&(this.local.key=a)}}_setTemplate(e){if(this.template=e,!this.flags.label&&this.path.length===0){let t=this._template(this.template,"root");t&&(this.local.label=t)}}toString(){if(this.message)return this.message;let e=this.code;if(!this.prefs.errors.render)return this.code;let t=this._template(this.template)||this._template(this.prefs.messages)||this._template(this.messages);return t===void 0?`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(e,t){return G.template(this.value,e,t||this.code,this.state,this.prefs)}};G.path=function(e){let t="";for(let r of e)typeof r!="object"&&(typeof r=="string"?(t&&(t+="."),t+=r):t+=`[${r}]`);return t};G.template=function(e,t,r,n,s){if(!t)return;if(oc.isTemplate(t))return r!=="root"?t:null;let i=s.errors.language;if(ic.isResolvable(i)&&(i=i.resolve(e,n,s)),i&&t[i]){if(t[i][r]!==void 0)return t[i][r];if(t[i]["*"]!==void 0)return t[i]["*"]}return t[r]?t[r]:t["*"]};G.label=function(e,t,r,n){if(!r.errors.label)return"";if(e.label)return e.label;let s=t.path;r.errors.label==="key"&&t.path.length>1&&(s=t.path.slice(-1));let i=G.path(s);return i||G.template(null,r.messages,"root",t,r)||n&&G.template(null,n,"root",t,r)||"value"};G.process=function(e,t,r){if(!e)return null;let{override:n,message:s,details:i}=G.details(e);if(n)return n;if(r.errors.stack)return new G.ValidationError(s,i,t);let o=Error.stackTraceLimit;Error.stackTraceLimit=0;let a=new G.ValidationError(s,i,t);return Error.stackTraceLimit=o,a};G.details=function(e,t={}){let r=[],n=[];for(let s of e){if(s instanceof Error){if(t.override!==!1)return{override:s};let o=s.toString();r.push(o),n.push({message:o,type:"override",context:{error:s}});continue}let i=s.toString();r.push(i),n.push({message:i,path:s.path.filter(o=>typeof o!="object"),type:s.code,context:s.local})}return r.length>1&&(r=[...new Set(r)]),{message:r.join(". "),details:n}};G.ValidationError=class extends Error{constructor(e,t,r){super(e),this._original=r,this.details=t}static isError(e){return e instanceof G.ValidationError}};G.ValidationError.prototype.isJoi=!0;G.ValidationError.prototype.name="ValidationError";G.ValidationError.prototype.annotate=sc.error});var Be=p(_e=>{"use strict";var ye=$(),ac=oe(),lc=Qe(),Nt=M(),vr,be={symbol:Symbol("ref"),defaults:{adjust:null,in:!1,iterables:null,map:null,separator:".",type:"value"}};_e.create=function(e,t={}){ye(typeof e=="string","Invalid reference key:",e),Nt.assertOptions(t,["adjust","ancestor","in","iterables","map","prefix","render","separator"]),ye(!t.prefix||typeof t.prefix=="object","options.prefix must be of type object");let r=Object.assign({},be.defaults,t);delete r.prefix;let n=r.separator,s=be.context(e,n,t.prefix);if(r.type=s.type,e=s.key,r.type==="value")if(s.root&&(ye(!n||e[0]!==n,"Cannot specify relative path with root prefix"),r.ancestor="root",e||(e=null)),n&&n===e)e=null,r.ancestor=0;else if(r.ancestor!==void 0)ye(!n||!e||e[0]!==n,"Cannot combine prefix with ancestor option");else{let[i,o]=be.ancestor(e,n);o&&(e=e.slice(o),e===""&&(e=null)),r.ancestor=i}return r.path=n?e===null?[]:e.split(n):[e],new be.Ref(r)};_e.in=function(e,t={}){return _e.create(e,{...t,in:!0})};_e.isRef=function(e){return e?!!e[Nt.symbols.ref]:!1};be.Ref=class{constructor(e){ye(typeof e=="object","Invalid reference construction"),Nt.assertOptions(e,["adjust","ancestor","in","iterables","map","path","render","separator","type","depth","key","root","display"]),ye([!1,void 0].includes(e.separator)||typeof e.separator=="string"&&e.separator.length===1,"Invalid separator"),ye(!e.adjust||typeof e.adjust=="function","options.adjust must be a function"),ye(!e.map||Array.isArray(e.map),"options.map must be an array"),ye(!e.map||!e.adjust,"Cannot set both map and adjust options"),Object.assign(this,be.defaults,e),ye(this.type==="value"||this.ancestor===void 0,"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,t,r,n,s={}){return ye(!this.in||s.in,"Invalid in() reference usage"),this.type==="global"?this._resolve(r.context,t,s):this.type==="local"?this._resolve(n,t,s):this.ancestor?this.ancestor==="root"?this._resolve(t.ancestors[t.ancestors.length-1],t,s):(ye(this.ancestor<=t.ancestors.length,"Invalid reference exceeds the schema root:",this.display),this._resolve(t.ancestors[this.ancestor-1],t,s)):this._resolve(e,t,s)}_resolve(e,t,r){let n;if(this.type==="value"&&t.mainstay.shadow&&r.shadow!==!1&&(n=t.mainstay.shadow.get(this.absolute(t))),n===void 0&&(n=lc(e,this.path,{iterables:this.iterables,functions:!0})),this.adjust&&(n=this.adjust(n)),this.map){let s=this.map.get(n);s!==void 0&&(n=s)}return t.mainstay&&t.mainstay.tracer.resolve(t,this,n),n}toString(){return this.display}absolute(e){return[...e.path.slice(0,-this.ancestor),...this.path]}clone(){return new be.Ref(this)}describe(){let e={path:this.path};this.type!=="value"&&(e.type=this.type),this.separator!=="."&&(e.separator=this.separator),this.type==="value"&&this.ancestor!==1&&(e.ancestor=this.ancestor),this.map&&(e.map=[...this.map]);for(let t of["adjust","iterables","render"])this[t]!==null&&this[t]!==void 0&&(e[t]=this[t]);return this.in!==!1&&(e.in=!0),{ref:e}}updateDisplay(){let e=this.key!==null?this.key:"";if(this.type!=="value"){this.display=`ref:${this.type}:${e}`;return}if(!this.separator){this.display=`ref:${e}`;return}if(!this.ancestor){this.display=`ref:${this.separator}${e}`;return}if(this.ancestor==="root"){this.display=`ref:root:${e}`;return}if(this.ancestor===1){this.display=`ref:${e||".."}`;return}let t=new Array(this.ancestor+1).fill(this.separator).join("");this.display=`ref:${t}${e||""}`}};be.Ref.prototype[Nt.symbols.ref]=!0;_e.build=function(e){return e=Object.assign({},be.defaults,e),e.type==="value"&&e.ancestor===void 0&&(e.ancestor=1),new be.Ref(e)};be.context=function(e,t,r={}){if(e=e.trim(),r){let n=r.global===void 0?"$":r.global;if(n!==t&&e.startsWith(n))return{key:e.slice(n.length),type:"global"};let s=r.local===void 0?"#":r.local;if(s!==t&&e.startsWith(s))return{key:e.slice(s.length),type:"local"};let i=r.root===void 0?"/":r.root;if(i!==t&&e.startsWith(i))return{key:e.slice(i.length),type:"value",root:!0}}return{key:e,type:"value"}};be.ancestor=function(e,t){if(!t)return[1,0];if(e[0]!==t)return[1,0];if(e[1]!==t)return[0,1];let r=2;for(;e[r]===t;)++r;return[r-1,r]};_e.toSibling=0;_e.toParent=1;_e.Manager=class{constructor(){this.refs=[]}register(e,t){if(e){if(t=t===void 0?_e.toParent:t,Array.isArray(e)){for(let r of e)this.register(r,t);return}if(Nt.isSchema(e)){for(let r of e._refs.refs)r.ancestor-t>=0&&this.refs.push({ancestor:r.ancestor-t,root:r.root});return}_e.isRef(e)&&e.type==="value"&&e.ancestor-t>=0&&this.refs.push({ancestor:e.ancestor-t,root:e.root}),vr=vr||Ke(),vr.isTemplate(e)&&this.register(e.refs(),t)}}get length(){return this.refs.length}clone(){let e=new _e.Manager;return e.refs=ac(this.refs),e}reset(){this.refs=[]}roots(){return this.refs.filter(e=>!e.ancestor).map(e=>e.root)}}});var Ke=p((Cs,Ns)=>{"use strict";var Ft=$(),cc=oe(),uc=_s(),fc=As(),Ss=M(),Os=qe(),Rs=Be(),k={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}};Ns.exports=Cs=k.Template=class{constructor(e,t){if(Ft(typeof e=="string","Template source must be a string"),Ft(!e.includes("\0")&&!e.includes(""),"Template source cannot contain reserved control characters"),this.source=e,this.rendered=e,this._template=null,t){let{functions:r,...n}=t;this._settings=Object.keys(n).length?cc(n):void 0,this._functions=r,this._functions&&(Ft(Object.keys(this._functions).every(s=>typeof s=="string"),"Functions keys must be strings"),Ft(Object.values(this._functions).every(s=>typeof s=="function"),"Functions values must be functions"))}else this._settings=void 0,this._functions=void 0;this._parse()}_parse(){if(!this.source.includes("{"))return;let e=k.encode(this.source),t=k.split(e),r=!1,n=[],s=t.shift();s&&n.push(s);for(let i of t){let o=i[0]!=="{",a=o?"}":"}}",l=i.indexOf(a);if(l===-1||i[1]==="{"){n.push(`{${k.decode(i)}`);continue}let c=i.slice(o?0:1,l),f=c[0]===":";f&&(c=c.slice(1));let u=this._ref(k.decode(c),{raw:o,wrapped:f});n.push(u),typeof u!="string"&&(r=!0);let d=i.slice(l+a.length);d&&n.push(k.decode(d))}if(!r){this.rendered=n.join("");return}this._template=n}static date(e,t){return k.dateFormat[t.dateFormat].call(e)}describe(e={}){if(!this._settings&&e.compact)return this.source;let t={template:this.source};return this._settings&&(t.options=this._settings),this._functions&&(t.functions=this._functions),t}static build(e){return new k.Template(e.template,e.options||e.functions?{...e.options,functions:e.functions}:void 0)}isDynamic(){return!!this._template}static isTemplate(e){return e?!!e[Ss.symbols.template]:!1}refs(){if(!this._template)return;let e=[];for(let t of this._template)typeof t!="string"&&e.push(...t.refs);return e}resolve(e,t,r,n){return this._template&&this._template.length===1?this._part(this._template[0],e,t,r,n,{}):this.render(e,t,r,n)}_part(e,...t){return e.ref?e.ref.resolve(...t):e.formula.evaluate(t)}render(e,t,r,n,s={}){if(!this.isDynamic())return this.rendered;let i=[];for(let o of this._template)if(typeof o=="string")i.push(o);else{let a=this._part(o,e,t,r,n,s),l=k.stringify(a,e,t,r,n,s);if(l!==void 0){let c=o.raw||(s.errors&&s.errors.escapeHtml)===!1?l:uc(l);i.push(k.wrap(c,o.wrapped&&r.errors.wrap.label))}}return i.join("")}_ref(e,{raw:t,wrapped:r}){let n=[],s=o=>{let a=Rs.create(o,this._settings);return n.push(a),l=>{let c=a.resolve(...l);return c!==void 0?c:null}};try{let o=this._functions?{...k.functions,...this._functions}:k.functions;var i=new fc.Parser(e,{reference:s,functions:o,constants:k.constants})}catch(o){throw o.message=`Invalid template variable "${e}" fails due to: ${o.message}`,o}if(i.single){if(i.single.type==="reference"){let o=n[0];return{ref:o,raw:t,refs:n,wrapped:r||o.type==="local"&&o.key==="label"}}return k.stringify(i.single.value)}return{formula:i,raw:t,refs:n}}toString(){return this.source}};k.Template.prototype[Ss.symbols.template]=!0;k.Template.prototype.isImmutable=!0;k.encode=function(e){return e.replace(/\\(\{+)/g,(t,r)=>k.opens.slice(0,r.length)).replace(/\\(\}+)/g,(t,r)=>k.closes.slice(0,r.length))};k.decode=function(e){return e.replace(/\u0000/g,"{").replace(/\u0001/g,"}")};k.split=function(e){let t=[],r="";for(let n=0;n<e.length;++n){let s=e[n];if(s==="{"){let i="";for(;n+1<e.length&&e[n+1]==="{";)i+="{",++n;t.push(r),r=i}else r+=s}return t.push(r),t};k.wrap=function(e,t){return t?t.length===1?`${t}${e}${t}`:`${t[0]}${e}${t[1]}`:e};k.stringify=function(e,t,r,n,s,i={}){let o=typeof e,a=n&&n.errors&&n.errors.wrap||{},l=!1;if(Rs.isRef(e)&&e.render&&(l=e.in,e=e.resolve(t,r,n,s,{in:e.in,...i})),e===null)return"null";if(o==="string")return k.wrap(e,i.arrayItems&&a.string);if(o==="number"||o==="function"||o==="symbol")return e.toString();if(o!=="object")return JSON.stringify(e);if(e instanceof Date)return k.Template.date(e,n);if(e instanceof Map){let f=[];for(let[u,d]of e.entries())f.push(`${u.toString()} -> ${d.toString()}`);e=f}if(!Array.isArray(e))return e.toString();let c=[];for(let f of e)c.push(k.stringify(f,t,r,n,s,{arrayItems:!0,...i}));return k.wrap(c.join(", "),!l&&a.array)};k.constants={true:!0,false:!1,null:null,second:1e3,minute:60*1e3,hour:60*60*1e3,day:24*60*60*1e3};k.functions={if(e,t,r){return e?t:r},length(e){return typeof e=="string"?e.length:!e||typeof e!="object"?null:Array.isArray(e)?e.length:Object.keys(e).length},msg(e){let[t,r,n,s,i]=this,o=i.messages;if(!o)return"";let a=Os.template(t,o[0],e,r,n)||Os.template(t,o[1],e,r,n);return a?a.render(t,r,n,s,i):""},number(e){return typeof e=="number"?e:typeof e=="string"?parseFloat(e):typeof e=="boolean"?e?1:0:e instanceof Date?e.getTime():null}}});var dt=p(vt=>{"use strict";var tt=$(),vs=oe(),de=Ke();vt.compile=function(e,t){if(typeof e=="string")return tt(!t,"Cannot set single message string"),new de(e);if(de.isTemplate(e))return tt(!t,"Cannot set single message template"),e;tt(typeof e=="object"&&!Array.isArray(e),"Invalid message options"),t=t?vs(t):{};for(let r in e){let n=e[r];if(r==="root"||de.isTemplate(n)){t[r]=n;continue}if(typeof n=="string"){t[r]=new de(n);continue}tt(typeof n=="object"&&!Array.isArray(n),"Invalid message for",r);let s=r;t[s]=t[s]||{};for(r in n){let i=n[r];if(r==="root"||de.isTemplate(i)){t[s][r]=i;continue}tt(typeof i=="string","Invalid message for",r,"in",s),t[s][r]=new de(i)}}return t};vt.decompile=function(e){let t={};for(let r in e){let n=e[r];if(r==="root"){t.root=n;continue}if(de.isTemplate(n)){t[r]=n.describe({compact:!0});continue}let s=r;t[s]={};for(r in n){let i=n[r];if(r==="root"){t[s].root=i;continue}t[s][r]=i.describe({compact:!0})}}return t};vt.merge=function(e,t){if(!e)return vt.compile(t);if(!t)return e;if(typeof t=="string")return new de(t);if(de.isTemplate(t))return t;let r=vs(e);for(let n in t){let s=t[n];if(n==="root"||de.isTemplate(s)){r[n]=s;continue}if(typeof s=="string"){r[n]=new de(s);continue}tt(typeof s=="object"&&!Array.isArray(s),"Invalid message for",n);let i=n;r[i]=r[i]||{};for(n in s){let o=s[n];if(n==="root"||de.isTemplate(o)){r[i][n]=o;continue}tt(typeof o=="string","Invalid message for",n,"in",i),r[i][n]=new de(o)}}return r}});var M=p(P=>{"use strict";var Ut=$(),dc=Sr(),hc=ys(),Ir,Tr,mc={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)?)?)?)?$/};P.version=hc.version;P.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};P.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")};P.assertOptions=function(e,t,r="Options"){Ut(e&&typeof e=="object"&&!Array.isArray(e),"Options must be of type object");let n=Object.keys(e).filter(s=>!t.includes(s));Ut(n.length===0,`${r} contain unknown keys: ${n}`)};P.checkPreferences=function(e){Tr=Tr||Bt();let t=Tr.preferences.validate(e);if(t.error)throw new dc([t.error.details[0].message])};P.compare=function(e,t,r){switch(r){case"=":return e===t;case">":return e>t;case"<":return e<t;case">=":return e>=t;case"<=":return e<=t}};P.default=function(e,t){return e===void 0?t:e};P.isIsoDate=function(e){return mc.isoDate.test(e)};P.isNumber=function(e){return typeof e=="number"&&!isNaN(e)};P.isResolvable=function(e){return e?e[P.symbols.ref]||e[P.symbols.template]:!1};P.isSchema=function(e,t={}){let r=e&&e[P.symbols.any];return r?(Ut(t.legacy||r.version===P.version,"Cannot mix different versions of joi schemas"),!0):!1};P.isValues=function(e){return e[P.symbols.values]};P.limit=function(e){return Number.isSafeInteger(e)&&e>=0};P.preferences=function(e,t){Ir=Ir||dt(),e=e||{},t=t||{};let r=Object.assign({},e,t);return t.errors&&e.errors&&(r.errors=Object.assign({},e.errors,t.errors),r.errors.wrap=Object.assign({},e.errors.wrap,t.errors.wrap)),t.messages&&(r.messages=Ir.compile(t.messages,e.messages)),delete r[P.symbols.prefs],r};P.tryWithPath=function(e,t,r={}){try{return e()}catch(n){throw n.path!==void 0?n.path=t+"."+n.path:n.path=t,r.append&&(n.message=`${n.message} (${n.path})`),n}};P.validateArg=function(e,t,{assert:r,message:n}){if(P.isSchema(r)){let s=r.validate(e);return s.error?s.error.message:void 0}else if(!r(e))return t?`${t} ${n}`:n};P.verifyFlat=function(e,t){for(let r of e)Ut(!Array.isArray(r),"Method no longer accepts array arguments:",t)}});var xr=p(Is=>{"use strict";var pc=$(),gc=oe(),yc=M(),ht={max:1e3,supported:new Set(["undefined","boolean","number","string"])};Is.provider={provision(e){return new ht.Cache(e)}};ht.Cache=class{constructor(e={}){yc.assertOptions(e,["max"]),pc(e.max===void 0||e.max&&e.max>0&&isFinite(e.max),"Invalid max cache size"),this._max=e.max||ht.max,this._map=new Map,this._list=new ht.List}get length(){return this._map.size}set(e,t){if(e!==null&&!ht.supported.has(typeof e))return;let r=this._map.get(e);if(r){r.value=t,this._list.first(r);return}r=this._list.unshift({key:e,value:t}),this._map.set(e,r),this._compact()}get(e){let t=this._map.get(e);if(t)return this._list.first(t),gc(t.value)}_compact(){if(this._map.size>this._max){let e=this._list.pop();this._map.delete(e.key)}}};ht.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){let{next:t,prev:r}=e;return t.prev=r,r&&(r.next=t),e===this.tail&&(this.tail=t),e.prev=null,e.next=null,e}}});var rt=p(je=>{"use strict";var F=$(),he=M(),mt=Be(),Ae={};je.schema=function(e,t,r={}){he.assertOptions(r,["appendPath","override"]);try{return Ae.schema(e,t,r)}catch(n){throw r.appendPath&&n.path!==void 0&&(n.message=`${n.message} (${n.path})`),n}};Ae.schema=function(e,t,r){F(t!==void 0,"Invalid undefined schema"),Array.isArray(t)&&(F(t.length,"Invalid empty array schema"),t.length===1&&(t=t[0]));let n=(s,...i)=>r.override!==!1?s.valid(e.override,...i):s.valid(...i);if(Ae.simple(t))return n(e,t);if(typeof t=="function")return e.custom(t);if(F(typeof t=="object","Invalid schema content:",typeof t),he.isResolvable(t))return n(e,t);if(he.isSchema(t))return t;if(Array.isArray(t)){for(let s of t)if(!Ae.simple(s))return e.alternatives().try(...t);return n(e,...t)}return t instanceof RegExp?e.string().regex(t):t instanceof Date?n(e.date(),t):(F(Object.getPrototypeOf(t)===Object.getPrototypeOf({}),"Schema can only contain plain objects"),e.object().keys(t))};je.ref=function(e,t){return mt.isRef(e)?e:mt.create(e,t)};je.compile=function(e,t,r={}){he.assertOptions(r,["legacy"]);let n=t&&t[he.symbols.any];if(n)return F(r.legacy||n.version===he.version,"Cannot mix different versions of joi schemas:",n.version,he.version),t;if(typeof t!="object"||!r.legacy)return je.schema(e,t,{appendPath:!0});let s=Ae.walk(t);return s?s.compile(s.root,t):je.schema(e,t,{appendPath:!0})};Ae.walk=function(e){if(typeof e!="object")return null;if(Array.isArray(e)){for(let r of e){let n=Ae.walk(r);if(n)return n}return null}let t=e[he.symbols.any];if(t)return{root:e[t.root],compile:t.compile};F(Object.getPrototypeOf(e)===Object.getPrototypeOf({}),"Schema can only contain plain objects");for(let r in e){let n=Ae.walk(e[r]);if(n)return n}return null};Ae.simple=function(e){return e===null||["boolean","string","number"].includes(typeof e)};je.when=function(e,t,r){if(r===void 0&&(F(t&&typeof t=="object","Missing options"),r=t,t=mt.create(".")),Array.isArray(r)&&(r={switch:r}),he.assertOptions(r,["is","not","then","otherwise","switch","break"]),he.isSchema(t))return F(r.is===void 0,'"is" can not be used with a schema condition'),F(r.not===void 0,'"not" can not be used with a schema condition'),F(r.switch===void 0,'"switch" can not be used with a schema condition'),Ae.condition(e,{is:t,then:r.then,otherwise:r.otherwise,break:r.break});if(F(mt.isRef(t)||typeof t=="string","Invalid condition:",t),F(r.not===void 0||r.is===void 0,'Cannot combine "is" with "not"'),r.switch===void 0){let s=r;r.not!==void 0&&(s={is:r.not,then:r.otherwise,otherwise:r.then,break:r.break});let i=s.is!==void 0?e.$_compile(s.is):e.$_root.invalid(null,!1,0,"").required();return F(s.then!==void 0||s.otherwise!==void 0,'options must have at least one of "then", "otherwise", or "switch"'),F(s.break===void 0||s.then===void 0||s.otherwise===void 0,"Cannot specify then, otherwise, and break all together"),r.is!==void 0&&!mt.isRef(r.is)&&!he.isSchema(r.is)&&(i=i.required()),Ae.condition(e,{ref:je.ref(t),is:i,then:s.then,otherwise:s.otherwise,break:s.break})}F(Array.isArray(r.switch),'"switch" must be an array'),F(r.is===void 0,'Cannot combine "switch" with "is"'),F(r.not===void 0,'Cannot combine "switch" with "not"'),F(r.then===void 0,'Cannot combine "switch" with "then"');let n={ref:je.ref(t),switch:[],break:r.break};for(let s=0;s<r.switch.length;++s){let i=r.switch[s],o=s===r.switch.length-1;he.assertOptions(i,o?["is","then","otherwise"]:["is","then"]),F(i.is!==void 0,'Switch statement missing "is"'),F(i.then!==void 0,'Switch statement missing "then"');let a={is:e.$_compile(i.is),then:e.$_compile(i.then)};if(!mt.isRef(i.is)&&!he.isSchema(i.is)&&(a.is=a.is.required()),o){F(r.otherwise===void 0||i.otherwise===void 0,'Cannot specify "otherwise" inside and outside a "switch"');let l=r.otherwise!==void 0?r.otherwise:i.otherwise;l!==void 0&&(F(n.break===void 0,"Cannot specify both otherwise and break"),a.otherwise=e.$_compile(l))}n.switch.push(a)}return n};Ae.condition=function(e,t){for(let r of["then","otherwise"])t[r]===void 0?delete t[r]:t[r]=e.$_compile(t[r]);return t}});var $r=p(xs=>{"use strict";var ze=$(),bc=oe(),Ts=M(),_c=dt(),Ie={};xs.type=function(e,t){let r=Object.getPrototypeOf(e),n=bc(r),s=e._assign(Object.create(n)),i=Object.assign({},t);delete i.base,n._definition=i;let o=r._definition||{};i.messages=_c.merge(o.messages,i.messages),i.properties=Object.assign({},o.properties,i.properties),s.type=i.type,i.flags=Object.assign({},o.flags,i.flags);let a=Object.assign({},o.terms);if(i.terms)for(let u in i.terms){let d=i.terms[u];ze(s.$_terms[u]===void 0,"Invalid term override for",i.type,u),s.$_terms[u]=d.init,a[u]=d}i.terms=a,i.args||(i.args=o.args),i.prepare=Ie.prepare(i.prepare,o.prepare),i.coerce&&(typeof i.coerce=="function"&&(i.coerce={method:i.coerce}),i.coerce.from&&!Array.isArray(i.coerce.from)&&(i.coerce={method:i.coerce.method,from:[].concat(i.coerce.from)})),i.coerce=Ie.coerce(i.coerce,o.coerce),i.validate=Ie.validate(i.validate,o.validate);let l=Object.assign({},o.rules);if(i.rules)for(let u in i.rules){let d=i.rules[u];ze(typeof d=="object","Invalid rule definition for",i.type,u);let g=d.method;if(g===void 0&&(g=function(){return this.$_addRule(u)}),g&&(ze(!n[u],"Rule conflict in",i.type,u),n[u]=g),ze(!l[u],"Rule conflict in",i.type,u),l[u]=d,d.alias){let m=[].concat(d.alias);for(let b of m)n[b]=d.method}d.args&&(d.argsByName=new Map,d.args=d.args.map(m=>(typeof m=="string"&&(m={name:m}),ze(!d.argsByName.has(m.name),"Duplicated argument name",m.name),Ts.isSchema(m.assert)&&(m.assert=m.assert.strict().label(m.name)),d.argsByName.set(m.name,m),m)))}i.rules=l;let c=Object.assign({},o.modifiers);if(i.modifiers)for(let u in i.modifiers){ze(!n[u],"Rule conflict in",i.type,u);let d=i.modifiers[u];ze(typeof d=="function","Invalid modifier definition for",i.type,u);let g=function(m){return this.rule({[u]:m})};n[u]=g,c[u]=d}if(i.modifiers=c,i.overrides){n._super=r,s.$_super={};for(let u in i.overrides)ze(r[u],"Cannot override missing",u),i.overrides[u][Ts.symbols.parent]=r[u],s.$_super[u]=r[u].bind(s);Object.assign(n,i.overrides)}i.cast=Object.assign({},o.cast,i.cast);let f=Object.assign({},o.manifest,i.manifest);return f.build=Ie.build(i.manifest&&i.manifest.build,o.manifest&&o.manifest.build)