Created
March 10, 2025 17:28
-
-
Save sauntimo/84372c1ebd26606802efba1f6a91bb5f to your computer and use it in GitHub Desktop.
authz-dev
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! For license information please see auth0-authz.extension.2.13.0.js.LICENSE.txt */ | |
"use strict";var __webpack_modules__=[(e,t,r)=>{const s=r(1),n=r(5),a=r(6),{getWebtaskUrl:i}=r(8),o=(e,t)=>{a.info("Starting Authorization Extension - Version:","2.13.0"),a.info(" > WT_URL:",e("WT_URL")),a.info(" > PUBLIC_WT_URL:",e("PUBLIC_WT_URL"));return(0,r(10).default)(e,t)};e.exports=(e,t,r)=>{((e,t,r)=>{setImmediate((()=>{t.x_wt&&t.x_wt.ectx&&t.x_wt.ectx.PUBLIC_WT_URL||n.setValue("PUBLIC_WT_URL",i(t)),s.createServer(o)(e,t,r)}))})(e,t,r)}},(e,t,r)=>{const s=r(2),n=r(3),a=r(4);e.exports.createServer=function(e){return t=a.createServer(e),async function(e,a,p){if(u=function(e){return e.read=e.secrets.EXT_STORAGE_URL?r:t,e.write=e.secrets.EXT_STORAGE_URL?i:a,e;function t(e,t,r){"function"==typeof t&&(r=t,t={}),r(s.preconditionFailed("Storage is not available in this context"))}function r(t,r,a){"function"==typeof r&&(a=r,r={}),n.get(e.secrets.EXT_STORAGE_URL).set(r.headers||{}).query({path:t}).then((e=>404===e.statusCode&&Object.hasOwnProperty.call(r,"defaultValue")?a(null,r.defaultValue):e.statusCode>=400?a(s.create(e.statusCode,e.body&&e.body.message)):a(null,e.body))).catch((e=>a(s.boomify(e,502))))}function a(e,t,r,n){"function"==typeof r&&(n=r,r={}),n(s.preconditionFailed("Storage is not available in this context"))}function i(t,r,a,i){"function"==typeof a&&(i=a,a={}),n.put(e.secrets.EXT_STORAGE_URL).set(a.headers||{}).query({path:t}).send(r).then((e=>e.statusCode>=400?i(s.create(e.statusCode,e.body&&e.body.message)):i(null))).catch((e=>i(s.boomify(e,502))))}}(e),null==r){if(!(r=await t(u)))throw new Error("Server factory did not return a server instance");r.ext("onRequest",(function(e,t){const r=function(e){if(!e.container)return null;const t=e.container.replace(i,"\\$&"),r=e.jtn?e.jtn.replace(i,"\\$&"):"";if(e.url_format===c)return new RegExp("^/api/run/"+t+"/(?:"+r+"/?)?");if(e.url_format===l)return new RegExp("^/"+t+"/(?:"+r+"/?)?");if(e.url_format===o)return new RegExp("^/(?:"+r+"/?)?");throw new Error("Unsupported webtask URL format.")}(e.raw.req.x_wt);return r&&(e.originalUrl=e.path,e.setUrl(`${e.path}${e.url.search}`.replace(r,"/"))),e.headers["x-forwarded-proto"]&&(e.headers["x-forwarded-proto"]=e.headers["x-forwarded-proto"].split(",").shift()),e.webtaskContext=u,t.continue}))}r.listener.emit("request",a,p)};var t,r,u};const i=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;const o=3,l=2,c=1},e=>{e.exports=require("@hapi/[email protected]")},e=>{e.exports=require("[email protected]")},e=>{e.exports=require("[email protected]")},(e,t,r)=>{const s=r(4).config();e.exports=s},(e,t,r)=>{const s=r(7),n=new s.createLogger({format:s.format.json(),transports:[new s.transports.Console({level:"debug",json:!1})],exitOnError:!1});e.exports=n},e=>{e.exports=require("[email protected]")},(e,t,r)=>{const s=r(9);e.exports.getBasePath=function(e){return t=e.originalUrl||"",r=e.path,(n=(n=s.parse(t).pathname||"").replace(r,"").replace(/^\/|\/$/g,"")).startsWith("/")||(n="/"+n),n.endsWith("/")||(n+="/"),n;var t,r,n},e.exports.getBaseUrl=function(e,t){const r=s.parse(e.originalUrl||"").pathname||"";return s.format({protocol:t||"https",host:e.headers.host,pathname:r.replace(e.path,"").replace(/\/$/g,"")})};const n=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;e.exports.getWebtaskUrl=function(e){const t=function(e){if(!e.container)return null;const t=e.container.replace(n,"\\$&"),r=e.jtn?e.jtn.replace(n,"\\$&"):"";if(1===e.url_format)return new RegExp("^/api/run/"+t+"/(?:"+r+"/?)?");if(2===e.url_format)return new RegExp("^/"+t+"/(?:"+r+"/?)?");if(3===e.url_format)return new RegExp("^/(?:"+r+"/?)?");throw new Error("Unsupported webtask URL format.")}(e.x_wt),r=e.url,a=e.url.replace(t,"/"),i=s.parse(a||"").pathname,o=s.parse(r||"").pathname||"";var l=s.format({protocol:"https",host:e.headers.host,pathname:o.replace(i,"").replace(/\/$/g,"")});if(e.x_wt){const t=".it.auth0.com/api/run/"+e.x_wt.container+"/",r=function(e,t){if(!e)return null;const r=e.indexOf("sandbox8")>=0?"8":"";return"https://"+t+"."+(e.split(".it.auth0.com")[0].split("-")[1]||"us")+r+".webtask.io/"}(l,e.x_wt.container);l.indexOf(t)>=0&&(l=l.replace("https://"+e.headers.host+"/api/run/"+e.x_wt.container+"/",r))}return l}},e=>{e.exports=require("url")},(e,t,r)=>{r.r(t),r.d(t,{default:()=>h});var s=r(11),n=r(5),a=r.n(n),i=r(12),o=r(17),l=r(18),c=r(22),u=r(6),p=r.n(u);const h=(e,t,r)=>{null==r&&(r=e=>{if(e){p().error("Hapi initialization failed.");const{stack:t,details:r,message:s}=e;p().error({stack:t,details:r,message:s}),p().error(e)}else p().info("Hapi initialization completed.")}),a().setProvider((t=>e(t)||{WARN_DB_SIZE:409600,MAX_MULTISELECT_USERS:5,MULTISELECT_DEBOUNCE_MS:250,PER_PAGE:10,NODE_ENV:"production",CLIENT_VERSION:"2.13.0"}[t]));const n=a()("PUBLIC_WT_URL"),u="auth0c.com"===new s.URL(n).hostname.split(".").slice(-2).join(".");return a().setValue("IS_LAYER0_TEST_SPACE",u),(0,o.init)(new i.default({provider:(0,l.createProvider)(t)})),(0,c.default)(r)}},e=>{e.exports=require("node:url")},(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var s=r(13),n=r.n(s),a=r(4),i=r(5),o=r.n(i),l=r(14).Buffer;const c=(e=[],t="Record with that identifier is already exists.",r)=>0===e.length||r&&1===e.length&&e[0]._id===r?null:Promise.reject(new a.ValidationError(t));class u{constructor(e={}){if(!e.provider)throw new a.ArgumentError("The 'provider' has to be set when initializing the database.");this.provider=e.provider}getStatus(){return o()("STORAGE_TYPE")&&"webtask"!==o()("STORAGE_TYPE")?Promise.resolve({size:null,type:o()("STORAGE_TYPE")}):this.provider.storageContext.read().then((e=>({size:l.byteLength(JSON.stringify(e),"utf8"),type:"default"})))}canChange(e,t,r){return this.provider.getAll(e).then((e=>n().filter(e,(e=>e[t]&&n().includes(e[t],r))))).then((r=>{if(r.length){const s=r.map((e=>e.name)).join(", "),n=`Unable to touch ${t} while used in ${e}: ${s}`;return Promise.reject(new a.ValidationError(n))}return Promise.resolve()}))}getApiKey(){return this.provider.getAll("configuration").then((e=>e.length?e[0].apikey:null))}updateApiKey(e){return this.provider.getAll("configuration").then((e=>e.length?e[0]:{})).then((t=>this.provider.update("configuration","v1",{...t,apikey:e},!0)))}getConfiguration(){return this.provider.getAll("configuration").then((e=>e.length?e[0]:null))}updateConfiguration(e){return this.provider.update("configuration","v1",e,!0)}getRules(){return this.provider.getAll("rules")}createRule(e){return this.provider.create("rules",e)}getPermissions(){return this.provider.getAll("permissions")}getPermission(e){return this.provider.get("permissions",e)}createPermission(e){return this.getPermissions().then((t=>c(t.filter((t=>t.name.toLowerCase()===e.name.toLowerCase()&&t.applicationId===e.applicationId)),`Permission with name "${e.name}" already exists for this application`))).then((()=>this.provider.create("permissions",e)))}updatePermission(e,t){return this.getPermissions().then((r=>c(r.filter((e=>e.name.toLowerCase()===t.name.toLowerCase()&&e.applicationId===t.applicationId)),`Permission with name "${t.name}" already exists for this application`,e))).then((()=>this.canChange("roles","permissions",e))).then((()=>this.canChange("groups","permissions",e))).then((()=>this.provider.update("permissions",e,t)))}deletePermission(e){return this.canChange("roles","permissions",e).then((()=>this.provider.delete("permissions",e)))}getRoles(){return this.provider.getAll("roles")}getRole(e){return this.provider.get("roles",e)}createRole(e){return this.getRoles().then((t=>c(t.filter((t=>t.name.toLowerCase()===e.name.toLowerCase()&&t.applicationId===e.applicationId)),`Role with name "${e.name}" already exists for this application`))).then((()=>this.provider.create("roles",e)))}updateRole(e,t){return this.getRoles().then((r=>c(r.filter((e=>e.name.toLowerCase()===t.name.toLowerCase()&&e.applicationId===t.applicationId)),`Role with name "${t.name}" already exists for this application`,e))).then((()=>this.provider.update("roles",e,t)))}deleteRole(e){return this.canChange("groups","roles",e).then((()=>this.provider.delete("roles",e)))}getGroups(){return this.provider.getAll("groups")}getGroup(e){return this.provider.get("groups",e)}createGroup(e){return this.getGroups().then((t=>c(t.filter((t=>t.name.toLowerCase()===e.name.toLowerCase())),`Group with name "${e.name}" already exists`))).then((()=>this.provider.create("groups",e)))}updateGroup(e,t){return this.getGroups().then((r=>c(r.filter((e=>e.name.toLowerCase()===t.name.toLowerCase())),`Group with name "${t.name}" already exists`,e))).then((()=>this.provider.update("groups",e,t)))}deleteGroup(e){return this.canChange("groups","nested",e).then((()=>this.provider.delete("groups",e)))}getApplications(){return this.provider.getAll("applications")}getApplication(e){return this.provider.get("applications",e)}updateApplication(e,t){return this.provider.update("applications",e,t,!0)}}},e=>{e.exports=require("[email protected]")},(e,t,r)=>{var s=r(15),n=r(16),a="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=l,t.SlowBuffer=function(e){+e!=e&&(e=0);return l.alloc(+e)},t.INSPECT_MAX_BYTES=50;var i=2147483647;function o(e){if(e>i)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,l.prototype),t}function l(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return p(e)}return c(e,t,r)}function c(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!l.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|m(e,t),s=o(r),n=s.write(e,t);n!==r&&(s=s.slice(0,n));return s}(e,t);if(ArrayBuffer.isView(e))return function(e){if(G(e,Uint8Array)){var t=new Uint8Array(e);return d(t.buffer,t.byteOffset,t.byteLength)}return h(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(G(e,ArrayBuffer)||e&&G(e.buffer,ArrayBuffer))return d(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(G(e,SharedArrayBuffer)||e&&G(e.buffer,SharedArrayBuffer)))return d(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var s=e.valueOf&&e.valueOf();if(null!=s&&s!==e)return l.from(s,t,r);var n=function(e){if(l.isBuffer(e)){var t=0|f(e.length),r=o(t);return 0===r.length||e.copy(r,0,0,t),r}if(void 0!==e.length)return"number"!=typeof e.length||F(e.length)?o(0):h(e);if("Buffer"===e.type&&Array.isArray(e.data))return h(e.data)}(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return l.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function p(e){return u(e),o(e<0?0:0|f(e))}function h(e){for(var t=e.length<0?0:0|f(e.length),r=o(t),s=0;s<t;s+=1)r[s]=255&e[s];return r}function d(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var s;return s=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(s,l.prototype),s}function f(e){if(e>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|e}function m(e,t){if(l.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||G(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,s=arguments.length>2&&!0===arguments[2];if(!s&&0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return P(e).length;default:if(n)return s?-1:U(e).length;t=(""+t).toLowerCase(),n=!0}}function g(e,t,r){var s=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return T(this,t,r);case"utf8":case"utf-8":return $(this,t,r);case"ascii":return O(this,t,r);case"latin1":case"binary":return I(this,t,r);case"base64":return S(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,r);default:if(s)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),s=!0}}function y(e,t,r){var s=e[t];e[t]=e[r],e[r]=s}function b(e,t,r,s,n){if(0===e.length)return-1;if("string"==typeof r?(s=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),F(r=+r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=l.from(t,s)),l.isBuffer(t))return 0===t.length?-1:v(e,t,r,s,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,s,n);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,s,n){var a,i=1,o=e.length,l=t.length;if(void 0!==s&&("ucs2"===(s=String(s).toLowerCase())||"ucs-2"===s||"utf16le"===s||"utf-16le"===s)){if(e.length<2||t.length<2)return-1;i=2,o/=2,l/=2,r/=2}function c(e,t){return 1===i?e[t]:e.readUInt16BE(t*i)}if(n){var u=-1;for(a=r;a<o;a++)if(c(e,a)===c(t,-1===u?0:a-u)){if(-1===u&&(u=a),a-u+1===l)return u*i}else-1!==u&&(a-=a-u),u=-1}else for(r+l>o&&(r=o-l),a=r;a>=0;a--){for(var p=!0,h=0;h<l;h++)if(c(e,a+h)!==c(t,h)){p=!1;break}if(p)return a}return-1}function _(e,t,r,s){r=Number(r)||0;var n=e.length-r;s?(s=Number(s))>n&&(s=n):s=n;var a=t.length;s>a/2&&(s=a/2);for(var i=0;i<s;++i){var o=parseInt(t.substr(2*i,2),16);if(F(o))return i;e[r+i]=o}return i}function w(e,t,r,s){return B(U(t,e.length-r),e,r,s)}function A(e,t,r,s){return B(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,s)}function E(e,t,r,s){return B(P(t),e,r,s)}function R(e,t,r,s){return B(function(e,t){for(var r,s,n,a=[],i=0;i<e.length&&!((t-=2)<0);++i)s=(r=e.charCodeAt(i))>>8,n=r%256,a.push(n),a.push(s);return a}(t,e.length-r),e,r,s)}function S(e,t,r){return 0===t&&r===e.length?s.fromByteArray(e):s.fromByteArray(e.slice(t,r))}function $(e,t,r){r=Math.min(e.length,r);for(var s=[],n=t;n<r;){var a,i,o,l,c=e[n],u=null,p=c>239?4:c>223?3:c>191?2:1;if(n+p<=r)switch(p){case 1:c<128&&(u=c);break;case 2:128==(192&(a=e[n+1]))&&(l=(31&c)<<6|63&a)>127&&(u=l);break;case 3:a=e[n+1],i=e[n+2],128==(192&a)&&128==(192&i)&&(l=(15&c)<<12|(63&a)<<6|63&i)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:a=e[n+1],i=e[n+2],o=e[n+3],128==(192&a)&&128==(192&i)&&128==(192&o)&&(l=(15&c)<<18|(63&a)<<12|(63&i)<<6|63&o)>65535&&l<1114112&&(u=l)}null===u?(u=65533,p=1):u>65535&&(u-=65536,s.push(u>>>10&1023|55296),u=56320|1023&u),s.push(u),n+=p}return function(e){var t=e.length;if(t<=x)return String.fromCharCode.apply(String,e);var r="",s=0;for(;s<t;)r+=String.fromCharCode.apply(String,e.slice(s,s+=x));return r}(s)}t.kMaxLength=i,l.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),l.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}}),l.poolSize=8192,l.from=function(e,t,r){return c(e,t,r)},Object.setPrototypeOf(l.prototype,Uint8Array.prototype),Object.setPrototypeOf(l,Uint8Array),l.alloc=function(e,t,r){return function(e,t,r){return u(e),e<=0?o(e):void 0!==t?"string"==typeof r?o(e).fill(t,r):o(e).fill(t):o(e)}(e,t,r)},l.allocUnsafe=function(e){return p(e)},l.allocUnsafeSlow=function(e){return p(e)},l.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==l.prototype},l.compare=function(e,t){if(G(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),G(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(e)||!l.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,s=t.length,n=0,a=Math.min(r,s);n<a;++n)if(e[n]!==t[n]){r=e[n],s=t[n];break}return r<s?-1:s<r?1:0},l.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},l.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return l.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var s=l.allocUnsafe(t),n=0;for(r=0;r<e.length;++r){var a=e[r];if(G(a,Uint8Array))n+a.length>s.length?l.from(a).copy(s,n):Uint8Array.prototype.set.call(s,a,n);else{if(!l.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(s,n)}n+=a.length}return s},l.byteLength=m,l.prototype._isBuffer=!0,l.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},l.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},l.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},l.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?$(this,0,e):g.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(e){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===l.compare(this,e)},l.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},a&&(l.prototype[a]=l.prototype.inspect),l.prototype.compare=function(e,t,r,s,n){if(G(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===s&&(s=0),void 0===n&&(n=this.length),t<0||r>e.length||s<0||n>this.length)throw new RangeError("out of range index");if(s>=n&&t>=r)return 0;if(s>=n)return-1;if(t>=r)return 1;if(this===e)return 0;for(var a=(n>>>=0)-(s>>>=0),i=(r>>>=0)-(t>>>=0),o=Math.min(a,i),c=this.slice(s,n),u=e.slice(t,r),p=0;p<o;++p)if(c[p]!==u[p]){a=c[p],i=u[p];break}return a<i?-1:i<a?1:0},l.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},l.prototype.indexOf=function(e,t,r){return b(this,e,t,r,!0)},l.prototype.lastIndexOf=function(e,t,r){return b(this,e,t,r,!1)},l.prototype.write=function(e,t,r,s){if(void 0===t)s="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)s=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===s&&(s="utf8")):(s=r,r=void 0)}var n=this.length-t;if((void 0===r||r>n)&&(r=n),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");for(var a=!1;;)switch(s){case"hex":return _(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":case"latin1":case"binary":return A(this,e,t,r);case"base64":return E(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),a=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var x=4096;function O(e,t,r){var s="";r=Math.min(e.length,r);for(var n=t;n<r;++n)s+=String.fromCharCode(127&e[n]);return s}function I(e,t,r){var s="";r=Math.min(e.length,r);for(var n=t;n<r;++n)s+=String.fromCharCode(e[n]);return s}function T(e,t,r){var s=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>s)&&(r=s);for(var n="",a=t;a<r;++a)n+=q[e[a]];return n}function C(e,t,r){for(var s=e.slice(t,r),n="",a=0;a<s.length-1;a+=2)n+=String.fromCharCode(s[a]+256*s[a+1]);return n}function N(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function k(e,t,r,s,n,a){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<a)throw new RangeError('"value" argument is out of bounds');if(r+s>e.length)throw new RangeError("Index out of range")}function j(e,t,r,s,n,a){if(r+s>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(e,t,r,s,a){return t=+t,r>>>=0,a||j(e,0,r,4),n.write(e,t,r,s,23,4),r+4}function M(e,t,r,s,a){return t=+t,r>>>=0,a||j(e,0,r,8),n.write(e,t,r,s,52,8),r+8}l.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var s=this.subarray(e,t);return Object.setPrototypeOf(s,l.prototype),s},l.prototype.readUintLE=l.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||N(e,t,this.length);for(var s=this[e],n=1,a=0;++a<t&&(n*=256);)s+=this[e+a]*n;return s},l.prototype.readUintBE=l.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||N(e,t,this.length);for(var s=this[e+--t],n=1;t>0&&(n*=256);)s+=this[e+--t]*n;return s},l.prototype.readUint8=l.prototype.readUInt8=function(e,t){return e>>>=0,t||N(e,1,this.length),this[e]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(e,t){return e>>>=0,t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(e,t){return e>>>=0,t||N(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},l.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||N(e,t,this.length);for(var s=this[e],n=1,a=0;++a<t&&(n*=256);)s+=this[e+a]*n;return s>=(n*=128)&&(s-=Math.pow(2,8*t)),s},l.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||N(e,t,this.length);for(var s=t,n=1,a=this[e+--s];s>0&&(n*=256);)a+=this[e+--s]*n;return a>=(n*=128)&&(a-=Math.pow(2,8*t)),a},l.prototype.readInt8=function(e,t){return e>>>=0,t||N(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.prototype.readInt16LE=function(e,t){e>>>=0,t||N(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt16BE=function(e,t){e>>>=0,t||N(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt32LE=function(e,t){return e>>>=0,t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},l.prototype.readInt32BE=function(e,t){return e>>>=0,t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},l.prototype.readFloatLE=function(e,t){return e>>>=0,t||N(e,4,this.length),n.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return e>>>=0,t||N(e,4,this.length),n.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return e>>>=0,t||N(e,8,this.length),n.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return e>>>=0,t||N(e,8,this.length),n.read(this,e,!1,52,8)},l.prototype.writeUintLE=l.prototype.writeUIntLE=function(e,t,r,s){(e=+e,t>>>=0,r>>>=0,s)||k(this,e,t,r,Math.pow(2,8*r)-1,0);var n=1,a=0;for(this[t]=255&e;++a<r&&(n*=256);)this[t+a]=e/n&255;return t+r},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(e,t,r,s){(e=+e,t>>>=0,r>>>=0,s)||k(this,e,t,r,Math.pow(2,8*r)-1,0);var n=r-1,a=1;for(this[t+n]=255&e;--n>=0&&(a*=256);)this[t+n]=e/a&255;return t+r},l.prototype.writeUint8=l.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,1,255,0),this[t]=255&e,t+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},l.prototype.writeIntLE=function(e,t,r,s){if(e=+e,t>>>=0,!s){var n=Math.pow(2,8*r-1);k(this,e,t,r,n-1,-n)}var a=0,i=1,o=0;for(this[t]=255&e;++a<r&&(i*=256);)e<0&&0===o&&0!==this[t+a-1]&&(o=1),this[t+a]=(e/i>>0)-o&255;return t+r},l.prototype.writeIntBE=function(e,t,r,s){if(e=+e,t>>>=0,!s){var n=Math.pow(2,8*r-1);k(this,e,t,r,n-1,-n)}var a=r-1,i=1,o=0;for(this[t+a]=255&e;--a>=0&&(i*=256);)e<0&&0===o&&0!==this[t+a+1]&&(o=1),this[t+a]=(e/i>>0)-o&255;return t+r},l.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},l.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},l.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},l.prototype.writeFloatLE=function(e,t,r){return L(this,e,t,!0,r)},l.prototype.writeFloatBE=function(e,t,r){return L(this,e,t,!1,r)},l.prototype.writeDoubleLE=function(e,t,r){return M(this,e,t,!0,r)},l.prototype.writeDoubleBE=function(e,t,r){return M(this,e,t,!1,r)},l.prototype.copy=function(e,t,r,s){if(!l.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),s||0===s||(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s<r&&(s=r),s===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t<s-r&&(s=e.length-t+r);var n=s-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,s):Uint8Array.prototype.set.call(e,this.subarray(r,s),t),n},l.prototype.fill=function(e,t,r,s){if("string"==typeof e){if("string"==typeof t?(s=t,t=0,r=this.length):"string"==typeof r&&(s=r,r=this.length),void 0!==s&&"string"!=typeof s)throw new TypeError("encoding must be a string");if("string"==typeof s&&!l.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(1===e.length){var n=e.charCodeAt(0);("utf8"===s&&n<128||"latin1"===s)&&(e=n)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var a;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(a=t;a<r;++a)this[a]=e;else{var i=l.isBuffer(e)?e:l.from(e,s),o=i.length;if(0===o)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(a=0;a<r-t;++a)this[a+t]=i[a%o]}return this};var D=/[^+/0-9A-Za-z-_]/g;function U(e,t){var r;t=t||1/0;for(var s=e.length,n=null,a=[],i=0;i<s;++i){if((r=e.charCodeAt(i))>55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(i+1===s){(t-=3)>-1&&a.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&a.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function P(e){return s.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(D,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function B(e,t,r,s){for(var n=0;n<s&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}function G(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function F(e){return e!=e}var q=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var s=16*r,n=0;n<16;++n)t[s+n]=e[r]+e[n];return t}()},(e,t)=>{t.byteLength=function(e){var t=o(e),r=t[0],s=t[1];return 3*(r+s)/4-s},t.toByteArray=function(e){var t,r,a=o(e),i=a[0],l=a[1],c=new n(function(e,t,r){return 3*(t+r)/4-r}(0,i,l)),u=0,p=l>0?i-4:i;for(r=0;r<p;r+=4)t=s[e.charCodeAt(r)]<<18|s[e.charCodeAt(r+1)]<<12|s[e.charCodeAt(r+2)]<<6|s[e.charCodeAt(r+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=255&t;2===l&&(t=s[e.charCodeAt(r)]<<2|s[e.charCodeAt(r+1)]>>4,c[u++]=255&t);1===l&&(t=s[e.charCodeAt(r)]<<10|s[e.charCodeAt(r+1)]<<4|s[e.charCodeAt(r+2)]>>2,c[u++]=t>>8&255,c[u++]=255&t);return c},t.fromByteArray=function(e){for(var t,s=e.length,n=s%3,a=[],i=16383,o=0,c=s-n;o<c;o+=i)a.push(l(e,o,o+i>c?c:o+i));1===n?(t=e[s-1],a.push(r[t>>2]+r[t<<4&63]+"==")):2===n&&(t=(e[s-2]<<8)+e[s-1],a.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return a.join("")};for(var r=[],s=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0;i<64;++i)r[i]=a[i],s[a.charCodeAt(i)]=i;function o(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e,t,s){for(var n,a,i=[],o=t;o<s;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),i.push(r[(a=n)>>18&63]+r[a>>12&63]+r[a>>6&63]+r[63&a]);return i.join("")}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63},(e,t)=>{t.read=function(e,t,r,s,n){var a,i,o=8*n-s-1,l=(1<<o)-1,c=l>>1,u=-7,p=r?n-1:0,h=r?-1:1,d=e[t+p];for(p+=h,a=d&(1<<-u)-1,d>>=-u,u+=o;u>0;a=256*a+e[t+p],p+=h,u-=8);for(i=a&(1<<-u)-1,a>>=-u,u+=s;u>0;i=256*i+e[t+p],p+=h,u-=8);if(0===a)a=1-c;else{if(a===l)return i?NaN:1/0*(d?-1:1);i+=Math.pow(2,s),a-=c}return(d?-1:1)*i*Math.pow(2,a-s)},t.write=function(e,t,r,s,n,a){var i,o,l,c=8*a-n-1,u=(1<<c)-1,p=u>>1,h=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=s?0:a-1,f=s?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,i=u):(i=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-i))<1&&(i--,l*=2),(t+=i+p>=1?h/l:h*Math.pow(2,1-p))*l>=2&&(i++,l/=2),i+p>=u?(o=0,i=u):i+p>=1?(o=(t*l-1)*Math.pow(2,n),i+=p):(o=t*Math.pow(2,p-1)*Math.pow(2,n),i=0));n>=8;e[r+d]=255&o,d+=f,o/=256,n-=8);for(i=i<<n|o,c+=n;c>0;e[r+d]=255&i,d+=f,i/=256,c-=8);e[r+d-f]|=128*m}},e=>{let t=null;e.exports.init=e=>{t=e},e.exports.getDb=()=>{if(!t)throw new Error("The database has not been initialized.");return t}},(e,t,r)=>{r.r(t),r.d(t,{createProvider:()=>p});var s=r(19),n=r.n(s),a=r(4),i=r(20),o=r(5),l=r.n(o),c=r(6),u=r.n(c);function p(e){if("s3"===l()("STORAGE_TYPE")){u().info("Initializing the S3 Storage Context.");const e=new i.S3StorageContext({path:l()("S3_PATH"),bucket:l()("S3_BUCKET"),keyId:l()("S3_KEY"),keySecret:l()("S3_SECRET"),defaultData:{}});return new a.BlobRecordProvider(e,{concurrentWrites:!1})}{u().info("Initializing the Webtask Storage Context.");const t=e?new a.WebtaskStorageContext(e,{force:0}):new a.FileStorageContext(n().join(__dirname,"../../data.json"),{mergeWrites:!0});return new a.BlobRecordProvider(t,{concurrentWrites:!1})}}},e=>{e.exports=require("path")},(e,t,r)=>{r.r(t),r.d(t,{S3StorageContext:()=>o});var s=r(21),n=r(4),a=r.n(n);const i=r(6);class o{#e=["AuthorizationHeaderMalformed","BadRequest","PermanentRedirect",301];constructor(e){if(null==e)throw new(a().ArgumentError)("The 'options' object is required when configuring the S3StorageContext.");if(!e.path||0===e.path.length)throw new(a().ArgumentError)("The 'path' property is required when configuring the S3StorageContext.");if(!e.bucket||0===e.bucket.length)throw new(a().ArgumentError)("The 'bucket' property is required when configuring the S3StorageContext.");if(!e.keyId||0===e.keyId.length)throw new(a().ArgumentError)("The 'keyId' property is required when configuring the S3StorageContext.");if(!e.keySecret||0===e.keySecret.length)throw new(a().ArgumentError)("The 'keySecret' property is required when configuring the S3StorageContext.");this.options=e,this.defaultData=e.defaultData||{},this.#t()}async read(){return this.#r((async()=>{const e={Key:this.options.path,Bucket:this.options.bucket};try{const t=await this.s3Client.send(new s.GetObjectCommand(e)),r=await(t?.Body?.transformToString());return r?JSON.parse(r):this.defaultData}catch(e){if("NoSuchKey"===e.Code)return this.defaultData;throw e}}))}async write(e){return this.#r((async()=>{const t={Key:this.options.path,Bucket:this.options.bucket,Body:JSON.stringify(e,null,2),ContentType:"application/json"};await this.s3Client.send(new s.PutObjectCommand(t))}))}async#r(e){try{return await e()}catch(t){i.info("Trying to resolve s3 bucket region...");const r=t.$response?.headers["x-amz-bucket-region"]||null,s=await this.s3Client.config.region();if(-1!==this.#e.indexOf(t.Code)&&r&&r!==s)return i.info(`Resolved following s3 bucket region: ${r}.`),this.#t(r),await e();throw t}}#t(e="us-east-1"){this.s3Client=new s.S3Client({credentials:{accessKeyId:this.options.keyId,secretAccessKey:this.options.keySecret},region:e})}}},e=>{e.exports=require("@aws-sdk/[email protected]")},(e,t,r)=>{r.r(t),r.d(t,{default:()=>_});var s=r(23),n=r.n(s),a=r(24),i=r(95),o=r.n(i),l=r(96),c=r.n(l),u=r(97),p=r.n(u),h=r(98),d=r.n(h),f=r(5),m=r.n(f),g=r(6),y=r.n(g),b=r(138),v=r.n(b);const _=async()=>{const e={plugin:{...r(231).plugin,name:"@hapi/good"},options:{ops:{interval:3e4},reporters:{console:[]}}};e.options.reporters.console.push(new(p())({color:!!m()("LOG_COLOR")})),e.options.reporters.console.push("stdout");const t=new(n().Server)({host:"localhost",port:3e3,routes:{cors:!0}});t.validator(d());const s=[e,{plugin:{...a,name:"inert"}},{plugin:{...o(),name:"blipp"}},{plugin:{...c(),name:"jwt"}}];return await t.register([...s,...v()]),y().debug=(...e)=>{t.log(["debug"],e.join(" "))},y().info=(...e)=>{t.log(["info"],e.join(" "))},y().error=(...e)=>{t.log(["error"],e.join(" "))},t.ext("onPreResponse",((e,r)=>{const s=e.response?.statusCode??e.response?.status;return s>=400&&(e.response.output.statusCode=s,e.response.output.payload={statusCode:s,error:"APIError"===e.response.name?"Bad Request":e.response.name,message:e.response.message}),e.response&&e.response.isBoom&&(t.log(["error"],`Request: ${e.method.toUpperCase()} ${e.path}`),t.log(["error"],`Response: ${JSON.stringify(e.response,null,2)}`)),r.continue})),t}},e=>{e.exports=require("@hapi/[email protected]")},(e,t,r)=>{const s=r(25),n=r(50),a=r(80),i=r(86),o=r(83),l={schema:n.object({etagsCacheMaxSize:n.number().integer().min(0).default(1e3)}).required(),fileMethod:function(e,t={}){return void 0!==t.confine&&!0!==t.confine||(t.confine="."),s.assert(void 0===t.end||+t.start<=+t.end,"options.start must be less than or equal to options.end"),this.response(o.response(e,t,this.request))}};t.plugin={pkg:r(94),once:!0,requirements:{hapi:">=20.0.0"},register(e,t){s.assert(0===Object.keys(t).length,"Inert does not support registration options");const r=n.attempt(e.settings.plugins?.inert??{},l.schema,'Invalid "inert" server options');e.expose("_etags",r.etagsCacheMaxSize>0?new i.Cache({max:r.etagsCacheMaxSize}):null),e.decorate("handler","file",o.handler),e.decorate("handler","directory",a.handler),e.decorate("toolkit","file",l.fileMethod)}}},(e,t,r)=>{t.applyToDefaults=r(26),t.assert=r(27),t.Bench=r(35),t.block=r(36),t.clone=r(30),t.contain=r(38),t.deepEqual=r(39),t.Error=r(28),t.escapeHeaderAttribute=r(41),t.escapeHtml=r(42),t.escapeJson=r(43),t.escapeRegex=r(40),t.flatten=r(44),t.ignore=r(37),t.intersect=r(45),t.isPromise=r(46),t.merge=r(34),t.once=r(47),t.reach=r(31),t.reachTemplate=r(48),t.stringify=r(29),t.wait=r(49)},(e,t,r)=>{const s=r(27),n=r(30),a=r(34),i=r(31),o={};e.exports=function(e,t,r={}){if(s(e&&"object"==typeof e,"Invalid defaults value: must be an object"),s(!t||!0===t||"object"==typeof t,"Invalid source value: must be true, falsy or an object"),s("object"==typeof r,"Invalid options: must be an object"),!t)return null;if(r.shallow)return o.applyToDefaultsWithShallow(e,t,r);const i=n(e);if(!0===t)return i;const l=void 0!==r.nullOverride&&r.nullOverride;return a(i,t,{nullOverride:l,mergeArrays:!1})},o.applyToDefaultsWithShallow=function(e,t,r){const l=r.shallow;s(Array.isArray(l),"Invalid keys");const c=new Map,u=!0===t?null:new Set;for(let r of l){r=Array.isArray(r)?r:r.split(".");const s=i(e,r);s&&"object"==typeof s?c.set(s,u&&i(t,r)||s):u&&u.add(r)}const p=n(e,{},c);if(!u)return p;for(const e of u)o.reachCopy(p,t,e);const h=void 0!==r.nullOverride&&r.nullOverride;return a(p,t,{nullOverride:h,mergeArrays:!1})},o.reachCopy=function(e,t,r){for(const e of r){if(!(e in t))return;const r=t[e];if("object"!=typeof r||null===r)return;t=r}const s=t;let n=e;for(let e=0;e<r.length-1;++e){const t=r[e];"object"!=typeof n[t]&&(n[t]={}),n=n[t]}n[r[r.length-1]]=s}},(e,t,r)=>{const s=r(28);e.exports=function(e,...t){if(!e){if(1===t.length&&t[0]instanceof Error)throw t[0];throw new s(t)}}},(e,t,r)=>{const s=r(29);e.exports=class extends Error{constructor(e){super(e.filter((e=>""!==e)).map((e=>"string"==typeof e?e:e instanceof Error?e.message:s(e))).join(" ")||"Unknown error"),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t.assert)}}},e=>{e.exports=function(...e){try{return JSON.stringify(...e)}catch(e){return"[Cannot display object: "+e.message+"]"}}},(e,t,r)=>{var s=r(14).Buffer;const n=r(31),a=r(32),i=r(33),o={needsProtoHack:new Set([a.set,a.map,a.weakSet,a.weakMap])};e.exports=o.clone=function(e,t={},r=null){if("object"!=typeof e||null===e)return e;let n=o.clone,l=r;if(t.shallow){if(!0!==t.shallow)return o.cloneWithShallow(e,t);n=e=>e}else if(l){const t=l.get(e);if(t)return t}else l=new Map;const c=a.getInternalProto(e);if(c===a.buffer)return s&&s.from(e);if(c===a.date)return new Date(e.getTime());if(c===a.regex)return new RegExp(e);const u=o.base(e,c,t);if(u===e)return e;if(l&&l.set(e,u),c===a.set)for(const r of e)u.add(n(r,t,l));else if(c===a.map)for(const[r,s]of e)u.set(r,n(s,t,l));const p=i.keys(e,t);for(const r of p){if("__proto__"===r)continue;if(c===a.array&&"length"===r){u.length=e.length;continue}const s=Object.getOwnPropertyDescriptor(e,r);s?s.get||s.set?Object.defineProperty(u,r,s):s.enumerable?u[r]=n(e[r],t,l):Object.defineProperty(u,r,{enumerable:!1,writable:!0,configurable:!0,value:n(e[r],t,l)}):Object.defineProperty(u,r,{enumerable:!0,writable:!0,configurable:!0,value:n(e[r],t,l)})}return u},o.cloneWithShallow=function(e,t){const r=t.shallow;(t=Object.assign({},t)).shallow=!1;const s=new Map;for(const t of r){const r=n(e,t);"object"!=typeof r&&"function"!=typeof r||s.set(r,r)}return o.clone(e,t,s)},o.base=function(e,t,r){if(!1===r.prototype)return o.needsProtoHack.has(t)?new t.constructor:t===a.array?[]:{};const s=Object.getPrototypeOf(e);if(s&&s.isImmutable)return e;if(t===a.array){const e=[];return s!==t&&Object.setPrototypeOf(e,s),e}if(o.needsProtoHack.has(t)){const e=new s.constructor;return s!==t&&Object.setPrototypeOf(e,s),e}return Object.create(s)}},(e,t,r)=>{const s=r(27),n={};e.exports=function(e,t,r){if(!1===t||null==t)return e;"string"==typeof(r=r||{})&&(r={separator:r});const a=Array.isArray(t);s(!a||!r.separator,"Separator option is not valid for array-based chain");const i=a?t:t.split(r.separator||".");let o=e;for(let e=0;e<i.length;++e){let a=i[e];const l=r.iterables&&n.iterables(o);if(Array.isArray(o)||"set"===l){const e=Number(a);Number.isInteger(e)&&(a=e<0?o.length+e:e)}if(!o||"function"==typeof o&&!1===r.functions||!l&&void 0===o[a]){s(!r.strict||e+1===i.length,"Missing segment",a,"in reach path ",t),s("object"==typeof o||!0===r.functions||"function"!=typeof o,"Invalid segment",a,"in reach path ",t),o=r.default;break}o=l?"set"===l?[...o][a]:o.get(a):o[a]}return o},n.iterables=function(e){return e instanceof Set?"set":e instanceof Map?"map":void 0}},(e,t,r)=>{var s=r(14).Buffer;const n={};t=e.exports={array:Array.prototype,buffer:s&&s.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(s&&e instanceof s)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}},(e,t)=>{t.keys=function(e,t={}){return!1!==t.symbols?Reflect.ownKeys(e):Object.getOwnPropertyNames(e)}},(e,t,r)=>{var s=r(14).Buffer;const n=r(27),a=r(30),i=r(33),o={};e.exports=o.merge=function(e,t,r){if(n(e&&"object"==typeof e,"Invalid target value: must be an object"),n(null==t||"object"==typeof t,"Invalid source value: must be null, undefined, or an object"),!t)return e;if(r=Object.assign({nullOverride:!0,mergeArrays:!0},r),Array.isArray(t)){n(Array.isArray(e),"Cannot merge array onto an object"),r.mergeArrays||(e.length=0);for(let s=0;s<t.length;++s)e.push(a(t[s],{symbols:r.symbols}));return e}const l=i.keys(t,r);for(let n=0;n<l.length;++n){const i=l[n];if("__proto__"===i||!Object.prototype.propertyIsEnumerable.call(t,i))continue;const c=t[i];if(c&&"object"==typeof c){if(e[i]===c)continue;!e[i]||"object"!=typeof e[i]||Array.isArray(e[i])!==Array.isArray(c)||c instanceof Date||s&&s.isBuffer(c)||c instanceof RegExp?e[i]=a(c,{symbols:r.symbols}):o.merge(e[i],c,r)}else(null!=c||r.nullOverride)&&(e[i]=c)}return e}},e=>{const t={};e.exports=t.Bench=class{constructor(){this.ts=0,this.reset()}reset(){this.ts=t.Bench.now()}elapsed(){return t.Bench.now()-this.ts}static now(){const e=process.hrtime();return 1e3*e[0]+e[1]/1e6}}},(e,t,r)=>{const s=r(37);e.exports=function(){return new Promise(s)}},e=>{e.exports=function(){}},(e,t,r)=>{const s=r(27),n=r(39),a=r(40),i=r(33),o={};e.exports=function(e,t,r={}){return"object"!=typeof t&&(t=[t]),s(!Array.isArray(t)||t.length,"Values array cannot be empty"),"string"==typeof e?o.string(e,t,r):Array.isArray(e)?o.array(e,t,r):(s("object"==typeof e,"Reference must be string or an object"),o.object(e,t,r))},o.array=function(e,t,r){if(Array.isArray(t)||(t=[t]),!e.length)return!1;if(r.only&&r.once&&e.length!==t.length)return!1;let s;const n=new Map;for(const e of t)if(r.deep&&e&&"object"==typeof e){s=s||o.compare(r);let t=!1;for(const[r,a]of n.entries())if(s(r,e)){++a.allowed,t=!0;break}t||n.set(e,{allowed:1,hits:0})}else{const t=n.get(e);t?++t.allowed:n.set(e,{allowed:1,hits:0})}let a=0;for(const t of e){let e;if(r.deep&&t&&"object"==typeof t){s=s||o.compare(r);for(const[r,a]of n.entries())if(s(r,t)){e=a;break}}else e=n.get(t);if(e&&(++e.hits,++a,r.once&&e.hits>e.allowed))return!1}if(r.only&&a!==e.length)return!1;for(const e of n.values())if(e.hits!==e.allowed&&e.hits<e.allowed&&!r.part)return!1;return!!a},o.object=function(e,t,r){s(void 0===r.once,"Cannot use option once with object");const n=i.keys(e,r);if(!n.length)return!1;if(Array.isArray(t))return o.array(n,t,r);const a=Object.getOwnPropertySymbols(t).filter((e=>t.propertyIsEnumerable(e))),l=[...Object.keys(t),...a],c=o.compare(r),u=new Set(l);for(const s of n)if(u.has(s)){if(!c(t[s],e[s]))return!1;u.delete(s)}else if(r.only)return!1;return!u.size||!!r.part&&u.size<l.length},o.string=function(e,t,r){if(""===e)return 1===t.length&&""===t[0]||!r.once&&!t.some((e=>""!==e));const n=new Map,i=[];for(const e of t)if(s("string"==typeof e,"Cannot compare string reference to non-string value"),e){const t=n.get(e);t?++t.allowed:(n.set(e,{allowed:1,hits:0}),i.push(a(e)))}else if(r.once||r.only)return!1;if(!i.length)return!0;const o=new RegExp(`(${i.join("|")})`,"g"),l=e.replace(o,((e,t)=>(++n.get(t).hits,"")));if(r.only&&l)return!1;let c=!1;for(const e of n.values())if(e.hits&&(c=!0),e.hits!==e.allowed){if(e.hits<e.allowed&&!r.part)return!1;if(r.once)return!1}return!!c},o.compare=function(e){if(!e.deep)return o.shallow;const t=void 0!==e.only,r=void 0!==e.part,s={prototype:t?e.only:!!r&&!e.part,part:t?!e.only:!!r&&e.part};return(e,t)=>n(e,t,s)},o.shallow=function(e,t){return e===t}},(e,t,r)=>{var s=r(14).Buffer;const n=r(32),a={mismatched:null};e.exports=function(e,t,r){return r=Object.assign({prototype:!0},r),!!a.isDeepEqual(e,t,r,[])},a.isDeepEqual=function(e,t,r,i){if(e===t)return 0!==e||1/e==1/t;const o=typeof e;if(o!==typeof t)return!1;if(null===e||null===t)return!1;if("function"===o){if(!r.deepFunction||e.toString()!==t.toString())return!1}else if("object"!==o)return e!=e&&t!=t;const l=a.getSharedType(e,t,!!r.prototype);switch(l){case n.buffer:return s&&s.prototype.equals.call(e,t);case n.promise:return e===t;case n.regex:return e.toString()===t.toString();case a.mismatched:return!1}for(let r=i.length-1;r>=0;--r)if(i[r].isSame(e,t))return!0;i.push(new a.SeenEntry(e,t));try{return!!a.isDeepEqualObj(l,e,t,r,i)}finally{i.pop()}},a.getSharedType=function(e,t,r){if(r)return Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?a.mismatched:n.getInternalProto(e);const s=n.getInternalProto(e);return s!==n.getInternalProto(t)?a.mismatched:s},a.valueOf=function(e){const t=e.valueOf;if(void 0===t)return e;try{return t.call(e)}catch(e){return e}},a.hasOwnEnumerableProperty=function(e,t){return Object.prototype.propertyIsEnumerable.call(e,t)},a.isSetSimpleEqual=function(e,t){for(const r of Set.prototype.values.call(e))if(!Set.prototype.has.call(t,r))return!1;return!0},a.isDeepEqualObj=function(e,t,r,s,i){const{isDeepEqual:o,valueOf:l,hasOwnEnumerableProperty:c}=a,{keys:u,getOwnPropertySymbols:p}=Object;if(e===n.array){if(!s.part){if(t.length!==r.length)return!1;for(let e=0;e<t.length;++e)if(!o(t[e],r[e],s,i))return!1;return!0}for(const e of t)for(const t of r)if(o(e,t,s,i))return!0}else if(e===n.set){if(t.size!==r.size)return!1;if(!a.isSetSimpleEqual(t,r)){const e=new Set(Set.prototype.values.call(r));for(const r of Set.prototype.values.call(t)){if(e.delete(r))continue;let t=!1;for(const n of e)if(o(r,n,s,i)){e.delete(n),t=!0;break}if(!t)return!1}}}else if(e===n.map){if(t.size!==r.size)return!1;for(const[e,n]of Map.prototype.entries.call(t)){if(void 0===n&&!Map.prototype.has.call(r,e))return!1;if(!o(n,Map.prototype.get.call(r,e),s,i))return!1}}else if(e===n.error&&(t.name!==r.name||t.message!==r.message))return!1;const h=l(t),d=l(r);if((t!==h||r!==d)&&!o(h,d,s,i))return!1;const f=u(t);if(!s.part&&f.length!==u(r).length&&!s.skip)return!1;let m=0;for(const e of f)if(s.skip&&s.skip.includes(e))void 0===r[e]&&++m;else{if(!c(r,e))return!1;if(!o(t[e],r[e],s,i))return!1}if(!s.part&&f.length-m!==u(r).length)return!1;if(!1!==s.symbols){const e=p(t),n=new Set(p(r));for(const a of e){if(!s.skip||!s.skip.includes(a))if(c(t,a)){if(!c(r,a))return!1;if(!o(t[a],r[a],s,i))return!1}else if(c(r,a))return!1;n.delete(a)}for(const e of n)if(c(r,e))return!1}return!0},a.SeenEntry=class{constructor(e,t){this.obj=e,this.ref=t}isSame(e,t){return this.obj===e&&this.ref===t}}},e=>{e.exports=function(e){return e.replace(/[\^\$\.\*\+\-\?\=\!\:\|\\\/\(\)\[\]\{\}\,]/g,"\\$&")}},(e,t,r)=>{const s=r(27);e.exports=function(e){return s(/^[ \w\!#\$%&'\(\)\*\+,\-\.\/\:;<\=>\?@\[\]\^`\{\|\}~\"\\]*$/.test(e),"Bad attribute value ("+e+")"),e.replace(/\\/g,"\\\\").replace(/\"/g,'\\"')}},e=>{const t={};e.exports=function(e){if(!e)return"";let r="";for(let s=0;s<e.length;++s){const n=e.charCodeAt(s);t.isSafe(n)?r+=e[s]:r+=t.escapeHtmlChar(n)}return r},t.escapeHtmlChar=function(e){const r=t.namedHtml.get(e);if(r)return r;if(e>=256)return"&#"+e+";";return`&#x${e.toString(16).padStart(2,"0")};`},t.isSafe=function(e){return t.safeCharCodes.has(e)},t.namedHtml=new Map([[38,"&"],[60,"<"],[62,">"],[34,"""],[160," "],[162,"¢"],[163,"£"],[164,"¤"],[169,"©"],[174,"®"]]),t.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}()},e=>{const t={};e.exports=function(e){return e?e.replace(/[<>&\u2028\u2029]/g,t.escape):""},t.escape=function(e){return t.replacements.get(e)},t.replacements=new Map([["<","\\u003c"],[">","\\u003e"],["&","\\u0026"],["\u2028","\\u2028"],["\u2029","\\u2029"]])},e=>{const t={};e.exports=t.flatten=function(e,r){const s=r||[];for(const r of e)Array.isArray(r)?t.flatten(r,s):s.push(r);return s}},e=>{const t={};e.exports=function(e,r,s={}){if(!e||!r)return s.first?null:[];const n=[],a=Array.isArray(e)?new Set(e):e,i=new Set;for(const e of r)if(t.has(a,e)&&!i.has(e)){if(s.first)return e;n.push(e),i.add(e)}return s.first?null:n},t.has=function(e,t){return"function"==typeof e.has?e.has(t):void 0!==e[t]}},e=>{e.exports=function(e){return!!e&&"function"==typeof e.then}},e=>{const t=Symbol("wrapped");e.exports=function(e){if(e[t])return e;let r=!1;const s=function(...t){r||(r=!0,e(...t))};return s[t]=!0,s}},(e,t,r)=>{const s=r(31);e.exports=function(e,t,r){return t.replace(/{([^{}]+)}/g,((t,n)=>{const a=s(e,n,r);return null==a?"":a}))}},e=>{const t=2**31-1;e.exports=function(e,r,s){if("bigint"==typeof e&&(e=Number(e)),e>=Number.MAX_SAFE_INTEGER&&(e=1/0),"number"!=typeof e&&void 0!==e)throw new TypeError("Timeout must be a number or bigint");return new Promise((n=>{const a=s?s.setTimeout:setTimeout,i=()=>{const s=Math.min(e,t);e-=s,a((()=>e>0?i():n(r)),s)};e!==1/0&&i()}))}},(e,t,r)=>{var s=r(14).Buffer;const n=r(27),a=r(30),i=r(51),o=r(57),l=r(58),c=r(56),u={types:{alternatives:r(60),any:r(61),array:r(68),boolean:r(69),date:r(70),function:r(71),link:r(74),number:r(75),object:r(76),string:r(77),symbol:r(78)},aliases:{alt:"alternatives",bool:"boolean",func:"function"}};s&&(u.types.binary=r(79)),u.root=function(){const e={_types:new Set(Object.keys(u.types))};for(const t of e._types)e[t]=function(...e){return n(!e.length||["alternatives","link","object"].includes(t),"The",t,"type does not allow arguments"),u.generate(this,u.types[t],e)};for(const t of["allow","custom","disallow","equal","exist","forbidden","invalid","not","only","optional","options","prefs","preferences","required","strip","valid","when"])e[t]=function(...e){return this.any()[t](...e)};Object.assign(e,u.methods);for(const t in u.aliases){const r=u.aliases[t];e[t]=e[r]}return e},u.methods={ValidationError:l.ValidationError,version:i.version,assert(e,t,...r){u.assert(e,t,!0,r)},attempt:(e,t,...r)=>u.assert(e,t,!1,r),checkPreferences(e){i.checkPreferences(e)},compile(e,t){return o.compile(this,e,t)},isError:l.ValidationError.isError,isRef:c.isRef,isSchema:i.isSchema,in:(...e)=>c.in(...e),override:i.symbols.override,ref:(...e)=>c.create(...e)},u.assert=function(e,t,r,s){const n=s[0]instanceof Error||"string"==typeof s[0]?s[0]:null,o=n?s[1]:s[0],c=t.validate(e,i.preferences({errors:{stack:!0}},o||{}));let u=c.error;if(!u)return c.value;if(n instanceof Error)throw n;const p=r&&"function"==typeof u.annotate?u.annotate():u.message;throw u instanceof l.ValidationError==!1&&(u=a(u)),u.message=n?`${n} ${p}`:p,u},u.generate=function(e,t,r){return n(e,"Must be invoked on a Joi instance."),t.$_root=e,t._definition.args&&r.length?t._definition.args(t,...r):t},e.exports=u.root()},(e,t,r)=>{const s=r(27),n=r(28),a=r(52);let i,o;const l={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)?)?)?)?$/};t.version=a.version,t.defaults={abortEarly:!0,allowUnknown:!1,context:null,convert:!0,dateFormat:"iso",errors:{escapeHtml:!1,label:"path",language:null,render:!0,stack:!1,wrap:{label:'"',array:"[]"}},messages:{},nonEnumerables:!1,noDefaults:!1,presence:"optional",skipFunctions:!1,stripUnknown:!1},t.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")},t.assertOptions=function(e,t,r="Options"){s(e&&"object"==typeof e&&!Array.isArray(e),"Options must be of type object");const n=Object.keys(e).filter((e=>!t.includes(e)));s(0===n.length,`${r} contain unknown keys: ${n}`)},t.checkPreferences=function(e){o=o||r(53);const t=o.preferences.validate(e);if(t.error)throw new n([t.error.details[0].message])},t.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}},t.default=function(e,t){return void 0===e?t:e},t.isIsoDate=function(e){return l.isoDate.test(e)},t.isNumber=function(e){return"number"==typeof e&&!isNaN(e)},t.isResolvable=function(e){return!!e&&(e[t.symbols.ref]||e[t.symbols.template])},t.isSchema=function(e,r={}){return!(!e||!e[t.symbols.any])},t.limit=function(e){return Number.isSafeInteger(e)&&e>=0},t.preferences=function(e,s){i=i||r(54),e=e||{},s=s||{};const n=Object.assign({},e,s);return s.errors&&e.errors&&(n.errors=Object.assign({},e.errors,s.errors),n.errors.wrap=Object.assign({},e.errors.wrap,s.errors.wrap)),s.messages&&(n.messages=i.compile(s.messages,e.messages)),delete n[t.symbols.prefs],n},t.tryWithPath=function(e,t,r={}){try{return e()}catch(e){throw void 0!==e.path?e.path=t+"."+e.path:e.path=t,r.append&&(e.message=`${e.message} (${e.path})`),e}},t.validateArg=function(e,r,{assert:s,message:n}){if(t.isSchema(s)){const t=s.validate(e);if(!t.error)return;return t.error.message}if(!s(e))return r?`${r} ${n}`:n},t.verifyFlat=function(e,t){for(const r of e)s(!Array.isArray(r),"Method no longer accepts array arguments:",t)}},e=>{e.exports=JSON.parse('{"name":"@hapi/validate","description":"Object schema validation","version":"1.1.3","repository":"git://github.com/hapijs/validate","main":"lib/index.js","files":["lib/**/*"],"dependencies":{"@hapi/hoek":"^9.0.0","@hapi/topo":"^5.0.0"},"devDependencies":{"@hapi/bourne":"2.x.x","@hapi/code":"8.x.x","@hapi/lab":"24.x.x"},"scripts":{"test":"lab -t 100 -a @hapi/code -L","test-cov-html":"lab -r html -o coverage.html -a @hapi/code"},"license":"BSD-3-Clause"}')},(e,t,r)=>{const s=r(50),n={};n.wrap=s.string().min(1).max(2).allow(!1),t.preferences=s.object({allowUnknown:s.boolean(),abortEarly:s.boolean(),context:s.object(),convert:s.boolean(),dateFormat:s.valid("date","iso","string","time","utc"),errors:{escapeHtml:s.boolean(),label:s.valid("path","key",!1),language:[s.string(),s.object().ref()],render:s.boolean(),stack:s.boolean(),wrap:{label:n.wrap,array:n.wrap}},messages:s.object(),noDefaults:s.boolean(),nonEnumerables:s.boolean(),presence:s.valid("required","optional","forbidden"),skipFunctions:s.boolean(),stripUnknown:s.object({arrays:s.boolean(),objects:s.boolean()}).or("arrays","objects").allow(!0,!1)}).strict()},(e,t,r)=>{const s=r(27),n=r(30),a=r(55);t.compile=function(e,t){if("string"==typeof e)return s(!t,"Cannot set single message string"),new a(e);if(a.isTemplate(e))return s(!t,"Cannot set single message template"),e;s("object"==typeof e&&!Array.isArray(e),"Invalid message options"),t=t?n(t):{};for(let r in e){const n=e[r];if("root"===r||a.isTemplate(n)){t[r]=n;continue}if("string"==typeof n){t[r]=new a(n);continue}s("object"==typeof n&&!Array.isArray(n),"Invalid message for",r);const i=r;for(r in t[i]=t[i]||{},n){const e=n[r];"root"===r||a.isTemplate(e)?t[i][r]=e:(s("string"==typeof e,"Invalid message for",r,"in",i),t[i][r]=new a(e))}}return t},t.merge=function(e,r){if(!e)return t.compile(r);if(!r)return e;if("string"==typeof r)return new a(r);if(a.isTemplate(r))return r;const i=n(e);for(let e in r){const t=r[e];if("root"===e||a.isTemplate(t)){i[e]=t;continue}if("string"==typeof t){i[e]=new a(t);continue}s("object"==typeof t&&!Array.isArray(t),"Invalid message for",e);const n=e;for(e in i[n]=i[n]||{},t){const r=t[e];"root"===e||a.isTemplate(r)?i[n][e]=r:(s("string"==typeof r,"Invalid message for",e,"in",n),i[n][e]=new a(r))}}return i}},(e,t,r)=>{const s=r(27),n=r(30),a=r(42),i=r(51),o=r(56),l={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=l.Template=class{constructor(e,t){s("string"==typeof e,"Template source must be a string"),s(!e.includes("\0")&&!e.includes(""),"Template source cannot contain reserved control characters"),this.source=e,this.rendered=e,this._template=null,this._settings=n(t),this._parse()}_parse(){if(!this.source.includes("{"))return;const e=l.encode(this.source),t=l.split(e),r=[],s=t.shift();s&&r.push(s);for(const e of t){const t="{"!==e[0],s=t?"}":"}}",n=e.indexOf(s);let a=e.slice(t?0:1,n);const i=":"===a[0];i&&(a=a.slice(1));const o=this._ref(l.decode(a),{raw:t,wrapped:i});r.push(o);const c=e.slice(n+s.length);c&&r.push(l.decode(c))}this._template=r}static date(e,t){return l.dateFormat[t.dateFormat].call(e)}isDynamic(){return!!this._template}static isTemplate(e){return!!e&&!!e[i.symbols.template]}render(e,t,r,s,n={}){if(!this.isDynamic())return this.rendered;const i=[];for(const o of this._template)if("string"==typeof o)i.push(o);else{const c=o.ref.resolve(e,t,r,s,n),u=l.stringify(c,r,n.errors),p=o.raw||!1===(n.errors&&n.errors.escapeHtml)?u:a(u);i.push(l.wrap(p,o.wrapped&&r.errors.wrap.label))}return i.join("")}_ref(e,{raw:t,wrapped:r}){const s=o.create(e,this._settings);return{ref:s,raw:t,wrapped:r||"local"===s.type&&"label"===s.key}}toString(){return this.source}},l.Template.prototype[i.symbols.template]=!0,l.Template.prototype.isImmutable=!0,l.encode=function(e){return e.replace(/\\(\{+)/g,((e,t)=>l.opens.slice(0,t.length))).replace(/\\(\}+)/g,((e,t)=>l.closes.slice(0,t.length)))},l.decode=function(e){return e.replace(/\u0000/g,"{").replace(/\u0001/g,"}")},l.split=function(e){const t=[];let r="";for(let s=0;s<e.length;++s){const n=e[s];if("{"===n){let n="";for(;s+1<e.length&&"{"===e[s+1];)n+="{",++s;t.push(r),r=n}else r+=n}return t.push(r),t},l.wrap=function(e,t){return t?1===t.length?`${t}${e}${t}`:`${t[0]}${e}${t[1]}`:e},l.stringify=function(e,t,r){const s=typeof e;if(null===e)return"null";if(void 0===e)return"";if("string"===s)return e;if("number"===s||"function"===s||"symbol"===s)return e.toString();if("object"!==s)return JSON.stringify(e);if(e instanceof Date)return l.Template.date(e,t);if(e instanceof Map){const t=[];for(const[r,s]of e.entries())t.push(`${r.toString()} -> ${s.toString()}`);e=t}if(!Array.isArray(e))return e.toString();let n="";for(const s of e)n=n+(n.length?", ":"")+l.stringify(s,t,r);return l.wrap(n,t.errors.wrap.array)}},(e,t,r)=>{const s=r(27),n=r(30),a=r(31),i=r(51),o={symbol:Symbol("ref"),defaults:{adjust:null,in:!1,iterables:null,map:null,separator:".",type:"value"}};t.create=function(e,t={}){s("string"==typeof e,"Invalid reference key:",e),i.assertOptions(t,["adjust","ancestor","in","iterables","map","prefix","separator"]),s(!t.prefix||"object"==typeof t.prefix,"options.prefix must be of type object");const r=Object.assign({},o.defaults,t);delete r.prefix;const n=r.separator,a=o.context(e,n,t.prefix);if(r.type=a.type,e=a.key,"value"===r.type)if(a.root&&(s(!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(void 0!==r.ancestor)s(!n||!e||e[0]!==n,"Cannot combine prefix with ancestor option");else{const[t,s]=o.ancestor(e,n);s&&""===(e=e.slice(s))&&(e=null),r.ancestor=t}return r.path=n?null===e?[]:e.split(n):[e],new o.Ref(r)},t.in=function(e,r={}){return t.create(e,Object.assign({},r,{in:!0}))},t.isRef=function(e){return!!e&&!!e[i.symbols.ref]},o.Ref=class{constructor(e){s("object"==typeof e,"Invalid reference construction"),i.assertOptions(e,["adjust","ancestor","in","iterables","map","path","separator","type","depth","key","root","display"]),s([!1,void 0].includes(e.separator)||"string"==typeof e.separator&&1===e.separator.length,"Invalid separator"),s(!e.adjust||"function"==typeof e.adjust,"options.adjust must be a function"),s(!e.map||Array.isArray(e.map),"options.map must be an array"),s(!e.map||!e.adjust,"Cannot set both map and adjust options"),Object.assign(this,o.defaults,e),s("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,t,r,n,a={}){return s(!this.in||a.in,"Invalid in() reference usage"),"global"===this.type?this._resolve(r.context,t,a):"local"===this.type?this._resolve(n,t,a):this.ancestor?"root"===this.ancestor?this._resolve(t.ancestors[t.ancestors.length-1],t,a):(s(this.ancestor<=t.ancestors.length,"Invalid reference exceeds the schema root:",this.display),this._resolve(t.ancestors[this.ancestor-1],t,a)):this._resolve(e,t,a)}_resolve(e,t,r){let s;if("value"===this.type&&t.mainstay.shadow&&!1!==r.shadow&&(s=t.mainstay.shadow.get(this.absolute(t))),void 0===s&&(s=a(e,this.path,{iterables:this.iterables,functions:!0})),this.adjust&&(s=this.adjust(s)),this.map){const e=this.map.get(s);void 0!==e&&(s=e)}return s}toString(){return this.display}absolute(e){return[...e.path.slice(0,-this.ancestor),...this.path]}clone(){return new o.Ref(this)}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||""}`}},o.Ref.prototype[i.symbols.ref]=!0,o.context=function(e,t,r={}){if(e=e.trim(),r){const s=void 0===r.global?"$":r.global;if(s!==t&&e.startsWith(s))return{key:e.slice(s.length),type:"global"};const n=void 0===r.local?"#":r.local;if(n!==t&&e.startsWith(n))return{key:e.slice(n.length),type:"local"};const a=void 0===r.root?"/":r.root;if(a!==t&&e.startsWith(a))return{key:e.slice(a.length),type:"value",root:!0}}return{key:e,type:"value"}},o.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]},t.toSibling=0,t.toParent=1,t.Manager=class{constructor(){this.refs=[]}register(e,r){if(e)if(r=void 0===r?t.toParent:r,Array.isArray(e))for(const t of e)this.register(t,r);else if(i.isSchema(e))for(const t of e._refs.refs)t.ancestor-r>=0&&this.refs.push({ancestor:t.ancestor-r,root:t.root});else t.isRef(e)&&"value"===e.type&&e.ancestor-r>=0&&this.refs.push({ancestor:e.ancestor-r,root:e.root})}clone(){const e=new t.Manager;return e.refs=n(this.refs),e}reset(){this.refs=[]}roots(){return this.refs.filter((e=>!e.ancestor)).map((e=>e.root))}}},(e,t,r)=>{const s=r(27),n=r(51),a=r(56),i={};t.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,t,r){s(void 0!==t,"Invalid undefined schema"),Array.isArray(t)&&(s(t.length,"Invalid empty array schema"),1===t.length&&(t=t[0]));const a=(t,...s)=>!1!==r.override?t.valid(e.override,...s):t.valid(...s);if(i.simple(t))return a(e,t);if("function"==typeof t)return e.custom(t);if(s("object"==typeof t,"Invalid schema content:",typeof t),n.isResolvable(t))return a(e,t);if(n.isSchema(t))return t;if(Array.isArray(t)){for(const r of t)if(!i.simple(r))return e.alternatives().try(...t);return a(e,...t)}return t instanceof RegExp?e.string().regex(t):t instanceof Date?a(e.date(),t):(s(Object.getPrototypeOf(t)===Object.getPrototypeOf({}),"Schema can only contain plain objects"),e.object().keys(t))},t.ref=function(e,t){return a.isRef(e)?e:a.create(e,t)},t.compile=function(e,r){const a=r&&r[n.symbols.any];return a?(s(a.version===n.version,"Cannot mix different versions of joi schemas:",a.version,n.version),r):t.schema(e,r,{appendPath:!0})},i.simple=function(e){return null===e||["boolean","string","number"].includes(typeof e)},t.when=function(e,r,o){if(void 0===o&&(s(r&&"object"==typeof r,"Missing options"),o=r,r=a.create(".")),Array.isArray(o)&&(o={switch:o}),n.assertOptions(o,["is","not","then","otherwise","switch","break"]),n.isSchema(r))return s(void 0===o.is,'"is" can not be used with a schema condition'),s(void 0===o.not,'"not" can not be used with a schema condition'),s(void 0===o.switch,'"switch" can not be used with a schema condition'),i.condition(e,{is:r,then:o.then,otherwise:o.otherwise,break:o.break});if(s(a.isRef(r)||"string"==typeof r,"Invalid condition:",r),s(void 0===o.not||void 0===o.is,'Cannot combine "is" with "not"'),void 0===o.switch){let l=o;void 0!==o.not&&(l={is:o.not,then:o.otherwise,otherwise:o.then,break:o.break});let c=void 0!==l.is?e.$_compile(l.is):e.$_root.invalid(null,!1,0,"").required();return s(void 0!==l.then||void 0!==l.otherwise,'options must have at least one of "then", "otherwise", or "switch"'),s(void 0===l.break||void 0===l.then||void 0===l.otherwise,"Cannot specify then, otherwise, and break all together"),void 0===o.is||a.isRef(o.is)||n.isSchema(o.is)||(c=c.required()),i.condition(e,{ref:t.ref(r),is:c,then:l.then,otherwise:l.otherwise,break:l.break})}s(Array.isArray(o.switch),'"switch" must be an array'),s(void 0===o.is,'Cannot combine "switch" with "is"'),s(void 0===o.not,'Cannot combine "switch" with "not"'),s(void 0===o.then,'Cannot combine "switch" with "then"');const l={ref:t.ref(r),switch:[],break:o.break};for(let t=0;t<o.switch.length;++t){const r=o.switch[t],i=t===o.switch.length-1;n.assertOptions(r,i?["is","then","otherwise"]:["is","then"]),s(void 0!==r.is,'Switch statement missing "is"'),s(void 0!==r.then,'Switch statement missing "then"');const c={is:e.$_compile(r.is),then:e.$_compile(r.then)};if(a.isRef(r.is)||n.isSchema(r.is)||(c.is=c.is.required()),i){s(void 0===o.otherwise||void 0===r.otherwise,'Cannot specify "otherwise" inside and outside a "switch"');const t=void 0!==o.otherwise?o.otherwise:r.otherwise;void 0!==t&&(s(void 0===l.break,"Cannot specify both otherwise and break"),c.otherwise=e.$_compile(t))}l.switch.push(c)}return l},i.condition=function(e,t){for(const r of["then","otherwise"])void 0===t[r]?delete t[r]:t[r]=e.$_compile(t[r]);return t}},(e,t,r)=>{const s=r(59),n=r(51),a=r(55);t.Report=class{constructor(e,r,s,n,a,i,o){if(this.code=e,this.flags=n,this.messages=a,this.path=i.path,this.prefs=o,this.state=i,this.value=r,this.message=null,this.local=s||{},this.local.label=t.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)}}toString(){if(this.message)return this.message;const e=this.code;if(!this.prefs.errors.render)return this.code;const t=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(e){return t.template(this.value,e,this.code,this.state,this.prefs)}},t.path=function(e){let t="";for(const r of e)"object"!=typeof r&&("string"==typeof r?(t&&(t+="."),t+=r):t+=`[${r}]`);return t},t.template=function(e,t,r,s,i){if(a.isTemplate(t))return"root"!==r?t:null;let o=i.errors.language;return n.isResolvable(o)&&(o=o.resolve(e,s,i)),o&&t[o]&&void 0!==t[o][r]?t[o][r]:t[r]},t.label=function(e,r,s,n){if(!s.errors.label)return"";let a=r.path;"key"===s.errors.label&&r.path.length>1&&(a=r.path.slice(-1));const i=t.path(a);return i||(t.template(null,s.messages,"root",r,s)||t.template(null,n,"root",r,s)||"value")},t.process=function(e,r,s){if(!e)return null;const{override:n,message:a,details:i}=t.details(e);if(n)return n;if(s.errors.stack)return new t.ValidationError(a,i,r);const o=Error.stackTraceLimit;Error.stackTraceLimit=0;const l=new t.ValidationError(a,i,r);return Error.stackTraceLimit=o,l},t.details=function(e,t={}){let r=[];const s=[];for(const n of e){if(n instanceof Error){if(!1!==t.override)return{override:n};const e=n.toString();r.push(e),s.push({message:e,type:"override",context:{error:n}});continue}const e=n.toString();r.push(e),s.push({message:e,path:n.path.filter((e=>"object"!=typeof e)),type:n.code,context:n.local})}return r.length>1&&(r=[...new Set(r)]),{message:r.join(". "),details:s}},t.ValidationError=class extends Error{constructor(e,t,r){super(e),this._original=r,this.details=t}static isError(e){return e instanceof t.ValidationError}},t.ValidationError.prototype.isJoi=!0,t.ValidationError.prototype.name="ValidationError",t.ValidationError.prototype.annotate=s.error},(e,t,r)=>{const s=r(30),n=r(51),a={annotations:Symbol("annotations")};t.error=function(e){if(!this._original||"object"!=typeof this._original)return this.details[0].message;const t=e?"":"[31m",r=e?"":"[41m",i=e?"":"[0m",o=s(this._original);for(let e=this.details.length-1;e>=0;--e){const t=e+1,r=this.details[e],s=r.path;let i=o;for(let e=0;;++e){const o=s[e];if(n.isSchema(i)&&(i=i.clone()),!(e+1<s.length&&"string"!=typeof i[o])){const e=i[a.annotations]||{errors:{},missing:{}};i[a.annotations]=e;const s=o||r.context.key;void 0!==i[o]?(e.errors[s]=e.errors[s]||[],e.errors[s].push(t)):e.missing[s]=t;break}i=i[o]}}const l=/_\$key\$_([, \d]+)_\$end\$_"/g,c=/"_\$miss\$_([^|]+)\|(\d+)_\$end\$_": "__missing__"/g,u=/\s*"_\$idx\$_([, \d]+)_\$end\$_",?\n(.*)/g,p=/"\[(NaN|Symbol.*|-?Infinity|function.*|\(.*)]"/g;let h=a.safeStringify(o,2).replace(l,((e,r)=>`" ${t}[${r}]${i}`)).replace(c,((e,s,n)=>`${r}"${s}"${i}${t} [${n}]: -- missing --${i}`)).replace(u,((e,r,s)=>`\n${s} ${t}[${r}]${i}`)).replace(p,((e,t)=>t));h=`${h}\n${t}`;for(let e=0;e<this.details.length;++e){h=`${h}\n[${e+1}] ${this.details[e].message}`}return h+=i,h},a.safeStringify=function(e,t){return JSON.stringify(e,a.serializer(),t)},a.serializer=function(){const e=[],t=[],r=(r,s)=>t[0]===s?"[Circular ~]":"[Circular ~."+e.slice(0,t.indexOf(s)).join(".")+"]";return function(s,n){if(t.length>0){const a=t.indexOf(this);~a?(t.length=a+1,e.length=a+1,e[a]=s):(t.push(this),e.push(s)),~t.indexOf(n)&&(n=r.call(this,s,n))}else t.push(n);if(n){const e=n[a.annotations];if(e){if(Array.isArray(n)){const t=[];for(let r=0;r<n.length;++r)e.errors[r]&&t.push(`_$idx$_${e.errors[r].sort().join(", ")}_$end$_`),t.push(n[r]);n=t}else{for(const t in e.errors)n[`${t}_$key$_${e.errors[t].sort().join(", ")}_$end$_`]=n[t],n[t]=void 0;for(const t in e.missing)n[`_$miss$_${t}|${e.missing[t]}_$end$_`]="__missing__"}return n}}return n===1/0||n===-1/0||Number.isNaN(n)||"function"==typeof n||"symbol"==typeof n?"["+n.toString()+"]":n}}},(e,t,r)=>{const s=r(27),n=r(61),a=r(51),i=r(57),o=r(58),l=r(56),c={};e.exports=n._extend({type:"alternatives",flags:{match:{default:"any"}},terms:{matches:{init:[],register:l.toSibling}},args:(e,...t)=>1===t.length&&Array.isArray(t[0])?e.try(...t[0]):e.try(...t),validate(e,t){const{schema:r,error:s,state:n,prefs:a}=t;if(r._flags.match){let t,i=0;for(let s=0;s<r.$_terms.matches.length;++s){const o=r.$_terms.matches[s],l=n.nest(o.schema,`match.${s}`);l.snapshot();const c=o.schema.$_validate(e,l,a);c.errors?l.restore():(++i,t=c.value)}return i?"one"===r._flags.match?1===i?{value:t}:{errors:s("alternatives.one")}:i===r.$_terms.matches.length?{value:e}:{errors:s("alternatives.all")}:{errors:s("alternatives.any")}}const i=[];for(let t=0;t<r.$_terms.matches.length;++t){const s=r.$_terms.matches[t];if(s.schema){const r=n.nest(s.schema,`match.${t}`);r.snapshot();const o=s.schema.$_validate(e,r,a);if(!o.errors)return o;r.restore(),i.push({schema:s.schema,reports:o.errors});continue}const o=s.ref?s.ref.resolve(e,n,a):e,l=s.is?[s]:s.switch;for(let r=0;r<l.length;++r){const i=l[r],{is:c,then:u,otherwise:p}=i,h=`match.${t}${s.switch?"."+r:""}`;if(c.$_match(o,n.nest(c,`${h}.is`),a)){if(u)return u.$_validate(e,n.nest(u,`${h}.then`),a)}else if(p)return p.$_validate(e,n.nest(p,`${h}.otherwise`),a)}}return c.errors(i,t)},rules:{conditional:{method(e,t){s(!this._flags._endedSwitch,"Unreachable condition"),s(!this._flags.match,"Cannot combine match mode",this._flags.match,"with conditional rule"),s(void 0===t.break,"Cannot use break option with alternatives conditional");const r=this.clone(),n=i.when(r,e,t),a=n.is?[n]:n.switch;for(const e of a)if(e.then&&e.otherwise){r.$_setFlag("_endedSwitch",!0,{clone:!1});break}return r.$_terms.matches.push(n),r.$_mutateRebuild()}},match:{method(e){if(s(["any","one","all"].includes(e),"Invalid alternatives match mode",e),"any"!==e)for(const t of this.$_terms.matches)s(t.schema,"Cannot combine match mode",e,"with conditional rules");return this.$_setFlag("match",e)}},try:{method(...e){s(e.length,"Missing alternative schemas"),a.verifyFlat(e,"try"),s(!this._flags._endedSwitch,"Unreachable condition");const t=this.clone();for(const r of e)t.$_terms.matches.push({schema:t.$_compile(r)});return t.$_mutateRebuild()}}},rebuild(e){e.$_modify({each:t=>{a.isSchema(t)&&"array"===t.type&&e.$_setFlag("_arrayItems",!0,{clone:!1})}})},messages:{"alternatives.all":"{{#label}} does not match all of the required types","alternatives.any":"{{#label}} does not match any of the allowed types","alternatives.match":"{{#label}} does not match any of the allowed types","alternatives.one":"{{#label}} matches more than one allowed type","alternatives.types":"{{#label}} must be one of {{#types}}"}}),c.errors=function(e,{error:t,state:r}){if(!e.length)return{errors:t("alternatives.any")};if(1===e.length)return{errors:e[0].reports};const s=new Set,n=[];for(const{reports:a,schema:i}of e){if(a.length>1)return c.unmatched(e,t);const l=a[0];if(l instanceof o.Report==!1)return c.unmatched(e,t);if(l.state.path.length!==r.path.length){n.push({type:i.type,report:l});continue}if("any.only"===l.code){for(const e of l.local.valids)s.add(e);continue}const[u,p]=l.code.split(".");"base"===p?s.add(u):n.push({type:i.type,report:l})}return n.length?1===n.length?{errors:n[0].report}:c.unmatched(e,t):{errors:t("alternatives.types",{types:[...s]})}},c.unmatched=function(e,t){const r=[];for(const t of e)r.push(...t.reports);return{errors:t("alternatives.match",o.details(r,{override:!1}))}}},(e,t,r)=>{const s=r(27),n=r(62),a=r(51);e.exports=n._extend({type:"any",flags:{only:{default:!1}},terms:{alterations:{init:null},examples:{init:null},metas:{init:[]},notes:{init:[]},shared:{init:null},tags:{init:[]},whens:{init:null}},rules:{custom:{method(e,t){return s("function"==typeof e,"Method must be a function"),s(void 0===t||t&&"string"==typeof t,"Description must be a non-empty string"),this.$_addRule({name:"custom",args:{method:e,description:t}})},validate(e,t,{method:r}){try{return r(e,t)}catch(e){return t.error("any.custom",{error:e})}},args:["method","description"],multi:!0},messages:{method(e){return this.prefs({messages:e})}},shared:{method(e){s(a.isSchema(e)&&e._flags.id,"Schema must be a schema with an id");const t=this.clone();return t.$_terms.shared=t.$_terms.shared||[],t.$_terms.shared.push(e),t.$_mutateRegister(e),t}}},messages:{"any.custom":"{{#label}} failed custom validation because {{#error.message}}","any.default":"{{#label}} threw an error when running default method","any.failover":"{{#label}} threw an error when running failover method","any.invalid":"{{#label}} contains an invalid value","any.only":"{{#label}} must be one of {{#valids}}","any.ref":"{{#label}} {{#arg}} references {{:#ref}} which {{#reason}}","any.required":"{{#label}} is required","any.unknown":"{{#label}} is not allowed"}})},(e,t,r)=>{const s=r(27),n=r(30),a=r(39),i=r(34),o=r(51),l=r(57),c=r(58),u=r(63),p=r(54),h=r(64),d=r(56),f=r(65),m=r(67),g={Base:class{constructor(e){this.type=e,this.$_root=null,this._definition={},this._ids=new h.Ids,this._preferences=null,this._refs=new d.Manager,this._cache=null,this._valids=null,this._invalids=null,this._flags={},this._rules=[],this._singleRules=new Map,this.$_terms={},this.$_temp={whens:{}}}allow(...e){return o.verifyFlat(e,"allow"),this._values(e,"_valids")}cast(e){return s(!1===e||"string"==typeof e,"Invalid to value"),s(!1===e||this._definition.cast[e],"Type",this.type,"does not support casting to",e),this.$_setFlag("cast",!1===e?void 0:e)}default(e,t){return this._default("default",e,t)}empty(e){const t=this.clone();return void 0!==e&&(e=t.$_compile(e,{override:!1})),t.$_setFlag("empty",e,{clone:!1})}error(e){return s(e,"Missing error"),s(e instanceof Error||"function"==typeof e,"Must provide a valid Error object or a function"),this.$_setFlag("error",e)}failover(e,t){return this._default("failover",e,t)}forbidden(){return this.presence("forbidden")}id(e){return e?(s("string"==typeof e,"id must be a non-empty string"),s(/^[^\.]+$/.test(e),"id cannot contain period character"),this.$_setFlag("id",e)):this.$_setFlag("id",void 0)}invalid(...e){return this._values(e,"_invalids")}only(e=!0){return s("boolean"==typeof e,"Invalid mode:",e),this.$_setFlag("only",e)}optional(){return this.presence("optional")}prefs(e){s(e,"Missing preferences"),s(void 0===e.context,"Cannot override context"),o.checkPreferences(e);const t=this.clone();return t._preferences=o.preferences(t._preferences,e),t}presence(e){return s(["optional","required","forbidden"].includes(e),"Unknown presence mode",e),this.$_setFlag("presence",e)}raw(e=!0){return this.$_setFlag("result",e?"raw":void 0)}required(){return this.presence("required")}strict(e){const t=this.clone(),r=void 0!==e&&!e;return t._preferences=o.preferences(t._preferences,{convert:r}),t}strip(e=!0){return this.$_setFlag("result",e?"strip":void 0)}valid(...e){o.verifyFlat(e,"valid");const t=this.allow(...e);return t.$_setFlag("only",!!t._valids,{clone:!1}),t}when(e,t){const r=this.clone();r.$_terms.whens||(r.$_terms.whens=[]);const n=l.when(r,e,t);if(!["any","link"].includes(r.type)){const e=n.is?[n]:n.switch;for(const t of e)s(!t.then||"any"===t.then.type||t.then.type===r.type,"Cannot combine",r.type,"with",t.then&&t.then.type),s(!t.otherwise||"any"===t.otherwise.type||t.otherwise.type===r.type,"Cannot combine",r.type,"with",t.otherwise&&t.otherwise.type)}return r.$_terms.whens.push(n),r.$_mutateRebuild()}clone(){const e=Object.create(Object.getPrototypeOf(this));return this._assign(e)}concat(e){s(o.isSchema(e),"Invalid schema object"),s("any"===this.type||"any"===e.type||e.type===this.type,"Cannot merge type",this.type,"with another type:",e.type);let t=this.clone();if("any"===this.type&&"any"!==e.type){const r=e.clone();for(const e of Object.keys(t))"type"!==e&&(r[e]=t[e]);t=r}t._ids.concat(e._ids),t._refs.register(e,d.toSibling),t._preferences=t._preferences?o.preferences(t._preferences,e._preferences):e._preferences,t._valids=m.merge(t._valids,e._valids,e._invalids),t._invalids=m.merge(t._invalids,e._invalids,e._valids);for(const r of e._singleRules.keys())t._singleRules.has(r)&&(t._rules=t._rules.filter((e=>e.name!==r)),t._singleRules.delete(r));for(const r of e._rules)e._definition.rules[r.method].multi||t._singleRules.set(r.name,r),t._rules.push(r);if(t._flags.empty&&e._flags.empty){t._flags.empty=t._flags.empty.concat(e._flags.empty);const r=Object.assign({},e._flags);delete r.empty,i(t._flags,r)}else if(e._flags.empty){t._flags.empty=e._flags.empty;const r=Object.assign({},e._flags);delete r.empty,i(t._flags,r)}else i(t._flags,e._flags);for(const r in e.$_terms){const s=e.$_terms[r];s?t.$_terms[r]?t.$_terms[r]=t.$_terms[r].concat(s):t.$_terms[r]=s.slice():t.$_terms[r]||(t.$_terms[r]=s)}return t.$_mutateRebuild()}validate(e,t){return f.entry(e,this,t)}validateAsync(e,t){const r=this.validate(e,t);if(r.error)throw r.error;return r.value}$_addRule(e){"string"==typeof e&&(e={name:e}),s(e&&"object"==typeof e,"Invalid options"),s(e.name&&"string"==typeof e.name,"Invalid rule name");for(const t in e)s("_"!==t[0],"Cannot set private rule properties");const t=Object.assign({},e);t._resolve=[],t.method=t.method||t.name;const r=this._definition.rules[t.method],n=t.args;s(r,"Unknown rule",t.method);const a=this.clone();if(n){s(1===Object.keys(n).length||Object.keys(n).length===this._definition.rules[t.name].args.length,"Invalid rule definition for",this.type,t.name);for(const e in n){let i=n[e];if(void 0!==i){if(r.argsByName){const l=r.argsByName.get(e);if(l.ref&&o.isResolvable(i))t._resolve.push(e),a.$_mutateRegister(i);else if(l.normalize&&(i=l.normalize(i),n[e]=i),l.assert){const t=o.validateArg(i,e,l);s(!t,t,"or reference")}}n[e]=i}else delete n[e]}}return r.multi||(a._ruleRemove(t.name),a._singleRules.set(t.name,t)),r.priority?a._rules.unshift(t):a._rules.push(t),a}$_compile(e,t){return l.schema(this.$_root,e,t)}$_createError(e,t,r,s,n,a={}){const i=!1!==a.flags?this._flags:{},o=a.messages?p.merge(this._definition.messages,a.messages):this._definition.messages;return new c.Report(e,t,r,i,o,s,n)}$_getRule(e){return this._singleRules.get(e)}$_match(e,t,r,s){(r=Object.assign({},r)).abortEarly=!0,r._externals=!1,t.snapshot();const n=!f.validate(e,this,t,r,s).errors;return t.restore(),n}$_modify(e){return o.assertOptions(e,["each","once","ref","schema"]),h.schema(this,e)||this}$_mutateRebuild(){this._refs.reset(),this._ids.reset();return this.$_modify({each:(e,{source:t,name:r,path:s,key:n})=>{const a=this._definition[t][r]&&this._definition[t][r].register;!1!==a&&this.$_mutateRegister(e,{family:a,key:n})}}),this._definition.rebuild&&this._definition.rebuild(this),this}$_mutateRegister(e,{family:t,key:r}={}){this._refs.register(e,t),this._ids.register(e,{key:r})}$_property(e){return this._definition.properties[e]}$_reach(e){return this._ids.reach(e)}$_rootReferences(){return this._refs.roots()}$_setFlag(e,t,r={}){const s=this._definition.flags[e]||{};if(a(t,s.default)&&(t=void 0),a(t,this._flags[e]))return this;const n=!1!==r.clone?this.clone():this;return void 0!==t?(n._flags[e]=t,n.$_mutateRegister(t)):delete n._flags[e],n}$_parent(e,...t){return this[e][o.symbols.parent].call(this,...t)}$_validate(e,t,r){return f.validate(e,this,t,r)}_assign(e){e.type=this.type,e.$_root=this.$_root,e.$_temp=Object.assign({},this.$_temp),e.$_temp.whens={},e._ids=this._ids.clone(),e._preferences=this._preferences,e._valids=this._valids&&this._valids.clone(),e._invalids=this._invalids&&this._invalids.clone(),e._rules=this._rules.slice(),e._singleRules=n(this._singleRules,{shallow:!0}),e._refs=this._refs.clone(),e._flags=Object.assign({},this._flags),e._cache=null,e.$_terms={};for(const t in this.$_terms)e.$_terms[t]=this.$_terms[t]?this.$_terms[t].slice():null;e.$_super={};for(const t in this.$_super)e.$_super[t]=this._super[t].bind(e);return e}_default(e,t,r={}){o.assertOptions(r,"literal"),s(void 0!==t,"Missing",e,"value"),s("function"==typeof t||!r.literal,"Only function value supports literal option"),"function"==typeof t&&r.literal&&(t={[o.symbols.literal]:!0,literal:t});return this.$_setFlag(e,t)}_extend(e){return s(!e.base,"Cannot extend type with another base"),u.type(this,e)}_generate(e,t,r){if(!this.$_terms.whens)return{schema:this};const s=[],n=[];for(let a=0;a<this.$_terms.whens.length;++a){const i=this.$_terms.whens[a];if(i.concat){s.push(i.concat),n.push(`${a}.concat`);continue}const o=i.ref?i.ref.resolve(e,t,r):e,l=i.is?[i]:i.switch,c=n.length;for(let c=0;c<l.length;++c){const{is:u,then:p,otherwise:h}=l[c],d=`${a}${i.switch?"."+c:""}`;if(u.$_match(o,t.nest(u,`${d}.is`),r)){if(p){const a=t.localize([...t.path,`${d}.then`],t.ancestors,t.schemas),{schema:i,id:o}=p._generate(e,a,r);s.push(i),n.push(`${d}.then${o?`(${o})`:""}`);break}}else if(h){const a=t.localize([...t.path,`${d}.otherwise`],t.ancestors,t.schemas),{schema:i,id:o}=h._generate(e,a,r);s.push(i),n.push(`${d}.otherwise${o?`(${o})`:""}`);break}}if(i.break&&n.length>c)break}const a=n.join(", ");if(!a)return{schema:this};if(this.$_temp.whens[a])return{schema:this.$_temp.whens[a],id:a};let i=this;this._definition.generate&&(i=this._definition.generate(this,e,t,r));for(const e of s)i=i.concat(e);return this.$_temp.whens[a]=i,{schema:i,id:a}}_ruleRemove(e){if(!this._singleRules.has(e))return this;this._singleRules.delete(e);const t=[];for(let r=0;r<this._rules.length;++r){const s=this._rules[r];s.name!==e&&t.push(s)}this._rules=t}_values(e,t){o.verifyFlat(e,t.slice(1,-1));const r=this.clone(),n=e[0]===o.symbols.override;if(n&&(e=e.slice(1)),!r[t]&&e.length?r[t]=new m:n&&(r[t]=e.length?new m:null,r.$_mutateRebuild()),!r[t])return r;n&&r[t].override();for(const n of e){s(void 0!==n,"Cannot call allow/valid/invalid with undefined"),s(n!==o.symbols.override,"Override must be the first value");const e="_invalids"===t?"_valids":"_invalids";r[e]&&(r[e].remove(n),r[e].length||(s("_valids"===t||!r._flags.only,"Setting invalid value",n,"leaves schema rejecting all values due to previous valid rule"),r[e]=null)),r[t].add(n,r._refs)}return r}}};g.Base.prototype[o.symbols.any]={version:o.version,compile:l.compile,root:"$_root"},g.Base.prototype.isImmutable=!0,g.Base.prototype.deny=g.Base.prototype.invalid,g.Base.prototype.disallow=g.Base.prototype.invalid,g.Base.prototype.equal=g.Base.prototype.valid,g.Base.prototype.exist=g.Base.prototype.required,g.Base.prototype.not=g.Base.prototype.invalid,g.Base.prototype.options=g.Base.prototype.prefs,g.Base.prototype.preferences=g.Base.prototype.prefs,e.exports=new g.Base},(e,t,r)=>{const s=r(27),n=r(30),a=r(51),i=r(54);t.type=function(e,t){const r=Object.getPrototypeOf(e),o=n(r),l=e._assign(Object.create(o)),c=Object.assign({},t);delete c.base,o._definition=c;const u=r._definition||{};c.messages=i.merge(u.messages,c.messages),c.properties=Object.assign({},u.properties,c.properties),l.type=c.type,c.flags=Object.assign({},u.flags,c.flags);const p=Object.assign({},u.terms);if(c.terms)for(const e in c.terms){const t=c.terms[e];s(void 0===l.$_terms[e],"Invalid term override for",c.type,e),l.$_terms[e]=t.init,p[e]=t}c.terms=p,c.args||(c.args=u.args),c.coerce&&("function"==typeof c.coerce&&(c.coerce={method:c.coerce}),c.coerce.from&&!Array.isArray(c.coerce.from)&&(c.coerce={method:c.coerce.method,from:[].concat(c.coerce.from)})),c.coerce=c.coerce||u.coerce,c.validate=c.validate||u.validate;const h=Object.assign({},u.rules);if(c.rules)for(const e in c.rules){const t=c.rules[e];s("object"==typeof t,"Invalid rule definition for",c.type,e);const r=t.method;if(r&&(s(!o[e],"Rule conflict in",c.type,e),o[e]=r),s(!h[e],"Rule conflict in",c.type,e),h[e]=t,t.alias){const e=[].concat(t.alias);for(const r of e)o[r]=t.method}t.args&&(t.argsByName=new Map,t.args=t.args.map((e=>("string"==typeof e&&(e={name:e}),s(!t.argsByName.has(e.name),"Duplicated argument name",e.name),t.argsByName.set(e.name,e),e))))}if(c.rules=h,c.overrides){o._super=r,l.$_super={};for(const e in c.overrides)s(r[e],"Cannot override missing",e),c.overrides[e][a.symbols.parent]=r[e],l.$_super[e]=r[e].bind(l);Object.assign(o,c.overrides)}return c.cast=Object.assign({},u.cast,c.cast),c.rebuild=c.rebuild||u.rebuild,l}},(e,t,r)=>{const s=r(27),n=r(51),a=r(56),i={};t.Ids=i.Ids=class{constructor(){this._byId=new Map,this._byKey=new Map,this._schemaChain=!1}clone(){const e=new i.Ids;return e._byId=new Map(this._byId),e._byKey=new Map(this._byKey),e._schemaChain=this._schemaChain,e}concat(e){e._schemaChain&&(this._schemaChain=!0);for(const[t,r]of e._byId.entries())s(!this._byKey.has(t),"Schema id conflicts with existing key:",t),this._byId.set(t,r);for(const[t,r]of e._byKey.entries())s(!this._byId.has(t),"Schema key conflicts with existing id:",t),this._byKey.set(t,r)}reach(e,t=[]){const r=e[0],n=this._get(r);s(n,"Schema does not contain path",[...t,...e].join("."));const a=e.slice(1);return a.length?n.schema._ids.reach(a,[...t,r]):n.schema}register(e,{key:t}={}){if(!e||!n.isSchema(e))return;(e.$_property("schemaChain")||e._ids._schemaChain)&&(this._schemaChain=!0);const r=e._flags.id;if(r){const t=this._byId.get(r);s(!t||t.schema===e,"Cannot add different schemas with the same id:",r),s(!this._byKey.has(r),"Schema id conflicts with existing key:",r),this._byId.set(r,{schema:e,id:r})}t&&(s(!this._byKey.has(t),"Schema already contains key:",t),s(!this._byId.has(t),"Schema key conflicts with existing id:",t),this._byKey.set(t,{schema:e,id:t}))}reset(){this._byId=new Map,this._byKey=new Map,this._schemaChain=!1}_get(e){return this._byId.get(e)||this._byKey.get(e)}},t.schema=function(e,t){let r;for(const s in e._flags){if("_"===s[0])continue;const n=i.scan(e._flags[s],{source:"flags",name:s},t);void 0!==n&&(r=r||e.clone(),r._flags[s]=n)}for(let s=0;s<e._rules.length;++s){const n=e._rules[s],a=i.scan(n.args,{source:"rules",name:n.name},t);if(void 0!==a){r=r||e.clone();const t=Object.assign({},n);t.args=a,r._rules[s]=t;r._singleRules.get(n.name)===n&&r._singleRules.set(n.name,t)}}for(const s in e.$_terms){if("_"===s[0])continue;const n=i.scan(e.$_terms[s],{source:"terms",name:s},t);void 0!==n&&(r=r||e.clone(),r.$_terms[s]=n)}return r},i.scan=function(e,t,r,s,o){const l=s||[];if(null===e||"object"!=typeof e)return;let c;if(Array.isArray(e)){for(let s=0;s<e.length;++s){const n="keys"===t.name&&e[s].key,a=i.scan(e[s],t,r,[s,...l],n);void 0!==a&&(c=c||e.slice(),c[s]=a)}return c}if(!1!==r.schema&&n.isSchema(e)||!1!==r.ref&&a.isRef(e)){return r.each(e,{...t,path:l,key:o})}for(const s in e){if("_"===s[0])continue;const n=i.scan(e[s],t,r,[s,...l],o);void 0!==n&&(c=c||Object.assign({},e),c[s]=n)}return c}},(e,t,r)=>{const s=r(27),n=r(30),a=r(51),i=r(58),o=r(66),l={result:Symbol("result")};t.entry=function(e,t,r){let s=a.defaults;r&&(s=a.preferences(a.defaults,r));const n=l.entry(e,t,s),i={value:n.value};return n.error&&(i.error=n.error),i},l.entry=function(e,r,s){const n={links:r._ids._schemaChain?new Map:null},a=r._ids._schemaChain?[{schema:r}]:null,l=new o([],[],{mainstay:n,schemas:a}),c=t.validate(e,r,l,s),u=i.process(c.errors,e,s);return{value:c.value,error:u,mainstay:n}},t.validate=function(e,t,r,s,n={}){t.$_terms.whens&&(t=t._generate(e,r,s).schema),t._preferences&&(s=l.prefs(t,s));const i={original:e,prefs:s,schema:t,state:r,error:(n,a,i)=>t.$_createError(n,e,a,i||r,s),errorsArray:l.errorsArray,message:(n,a)=>t.$_createError("custom",e,a,r,s,{messages:n})},o=t._definition;if(o.coerce&&void 0!==e&&s.convert&&(!o.coerce.from||o.coerce.from.includes(typeof e))){const t=o.coerce.method(e,i);if(t){if(t.errors)return l.finalize(t.value,[].concat(t.errors),i);e=t.value}}const c=t._flags.empty;c&&c.$_match(l.trim(e,t),r.nest(c),a.defaults)&&(e=void 0);const u=n.presence||t._flags.presence||(t._flags._endedSwitch?null:s.presence);if(void 0===e){if("forbidden"===u)return l.finalize(e,null,i);if("required"===u)return l.finalize(e,[t.$_createError("any.required",e,null,r,s)],i);if("optional"===u){if(t._flags.default!==a.symbols.deepDefault)return l.finalize(e,null,i);e={}}}else if("forbidden"===u)return l.finalize(e,[t.$_createError("any.unknown",e,null,r,s)],i);const p=[];if(t._valids){const n=t._valids.get(e,r,s,t._flags.insensitive);if(n)return s.convert&&(e=n.value),l.finalize(e,null,i);if(t._flags.only){const n=t.$_createError("any.only",e,{valids:t._valids.values({display:!0})},r,s);if(s.abortEarly)return l.finalize(e,[n],i);p.push(n)}}if(t._invalids){if(t._invalids.get(e,r,s,t._flags.insensitive)){const n=t.$_createError("any.invalid",e,{invalids:t._invalids.values({display:!0})},r,s);if(s.abortEarly)return l.finalize(e,[n],i);p.push(n)}}if(o.validate){const t=o.validate(e,i);if(t&&(e=t.value,t.errors)){if(!Array.isArray(t.errors))return p.push(t.errors),l.finalize(e,p,i);if(t.errors.length)return p.push(...t.errors),l.finalize(e,p,i)}}return t._rules.length?l.rules(e,p,i):l.finalize(e,p,i)},l.rules=function(e,t,r){const{schema:s,state:n,prefs:i}=r;for(const o of s._rules){const c=s._definition.rules[o.method];if(c.convert&&i.convert)continue;let u,p=o.args;if(o._resolve.length){p=Object.assign({},p);for(const t of o._resolve){const r=c.argsByName.get(t),o=p[t].resolve(e,n,i),l=r.normalize?r.normalize(o):o,h=a.validateArg(l,null,r);if(h){u=s.$_createError("any.ref",o,{arg:t,ref:p[t],reason:h},n,i);break}p[t]=l}}u=u||c.validate(e,r,p,o);const h=l.rule(u,o);if(h.errors){if(i.abortEarly)return l.finalize(e,h.errors,r);t.push(...h.errors)}else e=h.value}return l.finalize(e,t,r)},l.rule=function(e,t){return e instanceof i.Report?{errors:[e],value:null}:Array.isArray(e)&&e[a.symbols.errors]?{errors:e,value:null}:{errors:null,value:e}},l.finalize=function(e,t,r){t=t||[];const{schema:n,state:a}=r;if(t.length){const s=l.default("failover",void 0,t,r);void 0!==s&&(e=s,t=[])}if(t.length&&n._flags.error)if("function"==typeof n._flags.error){t=n._flags.error(t),Array.isArray(t)||(t=[t]);for(const e of t)s(e instanceof Error||e instanceof i.Report,"error() must return an Error object")}else t=[n._flags.error];if(void 0===e){e=l.default("default",e,t,r)}if(n._flags.cast&&void 0!==e){const t=n._definition.cast[n._flags.cast];if(t.from(e)){e=t.to(e,r)}}const o={value:e,errors:t.length?t:null};return n._flags.result&&(o.value="strip"===n._flags.result?void 0:r.original,a.shadow(e,n._flags.result)),o},l.prefs=function(e,t){const r=t===a.defaults;return r&&e._preferences[a.symbols.prefs]?e._preferences[a.symbols.prefs]:(t=a.preferences(t,e._preferences),r&&(e._preferences[a.symbols.prefs]=t),t)},l.default=function(e,t,r,s){const{schema:i,state:o,prefs:l}=s,c=i._flags[e];if(l.noDefaults||void 0===c)return t;if(!c)return c;if("function"==typeof c){const t=c.length?[n(o.ancestors[0]),s]:[];try{return c(...t)}catch(t){return void r.push(i.$_createError(`any.${e}`,null,{error:t},o,l))}}return"object"!=typeof c?c:c[a.symbols.literal]?c.literal:a.isResolvable(c)?c.resolve(t,o,l):n(c)},l.trim=function(e,t){if("string"!=typeof e)return e;const r=t.$_getRule("trim");return r&&r.args.enabled?e.trim():e},l.errorsArray=function(){const e=[];return e[a.symbols.errors]=!0,e}},(e,t,r)=>{const s=r(30),n=r(31),a=r(51),i={value:Symbol("value")};e.exports=i.State=class{constructor(e,t,r){this.path=e,this.ancestors=t,this.mainstay=r.mainstay,this.schemas=r.schemas}localize(e,t=null,r=null){const s=new i.State(e,t,this);return r&&s.schemas&&(s.schemas=[i.schemas(r),...s.schemas]),s}nest(e){const t=new i.State(this.path,this.ancestors,this);return t.schemas=t.schemas&&[i.schemas(e),...t.schemas],t}shadow(e,t){this.mainstay.shadow=this.mainstay.shadow||new i.Shadow,this.mainstay.shadow.set(this.path,e,t)}snapshot(){this.mainstay.shadow&&(this._snapshot=s(this.mainstay.shadow.node(this.path)))}restore(){this.mainstay.shadow&&(this.mainstay.shadow.override(this.path,this._snapshot),this._snapshot=void 0)}},i.schemas=function(e){return a.isSchema(e)?{schema:e}:e},i.Shadow=class{constructor(){this._values=null}set(e,t,r){if(!e.length)return;if("strip"===r&&"number"==typeof e[e.length-1])return;this._values=this._values||new Map;let s=this._values;for(let t=0;t<e.length;++t){const r=e[t];let n=s.get(r);n||(n=new Map,s.set(r,n)),s=n}s[i.value]=t}get(e){const t=this.node(e);if(t)return t[i.value]}node(e){if(this._values)return n(this._values,e,{iterables:!0})}override(e,t){if(!this._values)return;const r=e.slice(0,-1),s=e[e.length-1],a=n(this._values,r,{iterables:!0});t?a.set(s,t):a&&a.delete(s)}}},(e,t,r)=>{const s=r(27),n=r(39),a=r(51),i={};e.exports=i.Values=class{constructor(e,t){this._values=new Set(e),this._refs=new Set(t),this._lowercase=i.lowercases(e),this._override=!1}get length(){return this._values.size+this._refs.size}add(e,t){a.isResolvable(e)?this._refs.has(e)||(this._refs.add(e),t&&t.register(e)):this.has(e,null,null,!1)||(this._values.add(e),"string"==typeof e&&this._lowercase.set(e.toLowerCase(),e))}static merge(e,t,r){if(e=e||new i.Values,t){if(t._override)return t.clone();for(const r of[...t._values,...t._refs])e.add(r)}if(r)for(const t of[...r._values,...r._refs])e.remove(t);return e.length?e:null}remove(e){a.isResolvable(e)?this._refs.delete(e):(this._values.delete(e),"string"==typeof e&&this._lowercase.delete(e.toLowerCase()))}has(e,t,r,s){return!!this.get(e,t,r,s)}get(e,t,r,s){if(!this.length)return!1;if(this._values.has(e))return{value:e};if("string"==typeof e&&e&&s){const t=this._lowercase.get(e.toLowerCase());if(t)return{value:t}}if(!this._refs.size&&"object"!=typeof e)return!1;if("object"==typeof e)for(const t of this._values)if(n(t,e))return{value:t};if(t)for(const a of this._refs){const i=a.resolve(e,t,r,null,{in:!0});if(void 0===i)continue;const o=a.in&&"object"==typeof i?Array.isArray(i)?i:Object.keys(i):[i];for(const t of o)if(typeof t==typeof e)if(s&&e&&"string"==typeof e){if(t.toLowerCase()===e.toLowerCase())return{value:t,ref:a}}else if(n(t,e))return{value:t,ref:a}}return!1}override(){this._override=!0}values(e){if(e&&e.display){const e=[];for(const t of[...this._values,...this._refs])void 0!==t&&e.push(t);return e}return Array.from([...this._values,...this._refs])}clone(){const e=new i.Values(this._values,this._refs);return e._override=this._override,e}concat(e){s(!e._override,"Cannot concat override set of values");const t=new i.Values([...this._values,...e._values],[...this._refs,...e._refs]);return t._override=this._override,t}},i.Values.prototype[a.symbols.values]=!0,i.Values.prototype.slice=i.Values.prototype.clone,i.lowercases=function(e){const t=new Map;if(e)for(const r of e)"string"==typeof r&&t.set(r.toLowerCase(),r);return t}},(e,t,r)=>{const s=r(27),n=r(39),a=r(31),i=r(61),o=r(51),l=r(57),c={};e.exports=i._extend({type:"array",flags:{single:{default:!1},sparse:{default:!1}},terms:{items:{init:[]},ordered:{init:[]},_exclusions:{init:[]},_inclusions:{init:[]},_requireds:{init:[]}},coerce:{from:"object",method(e,{schema:t,state:r,prefs:s}){if(!Array.isArray(e))return;const n=t.$_getRule("sort");return n?c.sort(t,e,n.args.options,r,s):void 0}},validate(e,{schema:t,error:r}){if(!Array.isArray(e)){if(t._flags.single){const t=[e];return t[o.symbols.arraySingle]=!0,{value:t}}return{errors:r("array.base")}}if(t.$_getRule("items"))return{value:e.slice()}},rules:{has:{method(e){e=this.$_compile(e,{appendPath:!0});const t=this.$_addRule({name:"has",args:{schema:e}});return t.$_mutateRegister(e),t},validate(e,{state:t,prefs:r,error:s},{schema:n}){const a=[e,...t.ancestors];for(let s=0;s<e.length;++s){const i=t.localize([...t.path,s],a,n);if(n.$_match(e[s],i,r))return e}return s("array.hasUnknown",null)},multi:!0},items:{method(...e){o.verifyFlat(e,"items");const t=this.$_addRule("items");for(let r=0;r<e.length;++r){const s=o.tryWithPath((()=>this.$_compile(e[r])),r,{append:!0});t.$_terms.items.push(s)}return t.$_mutateRebuild()},validate(e,{schema:t,error:r,state:s,prefs:n,errorsArray:a}){const i=t.$_terms._requireds.slice(),l=t.$_terms.ordered.slice(),u=[...t.$_terms._inclusions,...i],p=!e[o.symbols.arraySingle];delete e[o.symbols.arraySingle];const h=a();let d=e.length;for(let a=0;a<d;++a){const o=e[a];let f=!1,m=!1;const g=p?a:new Number(a),y=[...s.path,g];if(!t._flags.sparse&&void 0===o){if(h.push(r("array.sparse",{key:g,path:y,pos:a,value:void 0},s.localize(y))),n.abortEarly)return h;l.shift();continue}const b=[e,...s.ancestors];for(const e of t.$_terms._exclusions)if(e.$_match(o,s.localize(y,b,e),n,{presence:"ignore"})){if(h.push(r("array.excludes",{pos:a,value:o},s.localize(y))),n.abortEarly)return h;f=!0,l.shift();break}if(f)continue;if(t.$_terms.ordered.length){if(l.length){const i=l.shift(),u=i.$_validate(o,s.localize(y,b,i),n);if(u.errors){if(h.push(...u.errors),n.abortEarly)return h}else if("strip"===i._flags.result)c.fastSplice(e,a),--a,--d;else{if(!t._flags.sparse&&void 0===u.value){if(h.push(r("array.sparse",{key:g,path:y,pos:a,value:void 0},s.localize(y))),n.abortEarly)return h;continue}e[a]=u.value}continue}if(!t.$_terms.items.length){if(h.push(r("array.orderedLength",{pos:a,limit:t.$_terms.ordered.length})),n.abortEarly)return h;break}}const v=[];let _=i.length;for(let l=0;l<_;++l){const u=s.localize(y,b,i[l]);u.snapshot();const p=i[l].$_validate(o,u,n);if(v[l]=p,!p.errors){if(e[a]=p.value,m=!0,c.fastSplice(i,l),--l,--_,!t._flags.sparse&&void 0===p.value&&(h.push(r("array.sparse",{key:g,path:y,pos:a,value:void 0},s.localize(y))),n.abortEarly))return h;break}u.restore()}if(m)continue;const w=n.stripUnknown&&!!n.stripUnknown.arrays||!1;_=u.length;for(const l of u){let u;const p=i.indexOf(l);if(-1!==p)u=v[p];else{const i=s.localize(y,b,l);if(i.snapshot(),u=l.$_validate(o,i,n),!u.errors){"strip"===l._flags.result?(c.fastSplice(e,a),--a,--d):t._flags.sparse||void 0!==u.value?e[a]=u.value:(h.push(r("array.sparse",{key:g,path:y,pos:a,value:void 0},s.localize(y))),f=!0),m=!0;break}i.restore()}if(1===_){if(w){c.fastSplice(e,a),--a,--d,m=!0;break}if(h.push(...u.errors),n.abortEarly)return h;f=!0;break}}if(!f&&(t.$_terms._inclusions.length&&!m)){if(w){c.fastSplice(e,a),--a,--d;continue}if(h.push(r("array.includes",{pos:a,value:o},s.localize(y))),n.abortEarly)return h}}return i.length&&c.fillMissedErrors(t,h,i,e,s,n),l.length&&c.fillOrderedErrors(t,h,l,e,s,n),h.length?h:e},priority:!0},length:{method(e){return this.$_addRule({name:"length",args:{limit:e},operator:"="})},validate:(e,t,{limit:r},{name:s,operator:n,args:a})=>o.compare(e.length,r,n)?e:t.error("array."+s,{limit:a.limit,value:e}),args:[{name:"limit",ref:!0,assert:o.limit,message:"must be a positive integer"}]},max:{method(e){return this.$_addRule({name:"max",method:"length",args:{limit:e},operator:"<="})}},min:{method(e){return this.$_addRule({name:"min",method:"length",args:{limit:e},operator:">="})}},ordered:{method(...e){o.verifyFlat(e,"ordered");const t=this.$_addRule("items");for(let r=0;r<e.length;++r){const s=o.tryWithPath((()=>this.$_compile(e[r])),r,{append:!0});c.validateSingle(s,t),t.$_mutateRegister(s),t.$_terms.ordered.push(s)}return t.$_mutateRebuild()}},single:{method(e){const t=void 0===e||!!e;return s(!t||!this._flags._arrayItems,"Cannot specify single rule when array has array items"),this.$_setFlag("single",t)}},sort:{method(e={}){o.assertOptions(e,["by","order"]);const t={order:e.order||"ascending"};return e.by&&(t.by=l.ref(e.by,{ancestor:0}),s(!t.by.ancestor,"Cannot sort by ancestor")),this.$_addRule({name:"sort",args:{options:t}})},validate(e,{error:t,state:r,prefs:s,schema:n},{options:a}){const{value:i,errors:o}=c.sort(n,e,a,r,s);if(o)return o;for(let r=0;r<e.length;++r)if(e[r]!==i[r])return t("array.sort",{order:a.order,by:a.by?a.by.key:"value"});return e},convert:!0},sparse:{method(e){const t=void 0===e||!!e;if(this._flags.sparse===t)return this;return(t?this.clone():this.$_addRule("items")).$_setFlag("sparse",t,{clone:!1})}},unique:{method(e,t={}){s(!e||"function"==typeof e||"string"==typeof e,"comparator must be a function or a string"),o.assertOptions(t,["ignoreUndefined","separator"]);const r={name:"unique",args:{options:t,comparator:e}};if(e)if("string"==typeof e){const s=o.default(t.separator,".");r.path=s?e.split(s):[e]}else r.comparator=e;return this.$_addRule(r)},validate(e,{state:t,error:r,schema:i},{comparator:o,options:l},{comparator:c,path:u}){const p={string:Object.create(null),number:Object.create(null),undefined:Object.create(null),boolean:Object.create(null),object:new Map,function:new Map,custom:new Map},h=c||n,d=l.ignoreUndefined;for(let n=0;n<e.length;++n){const i=u?a(e[n],u):e[n],l=c?p.custom:p[typeof i];if(s(l,"Failed to find unique map container for type",typeof i),l instanceof Map){const s=l.entries();let a;for(;!(a=s.next()).done;)if(h(a.value[0],i)){const s=t.localize([...t.path,n],[e,...t.ancestors]),i={pos:n,value:e[n],dupePos:a.value[1],dupeValue:e[a.value[1]]};return u&&(i.path=o),r("array.unique",i,s)}l.set(i,n)}else{if((!d||void 0!==i)&&void 0!==l[i]){const s={pos:n,value:e[n],dupePos:l[i],dupeValue:e[l[i]]};u&&(s.path=o);return r("array.unique",s,t.localize([...t.path,n],[e,...t.ancestors]))}l[i]=n}}return e},args:["comparator","options"],multi:!0}},cast:{set:{from:Array.isArray,to:(e,t)=>new Set(e)}},rebuild(e){e.$_terms._inclusions=[],e.$_terms._exclusions=[],e.$_terms._requireds=[];for(const t of e.$_terms.items)c.validateSingle(t,e),"required"===t._flags.presence?e.$_terms._requireds.push(t):"forbidden"===t._flags.presence?e.$_terms._exclusions.push(t):e.$_terms._inclusions.push(t);for(const t of e.$_terms.ordered)c.validateSingle(t,e)},messages:{"array.base":"{{#label}} must be an array","array.excludes":"{{#label}} contains an excluded value","array.hasUnknown":"{{#label}} does not contain at least one required match","array.includes":"{{#label}} does not match any of the allowed types","array.includesRequiredBoth":"{{#label}} does not contain {{#knownMisses}} and {{#unknownMisses}} other required value(s)","array.includesRequiredKnowns":"{{#label}} does not contain {{#knownMisses}}","array.includesRequiredUnknowns":"{{#label}} does not contain {{#unknownMisses}} required value(s)","array.length":"{{#label}} must contain {{#limit}} items","array.max":"{{#label}} must contain less than or equal to {{#limit}} items","array.min":"{{#label}} must contain at least {{#limit}} items","array.orderedLength":"{{#label}} must contain at most {{#limit}} items","array.sort":"{{#label}} must be sorted in {#order} order by {{#by}}","array.sort.mismatching":"{{#label}} cannot be sorted due to mismatching types","array.sort.unsupported":"{{#label}} cannot be sorted due to unsupported type {#type}","array.sparse":"{{#label}} must not be a sparse array item","array.unique":"{{#label}} contains a duplicate value"}}),c.fillMissedErrors=function(e,t,r,s,n,a){let i=0;for(let e=0;e<r.length;++e)++i;t.push(e.$_createError("array.includesRequiredUnknowns",s,{unknownMisses:i},n,a))},c.fillOrderedErrors=function(e,t,r,s,n,a){const i=[];for(const e of r)"required"===e._flags.presence&&i.push(e);i.length&&c.fillMissedErrors(e,t,i,s,n,a)},c.fastSplice=function(e,t){let r=t;for(;r<e.length;)e[r++]=e[r];--e.length},c.validateSingle=function(e,t){("array"===e.type||e._flags._arrayItems)&&(s(!t._flags.single,"Cannot specify array item with single rule enabled"),t.$_setFlag("_arrayItems",!0,{clone:!1}))},c.sort=function(e,t,r,s,n){const a="ascending"===r.order?1:-1,i=-1*a,o=a,l=(l,u)=>{let p=c.compare(l,u,i,o);if(null!==p)return p;if(r.by&&(l=r.by.resolve(l,s,n),u=r.by.resolve(u,s,n)),p=c.compare(l,u,i,o),null!==p)return p;const h=typeof l;if(h!==typeof u)throw e.$_createError("array.sort.mismatching",t,null,s,n);if("number"!==h&&"string"!==h)throw e.$_createError("array.sort.unsupported",t,{type:h},s,n);return"number"===h?(l-u)*a:l<u?i:o};try{return{value:t.slice().sort(l)}}catch(e){return{errors:e}}},c.compare=function(e,t,r,s){return e===t?0:void 0===e?1:void 0===t?-1:null===e?s:null===t?r:null}},(e,t,r)=>{const s=r(27),n=r(61),a=r(51),i=r(67),o={isBool:function(e){return"boolean"==typeof e}};e.exports=n._extend({type:"boolean",flags:{sensitive:{default:!1}},terms:{falsy:{init:null},truthy:{init:null}},coerce(e,{schema:t}){if("boolean"!=typeof e){if("string"==typeof e){const r=t._flags.sensitive?e:e.toLowerCase();e="true"===r||"false"!==r&&e}return"boolean"!=typeof e&&(e=t.$_terms.truthy&&t.$_terms.truthy.has(e,null,null,!t._flags.sensitive)||(!t.$_terms.falsy||!t.$_terms.falsy.has(e,null,null,!t._flags.sensitive))&&e),{value:e}}},validate(e,{error:t}){if("boolean"!=typeof e)return{value:e,errors:t("boolean.base")}},rules:{truthy:{method(...e){a.verifyFlat(e,"truthy");const t=this.clone();t.$_terms.truthy=t.$_terms.truthy||new i;for(let r=0;r<e.length;++r){const n=e[r];s(void 0!==n,"Cannot call truthy with undefined"),t.$_terms.truthy.add(n)}return t}},falsy:{method(...e){a.verifyFlat(e,"falsy");const t=this.clone();t.$_terms.falsy=t.$_terms.falsy||new i;for(let r=0;r<e.length;++r){const n=e[r];s(void 0!==n,"Cannot call falsy with undefined"),t.$_terms.falsy.add(n)}return t}},sensitive:{method(e=!0){return this.$_setFlag("sensitive",e)}}},cast:{number:{from:o.isBool,to:(e,t)=>e?1:0},string:{from:o.isBool,to:(e,t)=>e?"true":"false"}},messages:{"boolean.base":"{{#label}} must be a boolean"}})},(e,t,r)=>{const s=r(27),n=r(61),a=r(51),i=r(55),o={isDate:function(e){return e instanceof Date}};e.exports=n._extend({type:"date",coerce:{from:["number","string"],method:(e,{schema:t})=>({value:o.parse(e,t._flags.format)||e})},validate(e,{schema:t,error:r,prefs:s}){if(e instanceof Date&&!isNaN(e.getTime()))return;const n=t._flags.format;return s.convert&&n&&"string"==typeof e?{value:e,errors:r("date.format",{format:n})}:{value:e,errors:r("date.base")}},rules:{compare:{method:!1,validate(e,t,{date:r},{name:s,operator:n,args:i}){const o="now"===r?Date.now():r.getTime();return a.compare(e.getTime(),o,n)?e:t.error("date."+s,{limit:i.date,value:e})},args:[{name:"date",ref:!0,normalize:e=>"now"===e?e:o.parse(e),assert:e=>null!==e,message:"must have a valid date format"}]},format:{method(e){return s(["iso","javascript","unix"].includes(e),"Unknown date format",e),this.$_setFlag("format",e)}},greater:{method(e){return this.$_addRule({name:"greater",method:"compare",args:{date:e},operator:">"})}},iso:{method(){return this.format("iso")}},less:{method(e){return this.$_addRule({name:"less",method:"compare",args:{date:e},operator:"<"})}},max:{method(e){return this.$_addRule({name:"max",method:"compare",args:{date:e},operator:"<="})}},min:{method(e){return this.$_addRule({name:"min",method:"compare",args:{date:e},operator:">="})}},timestamp:{method(e="javascript"){return s(["javascript","unix"].includes(e),'"type" must be one of "javascript, unix"'),this.format(e)}}},cast:{number:{from:o.isDate,to:(e,t)=>e.getTime()},string:{from:o.isDate,to:(e,{prefs:t})=>i.date(e,t)}},messages:{"date.base":"{{#label}} must be a valid date","date.format":"{{#label}} must be in {{#format}} format","date.greater":"{{#label}} must be greater than {{:#limit}}","date.less":"{{#label}} must be less than {{:#limit}}","date.max":"{{#label}} must be less than or equal to {{:#limit}}","date.min":"{{#label}} must be greater than or equal to {{:#limit}}"}}),o.parse=function(e,t){if(e instanceof Date)return e;if("string"!=typeof e&&(isNaN(e)||!isFinite(e)))return null;if(/^\s*$/.test(e))return null;if("iso"===t)return a.isIsoDate(e)?o.date(e.toString()):null;const r=e;if("string"==typeof e&&/^[+-]?\d+(\.\d+)?$/.test(e)&&(e=parseFloat(e)),t){if("javascript"===t)return o.date(1*e);if("unix"===t)return o.date(1e3*e);if("string"==typeof r)return null}return o.date(e)},o.date=function(e){const t=new Date(e);return isNaN(t.getTime())?null:t}},(e,t,r)=>{const s=r(27),n=r(72);e.exports=n._extend({type:"function",properties:{typeof:"function"},rules:{arity:{method(e){return s(Number.isSafeInteger(e)&&e>=0,"n must be a positive integer"),this.$_addRule({name:"arity",args:{n:e}})},validate:(e,t,{n:r})=>e.length===r?e:t.error("function.arity",{n:r})},class:{method(){return this.$_addRule("class")},validate:(e,t)=>/^\s*class\s/.test(e.toString())?e:t.error("function.class",{value:e})},minArity:{method(e){return s(Number.isSafeInteger(e)&&e>0,"n must be a strict positive integer"),this.$_addRule({name:"minArity",args:{n:e}})},validate:(e,t,{n:r})=>e.length>=r?e:t.error("function.minArity",{n:r})},maxArity:{method(e){return s(Number.isSafeInteger(e)&&e>=0,"n must be a positive integer"),this.$_addRule({name:"maxArity",args:{n:e}})},validate:(e,t,{n:r})=>e.length<=r?e:t.error("function.maxArity",{n:r})}},messages:{"function.arity":"{{#label}} must have an arity of {{#n}}","function.class":"{{#label}} must be a class","function.maxArity":"{{#label}} must have an arity lesser or equal to {{#n}}","function.minArity":"{{#label}} must have an arity greater or equal to {{#n}}"}})},(e,t,r)=>{const s=r(26),n=r(27),a=r(30),i=r(73),o=r(61),l=r(51),c=r(57),u=r(58),p=r(56),h={renameDefaults:{alias:!1,multiple:!1,override:!1}};e.exports=o._extend({type:"_keys",properties:{typeof:"object"},flags:{unknown:{default:!1}},terms:{dependencies:{init:null},keys:{init:null},patterns:{init:null},renames:{init:null}},args:(e,t)=>e.keys(t),validate(e,{schema:t,error:r,state:s,prefs:n}){if(!e||typeof e!==t.$_property("typeof")||Array.isArray(e))return{value:e,errors:r("object.base",{type:t.$_property("typeof")})};if(!(t.$_terms.renames||t.$_terms.dependencies||t.$_terms.keys||t.$_terms.patterns))return;e=h.clone(e,n);const a=[];if(t.$_terms.renames&&!h.rename(t,e,s,n,a))return{value:e,errors:a};if(!t.$_terms.keys&&!t.$_terms.patterns&&!t.$_terms.dependencies)return{value:e,errors:a};const i=new Set(Object.keys(e));if(t.$_terms.keys){const r=[e,...s.ancestors];for(const o of t.$_terms.keys){const t=o.key,l=e[t];i.delete(t);const c=s.localize([...s.path,t],r,o),u=o.schema.$_validate(l,c,n);if(u.errors){if(n.abortEarly)return{value:e,errors:u.errors};a.push(...u.errors)}else"strip"===o.schema._flags.result||void 0===u.value&&void 0!==l?delete e[t]:void 0!==u.value&&(e[t]=u.value)}}if(i.size||t._flags._hasPatternMatch){const r=h.unknown(t,e,i,a,s,n);if(r)return r}if(t.$_terms.dependencies)for(const r of t.$_terms.dependencies){if(r.key&&void 0===r.key.resolve(e,s,n,null,{shadow:!1}))continue;const i=h.dependencies[r.rel](t,r,e,s,n);if(i){const r=t.$_createError(i.code,e,i.context,s,n);if(n.abortEarly)return{value:e,errors:r};a.push(r)}}return{value:e,errors:a}},rules:{and:{method(...e){return l.verifyFlat(e,"and"),h.dependency(this,"and",null,e)}},append:{method(e){return null==e||0===Object.keys(e).length?this:this.keys(e)}},assert:{method(e,t,r){e=c.ref(e),n(void 0===r||"string"==typeof r,"Message must be a string"),t=this.$_compile(t,{appendPath:!0});const s=this.$_addRule({name:"assert",args:{subject:e,schema:t,message:r}});return s.$_mutateRegister(e),s.$_mutateRegister(t),s},validate(e,{error:t,prefs:r,state:s},{subject:n,schema:a,message:i}){const o=n.resolve(e,s,r),l=n.absolute(s);return a.$_match(o,s.localize(l,[e,...s.ancestors],a),r)?e:t("object.assert",{subject:n,message:i})},args:["subject","schema","message"],multi:!0},instance:{method(e,t){return n("function"==typeof e,"constructor must be a function"),t=t||e.name,this.$_addRule({name:"instance",args:{constructor:e,name:t}})},validate:(e,t,{constructor:r,name:s})=>e instanceof r?e:t.error("object.instance",{type:s,value:e}),args:["constructor","name"]},keys:{method(e){n(void 0===e||"object"==typeof e,"Object schema must be a valid object"),n(!l.isSchema(e),"Object schema cannot be a joi schema");const t=this.clone();if(e)if(Object.keys(e).length){t.$_terms.keys=t.$_terms.keys?t.$_terms.keys.filter((t=>!e.hasOwnProperty(t.key))):new h.Keys;for(const r in e)l.tryWithPath((()=>t.$_terms.keys.push({key:r,schema:this.$_compile(e[r])})),r)}else t.$_terms.keys=new h.Keys;else t.$_terms.keys=null;return t.$_mutateRebuild()}},length:{method(e){return this.$_addRule({name:"length",args:{limit:e},operator:"="})},validate:(e,t,{limit:r},{name:s,operator:n,args:a})=>l.compare(Object.keys(e).length,r,n)?e:t.error("object."+s,{limit:a.limit,value:e}),args:[{name:"limit",ref:!0,assert:l.limit,message:"must be a positive integer"}]},max:{method(e){return this.$_addRule({name:"max",method:"length",args:{limit:e},operator:"<="})}},min:{method(e){return this.$_addRule({name:"min",method:"length",args:{limit:e},operator:">="})}},nand:{method(...e){return l.verifyFlat(e,"nand"),h.dependency(this,"nand",null,e)}},or:{method(...e){return l.verifyFlat(e,"or"),h.dependency(this,"or",null,e)}},oxor:{method(...e){return h.dependency(this,"oxor",null,e)}},pattern:{method(e,t,r={}){const s=e instanceof RegExp;s||(e=this.$_compile(e,{appendPath:!0})),n(void 0!==t,"Invalid rule"),l.assertOptions(r,["fallthrough","matches"]),s&&n(!e.flags.includes("g")&&!e.flags.includes("y"),"pattern should not use global or sticky mode"),t=this.$_compile(t,{appendPath:!0});const a=this.clone();a.$_terms.patterns=a.$_terms.patterns||[];const i={[s?"regex":"schema"]:e,rule:t};return r.matches&&(i.matches=this.$_compile(r.matches),"array"!==i.matches.type&&(i.matches=i.matches.$_root.array().items(i.matches)),a.$_mutateRegister(i.matches),a.$_setFlag("_hasPatternMatch",!0,{clone:!1})),r.fallthrough&&(i.fallthrough=!0),a.$_terms.patterns.push(i),a.$_mutateRegister(t),a}},ref:{method(){return this.$_addRule("ref")},validate:(e,t)=>p.isRef(e)?e:t.error("object.refType",{value:e})},regex:{method(){return this.$_addRule("regex")},validate:(e,t)=>e instanceof RegExp?e:t.error("object.regex",{value:e})},rename:{method(e,t,r={}){n("string"==typeof e||e instanceof RegExp,"Rename missing the from argument"),n("string"==typeof t,"Invalid rename to argument"),n(t!==e,"Cannot rename key to same name:",e),l.assertOptions(r,["alias","ignoreUndefined","override","multiple"]);const a=this.clone();a.$_terms.renames=a.$_terms.renames||[];for(const t of a.$_terms.renames)n(t.from!==e,"Cannot rename the same key multiple times");return a.$_terms.renames.push({from:e,to:t,options:s(h.renameDefaults,r)}),a}},schema:{method(e="any"){return this.$_addRule({name:"schema",args:{type:e}})},validate:(e,t,{type:r})=>!l.isSchema(e)||"any"!==r&&e.type!==r?t.error("object.schema",{type:r}):e},unknown:{method(e){return this.$_setFlag("unknown",!1!==e)}},with:{method(e,t,r={}){return h.dependency(this,"with",e,t,r)}},without:{method(e,t,r={}){return h.dependency(this,"without",e,t,r)}},xor:{method(...e){return l.verifyFlat(e,"xor"),h.dependency(this,"xor",null,e)}}},overrides:{default(e,t){return void 0===e&&(e=l.symbols.deepDefault),this.$_parent("default",e,t)}},rebuild(e){if(e.$_terms.keys){const t=new i.Sorter;for(const r of e.$_terms.keys)l.tryWithPath((()=>t.add(r,{after:r.schema.$_rootReferences(),group:r.key})),r.key);e.$_terms.keys=new h.Keys(...t.nodes)}},messages:{"object.and":"{{#label}} contains {{#present}} without its required peers {{#missing}}","object.assert":"{{#label}} is invalid because it failed to pass the assertion test","object.base":"{{#label}} must be of type {{#type}}","object.instance":"{{#label}} must be an instance of {{:#type}}","object.length":"{{#label}} must have {{#limit}} keys","object.max":"{{#label}} must have less than or equal to {{#limit}} keys","object.min":"{{#label}} must have at least {{#limit}} keys","object.missing":"{{#label}} must contain at least one of {{#peers}}","object.nand":"{{:#main}} must not exist simultaneously with {{#peers}}","object.oxor":"{{#label}} contains a conflict between optional exclusive peers {{#peers}}","object.pattern.match":"{{#label}} keys failed to match pattern requirements","object.refType":"{{#label}} must be a Joi reference","object.regex":"{{#label}} must be a RegExp object","object.rename.multiple":"{{#label}} cannot rename {{:#from}} because multiple renames are disabled and another key was already renamed to {{:#to}}","object.rename.override":"{{#label}} cannot rename {{:#from}} because override is disabled and target {{:#to}} exists","object.schema":"{{#label}} must be a Joi schema of {{#type}} type","object.unknown":"{{#label}} is not allowed","object.with":"{{:#main}} missing required peer {{:#peer}}","object.without":"{{:#main}} conflict with forbidden peer {{:#peer}}","object.xor":"{{#label}} contains a conflict between exclusive peers {{#peers}}"}}),h.clone=function(e,t){if("object"==typeof e){if(t.nonEnumerables)return a(e,{shallow:!0});const r=Object.create(Object.getPrototypeOf(e));return Object.assign(r,e),r}const r=function(...t){return e.apply(this,t)};return r.prototype=a(e.prototype),Object.defineProperty(r,"name",{value:e.name,writable:!1}),Object.defineProperty(r,"length",{value:e.length,writable:!1}),Object.assign(r,e),r},h.dependency=function(e,t,r,s,a){n(null===r||"string"==typeof r,t,"key must be a strings"),a||(a=s.length>1&&"object"==typeof s[s.length-1]?s.pop():{}),l.assertOptions(a,["separator"]),s=[].concat(s);const i=l.default(a.separator,"."),o=[];for(const e of s)n("string"==typeof e,t,"peers must be a string or a reference"),o.push(c.ref(e,{separator:i,ancestor:0,prefix:!1}));null!==r&&(r=c.ref(r,{separator:i,ancestor:0,prefix:!1}));const u=e.clone();return u.$_terms.dependencies=u.$_terms.dependencies||[],u.$_terms.dependencies.push(new h.Dependency(t,r,o,s)),u},h.dependencies={and(e,t,r,s,n){const a=[],i=[],o=t.peers.length;for(const e of t.peers)void 0===e.resolve(r,s,n,null,{shadow:!1})?a.push(e.key):i.push(e.key);if(a.length!==o&&i.length!==o)return{code:"object.and",context:{present:i,missing:a}}},nand(e,t,r,s,n){const a=[];for(const e of t.peers)void 0!==e.resolve(r,s,n,null,{shadow:!1})&&a.push(e.key);if(a.length!==t.peers.length)return;return{code:"object.nand",context:{main:t.paths[0],peers:t.paths.slice(1)}}},or(e,t,r,s,n){for(const e of t.peers)if(void 0!==e.resolve(r,s,n,null,{shadow:!1}))return;return{code:"object.missing",context:{peers:t.paths}}},oxor(e,t,r,s,n){const a=[];for(const e of t.peers)void 0!==e.resolve(r,s,n,null,{shadow:!1})&&a.push(e.key);if(!a.length||1===a.length)return;const i={peers:t.paths};return i.present=a,{code:"object.oxor",context:i}},with(e,t,r,s,n){for(const e of t.peers)if(void 0===e.resolve(r,s,n,null,{shadow:!1}))return{code:"object.with",context:{main:t.key.key,peer:e.key}}},without(e,t,r,s,n){for(const e of t.peers)if(void 0!==e.resolve(r,s,n,null,{shadow:!1}))return{code:"object.without",context:{main:t.key.key,peer:e.key}}},xor(e,t,r,s,n){const a=[];for(const e of t.peers)void 0!==e.resolve(r,s,n,null,{shadow:!1})&&a.push(e.key);if(1===a.length)return;const i={peers:t.paths};return 0===a.length?{code:"object.missing",context:i}:(i.present=a,{code:"object.xor",context:i})}},h.rename=function(e,t,r,s,n){const a={};for(const i of e.$_terms.renames){const o=[],l="string"!=typeof i.from;if(l)for(const e in t){if(void 0===t[e]&&i.options.ignoreUndefined)continue;if(e===i.to)continue;const r=i.from.exec(e);r&&o.push({from:e,to:i.to,match:r})}else!Object.prototype.hasOwnProperty.call(t,i.from)||void 0===t[i.from]&&i.options.ignoreUndefined||o.push(i);for(const c of o){const o=c.from,u=c.to;if(!i.options.multiple&&a[u]&&(n.push(e.$_createError("object.rename.multiple",t,{from:o,to:u,pattern:l},r,s)),s.abortEarly))return!1;if(Object.prototype.hasOwnProperty.call(t,u)&&!i.options.override&&!a[u]&&(n.push(e.$_createError("object.rename.override",t,{from:o,to:u,pattern:l},r,s)),s.abortEarly))return!1;void 0===t[o]?delete t[u]:t[u]=t[o],a[u]=!0,i.options.alias||delete t[o]}}return!0},h.unknown=function(e,t,r,s,n,a){if(e.$_terms.patterns){let i=!1;const o=e.$_terms.patterns.map((e=>{if(e.matches)return i=!0,[]})),l=[t,...n.ancestors];for(const i of r){const c=t[i],u=[...n.path,i];for(let p=0;p<e.$_terms.patterns.length;++p){const h=e.$_terms.patterns[p];if(h.regex){if(!h.regex.test(i))continue}else if(!h.schema.$_match(i,n.nest(h.schema,`pattern.${p}`),a))continue;r.delete(i);const d=n.localize(u,l,{schema:h.rule,key:i}),f=h.rule.$_validate(c,d,a);if(f.errors){if(a.abortEarly)return{value:t,errors:f.errors};s.push(...f.errors)}if(h.matches&&o[p].push(i),t[i]=f.value,!h.fallthrough)break}}if(i)for(let r=0;r<o.length;++r){const i=o[r];if(!i)continue;const c=e.$_terms.patterns[r].matches,p=n.localize(n.path,l,c),h=c.$_validate(i,p,a);if(h.errors){const r=u.details(h.errors,{override:!1});r.matches=i;const o=e.$_createError("object.pattern.match",t,r,n,a);if(a.abortEarly)return{value:t,errors:o};s.push(o)}}}if(!r.size||!e.$_terms.keys&&!e.$_terms.patterns)return;if(a.stripUnknown&&!e._flags.unknown||a.skipFunctions){const e=!!a.stripUnknown&&(!0===a.stripUnknown||!!a.stripUnknown.objects);for(const s of r)e?(delete t[s],r.delete(s)):"function"==typeof t[s]&&r.delete(s)}if(!l.default(e._flags.unknown,a.allowUnknown))for(const i of r){const r=n.localize([...n.path,i],[]),o=e.$_createError("object.unknown",t[i],{child:i},r,a,{flags:!1});if(a.abortEarly)return{value:t,errors:o};s.push(o)}},h.Dependency=class{constructor(e,t,r,s){this.rel=e,this.key=t,this.peers=r,this.paths=s}},h.Keys=class extends Array{concat(e){const t=this.slice(),r=new Map;for(let e=0;e<t.length;++e)r.set(t[e].key,e);for(const s of e){const e=s.key,n=r.get(e);void 0!==n?t[n]={key:e,schema:t[n].schema.concat(s.schema)}:t.push(s)}return t}}},(e,t,r)=>{const{assert:s}=r(25),n={};t.Sorter=class{constructor(){this._items=[],this.nodes=[]}add(e,t){const r=[].concat((t=t??{}).before??[]),n=[].concat(t.after??[]),a=t.group??"?",i=t.sort??0;s(!r.includes(a),`Item cannot come before itself: ${a}`),s(!r.includes("?"),"Item cannot come before unassociated items"),s(!n.includes(a),`Item cannot come after itself: ${a}`),s(!n.includes("?"),"Item cannot come after unassociated items"),Array.isArray(e)||(e=[e]);for(const t of e){const e={seq:this._items.length,sort:i,before:r,after:n,group:a,node:t};this._items.push(e)}if(!t.manual){const e=this._sort();s(e,"item","?"!==a?`added into group ${a}`:"","created a dependencies error")}return this.nodes}merge(e){Array.isArray(e)||(e=[e]);for(const t of e)if(t)for(const e of t._items)this._items.push(Object.assign({},e));this._items.sort(n.mergeSort);for(let e=0;e<this._items.length;++e)this._items[e].seq=e;const t=this._sort();return s(t,"merge created a dependencies error"),this.nodes}sort(){const e=this._sort();return s(e,"sort created a dependencies error"),this.nodes}_sort(){const e={},t=Object.create(null),r=Object.create(null);for(const s of this._items){const n=s.seq,a=s.group;r[a]=r[a]??[],r[a].push(n),e[n]=s.before;for(const e of s.after)t[e]=t[e]??[],t[e].push(n)}for(const t in e){const s=[];for(const n in e[t]){const a=e[t][n];r[a]=r[a]??[],s.push(...r[a])}e[t]=s}for(const s in t)if(r[s])for(const n of r[s])e[n].push(...t[s]);const s={};for(const t in e){const r=e[t];for(const e of r)s[e]=s[e]??[],s[e].push(t)}const n={},a=[];for(let e=0;e<this._items.length;++e){let t=e;if(s[e]){t=null;for(let e=0;e<this._items.length;++e){if(!0===n[e])continue;s[e]||(s[e]=[]);const r=s[e].length;let a=0;for(let t=0;t<r;++t)n[s[e][t]]&&++a;if(a===r){t=e;break}}}null!==t&&(n[t]=!0,a.push(t))}if(a.length!==this._items.length)return!1;const i={};for(const e of this._items)i[e.seq]=e;this._items=[],this.nodes=[];for(const e of a){const t=i[e];this.nodes.push(t.node),this._items.push(t)}return!0}},n.mergeSort=(e,t)=>e.sort===t.sort?0:e.sort<t.sort?-1:1},(e,t,r)=>{const s=r(27),n=r(61),a=r(51),i=r(57),o=r(58),l={};e.exports=n._extend({type:"link",properties:{schemaChain:!0},terms:{link:{init:null,register:!1}},args:(e,t)=>e.ref(t),validate(e,{schema:t,state:r,prefs:n}){s(t.$_terms.link,"Uninitialized link schema");const a=l.generate(t,e,r,n),i=t.$_terms.link[0].ref;return a.$_validate(e,r.nest(a,`link:${i.display}:${a.type}`),n)},generate:(e,t,r,s)=>l.generate(e,t,r,s),rules:{ref:{method(e){s(!this.$_terms.link,"Cannot reinitialize schema"),e=i.ref(e),s("value"===e.type||"local"===e.type,"Invalid reference type:",e.type),s("local"===e.type||"root"===e.ancestor||e.ancestor>0,"Link cannot reference itself");const t=this.clone();return t.$_terms.link=[{ref:e}],t}},relative:{method(e=!0){return this.$_setFlag("relative",e)}}},overrides:{concat(e){s(this.$_terms.link,"Uninitialized link schema"),s(a.isSchema(e),"Invalid schema object"),s("link"!==e.type,"Cannot merge type link with another link");const t=this.clone();return t.$_terms.whens||(t.$_terms.whens=[]),t.$_terms.whens.push({concat:e}),t.$_mutateRebuild()}}}),l.generate=function(e,t,r,s){let n=r.mainstay.links.get(e);if(n)return n._generate(t,r,s).schema;const a=e.$_terms.link[0].ref,{perspective:i,path:o}=l.perspective(a,r);l.assert(i,"which is outside of schema boundaries",a,e,r,s);try{n=o.length?i.$_reach(o):i}catch(t){l.assert(!1,"to non-existing schema",a,e,r,s)}return l.assert("link"!==n.type,"which is another link",a,e,r,s),e._flags.relative||r.mainstay.links.set(e,n),n._generate(t,r,s).schema},l.perspective=function(e,t){if("local"===e.type){for(const{schema:r,key:s}of t.schemas){if((r._flags.id||s)===e.path[0])return{perspective:r,path:e.path.slice(1)};if(r.$_terms.shared)for(const t of r.$_terms.shared)if(t._flags.id===e.path[0])return{perspective:t,path:e.path.slice(1)}}return{perspective:null,path:null}}return"root"===e.ancestor?{perspective:t.schemas[t.schemas.length-1].schema,path:e.path}:{perspective:t.schemas[e.ancestor]&&t.schemas[e.ancestor].schema,path:e.path}},l.assert=function(e,t,r,n,a,i){e||s(!1,`"${o.label(n._flags,a,i)}" contains link reference "${r.display}" ${t}`)}},(e,t,r)=>{const s=r(27),n=r(61),a=r(51),i={numberRx:/^\s*[+-]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:e([+-]?\d+))?\s*$/i,precisionRx:/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/};e.exports=n._extend({type:"number",flags:{unsafe:{default:!1}},coerce:{from:"string",method(e,{schema:t,error:r}){const s=e.match(i.numberRx);if(!s)return;e=e.trim();const n={value:parseFloat(e)};if(0===n.value&&(n.value=0),!t._flags.unsafe)if(e.match(/e/i)){if(i.normalizeExponent(`${n.value/Math.pow(10,s[1])}e${s[1]}`)!==i.normalizeExponent(e))return n.errors=r("number.unsafe"),n}else{const t=n.value.toString();if(t.match(/e/i))return n;if(t!==i.normalizeDecimal(e))return n.errors=r("number.unsafe"),n}return n}},validate(e,{schema:t,error:r,prefs:s}){if(e===1/0||e===-1/0)return{value:e,errors:r("number.infinity")};if(!a.isNumber(e))return{value:e,errors:r("number.base")};const n={value:e};if(s.convert){const e=t.$_getRule("precision");if(e){const t=Math.pow(10,e.args.limit);n.value=Math.round(n.value*t)/t}}return 0===n.value&&(n.value=0),!t._flags.unsafe&&(e>Number.MAX_SAFE_INTEGER||e<Number.MIN_SAFE_INTEGER)&&(n.errors=r("number.unsafe")),n},rules:{compare:{method:!1,validate:(e,t,{limit:r},{name:s,operator:n,args:i})=>a.compare(e,r,n)?e:t.error("number."+s,{limit:i.limit,value:e}),args:[{name:"limit",ref:!0,assert:a.isNumber,message:"must be a number"}]},greater:{method(e){return this.$_addRule({name:"greater",method:"compare",args:{limit:e},operator:">"})}},integer:{method(){return this.$_addRule("integer")},validate:(e,t)=>Math.trunc(e)-e==0?e:t.error("number.integer")},less:{method(e){return this.$_addRule({name:"less",method:"compare",args:{limit:e},operator:"<"})}},max:{method(e){return this.$_addRule({name:"max",method:"compare",args:{limit:e},operator:"<="})}},min:{method(e){return this.$_addRule({name:"min",method:"compare",args:{limit:e},operator:">="})}},multiple:{method(e){return this.$_addRule({name:"multiple",args:{base:e}})},validate:(e,t,{base:r},s)=>e%r==0?e:t.error("number.multiple",{multiple:s.args.base,value:e}),args:[{name:"base",ref:!0,assert:e=>"number"==typeof e&&isFinite(e)&&e>0,message:"must be a positive number"}],multi:!0},negative:{method(){return this.sign("negative")}},port:{method(){return this.$_addRule("port")},validate:(e,t)=>Number.isSafeInteger(e)&&e>=0&&e<=65535?e:t.error("number.port")},positive:{method(){return this.sign("positive")}},precision:{method(e){return s(Number.isSafeInteger(e),"limit must be an integer"),this.$_addRule({name:"precision",args:{limit:e}})},validate(e,t,{limit:r}){const s=e.toString().match(i.precisionRx);return Math.max((s[1]?s[1].length:0)-(s[2]?parseInt(s[2],10):0),0)<=r?e:t.error("number.precision",{limit:r,value:e})},convert:!0},sign:{method(e){return s(["negative","positive"].includes(e),"Invalid sign",e),this.$_addRule({name:"sign",args:{sign:e}})},validate:(e,t,{sign:r})=>"negative"===r&&e<0||"positive"===r&&e>0?e:t.error(`number.${r}`)},unsafe:{method(e=!0){return s("boolean"==typeof e,"enabled must be a boolean"),this.$_setFlag("unsafe",e)}}},cast:{string:{from:e=>"number"==typeof e,to:(e,t)=>e.toString()}},messages:{"number.base":"{{#label}} must be a number","number.greater":"{{#label}} must be greater than {{#limit}}","number.infinity":"{{#label}} cannot be infinity","number.integer":"{{#label}} must be an integer","number.less":"{{#label}} must be less than {{#limit}}","number.max":"{{#label}} must be less than or equal to {{#limit}}","number.min":"{{#label}} must be greater than or equal to {{#limit}}","number.multiple":"{{#label}} must be a multiple of {{#multiple}}","number.negative":"{{#label}} must be a negative number","number.port":"{{#label}} must be a valid port","number.positive":"{{#label}} must be a positive number","number.precision":"{{#label}} must have no more than {{#limit}} decimal places","number.unsafe":"{{#label}} must be a safe number"}}),i.normalizeExponent=function(e){return e.replace(/E/,"e").replace(/\.(\d*[1-9])?0+e/,".$1e").replace(/\.e/,"e").replace(/e\+/,"e").replace(/^\+/,"").replace(/^(-?)0+([1-9])/,"$1$2")},i.normalizeDecimal=function(e){return(e=e.replace(/^\+/,"").replace(/\.0+$/,"").replace(/^(-?)\.([^\.]*)$/,"$10.$2").replace(/^(-?)0+([1-9])/,"$1$2")).includes(".")&&e.endsWith("0")&&(e=e.replace(/0+$/,"")),"-0"===e?"0":e}},(e,t,r)=>{const s=r(72);e.exports=s._extend({type:"object",cast:{map:{from:e=>e&&"object"==typeof e,to:(e,t)=>new Map(Object.entries(e))}}})},(e,t,r)=>{var s=r(14).Buffer;const n=r(9),a=r(27),i=r(40),o=r(61),l=r(51),c={base64Regex:{true:{true:/^(?:[\w\-]{2}[\w\-]{2})*(?:[\w\-]{2}==|[\w\-]{3}=)?$/,false:/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/},false:{true:/^(?:[\w\-]{2}[\w\-]{2})*(?:[\w\-]{2}(==)?|[\w\-]{3}=?)?$/,false:/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}(==)?|[A-Za-z0-9+\/]{3}=?)?$/}},dataUriRegex:/^data:[\w+.-]+\/[\w+.-]+;((charset=[\w-]+|base64),)?(.*)$/,hexRegex:/^[a-f0-9]+$/i,isoDurationRegex:/^P(?!$)(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?$/,guidBrackets:{"{":"}","[":"]","(":")","":""},guidVersions:{uuidv1:"1",uuidv2:"2",uuidv3:"3",uuidv4:"4",uuidv5:"5"},guidSeparators:new Set([void 0,!0,!1,"-",":"]),normalizationForms:["NFC","NFD","NFKC","NFKD"],domainControlRx:/[\x00-\x20@\:\/]/,domainSegmentRx:/^[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,finalSegmentAdditionalRx:/[^0-9]/};e.exports=o._extend({type:"string",flags:{insensitive:{default:!1},truncate:{default:!1}},terms:{replacements:{init:null}},coerce:{from:"string",method(e,{schema:t,state:r,prefs:s}){const n=t.$_getRule("normalize");n&&(e=e.normalize(n.args.form));const a=t.$_getRule("case");a&&(e="upper"===a.args.direction?e.toLocaleUpperCase():e.toLocaleLowerCase());const i=t.$_getRule("trim");if(i&&i.args.enabled&&(e=e.trim()),t.$_terms.replacements)for(const r of t.$_terms.replacements)e=e.replace(r.pattern,r.replacement);const o=t.$_getRule("hex");if(o&&o.args.options.byteAligned&&e.length%2!=0&&(e=`0${e}`),t.$_getRule("isoDate")){const t=c.isoDate(e);t&&(e=t)}if(t._flags.truncate){const n=t.$_getRule("max");if(n){let a=n.args.limit;if(l.isResolvable(a)&&(a=a.resolve(e,r,s),!l.limit(a)))return{value:e,errors:t.$_createError("any.ref",a,{ref:n.args.limit,arg:"limit",reason:"must be a positive integer"},r,s)};e=e.slice(0,a)}}return{value:e}}},validate:(e,{error:t})=>"string"!=typeof e?{value:e,errors:t("string.base")}:""===e?{value:e,errors:t("string.empty")}:void 0,rules:{alphanum:{method(){return this.$_addRule("alphanum")},validate:(e,t)=>/^[a-zA-Z0-9]+$/.test(e)?e:t.error("string.alphanum")},base64:{method(e={}){return l.assertOptions(e,["paddingRequired","urlSafe"]),e={urlSafe:!1,paddingRequired:!0,...e},a("boolean"==typeof e.paddingRequired,"paddingRequired must be boolean"),a("boolean"==typeof e.urlSafe,"urlSafe must be boolean"),this.$_addRule({name:"base64",args:{options:e}})},validate:(e,t,{options:r})=>c.base64Regex[r.paddingRequired][r.urlSafe].test(e)?e:t.error("string.base64")},case:{method(e){return a(["lower","upper"].includes(e),"Invalid case:",e),this.$_addRule({name:"case",args:{direction:e}})},validate:(e,t,{direction:r})=>"lower"===r&&e===e.toLocaleLowerCase()||"upper"===r&&e===e.toLocaleUpperCase()?e:t.error(`string.${r}case`),convert:!0},creditCard:{method(){return this.$_addRule("creditCard")},validate(e,t){let r=e.length,s=0,n=1;for(;r--;){const t=e.charAt(r)*n;s+=t-9*(t>9),n^=3}return s>0&&s%10==0?e:t.error("string.creditCard")}},dataUri:{method(e={}){return l.assertOptions(e,["paddingRequired"]),e={paddingRequired:!0,...e},a("boolean"==typeof e.paddingRequired,"paddingRequired must be boolean"),this.$_addRule({name:"dataUri",args:{options:e}})},validate(e,t,{options:r}){const s=e.match(c.dataUriRegex);if(s){if(!s[2])return e;if("base64"!==s[2])return e;if(c.base64Regex[r.paddingRequired].false.test(s[3]))return e}return t.error("string.dataUri")}},guid:{alias:"uuid",method(e={}){l.assertOptions(e,["version","separator"]);let t="";if(e.version){const r=[].concat(e.version);a(r.length>=1,"version must have at least 1 valid version specified");const s=new Set;for(let e=0;e<r.length;++e){const n=r[e];a("string"==typeof n,"version at position "+e+" must be a string");const i=c.guidVersions[n.toLowerCase()];a(i,"version at position "+e+" must be one of "+Object.keys(c.guidVersions).join(", ")),a(!s.has(i),"version at position "+e+" must not be a duplicate"),t+=i,s.add(i)}}a(c.guidSeparators.has(e.separator),'separator must be one of true, false, "-", or ":"');const r=void 0===e.separator?"[:-]?":!0===e.separator?"[:-]":!1===e.separator?"[]?":`\\${e.separator}`,s=new RegExp(`^([\\[{\\(]?)[0-9A-F]{8}(${r})[0-9A-F]{4}\\2?[${t||"0-9A-F"}][0-9A-F]{3}\\2?[${t?"89AB":"0-9A-F"}][0-9A-F]{3}\\2?[0-9A-F]{12}([\\]}\\)]?)$`,"i");return this.$_addRule({name:"guid",args:{options:e},regex:s})},validate(e,t,r,{regex:s}){const n=s.exec(e);return n?c.guidBrackets[n[1]]!==n[n.length-1]?t.error("string.guid"):e:t.error("string.guid")}},hex:{method(e={}){return l.assertOptions(e,["byteAligned"]),e={byteAligned:!1,...e},a("boolean"==typeof e.byteAligned,"byteAligned must be boolean"),this.$_addRule({name:"hex",args:{options:e}})},validate:(e,t,{options:r})=>c.hexRegex.test(e)?r.byteAligned&&e.length%2!=0?t.error("string.hexAlign"):e:t.error("string.hex")},hostname:{method(){return this.$_addRule("hostname")},validate:(e,t)=>c.isDomainValid(e)||c.ipRegex.test(e)?e:t.error("string.hostname")},insensitive:{method(){return this.$_setFlag("insensitive",!0)}},isoDate:{method(){return this.$_addRule("isoDate")},validate:(e,{error:t})=>c.isoDate(e)?e:t("string.isoDate")},isoDuration:{method(){return this.$_addRule("isoDuration")},validate:(e,t)=>c.isoDurationRegex.test(e)?e:t.error("string.isoDuration")},length:{method(e,t){return c.length(this,"length",e,"=",t)},validate(e,t,{limit:r,encoding:n},{name:a,operator:i,args:o}){const c=n?s&&s.byteLength(e,n):e.length;return l.compare(c,r,i)?e:t.error("string."+a,{limit:o.limit,value:e,encoding:n})},args:[{name:"limit",ref:!0,assert:l.limit,message:"must be a positive integer"},"encoding"]},lowercase:{method(){return this.case("lower")}},max:{method(e,t){return c.length(this,"max",e,"<=",t)},args:["limit","encoding"]},min:{method(e,t){return c.length(this,"min",e,">=",t)},args:["limit","encoding"]},normalize:{method(e="NFC"){return a(c.normalizationForms.includes(e),"normalization form must be one of "+c.normalizationForms.join(", ")),this.$_addRule({name:"normalize",args:{form:e}})},validate:(e,{error:t},{form:r})=>e===e.normalize(r)?e:t("string.normalize",{value:e,form:r}),convert:!0},pattern:{alias:"regex",method(e,t={}){a(e instanceof RegExp,"regex must be a RegExp"),a(!e.flags.includes("g")&&!e.flags.includes("y"),"regex should not use global or sticky mode"),"string"==typeof t&&(t={name:t}),l.assertOptions(t,["invert","name"]);const r=["string.pattern",t.invert?".invert":"",t.name?".name":".base"].join("");return this.$_addRule({name:"pattern",args:{regex:e,options:t},errorCode:r})},validate:(e,t,{regex:r,options:s},{errorCode:n})=>r.test(e)^s.invert?e:t.error(n,{name:s.name,regex:r,value:e}),args:["regex","options"],multi:!0},replace:{method(e,t){"string"==typeof e&&(e=new RegExp(i(e),"g")),a(e instanceof RegExp,"pattern must be a RegExp"),a("string"==typeof t,"replacement must be a String");const r=this.clone();return r.$_terms.replacements||(r.$_terms.replacements=[]),r.$_terms.replacements.push({pattern:e,replacement:t}),r}},token:{method(){return this.$_addRule("token")},validate:(e,t)=>/^\w+$/.test(e)?e:t.error("string.token")},trim:{method(e=!0){return a("boolean"==typeof e,"enabled must be a boolean"),this.$_addRule({name:"trim",args:{enabled:e}})},validate:(e,t,{enabled:r})=>r&&e!==e.trim()?t.error("string.trim"):e,convert:!0},truncate:{method(e=!0){return a("boolean"==typeof e,"enabled must be a boolean"),this.$_setFlag("truncate",e)}},uppercase:{method(){return this.case("upper")}}},messages:{"string.alphanum":"{{#label}} must only contain alpha-numeric characters","string.base":"{{#label}} must be a string","string.base64":"{{#label}} must be a valid base64 string","string.creditCard":"{{#label}} must be a credit card","string.dataUri":"{{#label}} must be a valid dataUri string","string.empty":"{{#label}} is not allowed to be empty","string.guid":"{{#label}} must be a valid GUID","string.hex":"{{#label}} must only contain hexadecimal characters","string.hexAlign":"{{#label}} hex decoded representation must be byte aligned","string.hostname":"{{#label}} must be a valid hostname","string.isoDate":"{{#label}} must be in iso format","string.isoDuration":"{{#label}} must be a valid ISO 8601 duration","string.length":"{{#label}} length must be {{#limit}} characters long","string.lowercase":"{{#label}} must only contain lowercase characters","string.max":"{{#label}} length must be less than or equal to {{#limit}} characters long","string.min":"{{#label}} length must be at least {{#limit}} characters long","string.normalize":"{{#label}} must be unicode normalized in the {{#form}} form","string.token":"{{#label}} must only contain alpha-numeric and underscore characters","string.pattern.base":"{{#label}} with value {:.} fails to match the required pattern: {{#regex}}","string.pattern.name":"{{#label}} with value {:.} fails to match the {{#name}} pattern","string.pattern.invert.base":"{{#label}} with value {:.} matches the inverted pattern: {{#regex}}","string.pattern.invert.name":"{{#label}} with value {:.} matches the inverted {{#name}} pattern","string.trim":"{{#label}} must not have leading or trailing whitespace","string.uppercase":"{{#label}} must only contain uppercase characters"}}),c.isoDate=function(e){if(!l.isIsoDate(e))return null;const t=new Date(e);return isNaN(t.getTime())?null:t.toISOString()},c.length=function(e,t,r,n,i){return a(!i||s&&s.isEncoding(i),"Invalid encoding:",i),e.$_addRule({name:t,method:"length",args:{limit:r,encoding:i},operator:n})},c.rfc3986=function(){const e={},t="[\\dA-Fa-f]",r="(?:0{0,2}\\d|0?[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])";e.ipv4="(?:"+r+"\\.){3}"+r;const s=t+"{1,4}",n="(?:"+s+":"+s+"|"+e.ipv4+")",a="(?:"+s+":){6}"+n,i="::(?:"+s+":){5}"+n,o="(?:"+s+")?::(?:"+s+":){4}"+n,l="(?:(?:"+s+":){0,1}"+s+")?::(?:"+s+":){3}"+n,c="(?:(?:"+s+":){0,2}"+s+")?::(?:"+s+":){2}"+n,u="(?:(?:"+s+":){0,3}"+s+")?::"+s+":"+n,p="(?:(?:"+s+":){0,4}"+s+")?::"+n,h="(?:(?:"+s+":){0,5}"+s+")?::"+s,d="(?:(?:"+s+":){0,6}"+s+")?::";return e.v4Cidr="(?:\\d|[1-2]\\d|3[0-2])",e.v6Cidr="(?:0{0,2}\\d|0?[1-9]\\d|1[01]\\d|12[0-8])",e.ipv6="(?:"+a+"|"+i+"|"+o+"|"+l+"|"+c+"|"+u+"|"+p+"|"+h+"|"+d+")",e.ipvfuture="v"+t+"+\\.[\\w-\\.~!\\$&'\\(\\)\\*\\+,;=:]+",e},c.ipRegex=function(){const e=c.rfc3986(),t=`(?:${["ipv4","ipv6","ipvfuture"].map((t=>{const r=`\\/${"ipv4"===t?e.v4Cidr:e.v6Cidr}`;return`${e[t]}(?:${r})?`})).join("|")})`;return new RegExp(`^${t}$`)}(),c.isDomainValid=function(e){if(e.length>256)return!1;if(e=e.normalize("NFC"),c.domainControlRx.test(e))return!1;const t=(e=c.punycode(e)).split(".");for(let e=0;e<t.length;++e){const r=t[e];if(!r.length)return!1;if(r.length>63)return!1;if(!c.domainSegmentRx.test(r))return!1;if(e===t.length-1&&!c.finalSegmentAdditionalRx.test(r))return!1}return!0},c.punycode=function(e){try{return new n.URL(`http://${e}`).host}catch(t){return e}}},(e,t,r)=>{const s=r(27),n=r(61),a={};a.Map=class extends Map{slice(){return new a.Map(this)}},e.exports=n._extend({type:"symbol",terms:{map:{init:new a.Map}},coerce:{method(e,{schema:t,error:r}){const s=t.$_terms.map.get(e);return s&&(e=s),t._flags.only&&"symbol"!=typeof e?{value:e,errors:r("symbol.map",{map:t.$_terms.map})}:{value:e}}},validate(e,{error:t}){if("symbol"!=typeof e)return{value:e,errors:t("symbol.base")}},rules:{map:{method(e){e&&!e[Symbol.iterator]&&"object"==typeof e&&(e=Object.entries(e)),s(e&&e[Symbol.iterator],"Iterable must be an iterable or object");const t=this.clone(),r=[];for(const n of e){s(n&&n[Symbol.iterator],"Entry must be an iterable");const[e,a]=n;s("object"!=typeof e&&"function"!=typeof e&&"symbol"!=typeof e,"Key must not be of type object, function, or Symbol"),s("symbol"==typeof a,"Value must be a Symbol"),t.$_terms.map.set(e,a),r.push(a)}return t.valid(...r)}}},messages:{"symbol.base":"{{#label}} must be a symbol","symbol.map":"{{#label}} must be one of {{#map}}"}})},(e,t,r)=>{var s=r(14).Buffer;const n=r(27),a=r(61),i=r(51);e.exports=a._extend({type:"binary",coerce:{from:"string",method(e,{schema:t}){try{return{value:s.from(e,t._flags.encoding)}}catch(e){}}},validate(e,{error:t}){if(!s.isBuffer(e))return{value:e,errors:t("binary.base")}},rules:{encoding:{method(e){return n(s.isEncoding(e),"Invalid encoding:",e),this.$_setFlag("encoding",e)}},length:{method(e){return this.$_addRule({name:"length",method:"length",args:{limit:e},operator:"="})},validate:(e,t,{limit:r},{name:s,operator:n,args:a})=>i.compare(e.length,r,n)?e:t.error("binary."+s,{limit:a.limit,value:e}),args:[{name:"limit",ref:!0,assert:i.limit,message:"must be a positive integer"}]},max:{method(e){return this.$_addRule({name:"max",method:"length",args:{limit:e},operator:"<="})}},min:{method(e){return this.$_addRule({name:"min",method:"length",args:{limit:e},operator:">="})}}},cast:{string:{from:e=>s.isBuffer(e),to:(e,t)=>e.toString()}},messages:{"binary.base":"{{#label}} must be a buffer or a string","binary.length":"{{#label}} must be {{#limit}} bytes","binary.max":"{{#label}} must be less than or equal to {{#limit}} bytes","binary.min":"{{#label}} must be at least {{#limit}} bytes"}})},(e,t,r)=>{const s=r(19),n=r(2),a=r(81),i=r(25),o=r(50),l=r(83),c=r(92),u={};u.schema=o.object({path:o.alternatives(o.array().items(o.string()).single(),o.func()).required(),index:o.alternatives(o.boolean(),o.array().items(o.string()).single()).default(!0),listing:o.boolean(),showHidden:o.boolean(),redirectToSlash:o.boolean(),lookupCompressed:o.boolean(),lookupMap:o.object().min(1).pattern(/.+/,o.string()),etagMethod:o.string().valid("hash","simple").allow(!1),defaultExtension:o.string().alphanum()}),u.resolvePathOption=function(e){if(e instanceof Error)throw e;if("string"==typeof e)return[e];if(Array.isArray(e))return e;throw n.internal("Invalid path function")},t.handler=function(e,t){const r=o.attempt(t,u.schema,"Invalid directory handler options ("+e.path+")");i.assert("}"===e.path[e.path.length-1],"The route path for a directory handler must end with a parameter:",e.path);const c=/\w+/.exec(e.path.slice(e.path.lastIndexOf("{")))[0],p=e.settings.files.relativeTo,h=Array.isArray(r.path)?r.path:null,d=!0===r.index?["index.html"]:r.index||[];return async(e,t)=>{const i=h??u.resolvePathOption(r.path.call(null,e)),o=e.params[c]??"";if(s.isAbsolute(o))throw n.notFound(null,{});if(o&&!r.showHidden&&u.isFileHidden(o))throw n.notFound(null,{});o||!e.server.settings.router.stripTrailingSlash&&e.path.endsWith("/")||(e.path+="/");const f=e.path,m=f.endsWith("/"),g={confine:null,lookupCompressed:r.lookupCompressed,lookupMap:r.lookupMap,etagMethod:r.etagMethod},y=async i=>{g.confine=i;let c,h=o;try{return await l.load(h,e,g)}catch(e){a.ignore(e,"boom"),c=e}if(u.isNotFound(c)){if(!r.defaultExtension)throw c;return m&&(h=h.slice(0,-1)),await l.load(h+"."+r.defaultExtension,e,g)}if(u.isDirectory(c)){if(!1!==r.redirectToSlash&&!e.server.settings.router.stripTrailingSlash&&!m)return t.redirect(f+"/");for(const t of d){const r=s.join(h,t);try{return await l.load(r,e,g)}catch(e){if(a.ignore(e,"boom"),!u.isNotFound(e))throw n.internal(t+" is a directory",e)}}if(r.listing)return u.generateListing(s.join(p,i,h),f,o,m,r,e)}throw c};for(let e=0;e<i.length;++e)try{return await y(i[e])}catch(t){if(a.ignore(t,"boom"),!u.isNotFound(t)||e===i.length-1)throw t}throw n.notFound(null,{})}},u.generateListing=async function(e,t,r,s,o,l){let p;try{p=await c.readdir(e)}catch(e){throw a.rethrow(e,"system"),n.internal("Error accessing directory",e)}t=decodeURIComponent(t);const h=i.escapeHtml(t);let d="<html><head><title>"+h+"</title></head><body><h1>Directory: "+h+"</h1><ul>";if(r){const e=t.substring(0,t.lastIndexOf("/",t.length-(s?2:1)))+"/";d=d+'<li><a href="'+u.pathEncode(e)+'">Parent Directory</a></li>'}for(const e of p)!o.showHidden&&u.isFileHidden(e)||(d=d+'<li><a href="'+u.pathEncode(t+(s?"":"/")+e)+'">'+i.escapeHtml(e)+"</a></li>");return d+="</ul></body></html>",l.generateResponse(d)},u.isFileHidden=function(e){return/(^|[\\\/])\.([^.\\\/]|\.[^\\\/])/.test(e)},u.pathEncode=function(e){return encodeURIComponent(e).replace(/%2F/g,"/").replace(/%5C/g,"\\")},u.isNotFound=function(e){return 404===e.output.statusCode},u.isDirectory=function(e){return 403===e.output.statusCode&&"EISDIR"===e.data.code}},(e,t,r)=>{const s=r(82),n=r(2),a=r(25),i={system:[EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,s.AssertionError,a.Error]};t.rethrow=function(e,t,r={}){return i.catch(e,t,r,!0)},t.ignore=function(e,t,r={}){return i.catch(e,t,r,!1)},i.catch=function(e,t,r,s){if(i.match(e,t)===s){if(r.override&&(e=r.override),r.decorate&&Object.assign(e,r.decorate),r.return)return e;throw e}},t.background=async function(e,r="rethrow",s="system",n={}){try{"function"==typeof e?await e():await e}catch(e){t[r](e,s,n)}},t.isBoom=function(e){return n.isBoom(e)},t.isError=function(e){return e instanceof Error},t.isSystem=function(e){if(!e)return!1;if(e.isBoom)return!1;for(const t of i.system)if(e instanceof t)return!0;return!1},i.rules={system:t.isSystem,boom:t.isBoom},i.match=function(e,t){if(!t)return!0;t=Array.isArray(t)?t:[t];for(const r of t)if("string"==typeof r){if(i.rules[r](e))return!0}else if("object"==typeof r){if(a.contain(e,r,{deep:!0,part:!0}))return!0}else if(e instanceof r)return!0;return!1}},e=>{e.exports=require("assert")},(e,t,r)=>{const s=r(19),n=r(84),a=r(2),i=r(81),o=r(25),l=r(50),c=r(86),u=r(92),p={defaultMap:{gzip:".gz"}};p.schema=l.alternatives([l.string(),l.func(),l.object({path:l.alternatives(l.string(),l.func()).required(),confine:l.alternatives(l.string(),l.boolean()).default(!0),filename:l.string(),mode:l.string().valid("attachment","inline").allow(!1),lookupCompressed:l.boolean(),lookupMap:l.object().min(1).pattern(/.+/,l.string()),etagMethod:l.string().valid("hash","simple").allow(!1),start:l.number().integer().min(0).default(0),end:l.number().integer().min(l.ref("start"))}).with("filename","mode")]),t.handler=function(e,r){let s=l.attempt(r,p.schema,"Invalid file handler options ("+e.path+")");s="object"!=typeof r?{path:r,confine:"."}:s,s.confine=!0===s.confine?".":s.confine,o.assert("string"!=typeof s.path||"/"!==s.path[s.path.length-1],"File path cannot end with a '/':",e.path);return e=>{const r="function"==typeof s.path?s.path(e):s.path;return t.response(r,s,e)}},t.load=function(e,r,s){const n=t.response(e,s,r,!0);return p.prepare(n)},t.response=function(e,t,r,n){if(o.assert(!t.mode||-1!==["attachment","inline"].indexOf(t.mode),"options.mode must be either false, attachment, or inline"),t.confine){const n=s.resolve(r.route.settings.files.relativeTo,t.confine);0!==(e=s.isAbsolute(e)?s.normalize(e):s.join(n,e)).lastIndexOf(n,0)&&(e=null)}else e=s.isAbsolute(e)?s.normalize(e):s.join(r.route.settings.files.relativeTo,e);const a={path:e,settings:t,stat:null,file:null},i=n?null:p.prepare;return r.generateResponse(a,{variety:"file",marshal:p.marshal,prepare:i,close:p.close})},p.prepare=async function(e){const{request:t,source:r}=e,{settings:n,path:i}=r;if(null===i)throw a.forbidden(null,{code:"EACCES"});const o=r.file=new u.File(i);try{const r=await o.openStat("r"),a=n.start??0;if(void 0!==n.end?e.bytes(n.end-a+1):e.bytes(r.size-a),e.headers["content-type"]||e.type(t.server.mime.path(i).type??"application/octet-stream"),e.header("last-modified",r.mtime.toUTCString()),n.mode){const t=n.filename??s.basename(i);e.header("content-disposition",n.mode+"; filename="+encodeURIComponent(t))}return await c.apply(e,r),e}catch(t){throw p.close(e),t}},p.marshal=async function(e){const{request:t,source:r}=e,{settings:s}=r;if(s.lookupCompressed&&!s.start&&void 0===s.end&&!1!==t.server.settings.compression){const a=s.lookupMap??p.defaultMap,o=t.info.acceptEncoding,l=a.hasOwnProperty(o)?a[o]:null;if(l){const t=new u.File(`${r.path}${l}`);try{var n=await t.openStat("r")}catch(e){t.close(),i.ignore(e,"boom")}n&&(r.file.close(),r.file=t,e.bytes(n.size),e.header("content-encoding",o),e.vary("accept-encoding"))}}return p.createStream(e)},p.addContentRange=function(e){const{request:t}=e;let r=null;if(t.route.settings.response.ranges){const s=e.headers["content-length"];if(t.headers.range&&s&&(!t.headers["if-range"]||t.headers["if-range"]===e.headers.etag)){const i=t.server.mime.type(e.headers["content-type"]||"application/octet-stream"),o=t.server.settings.compression&&i.compressible&&!e.headers["content-encoding"]?t.info.acceptEncoding:null;if("identity"===o||!o){const i=n.header(t.headers.range,s);if(!i){const e=a.rangeNotSatisfiable();throw e.output.headers["content-range"]="bytes */"+s,e}1===i.length&&(r=i[0],e.code(206),e.bytes(r.to-r.from+1),e.header("content-range","bytes "+r.from+"-"+r.to+"/"+s))}}e.header("accept-ranges","bytes")}return r},p.createStream=function(e){const{settings:t,file:r}=e.source;o.assert(null!==r);const s=p.addContentRange(e),n={start:t.start??0,end:t.end};return s&&(n.end=s.to+n.start,n.start=s.from+n.start),r.createReadStream(n)},p.close=function(e){const{source:t}=e;null!==t.file&&(t.file.close(),t.file=null)}},(e,t,r)=>{const s=r(85),n=r(25),a={headerRx:/^bytes=[\s,]*((?:(?:\d+\-\d*)|(?:\-\d+))(?:\s*,\s*(?:(?:\d+\-\d*)|(?:\-\d+)))*)$/i};t.header=function(e,t){const r=a.headerRx.exec(e);if(!r)return null;const s=t-1,n=[],i=r[1].match(/\d*\-\d*/g);for(let e of i){let r,i;if(e=e.split("-"),e[0]&&(r=parseInt(e[0],10)),e[1]?(i=parseInt(e[1],10),void 0!==r?i>s&&(i=s):(r=t-i,i=s)):i=s,r>i)return null;n.push(new a.Range(r,i))}if(1===n.length)return n;n.sort(((e,t)=>e.from-t.from));const o=[];for(let e=n.length-1;e>0;--e){const t=n[e],r=n[e-1];t.from<=r.to+1?r.to=t.to:o.unshift(t)}return o.unshift(n[0]),o},a.Range=class{constructor(e,t){this.from=e,this.to=t}},t.Clip=class extends s.Transform{constructor(e){if(!(e instanceof a.Range)){n.assert("object"==typeof e,'Expected "range" object');const t=e.from??0;n.assert("number"==typeof t,'"range.from" must be a number'),n.assert(t===parseInt(t,10)&&t>=0,'"range.from" must be a positive integer');const r=e.to??0;n.assert("number"==typeof r,'"range.to" must be a number'),n.assert(r===parseInt(r,10)&&r>=0,'"range.to" must be a positive integer'),n.assert(r>=t,'"range.to" must be greater than or equal to "range.from"'),e=new a.Range(t,r)}super(),this._range=e,this._next=0,this._pipes=new Set,this.on("pipe",(e=>this._pipes.add(e))),this.on("unpipe",(e=>this._pipes.delete(e)))}_transform(e,t,r){try{a.processChunk(this,e)}catch(e){return r(e)}return r()}_flush(e){this._pipes.clear(),e()}},a.processChunk=function(e,t){const r=e._next;if(e._next=e._next+t.length,e._next<=e._range.from)return;if(r>e._range.to){for(const t of e._pipes)t.unpipe(e);return e._pipes.clear(),void e.end()}const s=Math.max(0,e._range.from-r),n=Math.min(t.length,e._range.to-r+1);e.push(t.slice(s,n))}},e=>{e.exports=require("stream")},(e,t,r)=>{const s=r(87),n=r(85),a=r(88),i=r(2),o=r(81),l=r(89),c={pendings:new Map,streamEnd:a.promisify(n.finished),computeHashed:async function(e,t){const r=e.request.server.plugins.inert._etags;if(!r)return null;const s=[e.source.path,t.ino,t.size,t.mtime.getTime()].join("-"),n=r.get(s);if(n)return n;let a=c.pendings.get(s);if(a)return await a;return c.pendings.set(s,a=(async()=>{try{const t=await c.hashFile(e);return r.set(s,t),t}finally{c.pendings.delete(s)}})()),await a},hashFile:async function(e){const t=s.createHash("sha1");t.setEncoding("hex");const r=e.source.file.createReadStream({autoClose:!1});r.pipe(t);try{return await c.streamEnd(r),t.read()}catch(t){throw o.rethrow(t,"system"),i.boomify(t,{message:"Failed to hash file",data:{path:e.source.path}})}},computeSimple:function(e,t){return t.size.toString(16)+"-"+t.mtime.getTime().toString(16)}};t.apply=async function(e,t){const r=e.source.settings.etagMethod;if(!1===r)return;let s;s="simple"===r?c.computeSimple(e,t):await c.computeHashed(e,t),null!==s&&e.etag(s,{vary:!0})},t.Cache=l},e=>{e.exports=require("crypto")},e=>{e.exports=require("util")},(e,t,r)=>{const s=r(90),n=Symbol("max"),a=Symbol("length"),i=Symbol("lengthCalculator"),o=Symbol("allowStale"),l=Symbol("maxAge"),c=Symbol("dispose"),u=Symbol("noDisposeOnSet"),p=Symbol("lruList"),h=Symbol("cache"),d=Symbol("updateAgeOnGet"),f=()=>1;const m=(e,t,r)=>{const s=e[h].get(t);if(s){const t=s.value;if(g(e,t)){if(b(e,s),!e[o])return}else r&&(e[d]&&(s.value.now=Date.now()),e[p].unshiftNode(s));return t.value}},g=(e,t)=>{if(!t||!t.maxAge&&!e[l])return!1;const r=Date.now()-t.now;return t.maxAge?r>t.maxAge:e[l]&&r>e[l]},y=e=>{if(e[a]>e[n])for(let t=e[p].tail;e[a]>e[n]&&null!==t;){const r=t.prev;b(e,t),t=r}},b=(e,t)=>{if(t){const r=t.value;e[c]&&e[c](r.key,r.value),e[a]-=r.length,e[h].delete(r.key),e[p].removeNode(t)}};class v{constructor(e,t,r,s,n){this.key=e,this.value=t,this.length=r,this.now=s,this.maxAge=n||0}}const _=(e,t,r,s)=>{let n=r.value;g(e,n)&&(b(e,r),e[o]||(n=void 0)),n&&t.call(s,n.value,n.key,e)};e.exports=class{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[n]=e.max||1/0;const t=e.length||f;if(this[i]="function"!=typeof t?f:t,this[o]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[l]=e.maxAge||0,this[c]=e.dispose,this[u]=e.noDisposeOnSet||!1,this[d]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[n]=e||1/0,y(this)}get max(){return this[n]}set allowStale(e){this[o]=!!e}get allowStale(){return this[o]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[l]=e,y(this)}get maxAge(){return this[l]}set lengthCalculator(e){"function"!=typeof e&&(e=f),e!==this[i]&&(this[i]=e,this[a]=0,this[p].forEach((e=>{e.length=this[i](e.value,e.key),this[a]+=e.length}))),y(this)}get lengthCalculator(){return this[i]}get length(){return this[a]}get itemCount(){return this[p].length}rforEach(e,t){t=t||this;for(let r=this[p].tail;null!==r;){const s=r.prev;_(this,e,r,t),r=s}}forEach(e,t){t=t||this;for(let r=this[p].head;null!==r;){const s=r.next;_(this,e,r,t),r=s}}keys(){return this[p].toArray().map((e=>e.key))}values(){return this[p].toArray().map((e=>e.value))}reset(){this[c]&&this[p]&&this[p].length&&this[p].forEach((e=>this[c](e.key,e.value))),this[h]=new Map,this[p]=new s,this[a]=0}dump(){return this[p].map((e=>!g(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[p]}set(e,t,r){if((r=r||this[l])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const s=r?Date.now():0,o=this[i](t,e);if(this[h].has(e)){if(o>this[n])return b(this,this[h].get(e)),!1;const i=this[h].get(e).value;return this[c]&&(this[u]||this[c](e,i.value)),i.now=s,i.maxAge=r,i.value=t,this[a]+=o-i.length,i.length=o,this.get(e),y(this),!0}const d=new v(e,t,o,s,r);return d.length>this[n]?(this[c]&&this[c](e,t),!1):(this[a]+=d.length,this[p].unshift(d),this[h].set(e,this[p].head),y(this),!0)}has(e){if(!this[h].has(e))return!1;const t=this[h].get(e).value;return!g(this,t)}get(e){return m(this,e,!0)}peek(e){return m(this,e,!1)}pop(){const e=this[p].tail;return e?(b(this,e),e.value):null}del(e){b(this,this[h].get(e))}load(e){this.reset();const t=Date.now();for(let r=e.length-1;r>=0;r--){const s=e[r],n=s.e||0;if(0===n)this.set(s.k,s.v);else{const e=n-t;e>0&&this.set(s.k,s.v,e)}}}prune(){this[h].forEach(((e,t)=>m(this,t,!1)))}}},(e,t,r)=>{function s(e){var t=this;if(t instanceof s||(t=new s),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e)}));else if(arguments.length>0)for(var r=0,n=arguments.length;r<n;r++)t.push(arguments[r]);return t}function n(e,t,r){var s=t===e.head?new o(r,null,t,e):new o(r,t,t.next,e);return null===s.next&&(e.tail=s),null===s.prev&&(e.head=s),e.length++,s}function a(e,t){e.tail=new o(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function i(e,t){e.head=new o(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function o(e,t,r,s){if(!(this instanceof o))return new o(e,t,r,s);this.list=s,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}e.exports=s,s.Node=o,s.create=s,s.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,r=e.prev;return t&&(t.prev=r),r&&(r.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=r),e.list.length--,e.next=null,e.prev=null,e.list=null,t},s.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},s.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},s.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)a(this,arguments[e]);return this.length},s.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)i(this,arguments[e]);return this.length},s.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},s.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},s.prototype.forEach=function(e,t){t=t||this;for(var r=this.head,s=0;null!==r;s++)e.call(t,r.value,s,this),r=r.next},s.prototype.forEachReverse=function(e,t){t=t||this;for(var r=this.tail,s=this.length-1;null!==r;s--)e.call(t,r.value,s,this),r=r.prev},s.prototype.get=function(e){for(var t=0,r=this.head;null!==r&&t<e;t++)r=r.next;if(t===e&&null!==r)return r.value},s.prototype.getReverse=function(e){for(var t=0,r=this.tail;null!==r&&t<e;t++)r=r.prev;if(t===e&&null!==r)return r.value},s.prototype.map=function(e,t){t=t||this;for(var r=new s,n=this.head;null!==n;)r.push(e.call(t,n.value,this)),n=n.next;return r},s.prototype.mapReverse=function(e,t){t=t||this;for(var r=new s,n=this.tail;null!==n;)r.push(e.call(t,n.value,this)),n=n.prev;return r},s.prototype.reduce=function(e,t){var r,s=this.head;if(arguments.length>1)r=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");s=this.head.next,r=this.head.value}for(var n=0;null!==s;n++)r=e(r,s.value,n),s=s.next;return r},s.prototype.reduceReverse=function(e,t){var r,s=this.tail;if(arguments.length>1)r=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");s=this.tail.prev,r=this.tail.value}for(var n=this.length-1;null!==s;n--)r=e(r,s.value,n),s=s.prev;return r},s.prototype.toArray=function(){for(var e=new Array(this.length),t=0,r=this.head;null!==r;t++)e[t]=r.value,r=r.next;return e},s.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,r=this.tail;null!==r;t++)e[t]=r.value,r=r.prev;return e},s.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new s;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var n=0,a=this.head;null!==a&&n<e;n++)a=a.next;for(;null!==a&&n<t;n++,a=a.next)r.push(a.value);return r},s.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new s;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var n=this.length,a=this.tail;null!==a&&n>t;n--)a=a.prev;for(;null!==a&&n>e;n--,a=a.prev)r.push(a.value);return r},s.prototype.splice=function(e,t){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var r=0,s=this.head;null!==s&&r<e;r++)s=s.next;var a=[];for(r=0;s&&r<t;r++)a.push(s.value),s=this.removeNode(s);null===s&&(s=this.tail),s!==this.head&&s!==this.tail&&(s=s.prev);for(r=2;r<arguments.length;r++)s=n(this,s,arguments[r]);return a},s.prototype.reverse=function(){for(var e=this.head,t=this.tail,r=e;null!==r;r=r.prev){var s=r.prev;r.prev=r.next,r.next=s}return this.head=t,this.tail=e,this};try{r(91)(s)}catch(e){}},e=>{e.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}},(e,t,r)=>{const s=r(93),n=r(88),a=r(2),i=r(81),o=r(25),l={methods:{promised:["open","close","fstat","readdir"],raw:["createReadStream"]},notFound:new Set(["ENOENT","ENOTDIR"])};t.File=class{constructor(e){this.path=e,this.fd=null}async open(e){o.assert(null===this.fd);try{this.fd=await t.open(this.path,e)}catch(e){const t={path:this.path};if(-1!==this.path.indexOf("\0")||l.notFound.has(e.code))throw a.notFound(null,t);if("EACCES"===e.code||"EPERM"===e.code)throw t.code=e.code,a.forbidden(null,t);throw a.boomify(e,{message:"Failed to open file",data:t})}}close(){null!==this.fd&&(i.background(t.close(this.fd)),this.fd=null)}async stat(){o.assert(null!==this.fd);try{const e=await t.fstat(this.fd);if(e.isDirectory())throw a.forbidden(null,{code:"EISDIR",path:this.path});return e}catch(e){throw this.close(this.fd),i.rethrow(e,["boom","system"]),a.boomify(e,{message:"Failed to stat file",data:{path:this.path}})}}async openStat(e){return await this.open(e),this.stat()}createReadStream(e){o.assert(null!==this.fd),e=Object.assign({fd:this.fd,start:0},e);const r=t.createReadStream(this.path,e);return!1!==e.autoClose&&(this.fd=null),r}};for(const e of l.methods.raw)t[e]=s[e].bind(s);for(const e of l.methods.promised)t[e]=n.promisify(s[e])},e=>{e.exports=require("fs")},e=>{e.exports=JSON.parse('{"name":"@hapi/inert","description":"Static file and directory handlers plugin for hapi.js","version":"7.1.0","repository":"https://github.com/hapijs/inert.git","main":"lib/index.js","types":"lib/index.d.ts","files":["lib"],"keywords":["file","directory","handler","hapi","plugin"],"eslintConfig":{"extends":["plugin:@hapi/module"]},"dependencies":{"@hapi/ammo":"^6.0.1","@hapi/boom":"^10.0.1","@hapi/bounce":"^3.0.1","@hapi/hoek":"^11.0.2","@hapi/validate":"^2.0.1","lru-cache":"^7.14.1"},"devDependencies":{"@hapi/code":"^9.0.3","@hapi/eslint-plugin":"*","@hapi/file":"^3.0.0","@hapi/hapi":"^21.3.0","@hapi/lab":"^25.1.2","@types/node":"^14.18.37","joi":"^17.8.3","typescript":"^4.9.5"},"scripts":{"test":"lab -f -a @hapi/code -t 100 -L -Y","test-cov-html":"lab -f -a @hapi/code -r html -o coverage.html"},"license":"BSD-3-Clause"}')},e=>{e.exports=require("[email protected]")},e=>{e.exports=require("[email protected]")},e=>{e.exports=require("@hapi/[email protected]")},(e,t,r)=>{var s=r(14).Buffer;const n=r(27),a=r(30),i=r(99),o=r(100),l=r(109),c=r(106),u=r(110),p=r(111),h=r(108),d=r(104),f=r(112);let m;const g={types:{alternatives:r(114),any:r(115),array:r(121),boolean:r(122),date:r(123),function:r(124),link:r(126),number:r(127),object:r(128),string:r(129),symbol:r(136)},aliases:{alt:"alternatives",bool:"boolean",func:"function"}};s&&(g.types.binary=r(137)),g.root=function(){const e={_types:new Set(Object.keys(g.types))};for(const t of e._types)e[t]=function(...e){return n(!e.length||["alternatives","link","object"].includes(t),"The",t,"type does not allow arguments"),g.generate(this,g.types[t],e)};for(const t of["allow","custom","disallow","equal","exist","forbidden","invalid","not","only","optional","options","prefs","preferences","required","strip","valid","when"])e[t]=function(...e){return this.any()[t](...e)};Object.assign(e,g.methods);for(const t in g.aliases){const r=g.aliases[t];e[t]=e[r]}return e.x=e.expression,f.setup&&f.setup(e),e},g.methods={ValidationError:c.ValidationError,version:o.version,cache:i.provider,assert(e,t,...r){g.assert(e,t,!0,r)},attempt:(e,t,...r)=>g.assert(e,t,!1,r),build(e){return n("function"==typeof p.build,"Manifest functionality disabled"),p.build(this,e)},checkPreferences(e){o.checkPreferences(e)},compile(e,t){return l.compile(this,e,t)},defaults(e){n("function"==typeof e,"modifier must be a function");const t=Object.assign({},this);for(const r of t._types){const s=e(t[r]());n(o.isSchema(s),"modifier must return a valid schema object"),t[r]=function(...e){return g.generate(this,s,e)}}return t},expression:(...e)=>new d(...e),extend(...e){o.verifyFlat(e,"extend"),m=m||r(102),n(e.length,"You need to provide at least one extension"),this.assert(e,m.extensions);const t=Object.assign({},this);t._types=new Set(t._types);for(let r of e){"function"==typeof r&&(r=r(t)),this.assert(r,m.extension);const e=g.expandExtension(r,t);for(const r of e){n(void 0===t[r.type]||t._types.has(r.type),"Cannot override name",r.type);const e=r.base||this.any(),s=u.type(e,r);t._types.add(r.type),t[r.type]=function(...e){return g.generate(this,s,e)}}}return t},isError:c.ValidationError.isError,isExpression:d.isTemplate,isRef:h.isRef,isSchema:o.isSchema,in:(...e)=>h.in(...e),override:o.symbols.override,ref:(...e)=>h.create(...e),types(){const e={};for(const t of this._types)e[t]=this[t]();for(const t in g.aliases)e[t]=this[t]();return e}},g.assert=function(e,t,r,s){const n=s[0]instanceof Error||"string"==typeof s[0]?s[0]:null,i=null!==n?s[1]:s[0],l=t.validate(e,o.preferences({errors:{stack:!0}},i||{}));let u=l.error;if(!u)return l.value;if(n instanceof Error)throw n;const p=r&&"function"==typeof u.annotate?u.annotate():u.message;throw u instanceof c.ValidationError==!1&&(u=a(u)),u.message=n?`${n} ${p}`:p,u},g.generate=function(e,t,r){return n(e,"Must be invoked on a Joi instance."),t.$_root=e,t._definition.args&&r.length?t._definition.args(t,...r):t},g.expandExtension=function(e,t){if("string"==typeof e.type)return[e];const r=[];for(const s of t._types)if(e.type.test(s)){const n=Object.assign({},e);n.type=s,n.base=t[s](),r.push(n)}return r},e.exports=g.root()},(e,t,r)=>{const s=r(27),n=r(30),a=r(100),i={max:1e3,supported:new Set(["undefined","boolean","number","string"])};t.provider={provision:e=>new i.Cache(e)},i.Cache=class{constructor(e={}){a.assertOptions(e,["max"]),s(void 0===e.max||e.max&&e.max>0&&isFinite(e.max),"Invalid max cache size"),this._max=e.max||i.max,this._map=new Map,this._list=new i.List}get length(){return this._map.size}set(e,t){if(null!==e&&!i.supported.has(typeof e))return;let r=this._map.get(e);if(r)return r.value=t,void this._list.first(r);r=this._list.unshift({key:e,value:t}),this._map.set(e,r),this._compact()}get(e){const t=this._map.get(e);if(t)return this._list.first(t),n(t.value)}_compact(){if(this._map.size>this._max){const e=this._list.pop();this._map.delete(e.key)}}},i.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:r}=e;return t.prev=r,r&&(r.next=t),e===this.tail&&(this.tail=t),e.prev=null,e.next=null,e}}},(e,t,r)=>{const s=r(27),n=r(28),a=r(101);let i,o;const l={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)?)?)?)?$/};t.version=a.version,t.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},t.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")},t.assertOptions=function(e,t,r="Options"){s(e&&"object"==typeof e&&!Array.isArray(e),"Options must be of type object");const n=Object.keys(e).filter((e=>!t.includes(e)));s(0===n.length,`${r} contain unknown keys: ${n}`)},t.checkPreferences=function(e){o=o||r(102);const t=o.preferences.validate(e);if(t.error)throw new n([t.error.details[0].message])},t.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}},t.default=function(e,t){return void 0===e?t:e},t.isIsoDate=function(e){return l.isoDate.test(e)},t.isNumber=function(e){return"number"==typeof e&&!isNaN(e)},t.isResolvable=function(e){return!!e&&(e[t.symbols.ref]||e[t.symbols.template])},t.isSchema=function(e,r={}){const n=e&&e[t.symbols.any];return!!n&&(s(r.legacy||n.version===t.version,"Cannot mix different versions of joi schemas"),!0)},t.isValues=function(e){return e[t.symbols.values]},t.limit=function(e){return Number.isSafeInteger(e)&&e>=0},t.preferences=function(e,s){i=i||r(103),e=e||{},s=s||{};const n=Object.assign({},e,s);return s.errors&&e.errors&&(n.errors=Object.assign({},e.errors,s.errors),n.errors.wrap=Object.assign({},e.errors.wrap,s.errors.wrap)),s.messages&&(n.messages=i.compile(s.messages,e.messages)),delete n[t.symbols.prefs],n},t.tryWithPath=function(e,t,r={}){try{return e()}catch(e){throw void 0!==e.path?e.path=t+"."+e.path:e.path=t,r.append&&(e.message=`${e.message} (${e.path})`),e}},t.validateArg=function(e,r,{assert:s,message:n}){if(t.isSchema(s)){const t=s.validate(e);if(!t.error)return;return t.error.message}if(!s(e))return r?`${r} ${n}`:n},t.verifyFlat=function(e,t){for(const r of e)s(!Array.isArray(r),"Method no longer accepts array arguments:",t)}},e=>{e.exports=JSON.parse('{"name":"joi","description":"Object schema validation","version":"17.12.2","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/[email protected]","@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"}')},(e,t,r)=>{const s=r(98),n={};n.wrap=s.string().min(1).max(2).allow(!1),t.preferences=s.object({allowUnknown:s.boolean(),abortEarly:s.boolean(),artifacts:s.boolean(),cache:s.boolean(),context:s.object(),convert:s.boolean(),dateFormat:s.valid("date","iso","string","time","utc"),debug:s.boolean(),errors:{escapeHtml:s.boolean(),label:s.valid("path","key",!1),language:[s.string(),s.object().ref()],render:s.boolean(),stack:s.boolean(),wrap:{label:n.wrap,array:n.wrap,string:n.wrap}},externals:s.boolean(),messages:s.object(),noDefaults:s.boolean(),nonEnumerables:s.boolean(),presence:s.valid("required","optional","forbidden"),skipFunctions:s.boolean(),stripUnknown:s.object({arrays:s.boolean(),objects:s.boolean()}).or("arrays","objects").allow(!0,!1),warnings:s.boolean()}).strict(),n.nameRx=/^[a-zA-Z0-9]\w*$/,n.rule=s.object({alias:s.array().items(s.string().pattern(n.nameRx)).single(),args:s.array().items(s.string(),s.object({name:s.string().pattern(n.nameRx).required(),ref:s.boolean(),assert:s.alternatives([s.function(),s.object().schema()]).conditional("ref",{is:!0,then:s.required()}),normalize:s.function(),message:s.string().when("assert",{is:s.function(),then:s.required()})})),convert:s.boolean(),manifest:s.boolean(),method:s.function().allow(!1),multi:s.boolean(),validate:s.function()}),t.extension=s.object({type:s.alternatives([s.string(),s.object().regex()]).required(),args:s.function(),cast:s.object().pattern(n.nameRx,s.object({from:s.function().maxArity(1).required(),to:s.function().minArity(1).maxArity(2).required()})),base:s.object().schema().when("type",{is:s.object().regex(),then:s.forbidden()}),coerce:[s.function().maxArity(3),s.object({method:s.function().maxArity(3).required(),from:s.array().items(s.string()).single()})],flags:s.object().pattern(n.nameRx,s.object({setter:s.string(),default:s.any()})),manifest:{build:s.function().arity(2)},messages:[s.object(),s.string()],modifiers:s.object().pattern(n.nameRx,s.function().minArity(1).maxArity(2)),overrides:s.object().pattern(n.nameRx,s.function()),prepare:s.function().maxArity(3),rebuild:s.function().arity(1),rules:s.object().pattern(n.nameRx,n.rule),terms:s.object().pattern(n.nameRx,s.object({init:s.array().allow(null).required(),manifest:s.object().pattern(/.+/,[s.valid("schema","single"),s.object({mapped:s.object({from:s.string().required(),to:s.string().required()}).required()})])})),validate:s.function().maxArity(3)}).strict(),t.extensions=s.array().items(s.object(),s.function().arity(1)).strict(),n.desc={buffer:s.object({buffer:s.string()}),func:s.object({function:s.function().required(),options:{literal:!0}}),override:s.object({override:!0}),ref:s.object({ref:s.object({type:s.valid("value","global","local"),path:s.array().required(),separator:s.string().length(1).allow(!1),ancestor:s.number().min(0).integer().allow("root"),map:s.array().items(s.array().length(2)).min(1),adjust:s.function(),iterables:s.boolean(),in:s.boolean(),render:s.boolean()}).required()}),regex:s.object({regex:s.string().min(3)}),special:s.object({special:s.valid("deep").required()}),template:s.object({template:s.string().required(),options:s.object()}),value:s.object({value:s.alternatives([s.object(),s.array()]).required()})},n.desc.entity=s.alternatives([s.array().items(s.link("...")),s.boolean(),s.function(),s.number(),s.string(),n.desc.buffer,n.desc.func,n.desc.ref,n.desc.regex,n.desc.special,n.desc.template,n.desc.value,s.link("/")]),n.desc.values=s.array().items(null,s.boolean(),s.function(),s.number().allow(1/0,-1/0),s.string().allow(""),s.symbol(),n.desc.buffer,n.desc.func,n.desc.override,n.desc.ref,n.desc.regex,n.desc.template,n.desc.value),n.desc.messages=s.object().pattern(/.+/,[s.string(),n.desc.template,s.object().pattern(/.+/,[s.string(),n.desc.template])]),t.description=s.object({type:s.string().required(),flags:s.object({cast:s.string(),default:s.any(),description:s.string(),empty:s.link("/"),failover:n.desc.entity,id:s.string(),label:s.string(),only:!0,presence:["optional","required","forbidden"],result:["raw","strip"],strip:s.boolean(),unit:s.string()}).unknown(),preferences:{allowUnknown:s.boolean(),abortEarly:s.boolean(),artifacts:s.boolean(),cache:s.boolean(),convert:s.boolean(),dateFormat:["date","iso","string","time","utc"],errors:{escapeHtml:s.boolean(),label:["path","key"],language:[s.string(),n.desc.ref],wrap:{label:n.wrap,array:n.wrap}},externals:s.boolean(),messages:n.desc.messages,noDefaults:s.boolean(),nonEnumerables:s.boolean(),presence:["required","optional","forbidden"],skipFunctions:s.boolean(),stripUnknown:s.object({arrays:s.boolean(),objects:s.boolean()}).or("arrays","objects").allow(!0,!1),warnings:s.boolean()},allow:n.desc.values,invalid:n.desc.values,rules:s.array().min(1).items({name:s.string().required(),args:s.object().min(1),keep:s.boolean(),message:[s.string(),n.desc.messages],warn:s.boolean()}),keys:s.object().pattern(/.*/,s.link("/")),link:n.desc.ref}).pattern(/^[a-z]\w*$/,s.any())},(e,t,r)=>{const s=r(27),n=r(30),a=r(104);t.compile=function(e,t){if("string"==typeof e)return s(!t,"Cannot set single message string"),new a(e);if(a.isTemplate(e))return s(!t,"Cannot set single message template"),e;s("object"==typeof e&&!Array.isArray(e),"Invalid message options"),t=t?n(t):{};for(let r in e){const n=e[r];if("root"===r||a.isTemplate(n)){t[r]=n;continue}if("string"==typeof n){t[r]=new a(n);continue}s("object"==typeof n&&!Array.isArray(n),"Invalid message for",r);const i=r;for(r in t[i]=t[i]||{},n){const e=n[r];"root"===r||a.isTemplate(e)?t[i][r]=e:(s("string"==typeof e,"Invalid message for",r,"in",i),t[i][r]=new a(e))}}return t},t.decompile=function(e){const t={};for(let r in e){const s=e[r];if("root"===r){t.root=s;continue}if(a.isTemplate(s)){t[r]=s.describe({compact:!0});continue}const n=r;for(r in t[n]={},s){const e=s[r];"root"!==r?t[n][r]=e.describe({compact:!0}):t[n].root=e}}return t},t.merge=function(e,r){if(!e)return t.compile(r);if(!r)return e;if("string"==typeof r)return new a(r);if(a.isTemplate(r))return r;const i=n(e);for(let e in r){const t=r[e];if("root"===e||a.isTemplate(t)){i[e]=t;continue}if("string"==typeof t){i[e]=new a(t);continue}s("object"==typeof t&&!Array.isArray(t),"Invalid message for",e);const n=e;for(e in i[n]=i[n]||{},t){const r=t[e];"root"===e||a.isTemplate(r)?i[n][e]=r:(s("string"==typeof r,"Invalid message for",e,"in",n),i[n][e]=new a(r))}}return i}},(e,t,r)=>{const s=r(27),n=r(30),a=r(42),i=r(105),o=r(100),l=r(106),c=r(108),u={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=u.Template=class{constructor(e,t){if(s("string"==typeof e,"Template source must be a string"),s(!e.includes("\0")&&!e.includes(""),"Template source cannot contain reserved control characters"),this.source=e,this.rendered=e,this._template=null,t){const{functions:e,...r}=t;this._settings=Object.keys(r).length?n(r):void 0,this._functions=e,this._functions&&(s(Object.keys(this._functions).every((e=>"string"==typeof e)),"Functions keys must be strings"),s(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=u.encode(this.source),t=u.split(e);let r=!1;const s=[],n=t.shift();n&&s.push(n);for(const e of t){const t="{"!==e[0],n=t?"}":"}}",a=e.indexOf(n);if(-1===a||"{"===e[1]){s.push(`{${u.decode(e)}`);continue}let i=e.slice(t?0:1,a);const o=":"===i[0];o&&(i=i.slice(1));const l=this._ref(u.decode(i),{raw:t,wrapped:o});s.push(l),"string"!=typeof l&&(r=!0);const c=e.slice(a+n.length);c&&s.push(u.decode(c))}r?this._template=s:this.rendered=s.join("")}static date(e,t){return u.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 u.Template(e.template,e.options||e.functions?{...e.options,functions:e.functions}:void 0)}isDynamic(){return!!this._template}static isTemplate(e){return!!e&&!!e[o.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,r,s){return this._template&&1===this._template.length?this._part(this._template[0],e,t,r,s,{}):this.render(e,t,r,s)}_part(e,...t){return e.ref?e.ref.resolve(...t):e.formula.evaluate(t)}render(e,t,r,s,n={}){if(!this.isDynamic())return this.rendered;const i=[];for(const o of this._template)if("string"==typeof o)i.push(o);else{const l=this._part(o,e,t,r,s,n),c=u.stringify(l,e,t,r,s,n);if(void 0!==c){const e=o.raw||!1===(n.errors&&n.errors.escapeHtml)?c:a(c);i.push(u.wrap(e,o.wrapped&&r.errors.wrap.label))}}return i.join("")}_ref(e,{raw:t,wrapped:r}){const s=[],n=e=>{const t=c.create(e,this._settings);return s.push(t),e=>{const r=t.resolve(...e);return void 0!==r?r:null}};try{const t=this._functions?{...u.functions,...this._functions}:u.functions;var a=new i.Parser(e,{reference:n,functions:t,constants:u.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=s[0];return{ref:e,raw:t,refs:s,wrapped:r||"local"===e.type&&"label"===e.key}}return u.stringify(a.single.value)}return{formula:a,raw:t,refs:s}}toString(){return this.source}},u.Template.prototype[o.symbols.template]=!0,u.Template.prototype.isImmutable=!0,u.encode=function(e){return e.replace(/\\(\{+)/g,((e,t)=>u.opens.slice(0,t.length))).replace(/\\(\}+)/g,((e,t)=>u.closes.slice(0,t.length)))},u.decode=function(e){return e.replace(/\u0000/g,"{").replace(/\u0001/g,"}")},u.split=function(e){const t=[];let r="";for(let s=0;s<e.length;++s){const n=e[s];if("{"===n){let n="";for(;s+1<e.length&&"{"===e[s+1];)n+="{",++s;t.push(r),r=n}else r+=n}return t.push(r),t},u.wrap=function(e,t){return t?1===t.length?`${t}${e}${t}`:`${t[0]}${e}${t[1]}`:e},u.stringify=function(e,t,r,s,n,a={}){const i=typeof e,o=s&&s.errors&&s.errors.wrap||{};let l=!1;if(c.isRef(e)&&e.render&&(l=e.in,e=e.resolve(t,r,s,n,{in:e.in,...a})),null===e)return"null";if("string"===i)return u.wrap(e,a.arrayItems&&o.string);if("number"===i||"function"===i||"symbol"===i)return e.toString();if("object"!==i)return JSON.stringify(e);if(e instanceof Date)return u.Template.date(e,s);if(e instanceof Map){const t=[];for(const[r,s]of e.entries())t.push(`${r.toString()} -> ${s.toString()}`);e=t}if(!Array.isArray(e))return e.toString();const p=[];for(const i of e)p.push(u.stringify(i,t,r,s,n,{arrayItems:!0,...a}));return u.wrap(p.join(", "),!l&&o.array)},u.constants={true:!0,false:!1,null:null,second:1e3,minute:6e4,hour:36e5,day:864e5},u.functions={if:(e,t,r)=>e?t:r,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,r,s,n,a]=this,i=a.messages;if(!i)return"";const o=l.template(t,i[0],e,r,s)||l.template(t,i[1],e,r,s);return o?o.render(t,r,s,n,a):""},number:e=>"number"==typeof e?e:"string"==typeof e?parseFloat(e):"boolean"==typeof e?e?1:0:e instanceof Date?e.getTime():null}},(e,t)=>{const r={operators:["!","^","*","/","%","+","-","<","<=",">",">=","==","!=","&&","||","??"],operatorCharacters:["!","^","*","/","%","+","-","<","=",">","&","|","?"],operatorsOrder:[["^"],["*","/","%"],["+","-"],["<","<=",">",">="],["==","!="],["&&"],["||","??"]],operatorsPrefix:["!","n"],literals:{'"':'"',"`":"`","'":"'","[":"]"},numberRx:/^(?:[0-9]*(\.[0-9]*)?){1}$/,tokenRx:/^[\w\$\#\.\@\:\{\}]+$/,symbol:Symbol("formula"),settings:Symbol("settings")};t.Parser=class{constructor(e,t={}){if(!t[r.settings]&&t.constants)for(const e in t.constants){const r=t.constants[e];if(null!==r&&!["boolean","number","string"].includes(typeof r))throw new Error(`Formula constant ${e} contains invalid ${typeof r} value type`)}this.settings=t[r.settings]?t:Object.assign({[r.settings]:!0,constants:{},functions:{}},t),this.single=null,this._parts=null,this._parse(e)}_parse(e){let s=[],n="",a=0,i=!1;const o=e=>{if(a)throw new Error("Formula missing closing parenthesis");const o=s.length?s[s.length-1]:null;if(i||n||e){if(o&&"reference"===o.type&&")"===e)return o.type="function",o.value=this._subFormula(n,o.value),void(n="");if(")"===e){const e=new t.Parser(n,this.settings);s.push({type:"segment",value:e})}else if(i){if("]"===i)return s.push({type:"reference",value:n}),void(n="");s.push({type:"literal",value:n})}else if(r.operatorCharacters.includes(n))o&&"operator"===o.type&&r.operators.includes(o.value+n)?o.value+=n:s.push({type:"operator",value:n});else if(n.match(r.numberRx))s.push({type:"constant",value:parseFloat(n)});else if(void 0!==this.settings.constants[n])s.push({type:"constant",value:this.settings.constants[n]});else{if(!n.match(r.tokenRx))throw new Error(`Formula contains invalid token: ${n}`);s.push({type:"reference",value:n})}n=""}};for(const t of e)i?t===i?(o(),i=!1):n+=t:a?"("===t?(n+=t,++a):")"===t?(--a,a?n+=t:o(t)):n+=t:t in r.literals?i=r.literals[t]:"("===t?(o(),++a):r.operatorCharacters.includes(t)?(o(),n=t,o()):" "!==t?n+=t:o();o(),s=s.map(((e,t)=>"operator"!==e.type||"-"!==e.value||t&&"operator"!==s[t-1].type?e:{type:"operator",value:"n"}));let l=!1;for(const e of s){if("operator"===e.type){if(r.operatorsPrefix.includes(e.value))continue;if(!l)throw new Error("Formula contains an operator in invalid position");if(!r.operators.includes(e.value))throw new Error(`Formula contains an unknown operator ${e.value}`)}else if(l)throw new Error("Formula missing expected operator");l=!l}if(!l)throw new Error("Formula contains invalid trailing operator");1===s.length&&["reference","literal","constant"].includes(s[0].type)&&(this.single={type:"reference"===s[0].type?"reference":"value",value:s[0].value}),this._parts=s.map((e=>{if("operator"===e.type)return r.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):r.reference(e.value)}))}_subFormula(e,s){const n=this.settings.functions[s];if("function"!=typeof n)throw new Error(`Formula contains unknown function ${s}`);let a=[];if(e){let t="",n=0,i=!1;const o=()=>{if(!t)throw new Error(`Formula contains function ${s} with invalid arguments ${e}`);a.push(t),t=""};for(let s=0;s<e.length;++s){const a=e[s];i?(t+=a,a===i&&(i=!1)):a in r.literals&&!n?(t+=a,i=r.literals[a]):","!==a||n?(t+=a,"("===a?++n:")"===a&&--n):o()}o()}return a=a.map((e=>new t.Parser(e,this.settings))),function(e){const t=[];for(const r of a)t.push(r.evaluate(e));return n.call(e,...t)}}evaluate(e){const t=this._parts.slice();for(let s=t.length-2;s>=0;--s){const n=t[s];if(n&&"operator"===n.type){const a=t[s+1];t.splice(s+1,1);const i=r.evaluate(a,e);t[s]=r.single(n.value,i)}}return r.operatorsOrder.forEach((s=>{for(let n=1;n<t.length-1;)if(s.includes(t[n])){const s=t[n],a=r.evaluate(t[n-1],e),i=r.evaluate(t[n+1],e);t.splice(n,2);const o=r.calculate(s,a,i);t[n-1]=0===o?0:o}else n+=2})),r.evaluate(t[0],e)}},t.Parser.prototype[r.symbol]=!0,r.reference=function(e){return function(t){return t&&void 0!==t[e]?t[e]:null}},r.evaluate=function(e,t){return null===e?null:"function"==typeof e?e(t):e[r.symbol]?e.evaluate(t):e},r.single=function(e,t){if("!"===e)return!t;const r=-t;return 0===r?0:r},r.calculate=function(e,t,s){if("??"===e)return r.exists(t)?t:s;if("string"==typeof t||"string"==typeof s){if("+"===e)return(t=r.exists(t)?t:"")+(s=r.exists(s)?s:"")}else switch(e){case"^":return Math.pow(t,s);case"*":return t*s;case"/":return t/s;case"%":return t%s;case"+":return t+s;case"-":return t-s}switch(e){case"<":return t<s;case"<=":return t<=s;case">":return t>s;case">=":return t>=s;case"==":return t===s;case"!=":return t!==s;case"&&":return t&&s;case"||":return t||s}return null},r.exists=function(e){return null!=e}},(e,t,r)=>{const s=r(107),n=r(100),a=r(104);t.Report=class{constructor(e,r,s,n,a,i,o){if(this.code=e,this.flags=n,this.messages=a,this.path=i.path,this.prefs=o,this.state=i,this.value=r,this.message=null,this.template=null,this.local=s||{},this.local.label=t.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(e,r){return t.template(this.value,e,r||this.code,this.state,this.prefs)}},t.path=function(e){let t="";for(const r of e)"object"!=typeof r&&("string"==typeof r?(t&&(t+="."),t+=r):t+=`[${r}]`);return t},t.template=function(e,t,r,s,i){if(!t)return;if(a.isTemplate(t))return"root"!==r?t:null;let o=i.errors.language;if(n.isResolvable(o)&&(o=o.resolve(e,s,i)),o&&t[o]){if(void 0!==t[o][r])return t[o][r];if(void 0!==t[o]["*"])return t[o]["*"]}return t[r]?t[r]:t["*"]},t.label=function(e,r,s,n){if(e.label)return e.label;if(!s.errors.label)return"";let a=r.path;"key"===s.errors.label&&r.path.length>1&&(a=r.path.slice(-1));const i=t.path(a);return i||(t.template(null,s.messages,"root",r,s)||n&&t.template(null,n,"root",r,s)||"value")},t.process=function(e,r,s){if(!e)return null;const{override:n,message:a,details:i}=t.details(e);if(n)return n;if(s.errors.stack)return new t.ValidationError(a,i,r);const o=Error.stackTraceLimit;Error.stackTraceLimit=0;const l=new t.ValidationError(a,i,r);return Error.stackTraceLimit=o,l},t.details=function(e,t={}){let r=[];const s=[];for(const n of e){if(n instanceof Error){if(!1!==t.override)return{override:n};const e=n.toString();r.push(e),s.push({message:e,type:"override",context:{error:n}});continue}const e=n.toString();r.push(e),s.push({message:e,path:n.path.filter((e=>"object"!=typeof e)),type:n.code,context:n.local})}return r.length>1&&(r=[...new Set(r)]),{message:r.join(". "),details:s}},t.ValidationError=class extends Error{constructor(e,t,r){super(e),this._original=r,this.details=t}static isError(e){return e instanceof t.ValidationError}},t.ValidationError.prototype.isJoi=!0,t.ValidationError.prototype.name="ValidationError",t.ValidationError.prototype.annotate=s.error},(e,t,r)=>{const s=r(30),n=r(100),a={annotations:Symbol("annotations")};t.error=function(e){if(!this._original||"object"!=typeof this._original)return this.details[0].message;const t=e?"":"[31m",r=e?"":"[41m",i=e?"":"[0m",o=s(this._original);for(let e=this.details.length-1;e>=0;--e){const t=e+1,r=this.details[e],s=r.path;let i=o;for(let e=0;;++e){const o=s[e];if(n.isSchema(i)&&(i=i.clone()),!(e+1<s.length&&"string"!=typeof i[o])){const e=i[a.annotations]||{errors:{},missing:{}};i[a.annotations]=e;const s=o||r.context.key;void 0!==i[o]?(e.errors[s]=e.errors[s]||[],e.errors[s].push(t)):e.missing[s]=t;break}i=i[o]}}const l=/_\$key\$_([, \d]+)_\$end\$_"/g,c=/"_\$miss\$_([^|]+)\|(\d+)_\$end\$_": "__missing__"/g,u=/\s*"_\$idx\$_([, \d]+)_\$end\$_",?\n(.*)/g,p=/"\[(NaN|Symbol.*|-?Infinity|function.*|\(.*)]"/g;let h=a.safeStringify(o,2).replace(l,((e,r)=>`" ${t}[${r}]${i}`)).replace(c,((e,s,n)=>`${r}"${s}"${i}${t} [${n}]: -- missing --${i}`)).replace(u,((e,r,s)=>`\n${s} ${t}[${r}]${i}`)).replace(p,((e,t)=>t));h=`${h}\n${t}`;for(let e=0;e<this.details.length;++e){h=`${h}\n[${e+1}] ${this.details[e].message}`}return h+=i,h},a.safeStringify=function(e,t){return JSON.stringify(e,a.serializer(),t)},a.serializer=function(){const e=[],t=[],r=(r,s)=>t[0]===s?"[Circular ~]":"[Circular ~."+e.slice(0,t.indexOf(s)).join(".")+"]";return function(s,n){if(t.length>0){const a=t.indexOf(this);~a?(t.length=a+1,e.length=a+1,e[a]=s):(t.push(this),e.push(s)),~t.indexOf(n)&&(n=r.call(this,s,n))}else t.push(n);if(n){const e=n[a.annotations];if(e){if(Array.isArray(n)){const t=[];for(let r=0;r<n.length;++r)e.errors[r]&&t.push(`_$idx$_${e.errors[r].sort().join(", ")}_$end$_`),t.push(n[r]);n=t}else{for(const t in e.errors)n[`${t}_$key$_${e.errors[t].sort().join(", ")}_$end$_`]=n[t],n[t]=void 0;for(const t in e.missing)n[`_$miss$_${t}|${e.missing[t]}_$end$_`]="__missing__"}return n}}return n===1/0||n===-1/0||Number.isNaN(n)||"function"==typeof n||"symbol"==typeof n?"["+n.toString()+"]":n}}},(e,t,r)=>{const s=r(27),n=r(30),a=r(31),i=r(100);let o;const l={symbol:Symbol("ref"),defaults:{adjust:null,in:!1,iterables:null,map:null,separator:".",type:"value"}};t.create=function(e,t={}){s("string"==typeof e,"Invalid reference key:",e),i.assertOptions(t,["adjust","ancestor","in","iterables","map","prefix","render","separator"]),s(!t.prefix||"object"==typeof t.prefix,"options.prefix must be of type object");const r=Object.assign({},l.defaults,t);delete r.prefix;const n=r.separator,a=l.context(e,n,t.prefix);if(r.type=a.type,e=a.key,"value"===r.type)if(a.root&&(s(!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(void 0!==r.ancestor)s(!n||!e||e[0]!==n,"Cannot combine prefix with ancestor option");else{const[t,s]=l.ancestor(e,n);s&&""===(e=e.slice(s))&&(e=null),r.ancestor=t}return r.path=n?null===e?[]:e.split(n):[e],new l.Ref(r)},t.in=function(e,r={}){return t.create(e,{...r,in:!0})},t.isRef=function(e){return!!e&&!!e[i.symbols.ref]},l.Ref=class{constructor(e){s("object"==typeof e,"Invalid reference construction"),i.assertOptions(e,["adjust","ancestor","in","iterables","map","path","render","separator","type","depth","key","root","display"]),s([!1,void 0].includes(e.separator)||"string"==typeof e.separator&&1===e.separator.length,"Invalid separator"),s(!e.adjust||"function"==typeof e.adjust,"options.adjust must be a function"),s(!e.map||Array.isArray(e.map),"options.map must be an array"),s(!e.map||!e.adjust,"Cannot set both map and adjust options"),Object.assign(this,l.defaults,e),s("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,t,r,n,a={}){return s(!this.in||a.in,"Invalid in() reference usage"),"global"===this.type?this._resolve(r.context,t,a):"local"===this.type?this._resolve(n,t,a):this.ancestor?"root"===this.ancestor?this._resolve(t.ancestors[t.ancestors.length-1],t,a):(s(this.ancestor<=t.ancestors.length,"Invalid reference exceeds the schema root:",this.display),this._resolve(t.ancestors[this.ancestor-1],t,a)):this._resolve(e,t,a)}_resolve(e,t,r){let s;if("value"===this.type&&t.mainstay.shadow&&!1!==r.shadow&&(s=t.mainstay.shadow.get(this.absolute(t))),void 0===s&&(s=a(e,this.path,{iterables:this.iterables,functions:!0})),this.adjust&&(s=this.adjust(s)),this.map){const e=this.map.get(s);void 0!==e&&(s=e)}return t.mainstay&&t.mainstay.tracer.resolve(t,this,s),s}toString(){return this.display}absolute(e){return[...e.path.slice(0,-this.ancestor),...this.path]}clone(){return new l.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||""}`}},l.Ref.prototype[i.symbols.ref]=!0,t.build=function(e){return"value"===(e=Object.assign({},l.defaults,e)).type&&void 0===e.ancestor&&(e.ancestor=1),new l.Ref(e)},l.context=function(e,t,r={}){if(e=e.trim(),r){const s=void 0===r.global?"$":r.global;if(s!==t&&e.startsWith(s))return{key:e.slice(s.length),type:"global"};const n=void 0===r.local?"#":r.local;if(n!==t&&e.startsWith(n))return{key:e.slice(n.length),type:"local"};const a=void 0===r.root?"/":r.root;if(a!==t&&e.startsWith(a))return{key:e.slice(a.length),type:"value",root:!0}}return{key:e,type:"value"}},l.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]},t.toSibling=0,t.toParent=1,t.Manager=class{constructor(){this.refs=[]}register(e,s){if(e)if(s=void 0===s?t.toParent:s,Array.isArray(e))for(const t of e)this.register(t,s);else if(i.isSchema(e))for(const t of e._refs.refs)t.ancestor-s>=0&&this.refs.push({ancestor:t.ancestor-s,root:t.root});else t.isRef(e)&&"value"===e.type&&e.ancestor-s>=0&&this.refs.push({ancestor:e.ancestor-s,root:e.root}),o=o||r(104),o.isTemplate(e)&&this.register(e.refs(),s)}get length(){return this.refs.length}clone(){const e=new t.Manager;return e.refs=n(this.refs),e}reset(){this.refs=[]}roots(){return this.refs.filter((e=>!e.ancestor)).map((e=>e.root))}}},(e,t,r)=>{const s=r(27),n=r(100),a=r(108),i={};t.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,t,r){s(void 0!==t,"Invalid undefined schema"),Array.isArray(t)&&(s(t.length,"Invalid empty array schema"),1===t.length&&(t=t[0]));const a=(t,...s)=>!1!==r.override?t.valid(e.override,...s):t.valid(...s);if(i.simple(t))return a(e,t);if("function"==typeof t)return e.custom(t);if(s("object"==typeof t,"Invalid schema content:",typeof t),n.isResolvable(t))return a(e,t);if(n.isSchema(t))return t;if(Array.isArray(t)){for(const r of t)if(!i.simple(r))return e.alternatives().try(...t);return a(e,...t)}return t instanceof RegExp?e.string().regex(t):t instanceof Date?a(e.date(),t):(s(Object.getPrototypeOf(t)===Object.getPrototypeOf({}),"Schema can only contain plain objects"),e.object().keys(t))},t.ref=function(e,t){return a.isRef(e)?e:a.create(e,t)},t.compile=function(e,r,a={}){n.assertOptions(a,["legacy"]);const o=r&&r[n.symbols.any];if(o)return s(a.legacy||o.version===n.version,"Cannot mix different versions of joi schemas:",o.version,n.version),r;if("object"!=typeof r||!a.legacy)return t.schema(e,r,{appendPath:!0});const l=i.walk(r);return l?l.compile(l.root,r):t.schema(e,r,{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 t=e[n.symbols.any];if(t)return{root:e[t.root],compile:t.compile};s(Object.getPrototypeOf(e)===Object.getPrototypeOf({}),"Schema can only contain plain objects");for(const t in e){const r=i.walk(e[t]);if(r)return r}return null},i.simple=function(e){return null===e||["boolean","string","number"].includes(typeof e)},t.when=function(e,r,o){if(void 0===o&&(s(r&&"object"==typeof r,"Missing options"),o=r,r=a.create(".")),Array.isArray(o)&&(o={switch:o}),n.assertOptions(o,["is","not","then","otherwise","switch","break"]),n.isSchema(r))return s(void 0===o.is,'"is" can not be used with a schema condition'),s(void 0===o.not,'"not" can not be used with a schema condition'),s(void 0===o.switch,'"switch" can not be used with a schema condition'),i.condition(e,{is:r,then:o.then,otherwise:o.otherwise,break:o.break});if(s(a.isRef(r)||"string"==typeof r,"Invalid condition:",r),s(void 0===o.not||void 0===o.is,'Cannot combine "is" with "not"'),void 0===o.switch){let l=o;void 0!==o.not&&(l={is:o.not,then:o.otherwise,otherwise:o.then,break:o.break});let c=void 0!==l.is?e.$_compile(l.is):e.$_root.invalid(null,!1,0,"").required();return s(void 0!==l.then||void 0!==l.otherwise,'options must have at least one of "then", "otherwise", or "switch"'),s(void 0===l.break||void 0===l.then||void 0===l.otherwise,"Cannot specify then, otherwise, and break all together"),void 0===o.is||a.isRef(o.is)||n.isSchema(o.is)||(c=c.required()),i.condition(e,{ref:t.ref(r),is:c,then:l.then,otherwise:l.otherwise,break:l.break})}s(Array.isArray(o.switch),'"switch" must be an array'),s(void 0===o.is,'Cannot combine "switch" with "is"'),s(void 0===o.not,'Cannot combine "switch" with "not"'),s(void 0===o.then,'Cannot combine "switch" with "then"');const l={ref:t.ref(r),switch:[],break:o.break};for(let t=0;t<o.switch.length;++t){const r=o.switch[t],i=t===o.switch.length-1;n.assertOptions(r,i?["is","then","otherwise"]:["is","then"]),s(void 0!==r.is,'Switch statement missing "is"'),s(void 0!==r.then,'Switch statement missing "then"');const c={is:e.$_compile(r.is),then:e.$_compile(r.then)};if(a.isRef(r.is)||n.isSchema(r.is)||(c.is=c.is.required()),i){s(void 0===o.otherwise||void 0===r.otherwise,'Cannot specify "otherwise" inside and outside a "switch"');const t=void 0!==o.otherwise?o.otherwise:r.otherwise;void 0!==t&&(s(void 0===l.break,"Cannot specify both otherwise and break"),c.otherwise=e.$_compile(t))}l.switch.push(c)}return l},i.condition=function(e,t){for(const r of["then","otherwise"])void 0===t[r]?delete t[r]:t[r]=e.$_compile(t[r]);return t}},(e,t,r)=>{const s=r(27),n=r(30),a=r(100),i=r(103),o={};t.type=function(e,t){const r=Object.getPrototypeOf(e),l=n(r),c=e._assign(Object.create(l)),u=Object.assign({},t);delete u.base,l._definition=u;const p=r._definition||{};u.messages=i.merge(p.messages,u.messages),u.properties=Object.assign({},p.properties,u.properties),c.type=u.type,u.flags=Object.assign({},p.flags,u.flags);const h=Object.assign({},p.terms);if(u.terms)for(const e in u.terms){const t=u.terms[e];s(void 0===c.$_terms[e],"Invalid term override for",u.type,e),c.$_terms[e]=t.init,h[e]=t}u.terms=h,u.args||(u.args=p.args),u.prepare=o.prepare(u.prepare,p.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=o.coerce(u.coerce,p.coerce),u.validate=o.validate(u.validate,p.validate);const d=Object.assign({},p.rules);if(u.rules)for(const e in u.rules){const t=u.rules[e];s("object"==typeof t,"Invalid rule definition for",u.type,e);let r=t.method;if(void 0===r&&(r=function(){return this.$_addRule(e)}),r&&(s(!l[e],"Rule conflict in",u.type,e),l[e]=r),s(!d[e],"Rule conflict in",u.type,e),d[e]=t,t.alias){const e=[].concat(t.alias);for(const r of e)l[r]=t.method}t.args&&(t.argsByName=new Map,t.args=t.args.map((e=>("string"==typeof e&&(e={name:e}),s(!t.argsByName.has(e.name),"Duplicated argument name",e.name),a.isSchema(e.assert)&&(e.assert=e.assert.strict().label(e.name)),t.argsByName.set(e.name,e),e))))}u.rules=d;const f=Object.assign({},p.modifiers);if(u.modifiers)for(const e in u.modifiers){s(!l[e],"Rule conflict in",u.type,e);const t=u.modifiers[e];s("function"==typeof t,"Invalid modifier definition for",u.type,e);const r=function(t){return this.rule({[e]:t})};l[e]=r,f[e]=t}if(u.modifiers=f,u.overrides){l._super=r,c.$_super={};for(const e in u.overrides)s(r[e],"Cannot override missing",e),u.overrides[e][a.symbols.parent]=r[e],c.$_super[e]=r[e].bind(c);Object.assign(l,u.overrides)}u.cast=Object.assign({},p.cast,u.cast);const m=Object.assign({},p.manifest,u.manifest);return m.build=o.build(u.manifest&&u.manifest.build,p.manifest&&p.manifest.build),u.manifest=m,u.rebuild=o.rebuild(u.rebuild,p.rebuild),c},o.build=function(e,t){return e&&t?function(r,s){return t(e(r,s),s)}:e||t},o.coerce=function(e,t){return e&&t?{from:e.from&&t.from?[...new Set([...e.from,...t.from])]:null,method(r,s){let n;if((!t.from||t.from.includes(typeof r))&&(n=t.method(r,s),n)){if(n.errors||void 0===n.value)return n;r=n.value}if(!e.from||e.from.includes(typeof r)){const t=e.method(r,s);if(t)return t}return n}}:e||t},o.prepare=function(e,t){return e&&t?function(r,s){const n=e(r,s);if(n){if(n.errors||void 0===n.value)return n;r=n.value}return t(r,s)||n}:e||t},o.rebuild=function(e,t){return e&&t?function(r){t(r),e(r)}:e||t},o.validate=function(e,t){return e&&t?function(r,s){const n=t(r,s);if(n){if(n.errors&&(!Array.isArray(n.errors)||n.errors.length))return n;r=n.value}return e(r,s)||n}:e||t}},(e,t,r)=>{var s=r(14).Buffer;const n=r(27),a=r(30),i=r(100),o=r(103),l=r(108),c=r(104);let u;const p={};t.describe=function(e){const t=e._definition,r={type:e.type,flags:{},rules:[]};for(const t in e._flags)"_"!==t[0]&&(r.flags[t]=p.describe(e._flags[t]));Object.keys(r.flags).length||delete r.flags,e._preferences&&(r.preferences=a(e._preferences,{shallow:["messages"]}),delete r.preferences[i.symbols.prefs],r.preferences.messages&&(r.preferences.messages=o.decompile(r.preferences.messages))),e._valids&&(r.allow=e._valids.describe()),e._invalids&&(r.invalid=e._invalids.describe());for(const s of e._rules){if(!1===t.rules[s.name].manifest)continue;const e={name:s.name};for(const r in t.modifiers)void 0!==s[r]&&(e[r]=p.describe(s[r]));if(s.args){e.args={};for(const t in s.args){const r=s.args[t];("options"!==t||Object.keys(r).length)&&(e.args[t]=p.describe(r,{assign:t}))}Object.keys(e.args).length||delete e.args}r.rules.push(e)}r.rules.length||delete r.rules;for(const s in e.$_terms){if("_"===s[0])continue;n(!r[s],"Cannot describe schema due to internal name conflict with",s);const a=e.$_terms[s];if(!a)continue;if(a instanceof Map){a.size&&(r[s]=[...a.entries()]);continue}if(i.isValues(a)){r[s]=a.describe();continue}n(t.terms[s],"Term",s,"missing configuration");const o=t.terms[s].manifest,l="object"==typeof o;if(!a.length&&!l)continue;const c=[];for(const e of a)c.push(p.describe(e));if(l){const{from:e,to:t}=o.mapped;r[s]={};for(const n of c)r[s][n[t]]=n[e]}else"single"!==o?r[s]=c:(n(1===c.length,"Term",s,"contains more than one item"),r[s]=c[0])}return p.validate(e.$_root,r),r},p.describe=function(e,t={}){if(Array.isArray(e))return e.map(p.describe);if(e===i.symbols.deepDefault)return{special:"deep"};if("object"!=typeof e||null===e)return e;if("options"===t.assign)return a(e);if(s&&s.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"===t.assign?e.toString():{regex:e.toString()};if(e[i.symbols.literal])return{function:e.literal};if("function"==typeof e.describe)return"ref"===t.assign?e.describe().ref:e.describe();const r={};for(const t in e){const s=e[t];void 0!==s&&(r[t]=p.describe(s,{assign:t}))}return r},t.build=function(e,t){return new p.Builder(e).parse(t)},p.Builder=class{constructor(e){this.joi=e}parse(e){p.validate(this.joi,e);let t=this.joi[e.type]()._bare();const r=t._definition;if(e.flags)for(const s in e.flags){const a=r.flags[s]&&r.flags[s].setter||s;n("function"==typeof t[a],"Invalid flag",s,"for type",e.type),t=t[a](this.build(e.flags[s]))}if(e.preferences&&(t=t.preferences(this.build(e.preferences))),e.allow&&(t=t.allow(...this.build(e.allow))),e.invalid&&(t=t.invalid(...this.build(e.invalid))),e.rules)for(const s of e.rules){n("function"==typeof t[s.name],"Invalid rule",s.name,"for type",e.type);const a=[];if(s.args){const t={};for(const e in s.args)t[e]=this.build(s.args[e],{assign:e});const i=Object.keys(t),o=r.rules[s.name].args;if(o){n(i.length<=o.length,"Invalid number of arguments for",e.type,s.name,"(expected up to",o.length,", found",i.length,")");for(const{name:e}of o)a.push(t[e])}else n(1===i.length,"Invalid number of arguments for",e.type,s.name,"(expected up to 1, found",i.length,")"),a.push(t[i[0]])}t=t[s.name](...a);const i={};for(const e in r.modifiers)void 0!==s[e]&&(i[e]=this.build(s[e]));Object.keys(i).length&&(t=t.rule(i))}const s={};for(const t in e){if(["allow","flags","invalid","whens","preferences","rules","type"].includes(t))continue;n(r.terms[t],"Term",t,"missing configuration");const a=r.terms[t].manifest;if("schema"!==a)if("values"!==a)if("single"!==a)if("object"!=typeof a)s[t]=this.build(e[t]);else{s[t]={};for(const r in e[t]){const n=e[t][r];s[t][r]=this.parse(n)}}else s[t]=this.build(e[t]);else s[t]=e[t].map((e=>this.build(e)));else s[t]=e[t].map((e=>this.parse(e)))}return e.whens&&(s.whens=e.whens.map((e=>this.build(e)))),t=r.manifest.build(t,s),t.$_temp.ruleset=!1,t}build(e,t={}){if(null===e)return null;if(Array.isArray(e))return e.map((e=>this.build(e)));if(e instanceof Error)return e;if("options"===t.assign)return a(e);if("regex"===t.assign)return p.regex(e);if("ref"===t.assign)return l.build(e);if("object"!=typeof e)return e;if(1===Object.keys(e).length){if(e.buffer)return n(s,"Buffers are not supported"),s&&s.from(e.buffer,"binary");if(e.function)return{[i.symbols.literal]:!0,literal:e.function};if(e.override)return i.symbols.override;if(e.ref)return l.build(e.ref);if(e.regex)return p.regex(e.regex);if(e.special)return n(["deep"].includes(e.special),"Unknown special value",e.special),i.symbols.deepDefault;if(e.value)return a(e.value)}if(e.type)return this.parse(e);if(e.template)return c.build(e);const r={};for(const t in e)r[t]=this.build(e[t],{assign:t});return r}},p.regex=function(e){const t=e.lastIndexOf("/"),r=e.slice(1,t),s=e.slice(t+1);return new RegExp(r,s)},p.validate=function(e,t){u=u||r(102),e.assert(t,u.description)}},(e,t,r)=>{const s=r(39),n=r(113),a=r(106),i={codes:{error:1,pass:2,full:3},labels:{0:"never used",1:"always error",2:"always pass"}};t.setup=function(e){const t=function(){return e._tracer=e._tracer||new i.Tracer,e._tracer};e.trace=t,e[Symbol.for("@hapi/lab/coverage/initialize")]=t,e.untrace=()=>{e._tracer=null}},t.location=function(e){return e.$_setFlag("_tracerLocation",n.location(2))},i.Tracer=class{constructor(){this.name="Joi",this._schemas=new Map}_register(e){const t=this._schemas.get(e);if(t)return t.store;const r=new i.Store(e),{filename:s,line:a}=e._flags._tracerLocation||n.location(5);return this._schemas.set(e,{filename:s,line:a,store:r}),r}_combine(e,t){for(const{store:r}of this._schemas.values())r._combine(e,t)}report(e){const t=[];for(const{filename:r,line:s,store:n}of this._schemas.values()){if(e&&e!==r)continue;const a=[],o=[];for(const[e,t]of n._sources.entries()){if(i.sub(t.paths,o))continue;if(!t.entry){a.push({status:"never reached",paths:[...t.paths]}),o.push(...t.paths);continue}for(const r of["valid","invalid"]){const s=e[`_${r}s`];if(!s)continue;const n=new Set(s._values),i=new Set(s._refs);for(const{value:e,ref:s}of t[r])n.delete(e),i.delete(s);(n.size||i.size)&&a.push({status:[...n,...[...i].map((e=>e.display))],rule:`${r}s`})}const r=e._rules.map((e=>e.name));for(const t of["default","failover"])void 0!==e._flags[t]&&r.push(t);for(const e of r){const r=i.labels[t.rule[e]||0];if(r){const s={rule:e,status:r};t.paths.size&&(s.paths=[...t.paths]),a.push(s)}}}a.length&&t.push({filename:r,line:s,missing:a,severity:"error",message:`Schema missing tests for ${a.map(i.message).join(", ")}`})}return t.length?t:null}},i.Store=class{constructor(e){this.active=!0,this._sources=new Map,this._combos=new Map,this._scan(e)}debug(e,t,r,s){e.mainstay.debug&&e.mainstay.debug.push({type:t,name:r,result:s,path:e.path})}entry(e,t){i.debug(t,{type:"entry"}),this._record(e,(e=>{e.entry=!0}))}filter(e,t,r,s){i.debug(t,{type:r,...s}),this._record(e,(e=>{e[r].add(s)}))}log(e,t,r,s,n){i.debug(t,{type:r,name:s,result:"full"===n?"pass":n}),this._record(e,(e=>{e[r][s]=e[r][s]||0,e[r][s]|=i.codes[n]}))}resolve(e,t,r){if(!e.mainstay.debug)return;const s={type:"resolve",ref:t.display,to:r,path:e.path};e.mainstay.debug.push(s)}value(e,t,r,n,a){if(!e.mainstay.debug||s(r,n))return;const i={type:"value",by:t,from:r,to:n,path:e.path};a&&(i.name=a),e.mainstay.debug.push(i)}_record(e,t){const r=this._sources.get(e);if(r)return void t(r);const s=this._combos.get(e);for(const e of s)this._record(e,t)}_scan(e,t){const r=t||[];let s=this._sources.get(e);s||(s={paths:new Set,entry:!1,rule:{},valid:new Set,invalid:new Set},this._sources.set(e,s)),r.length&&s.paths.add(r);e.$_modify({each:(e,t)=>{const s=i.id(e,t);this._scan(e,r.concat(s))},ref:!1})}_combine(e,t){this._combos.set(e,t)}},i.message=function(e){return`${e.paths?a.path(e.paths[0])+(e.rule?":":""):""}${e.rule||""} (${e.status})`},i.id=function(e,{source:t,name:r,path:s,key:n}){return e._flags.id?e._flags.id:n||(r=`@${r}`,"terms"===t?[r,s[Math.min(s.length-1,1)]]:r)},i.sub=function(e,t){for(const r of e)for(const e of t)if(s(r.slice(0,e.length),e))return!0;return!1},i.debug=function(e,t){e.mainstay.debug&&(t.path=e.debug?[...e.path,e.debug]:e.path,e.mainstay.debug.push(t))}},(e,t)=>{t.location=function(e=0){const t=Error.prepareStackTrace;Error.prepareStackTrace=(e,t)=>t;const r={};Error.captureStackTrace(r,this);const s=r.stack[e+1];return Error.prepareStackTrace=t,{filename:s.getFileName(),line:s.getLineNumber()}}},(e,t,r)=>{const s=r(27),n=r(34),a=r(115),i=r(100),o=r(109),l=r(106),c=r(108),u={};e.exports=a.extend({type:"alternatives",flags:{match:{default:"any"}},terms:{matches:{init:[],register:c.toSibling}},args:(e,...t)=>1===t.length&&Array.isArray(t[0])?e.try(...t[0]):e.try(...t),validate(e,t){const{schema:r,error:s,state:a,prefs:i}=t;if(r._flags.match){const t=[],o=[];for(let s=0;s<r.$_terms.matches.length;++s){const n=r.$_terms.matches[s],l=a.nest(n.schema,`match.${s}`);l.snapshot();const c=n.schema.$_validate(e,l,i);c.errors?(o.push(c.errors),l.restore()):(t.push(c.value),l.commit())}if(0===t.length){return{errors:s("alternatives.any",{details:o.map((e=>l.details(e,{override:!1})))})}}if("one"===r._flags.match)return 1===t.length?{value:t[0]}:{errors:s("alternatives.one")};if(t.length!==r.$_terms.matches.length){return{errors:s("alternatives.all",{details:o.map((e=>l.details(e,{override:!1})))})}}const c=e=>e.$_terms.matches.some((e=>"object"===e.schema.type||"alternatives"===e.schema.type&&c(e.schema)));return c(r)?{value:t.reduce(((e,t)=>n(e,t,{mergeArrays:!1})))}:{value:t[t.length-1]}}const o=[];for(let t=0;t<r.$_terms.matches.length;++t){const s=r.$_terms.matches[t];if(s.schema){const r=a.nest(s.schema,`match.${t}`);r.snapshot();const n=s.schema.$_validate(e,r,i);if(!n.errors)return r.commit(),n;r.restore(),o.push({schema:s.schema,reports:n.errors});continue}const n=s.ref?s.ref.resolve(e,a,i):e,l=s.is?[s]:s.switch;for(let r=0;r<l.length;++r){const o=l[r],{is:c,then:u,otherwise:p}=o,h=`match.${t}${s.switch?"."+r:""}`;if(c.$_match(n,a.nest(c,`${h}.is`),i)){if(u)return u.$_validate(e,a.nest(u,`${h}.then`),i)}else if(p)return p.$_validate(e,a.nest(p,`${h}.otherwise`),i)}}return u.errors(o,t)},rules:{conditional:{method(e,t){s(!this._flags._endedSwitch,"Unreachable condition"),s(!this._flags.match,"Cannot combine match mode",this._flags.match,"with conditional rule"),s(void 0===t.break,"Cannot use break option with alternatives conditional");const r=this.clone(),n=o.when(r,e,t),a=n.is?[n]:n.switch;for(const e of a)if(e.then&&e.otherwise){r.$_setFlag("_endedSwitch",!0,{clone:!1});break}return r.$_terms.matches.push(n),r.$_mutateRebuild()}},match:{method(e){if(s(["any","one","all"].includes(e),"Invalid alternatives match mode",e),"any"!==e)for(const t of this.$_terms.matches)s(t.schema,"Cannot combine match mode",e,"with conditional rules");return this.$_setFlag("match",e)}},try:{method(...e){s(e.length,"Missing alternative schemas"),i.verifyFlat(e,"try"),s(!this._flags._endedSwitch,"Unreachable condition");const t=this.clone();for(const r of e)t.$_terms.matches.push({schema:t.$_compile(r)});return t.$_mutateRebuild()}}},overrides:{label(e){return this.$_parent("label",e).$_modify({each:(t,r)=>"is"!==r.path[0]&&"string"!=typeof t._flags.label?t.label(e):void 0,ref:!1})}},rebuild(e){e.$_modify({each:t=>{i.isSchema(t)&&"array"===t.type&&e.$_setFlag("_arrayItems",!0,{clone:!1})}})},manifest:{build(e,t){if(t.matches)for(const r of t.matches){const{schema:t,ref:s,is:n,not:a,then:i,otherwise:o}=r;e=t?e.try(t):s?e.conditional(s,{is:n,then:i,not:a,otherwise:o,switch:r.switch}):e.conditional(n,{then:i,otherwise:o})}return e}},messages:{"alternatives.all":"{{#label}} does not match all of the required types","alternatives.any":"{{#label}} does not match any of the allowed types","alternatives.match":"{{#label}} does not match any of the allowed types","alternatives.one":"{{#label}} matches more than one allowed type","alternatives.types":"{{#label}} must be one of {{#types}}"}}),u.errors=function(e,{error:t,state:r}){if(!e.length)return{errors:t("alternatives.any")};if(1===e.length)return{errors:e[0].reports};const s=new Set,n=[];for(const{reports:a,schema:i}of e){if(a.length>1)return u.unmatched(e,t);const o=a[0];if(o instanceof l.Report==!1)return u.unmatched(e,t);if(o.state.path.length!==r.path.length){n.push({type:i.type,report:o});continue}if("any.only"===o.code){for(const e of o.local.valids)s.add(e);continue}const[c,p]=o.code.split(".");"base"===p?s.add(c):n.push({type:i.type,report:o})}return n.length?1===n.length?{errors:n[0].report}:u.unmatched(e,t):{errors:t("alternatives.types",{types:[...s]})}},u.unmatched=function(e,t){const r=[];for(const t of e)r.push(...t.reports);return{errors:t("alternatives.match",l.details(r,{override:!1}))}}},(e,t,r)=>{const s=r(27),n=r(116),a=r(100),i=r(103);e.exports=n.extend({type:"any",flags:{only:{default:!1}},terms:{alterations:{init:null},examples:{init:null},externals:{init:null},metas:{init:[]},notes:{init:[]},shared:{init:null},tags:{init:[]},whens:{init:null}},rules:{custom:{method(e,t){return s("function"==typeof e,"Method must be a function"),s(void 0===t||t&&"string"==typeof t,"Description must be a non-empty string"),this.$_addRule({name:"custom",args:{method:e,description:t}})},validate(e,t,{method:r}){try{return r(e,t)}catch(e){return t.error("any.custom",{error:e})}},args:["method","description"],multi:!0},messages:{method(e){return this.prefs({messages:e})}},shared:{method(e){s(a.isSchema(e)&&e._flags.id,"Schema must be a schema with an id");const t=this.clone();return t.$_terms.shared=t.$_terms.shared||[],t.$_terms.shared.push(e),t.$_mutateRegister(e),t}},warning:{method(e,t){return s(e&&"string"==typeof e,"Invalid warning code"),this.$_addRule({name:"warning",args:{code:e,local:t},warn:!0})},validate:(e,t,{code:r,local:s})=>t.error(r,s),args:["code","local"],multi:!0}},modifiers:{keep(e,t=!0){e.keep=t},message(e,t){e.message=i.compile(t)},warn(e,t=!0){e.warn=t}},manifest:{build(e,t){for(const r in t){const s=t[r];if(["examples","externals","metas","notes","tags"].includes(r))for(const t of s)e=e[r.slice(0,-1)](t);else if("alterations"!==r)if("whens"!==r){if("shared"===r)for(const t of s)e=e.shared(t)}else for(const t of s){const{ref:r,is:s,not:n,then:a,otherwise:i,concat:o}=t;e=o?e.concat(o):r?e.when(r,{is:s,not:n,then:a,otherwise:i,switch:t.switch,break:t.break}):e.when(s,{then:a,otherwise:i,break:t.break})}else{const t={};for(const{target:e,adjuster:r}of s)t[e]=r;e=e.alter(t)}}return e}},messages:{"any.custom":"{{#label}} failed custom validation because {{#error.message}}","any.default":"{{#label}} threw an error when running default method","any.failover":"{{#label}} threw an error when running failover method","any.invalid":"{{#label}} contains an invalid value","any.only":'{{#label}} must be {if(#valids.length == 1, "", "one of ")}{{#valids}}',"any.ref":"{{#label}} {{#arg}} references {{:#ref}} which {{#reason}}","any.required":"{{#label}} is required","any.unknown":"{{#label}} is not allowed"}})},(e,t,r)=>{const s=r(27),n=r(30),a=r(39),i=r(34),o=r(99),l=r(100),c=r(109),u=r(106),p=r(110),h=r(111),d=r(103),f=r(117),m=r(108),g=r(112),y=r(118),b=r(120),v={Base:class{constructor(e){this.type=e,this.$_root=null,this._definition={},this._reset()}_reset(){this._ids=new f.Ids,this._preferences=null,this._refs=new m.Manager,this._cache=null,this._valids=null,this._invalids=null,this._flags={},this._rules=[],this._singleRules=new Map,this.$_terms={},this.$_temp={ruleset:null,whens:{}}}describe(){return s("function"==typeof h.describe,"Manifest functionality disabled"),h.describe(this)}allow(...e){return l.verifyFlat(e,"allow"),this._values(e,"_valids")}alter(e){s(e&&"object"==typeof e&&!Array.isArray(e),"Invalid targets argument"),s(!this._inRuleset(),"Cannot set alterations inside a ruleset");const t=this.clone();t.$_terms.alterations=t.$_terms.alterations||[];for(const r in e){const n=e[r];s("function"==typeof n,"Alteration adjuster for",r,"must be a function"),t.$_terms.alterations.push({target:r,adjuster:n})}return t.$_temp.ruleset=!1,t}artifact(e){return s(void 0!==e,"Artifact cannot be undefined"),s(!this._cache,"Cannot set an artifact with a rule cache"),this.$_setFlag("artifact",e)}cast(e){return s(!1===e||"string"==typeof e,"Invalid to value"),s(!1===e||this._definition.cast[e],"Type",this.type,"does not support casting to",e),this.$_setFlag("cast",!1===e?void 0:e)}default(e,t){return this._default("default",e,t)}description(e){return s(e&&"string"==typeof e,"Description must be a non-empty string"),this.$_setFlag("description",e)}empty(e){const t=this.clone();return void 0!==e&&(e=t.$_compile(e,{override:!1})),t.$_setFlag("empty",e,{clone:!1})}error(e){return s(e,"Missing error"),s(e instanceof Error||"function"==typeof e,"Must provide a valid Error object or a function"),this.$_setFlag("error",e)}example(e,t={}){return s(void 0!==e,"Missing example"),l.assertOptions(t,["override"]),this._inner("examples",e,{single:!0,override:t.override})}external(e,t){return"object"==typeof e&&(s(!t,"Cannot combine options with description"),t=e.description,e=e.method),s("function"==typeof e,"Method must be a function"),s(void 0===t||t&&"string"==typeof t,"Description must be a non-empty string"),this._inner("externals",{method:e,description:t},{single:!0})}failover(e,t){return this._default("failover",e,t)}forbidden(){return this.presence("forbidden")}id(e){return e?(s("string"==typeof e,"id must be a non-empty string"),s(/^[^\.]+$/.test(e),"id cannot contain period character"),this.$_setFlag("id",e)):this.$_setFlag("id",void 0)}invalid(...e){return this._values(e,"_invalids")}label(e){return s(e&&"string"==typeof e,"Label name must be a non-empty string"),this.$_setFlag("label",e)}meta(e){return s(void 0!==e,"Meta cannot be undefined"),this._inner("metas",e,{single:!0})}note(...e){s(e.length,"Missing notes");for(const t of e)s(t&&"string"==typeof t,"Notes must be non-empty strings");return this._inner("notes",e)}only(e=!0){return s("boolean"==typeof e,"Invalid mode:",e),this.$_setFlag("only",e)}optional(){return this.presence("optional")}prefs(e){s(e,"Missing preferences"),s(void 0===e.context,"Cannot override context"),s(void 0===e.externals,"Cannot override externals"),s(void 0===e.warnings,"Cannot override warnings"),s(void 0===e.debug,"Cannot override debug"),l.checkPreferences(e);const t=this.clone();return t._preferences=l.preferences(t._preferences,e),t}presence(e){return s(["optional","required","forbidden"].includes(e),"Unknown presence mode",e),this.$_setFlag("presence",e)}raw(e=!0){return this.$_setFlag("result",e?"raw":void 0)}result(e){return s(["raw","strip"].includes(e),"Unknown result mode",e),this.$_setFlag("result",e)}required(){return this.presence("required")}strict(e){const t=this.clone(),r=void 0!==e&&!e;return t._preferences=l.preferences(t._preferences,{convert:r}),t}strip(e=!0){return this.$_setFlag("result",e?"strip":void 0)}tag(...e){s(e.length,"Missing tags");for(const t of e)s(t&&"string"==typeof t,"Tags must be non-empty strings");return this._inner("tags",e)}unit(e){return s(e&&"string"==typeof e,"Unit name must be a non-empty string"),this.$_setFlag("unit",e)}valid(...e){l.verifyFlat(e,"valid");const t=this.allow(...e);return t.$_setFlag("only",!!t._valids,{clone:!1}),t}when(e,t){const r=this.clone();r.$_terms.whens||(r.$_terms.whens=[]);const n=c.when(r,e,t);if(!["any","link"].includes(r.type)){const e=n.is?[n]:n.switch;for(const t of e)s(!t.then||"any"===t.then.type||t.then.type===r.type,"Cannot combine",r.type,"with",t.then&&t.then.type),s(!t.otherwise||"any"===t.otherwise.type||t.otherwise.type===r.type,"Cannot combine",r.type,"with",t.otherwise&&t.otherwise.type)}return r.$_terms.whens.push(n),r.$_mutateRebuild()}cache(e){s(!this._inRuleset(),"Cannot set caching inside a ruleset"),s(!this._cache,"Cannot override schema cache"),s(void 0===this._flags.artifact,"Cannot cache a rule with an artifact");const t=this.clone();return t._cache=e||o.provider.provision(),t.$_temp.ruleset=!1,t}clone(){const e=Object.create(Object.getPrototypeOf(this));return this._assign(e)}concat(e){s(l.isSchema(e),"Invalid schema object"),s("any"===this.type||"any"===e.type||e.type===this.type,"Cannot merge type",this.type,"with another type:",e.type),s(!this._inRuleset(),"Cannot concatenate onto a schema with open ruleset"),s(!e._inRuleset(),"Cannot concatenate a schema with open ruleset");let t=this.clone();if("any"===this.type&&"any"!==e.type){const r=e.clone();for(const e of Object.keys(t))"type"!==e&&(r[e]=t[e]);t=r}t._ids.concat(e._ids),t._refs.register(e,m.toSibling),t._preferences=t._preferences?l.preferences(t._preferences,e._preferences):e._preferences,t._valids=b.merge(t._valids,e._valids,e._invalids),t._invalids=b.merge(t._invalids,e._invalids,e._valids);for(const r of e._singleRules.keys())t._singleRules.has(r)&&(t._rules=t._rules.filter((e=>e.keep||e.name!==r)),t._singleRules.delete(r));for(const r of e._rules)e._definition.rules[r.method].multi||t._singleRules.set(r.name,r),t._rules.push(r);if(t._flags.empty&&e._flags.empty){t._flags.empty=t._flags.empty.concat(e._flags.empty);const r=Object.assign({},e._flags);delete r.empty,i(t._flags,r)}else if(e._flags.empty){t._flags.empty=e._flags.empty;const r=Object.assign({},e._flags);delete r.empty,i(t._flags,r)}else i(t._flags,e._flags);for(const r in e.$_terms){const s=e.$_terms[r];s?t.$_terms[r]?t.$_terms[r]=t.$_terms[r].concat(s):t.$_terms[r]=s.slice():t.$_terms[r]||(t.$_terms[r]=s)}return this.$_root._tracer&&this.$_root._tracer._combine(t,[this,e]),t.$_mutateRebuild()}extend(e){return s(!e.base,"Cannot extend type with another base"),p.type(this,e)}extract(e){return e=Array.isArray(e)?e:e.split("."),this._ids.reach(e)}fork(e,t){s(!this._inRuleset(),"Cannot fork inside a ruleset");let r=this;for(let s of[].concat(e))s=Array.isArray(s)?s:s.split("."),r=r._ids.fork(s,t,r);return r.$_temp.ruleset=!1,r}rule(e){const t=this._definition;l.assertOptions(e,Object.keys(t.modifiers)),s(!1!==this.$_temp.ruleset,"Cannot apply rules to empty ruleset or the last rule added does not support rule properties");const r=null===this.$_temp.ruleset?this._rules.length-1:this.$_temp.ruleset;s(r>=0&&r<this._rules.length,"Cannot apply rules to empty ruleset");const a=this.clone();for(let i=r;i<a._rules.length;++i){const r=a._rules[i],o=n(r);for(const n in e)t.modifiers[n](o,e[n]),s(o.name===r.name,"Cannot change rule name");a._rules[i]=o,a._singleRules.get(o.name)===r&&a._singleRules.set(o.name,o)}return a.$_temp.ruleset=!1,a.$_mutateRebuild()}get ruleset(){s(!this._inRuleset(),"Cannot start a new ruleset without closing the previous one");const e=this.clone();return e.$_temp.ruleset=e._rules.length,e}get $(){return this.ruleset}tailor(e){e=[].concat(e),s(!this._inRuleset(),"Cannot tailor inside a ruleset");let t=this;if(this.$_terms.alterations)for(const{target:r,adjuster:n}of this.$_terms.alterations)e.includes(r)&&(t=n(t),s(l.isSchema(t),"Alteration adjuster for",r,"failed to return a schema object"));return t=t.$_modify({each:t=>t.tailor(e),ref:!1}),t.$_temp.ruleset=!1,t.$_mutateRebuild()}tracer(){return g.location?g.location(this):this}validate(e,t){return y.entry(e,this,t)}validateAsync(e,t){return y.entryAsync(e,this,t)}$_addRule(e){"string"==typeof e&&(e={name:e}),s(e&&"object"==typeof e,"Invalid options"),s(e.name&&"string"==typeof e.name,"Invalid rule name");for(const t in e)s("_"!==t[0],"Cannot set private rule properties");const t=Object.assign({},e);t._resolve=[],t.method=t.method||t.name;const r=this._definition.rules[t.method],n=t.args;s(r,"Unknown rule",t.method);const a=this.clone();if(n){s(1===Object.keys(n).length||Object.keys(n).length===this._definition.rules[t.name].args.length,"Invalid rule definition for",this.type,t.name);for(const e in n){let i=n[e];if(r.argsByName){const o=r.argsByName.get(e);if(o.ref&&l.isResolvable(i))t._resolve.push(e),a.$_mutateRegister(i);else if(o.normalize&&(i=o.normalize(i),n[e]=i),o.assert){const t=l.validateArg(i,e,o);s(!t,t,"or reference")}}void 0!==i?n[e]=i:delete n[e]}}return r.multi||(a._ruleRemove(t.name,{clone:!1}),a._singleRules.set(t.name,t)),!1===a.$_temp.ruleset&&(a.$_temp.ruleset=null),r.priority?a._rules.unshift(t):a._rules.push(t),a}$_compile(e,t){return c.schema(this.$_root,e,t)}$_createError(e,t,r,s,n,a={}){const i=!1!==a.flags?this._flags:{},o=a.messages?d.merge(this._definition.messages,a.messages):this._definition.messages;return new u.Report(e,t,r,i,o,s,n)}$_getFlag(e){return this._flags[e]}$_getRule(e){return this._singleRules.get(e)}$_mapLabels(e){return e=Array.isArray(e)?e:e.split("."),this._ids.labels(e)}$_match(e,t,r,s){(r=Object.assign({},r)).abortEarly=!0,r._externals=!1,t.snapshot();const n=!y.validate(e,this,t,r,s).errors;return t.restore(),n}$_modify(e){return l.assertOptions(e,["each","once","ref","schema"]),f.schema(this,e)||this}$_mutateRebuild(){s(!this._inRuleset(),"Cannot add this rule inside a ruleset"),this._refs.reset(),this._ids.reset();return this.$_modify({each:(e,{source:t,name:r,path:s,key:n})=>{const a=this._definition[t][r]&&this._definition[t][r].register;!1!==a&&this.$_mutateRegister(e,{family:a,key:n})}}),this._definition.rebuild&&this._definition.rebuild(this),this.$_temp.ruleset=!1,this}$_mutateRegister(e,{family:t,key:r}={}){this._refs.register(e,t),this._ids.register(e,{key:r})}$_property(e){return this._definition.properties[e]}$_reach(e){return this._ids.reach(e)}$_rootReferences(){return this._refs.roots()}$_setFlag(e,t,r={}){s("_"===e[0]||!this._inRuleset(),"Cannot set flag inside a ruleset");const n=this._definition.flags[e]||{};if(a(t,n.default)&&(t=void 0),a(t,this._flags[e]))return this;const i=!1!==r.clone?this.clone():this;return void 0!==t?(i._flags[e]=t,i.$_mutateRegister(t)):delete i._flags[e],"_"!==e[0]&&(i.$_temp.ruleset=!1),i}$_parent(e,...t){return this[e][l.symbols.parent].call(this,...t)}$_validate(e,t,r){return y.validate(e,this,t,r)}_assign(e){e.type=this.type,e.$_root=this.$_root,e.$_temp=Object.assign({},this.$_temp),e.$_temp.whens={},e._ids=this._ids.clone(),e._preferences=this._preferences,e._valids=this._valids&&this._valids.clone(),e._invalids=this._invalids&&this._invalids.clone(),e._rules=this._rules.slice(),e._singleRules=n(this._singleRules,{shallow:!0}),e._refs=this._refs.clone(),e._flags=Object.assign({},this._flags),e._cache=null,e.$_terms={};for(const t in this.$_terms)e.$_terms[t]=this.$_terms[t]?this.$_terms[t].slice():null;e.$_super={};for(const t in this.$_super)e.$_super[t]=this._super[t].bind(e);return e}_bare(){const e=this.clone();e._reset();const t=e._definition.terms;for(const r in t){const s=t[r];e.$_terms[r]=s.init}return e.$_mutateRebuild()}_default(e,t,r={}){l.assertOptions(r,"literal"),s(void 0!==t,"Missing",e,"value"),s("function"==typeof t||!r.literal,"Only function value supports literal option"),"function"==typeof t&&r.literal&&(t={[l.symbols.literal]:!0,literal:t});return this.$_setFlag(e,t)}_generate(e,t,r){if(!this.$_terms.whens)return{schema:this};const s=[],n=[];for(let a=0;a<this.$_terms.whens.length;++a){const i=this.$_terms.whens[a];if(i.concat){s.push(i.concat),n.push(`${a}.concat`);continue}const o=i.ref?i.ref.resolve(e,t,r):e,l=i.is?[i]:i.switch,c=n.length;for(let c=0;c<l.length;++c){const{is:u,then:p,otherwise:h}=l[c],d=`${a}${i.switch?"."+c:""}`;if(u.$_match(o,t.nest(u,`${d}.is`),r)){if(p){const a=t.localize([...t.path,`${d}.then`],t.ancestors,t.schemas),{schema:i,id:o}=p._generate(e,a,r);s.push(i),n.push(`${d}.then${o?`(${o})`:""}`);break}}else if(h){const a=t.localize([...t.path,`${d}.otherwise`],t.ancestors,t.schemas),{schema:i,id:o}=h._generate(e,a,r);s.push(i),n.push(`${d}.otherwise${o?`(${o})`:""}`);break}}if(i.break&&n.length>c)break}const a=n.join(", ");if(t.mainstay.tracer.debug(t,"rule","when",a),!a)return{schema:this};if(!t.mainstay.tracer.active&&this.$_temp.whens[a])return{schema:this.$_temp.whens[a],id:a};let i=this;this._definition.generate&&(i=this._definition.generate(this,e,t,r));for(const e of s)i=i.concat(e);return this.$_root._tracer&&this.$_root._tracer._combine(i,[this,...s]),this.$_temp.whens[a]=i,{schema:i,id:a}}_inner(e,t,r={}){s(!this._inRuleset(),`Cannot set ${e} inside a ruleset`);const n=this.clone();return n.$_terms[e]&&!r.override||(n.$_terms[e]=[]),r.single?n.$_terms[e].push(t):n.$_terms[e].push(...t),n.$_temp.ruleset=!1,n}_inRuleset(){return null!==this.$_temp.ruleset&&!1!==this.$_temp.ruleset}_ruleRemove(e,t={}){if(!this._singleRules.has(e))return this;const r=!1!==t.clone?this.clone():this;r._singleRules.delete(e);const s=[];for(let t=0;t<r._rules.length;++t){const n=r._rules[t];n.name!==e||n.keep?s.push(n):r._inRuleset()&&t<r.$_temp.ruleset&&--r.$_temp.ruleset}return r._rules=s,r}_values(e,t){l.verifyFlat(e,t.slice(1,-1));const r=this.clone(),n=e[0]===l.symbols.override;if(n&&(e=e.slice(1)),!r[t]&&e.length?r[t]=new b:n&&(r[t]=e.length?new b:null,r.$_mutateRebuild()),!r[t])return r;n&&r[t].override();for(const n of e){s(void 0!==n,"Cannot call allow/valid/invalid with undefined"),s(n!==l.symbols.override,"Override must be the first value");const e="_invalids"===t?"_valids":"_invalids";r[e]&&(r[e].remove(n),r[e].length||(s("_valids"===t||!r._flags.only,"Setting invalid value",n,"leaves schema rejecting all values due to previous valid rule"),r[e]=null)),r[t].add(n,r._refs)}return r}}};v.Base.prototype[l.symbols.any]={version:l.version,compile:c.compile,root:"$_root"},v.Base.prototype.isImmutable=!0,v.Base.prototype.deny=v.Base.prototype.invalid,v.Base.prototype.disallow=v.Base.prototype.invalid,v.Base.prototype.equal=v.Base.prototype.valid,v.Base.prototype.exist=v.Base.prototype.required,v.Base.prototype.not=v.Base.prototype.invalid,v.Base.prototype.options=v.Base.prototype.prefs,v.Base.prototype.preferences=v.Base.prototype.prefs,e.exports=new v.Base},(e,t,r)=>{const s=r(27),n=r(100),a=r(108),i={};t.Ids=i.Ids=class{constructor(){this._byId=new Map,this._byKey=new Map,this._schemaChain=!1}clone(){const e=new i.Ids;return e._byId=new Map(this._byId),e._byKey=new Map(this._byKey),e._schemaChain=this._schemaChain,e}concat(e){e._schemaChain&&(this._schemaChain=!0);for(const[t,r]of e._byId.entries())s(!this._byKey.has(t),"Schema id conflicts with existing key:",t),this._byId.set(t,r);for(const[t,r]of e._byKey.entries())s(!this._byId.has(t),"Schema key conflicts with existing id:",t),this._byKey.set(t,r)}fork(e,t,r){const a=this._collect(e);a.push({schema:r});const o=a.shift();let l={id:o.id,schema:t(o.schema)};s(n.isSchema(l.schema),"adjuster function failed to return a joi schema type");for(const e of a)l={id:e.id,schema:i.fork(e.schema,l.id,l.schema)};return l.schema}labels(e,t=[]){const r=e[0],s=this._get(r);if(!s)return[...t,...e].join(".");const n=e.slice(1);return t=[...t,s.schema._flags.label||r],n.length?s.schema._ids.labels(n,t):t.join(".")}reach(e,t=[]){const r=e[0],n=this._get(r);s(n,"Schema does not contain path",[...t,...e].join("."));const a=e.slice(1);return a.length?n.schema._ids.reach(a,[...t,r]):n.schema}register(e,{key:t}={}){if(!e||!n.isSchema(e))return;(e.$_property("schemaChain")||e._ids._schemaChain)&&(this._schemaChain=!0);const r=e._flags.id;if(r){const t=this._byId.get(r);s(!t||t.schema===e,"Cannot add different schemas with the same id:",r),s(!this._byKey.has(r),"Schema id conflicts with existing key:",r),this._byId.set(r,{schema:e,id:r})}t&&(s(!this._byKey.has(t),"Schema already contains key:",t),s(!this._byId.has(t),"Schema key conflicts with existing id:",t),this._byKey.set(t,{schema:e,id:t}))}reset(){this._byId=new Map,this._byKey=new Map,this._schemaChain=!1}_collect(e,t=[],r=[]){const n=e[0],a=this._get(n);s(a,"Schema does not contain path",[...t,...e].join(".")),r=[a,...r];const i=e.slice(1);return i.length?a.schema._ids._collect(i,[...t,n],r):r}_get(e){return this._byId.get(e)||this._byKey.get(e)}},i.fork=function(e,r,s){const n=t.schema(e,{each:(e,{key:t})=>{if(r===(e._flags.id||t))return s},ref:!1});return n?n.$_mutateRebuild():e},t.schema=function(e,t){let r;for(const s in e._flags){if("_"===s[0])continue;const n=i.scan(e._flags[s],{source:"flags",name:s},t);void 0!==n&&(r=r||e.clone(),r._flags[s]=n)}for(let s=0;s<e._rules.length;++s){const n=e._rules[s],a=i.scan(n.args,{source:"rules",name:n.name},t);if(void 0!==a){r=r||e.clone();const t=Object.assign({},n);t.args=a,r._rules[s]=t;r._singleRules.get(n.name)===n&&r._singleRules.set(n.name,t)}}for(const s in e.$_terms){if("_"===s[0])continue;const n=i.scan(e.$_terms[s],{source:"terms",name:s},t);void 0!==n&&(r=r||e.clone(),r.$_terms[s]=n)}return r},i.scan=function(e,t,r,s,o){const l=s||[];if(null===e||"object"!=typeof e)return;let c;if(Array.isArray(e)){for(let s=0;s<e.length;++s){const n="terms"===t.source&&"keys"===t.name&&e[s].key,a=i.scan(e[s],t,r,[s,...l],n);void 0!==a&&(c=c||e.slice(),c[s]=a)}return c}if(!1!==r.schema&&n.isSchema(e)||!1!==r.ref&&a.isRef(e)){const s=r.each(e,{...t,path:l,key:o});if(s===e)return;return s}for(const s in e){if("_"===s[0])continue;const n=i.scan(e[s],t,r,[s,...l],o);void 0!==n&&(c=c||Object.assign({},e),c[s]=n)}return c}},(e,t,r)=>{const s=r(27),n=r(30),a=r(37),i=r(31),o=r(100),l=r(106),c=r(119),u={result:Symbol("result")};t.entry=function(e,t,r){let n=o.defaults;r&&(s(void 0===r.warnings,"Cannot override warnings preference in synchronous validation"),s(void 0===r.artifacts,"Cannot override artifacts preference in synchronous validation"),n=o.preferences(o.defaults,r));const a=u.entry(e,t,n);s(!a.mainstay.externals.length,"Schema with external rules must use validateAsync()");const i={value:a.value};return a.error&&(i.error=a.error),a.mainstay.warnings.length&&(i.warning=l.details(a.mainstay.warnings)),a.mainstay.debug&&(i.debug=a.mainstay.debug),a.mainstay.artifacts&&(i.artifacts=a.mainstay.artifacts),i},t.entryAsync=async function(e,t,r){let s=o.defaults;r&&(s=o.preferences(o.defaults,r));const n=u.entry(e,t,s),a=n.mainstay;if(n.error)throw a.debug&&(n.error.debug=a.debug),n.error;if(a.externals.length){let t=n.value;const c=[];for(const n of a.externals){const p=n.state.path,h="link"===n.schema.type?a.links.get(n.schema):null;let d,f,m=t;const g=p.length?[t]:[],y=p.length?i(e,p):e;if(p.length){d=p[p.length-1];let e=t;for(const t of p.slice(0,-1))e=e[t],g.unshift(e);f=g[0],m=f[d]}try{const e=(e,t)=>(h||n.schema).$_createError(e,m,t,n.state,s),i=await n.method(m,{schema:n.schema,linked:h,state:n.state,prefs:r,original:y,error:e,errorsArray:u.errorsArray,warn:(e,t)=>a.warnings.push((h||n.schema).$_createError(e,m,t,n.state,s)),message:(e,t)=>(h||n.schema).$_createError("external",m,t,n.state,s,{messages:e})});if(void 0===i||i===m)continue;if(i instanceof l.Report){if(a.tracer.log(n.schema,n.state,"rule","external","error"),c.push(i),s.abortEarly)break;continue}if(Array.isArray(i)&&i[o.symbols.errors]){if(a.tracer.log(n.schema,n.state,"rule","external","error"),c.push(...i),s.abortEarly)break;continue}f?(a.tracer.value(n.state,"rule",m,i,"external"),f[d]=i):(a.tracer.value(n.state,"rule",t,i,"external"),t=i)}catch(e){throw s.errors.label&&(e.message+=` (${n.label})`),e}}if(n.value=t,c.length)throw n.error=l.process(c,e,s),a.debug&&(n.error.debug=a.debug),n.error}if(!s.warnings&&!s.debug&&!s.artifacts)return n.value;const c={value:n.value};return a.warnings.length&&(c.warning=l.details(a.warnings)),a.debug&&(c.debug=a.debug),a.artifacts&&(c.artifacts=a.artifacts),c},u.Mainstay=class{constructor(e,t,r){this.externals=[],this.warnings=[],this.tracer=e,this.debug=t,this.links=r,this.shadow=null,this.artifacts=null,this._snapshots=[]}snapshot(){this._snapshots.push({externals:this.externals.slice(),warnings:this.warnings.slice()})}restore(){const e=this._snapshots.pop();this.externals=e.externals,this.warnings=e.warnings}commit(){this._snapshots.pop()}},u.entry=function(e,r,s){const{tracer:n,cleanup:a}=u.tracer(r,s),i=s.debug?[]:null,o=r._ids._schemaChain?new Map:null,p=new u.Mainstay(n,i,o),h=r._ids._schemaChain?[{schema:r}]:null,d=new c([],[],{mainstay:p,schemas:h}),f=t.validate(e,r,d,s);a&&r.$_root.untrace();const m=l.process(f.errors,e,s);return{value:f.value,error:m,mainstay:p}},u.tracer=function(e,t){return e.$_root._tracer?{tracer:e.$_root._tracer._register(e)}:t.debug?(s(e.$_root.trace,"Debug mode not supported"),{tracer:e.$_root.trace()._register(e),cleanup:!0}):{tracer:u.ignore}},t.validate=function(e,t,r,s,n={}){if(t.$_terms.whens&&(t=t._generate(e,r,s).schema),t._preferences&&(s=u.prefs(t,s)),t._cache&&s.cache){const s=t._cache.get(e);if(r.mainstay.tracer.debug(r,"validate","cached",!!s),s)return s}const a=(n,a,i)=>t.$_createError(n,e,a,i||r,s),i={original:e,prefs:s,schema:t,state:r,error:a,errorsArray:u.errorsArray,warn:(e,t,s)=>r.mainstay.warnings.push(a(e,t,s)),message:(n,a)=>t.$_createError("custom",e,a,r,s,{messages:n})};r.mainstay.tracer.entry(t,r);const l=t._definition;if(l.prepare&&void 0!==e&&s.convert){const t=l.prepare(e,i);if(t){if(r.mainstay.tracer.value(r,"prepare",e,t.value),t.errors)return u.finalize(t.value,[].concat(t.errors),i);e=t.value}}if(l.coerce&&void 0!==e&&s.convert&&(!l.coerce.from||l.coerce.from.includes(typeof e))){const t=l.coerce.method(e,i);if(t){if(r.mainstay.tracer.value(r,"coerced",e,t.value),t.errors)return u.finalize(t.value,[].concat(t.errors),i);e=t.value}}const c=t._flags.empty;c&&c.$_match(u.trim(e,t),r.nest(c),o.defaults)&&(r.mainstay.tracer.value(r,"empty",e,void 0),e=void 0);const p=n.presence||t._flags.presence||(t._flags._endedSwitch?null:s.presence);if(void 0===e){if("forbidden"===p)return u.finalize(e,null,i);if("required"===p)return u.finalize(e,[t.$_createError("any.required",e,null,r,s)],i);if("optional"===p){if(t._flags.default!==o.symbols.deepDefault)return u.finalize(e,null,i);r.mainstay.tracer.value(r,"default",e,{}),e={}}}else if("forbidden"===p)return u.finalize(e,[t.$_createError("any.unknown",e,null,r,s)],i);const h=[];if(t._valids){const n=t._valids.get(e,r,s,t._flags.insensitive);if(n)return s.convert&&(r.mainstay.tracer.value(r,"valids",e,n.value),e=n.value),r.mainstay.tracer.filter(t,r,"valid",n),u.finalize(e,null,i);if(t._flags.only){const n=t.$_createError("any.only",e,{valids:t._valids.values({display:!0})},r,s);if(s.abortEarly)return u.finalize(e,[n],i);h.push(n)}}if(t._invalids){const n=t._invalids.get(e,r,s,t._flags.insensitive);if(n){r.mainstay.tracer.filter(t,r,"invalid",n);const a=t.$_createError("any.invalid",e,{invalids:t._invalids.values({display:!0})},r,s);if(s.abortEarly)return u.finalize(e,[a],i);h.push(a)}}if(l.validate){const t=l.validate(e,i);if(t&&(r.mainstay.tracer.value(r,"base",e,t.value),e=t.value,t.errors)){if(!Array.isArray(t.errors))return h.push(t.errors),u.finalize(e,h,i);if(t.errors.length)return h.push(...t.errors),u.finalize(e,h,i)}}return t._rules.length?u.rules(e,h,i):u.finalize(e,h,i)},u.rules=function(e,t,r){const{schema:s,state:n,prefs:a}=r;for(const i of s._rules){const l=s._definition.rules[i.method];if(l.convert&&a.convert){n.mainstay.tracer.log(s,n,"rule",i.name,"full");continue}let c,p=i.args;if(i._resolve.length){p=Object.assign({},p);for(const t of i._resolve){const r=l.argsByName.get(t),i=p[t].resolve(e,n,a),u=r.normalize?r.normalize(i):i,h=o.validateArg(u,null,r);if(h){c=s.$_createError("any.ref",i,{arg:t,ref:p[t],reason:h},n,a);break}p[t]=u}}c=c||l.validate(e,r,p,i);const h=u.rule(c,i);if(h.errors){if(n.mainstay.tracer.log(s,n,"rule",i.name,"error"),i.warn){n.mainstay.warnings.push(...h.errors);continue}if(a.abortEarly)return u.finalize(e,h.errors,r);t.push(...h.errors)}else n.mainstay.tracer.log(s,n,"rule",i.name,"pass"),n.mainstay.tracer.value(n,"rule",e,h.value,i.name),e=h.value}return u.finalize(e,t,r)},u.rule=function(e,t){return e instanceof l.Report?(u.error(e,t),{errors:[e],value:null}):Array.isArray(e)&&e[o.symbols.errors]?(e.forEach((e=>u.error(e,t))),{errors:e,value:null}):{errors:null,value:e}},u.error=function(e,t){return t.message&&e._setTemplate(t.message),e},u.finalize=function(e,t,r){t=t||[];const{schema:n,state:a,prefs:i}=r;if(t.length){const s=u.default("failover",void 0,t,r);void 0!==s&&(a.mainstay.tracer.value(a,"failover",e,s),e=s,t=[])}if(t.length&&n._flags.error)if("function"==typeof n._flags.error){t=n._flags.error(t),Array.isArray(t)||(t=[t]);for(const e of t)s(e instanceof Error||e instanceof l.Report,"error() must return an Error object")}else t=[n._flags.error];if(void 0===e){const s=u.default("default",e,t,r);a.mainstay.tracer.value(a,"default",e,s),e=s}if(n._flags.cast&&void 0!==e){const t=n._definition.cast[n._flags.cast];if(t.from(e)){const s=t.to(e,r);a.mainstay.tracer.value(a,"cast",e,s,n._flags.cast),e=s}}if(n.$_terms.externals&&i.externals&&!1!==i._externals)for(const{method:e}of n.$_terms.externals)a.mainstay.externals.push({method:e,schema:n,state:a,label:l.label(n._flags,a,i)});const o={value:e,errors:t.length?t:null};return n._flags.result&&(o.value="strip"===n._flags.result?void 0:r.original,a.mainstay.tracer.value(a,n._flags.result,e,o.value),a.shadow(e,n._flags.result)),n._cache&&!1!==i.cache&&!n._refs.length&&n._cache.set(r.original,o),void 0===e||o.errors||void 0===n._flags.artifact||(a.mainstay.artifacts=a.mainstay.artifacts||new Map,a.mainstay.artifacts.has(n._flags.artifact)||a.mainstay.artifacts.set(n._flags.artifact,[]),a.mainstay.artifacts.get(n._flags.artifact).push(a.path)),o},u.prefs=function(e,t){const r=t===o.defaults;return r&&e._preferences[o.symbols.prefs]?e._preferences[o.symbols.prefs]:(t=o.preferences(t,e._preferences),r&&(e._preferences[o.symbols.prefs]=t),t)},u.default=function(e,t,r,s){const{schema:a,state:i,prefs:l}=s,c=a._flags[e];if(l.noDefaults||void 0===c)return t;if(i.mainstay.tracer.log(a,i,"rule",e,"full"),!c)return c;if("function"==typeof c){const t=c.length?[n(i.ancestors[0]),s]:[];try{return c(...t)}catch(t){return void r.push(a.$_createError(`any.${e}`,null,{error:t},i,l))}}return"object"!=typeof c?c:c[o.symbols.literal]?c.literal:o.isResolvable(c)?c.resolve(t,i,l):n(c)},u.trim=function(e,t){if("string"!=typeof e)return e;const r=t.$_getRule("trim");return r&&r.args.enabled?e.trim():e},u.ignore={active:!1,debug:a,entry:a,filter:a,log:a,resolve:a,value:a},u.errorsArray=function(){const e=[];return e[o.symbols.errors]=!0,e}},(e,t,r)=>{const s=r(30),n=r(31),a=r(100),i={value:Symbol("value")};e.exports=i.State=class{constructor(e,t,r){this.path=e,this.ancestors=t,this.mainstay=r.mainstay,this.schemas=r.schemas,this.debug=null}localize(e,t=null,r=null){const s=new i.State(e,t,this);return r&&s.schemas&&(s.schemas=[i.schemas(r),...s.schemas]),s}nest(e,t){const r=new i.State(this.path,this.ancestors,this);return r.schemas=r.schemas&&[i.schemas(e),...r.schemas],r.debug=t,r}shadow(e,t){this.mainstay.shadow=this.mainstay.shadow||new i.Shadow,this.mainstay.shadow.set(this.path,e,t)}snapshot(){this.mainstay.shadow&&(this._snapshot=s(this.mainstay.shadow.node(this.path))),this.mainstay.snapshot()}restore(){this.mainstay.shadow&&(this.mainstay.shadow.override(this.path,this._snapshot),this._snapshot=void 0),this.mainstay.restore()}commit(){this.mainstay.shadow&&(this.mainstay.shadow.override(this.path,this._snapshot),this._snapshot=void 0),this.mainstay.commit()}},i.schemas=function(e){return a.isSchema(e)?{schema:e}:e},i.Shadow=class{constructor(){this._values=null}set(e,t,r){if(!e.length)return;if("strip"===r&&"number"==typeof e[e.length-1])return;this._values=this._values||new Map;let s=this._values;for(let t=0;t<e.length;++t){const r=e[t];let n=s.get(r);n||(n=new Map,s.set(r,n)),s=n}s[i.value]=t}get(e){const t=this.node(e);if(t)return t[i.value]}node(e){if(this._values)return n(this._values,e,{iterables:!0})}override(e,t){if(!this._values)return;const r=e.slice(0,-1),s=e[e.length-1],a=n(this._values,r,{iterables:!0});t?a.set(s,t):a&&a.delete(s)}}},(e,t,r)=>{const s=r(27),n=r(39),a=r(100),i={};e.exports=i.Values=class{constructor(e,t){this._values=new Set(e),this._refs=new Set(t),this._lowercase=i.lowercases(e),this._override=!1}get length(){return this._values.size+this._refs.size}add(e,t){a.isResolvable(e)?this._refs.has(e)||(this._refs.add(e),t&&t.register(e)):this.has(e,null,null,!1)||(this._values.add(e),"string"==typeof e&&this._lowercase.set(e.toLowerCase(),e))}static merge(e,t,r){if(e=e||new i.Values,t){if(t._override)return t.clone();for(const r of[...t._values,...t._refs])e.add(r)}if(r)for(const t of[...r._values,...r._refs])e.remove(t);return e.length?e:null}remove(e){a.isResolvable(e)?this._refs.delete(e):(this._values.delete(e),"string"==typeof e&&this._lowercase.delete(e.toLowerCase()))}has(e,t,r,s){return!!this.get(e,t,r,s)}get(e,t,r,s){if(!this.length)return!1;if(this._values.has(e))return{value:e};if("string"==typeof e&&e&&s){const t=this._lowercase.get(e.toLowerCase());if(t)return{value:t}}if(!this._refs.size&&"object"!=typeof e)return!1;if("object"==typeof e)for(const t of this._values)if(n(t,e))return{value:t};if(t)for(const a of this._refs){const i=a.resolve(e,t,r,null,{in:!0});if(void 0===i)continue;const o=a.in&&"object"==typeof i?Array.isArray(i)?i:Object.keys(i):[i];for(const t of o)if(typeof t==typeof e)if(s&&e&&"string"==typeof e){if(t.toLowerCase()===e.toLowerCase())return{value:t,ref:a}}else if(n(t,e))return{value:t,ref:a}}return!1}override(){this._override=!0}values(e){if(e&&e.display){const e=[];for(const t of[...this._values,...this._refs])void 0!==t&&e.push(t);return e}return Array.from([...this._values,...this._refs])}clone(){const e=new i.Values(this._values,this._refs);return e._override=this._override,e}concat(e){s(!e._override,"Cannot concat override set of values");const t=new i.Values([...this._values,...e._values],[...this._refs,...e._refs]);return t._override=this._override,t}describe(){const e=[];this._override&&e.push({override:!0});for(const t of this._values.values())e.push(t&&"object"==typeof t?{value:t}:t);for(const t of this._refs.values())e.push(t.describe());return e}},i.Values.prototype[a.symbols.values]=!0,i.Values.prototype.slice=i.Values.prototype.clone,i.lowercases=function(e){const t=new Map;if(e)for(const r of e)"string"==typeof r&&t.set(r.toLowerCase(),r);return t}},(e,t,r)=>{const s=r(27),n=r(39),a=r(31),i=r(115),o=r(100),l=r(109),c={};e.exports=i.extend({type:"array",flags:{single:{default:!1},sparse:{default:!1}},terms:{items:{init:[],manifest:"schema"},ordered:{init:[],manifest:"schema"},_exclusions:{init:[]},_inclusions:{init:[]},_requireds:{init:[]}},coerce:{from:"object",method(e,{schema:t,state:r,prefs:s}){if(!Array.isArray(e))return;const n=t.$_getRule("sort");return n?c.sort(t,e,n.args.options,r,s):void 0}},validate(e,{schema:t,error:r}){if(!Array.isArray(e)){if(t._flags.single){const t=[e];return t[o.symbols.arraySingle]=!0,{value:t}}return{errors:r("array.base")}}if(t.$_getRule("items")||t.$_terms.externals)return{value:e.slice()}},rules:{has:{method(e){e=this.$_compile(e,{appendPath:!0});const t=this.$_addRule({name:"has",args:{schema:e}});return t.$_mutateRegister(e),t},validate(e,{state:t,prefs:r,error:s},{schema:n}){const a=[e,...t.ancestors];for(let s=0;s<e.length;++s){const i=t.localize([...t.path,s],a,n);if(n.$_match(e[s],i,r))return e}const i=n._flags.label;return i?s("array.hasKnown",{patternLabel:i}):s("array.hasUnknown",null)},multi:!0},items:{method(...e){o.verifyFlat(e,"items");const t=this.$_addRule("items");for(let r=0;r<e.length;++r){const s=o.tryWithPath((()=>this.$_compile(e[r])),r,{append:!0});t.$_terms.items.push(s)}return t.$_mutateRebuild()},validate(e,{schema:t,error:r,state:s,prefs:n,errorsArray:a}){const i=t.$_terms._requireds.slice(),l=t.$_terms.ordered.slice(),u=[...t.$_terms._inclusions,...i],p=!e[o.symbols.arraySingle];delete e[o.symbols.arraySingle];const h=a();let d=e.length;for(let a=0;a<d;++a){const o=e[a];let f=!1,m=!1;const g=p?a:new Number(a),y=[...s.path,g];if(!t._flags.sparse&&void 0===o){if(h.push(r("array.sparse",{key:g,path:y,pos:a,value:void 0},s.localize(y))),n.abortEarly)return h;l.shift();continue}const b=[e,...s.ancestors];for(const e of t.$_terms._exclusions)if(e.$_match(o,s.localize(y,b,e),n,{presence:"ignore"})){if(h.push(r("array.excludes",{pos:a,value:o},s.localize(y))),n.abortEarly)return h;f=!0,l.shift();break}if(f)continue;if(t.$_terms.ordered.length){if(l.length){const i=l.shift(),u=i.$_validate(o,s.localize(y,b,i),n);if(u.errors){if(h.push(...u.errors),n.abortEarly)return h}else if("strip"===i._flags.result)c.fastSplice(e,a),--a,--d;else{if(!t._flags.sparse&&void 0===u.value){if(h.push(r("array.sparse",{key:g,path:y,pos:a,value:void 0},s.localize(y))),n.abortEarly)return h;continue}e[a]=u.value}continue}if(!t.$_terms.items.length){if(h.push(r("array.orderedLength",{pos:a,limit:t.$_terms.ordered.length})),n.abortEarly)return h;break}}const v=[];let _=i.length;for(let l=0;l<_;++l){const u=s.localize(y,b,i[l]);u.snapshot();const p=i[l].$_validate(o,u,n);if(v[l]=p,!p.errors){if(u.commit(),e[a]=p.value,m=!0,c.fastSplice(i,l),--l,--_,!t._flags.sparse&&void 0===p.value&&(h.push(r("array.sparse",{key:g,path:y,pos:a,value:void 0},s.localize(y))),n.abortEarly))return h;break}u.restore()}if(m)continue;const w=n.stripUnknown&&!!n.stripUnknown.arrays||!1;_=u.length;for(const l of u){let u;const p=i.indexOf(l);if(-1!==p)u=v[p];else{const i=s.localize(y,b,l);if(i.snapshot(),u=l.$_validate(o,i,n),!u.errors){i.commit(),"strip"===l._flags.result?(c.fastSplice(e,a),--a,--d):t._flags.sparse||void 0!==u.value?e[a]=u.value:(h.push(r("array.sparse",{key:g,path:y,pos:a,value:void 0},s.localize(y))),f=!0),m=!0;break}i.restore()}if(1===_){if(w){c.fastSplice(e,a),--a,--d,m=!0;break}if(h.push(...u.errors),n.abortEarly)return h;f=!0;break}}if(!f&&((t.$_terms._inclusions.length||t.$_terms._requireds.length)&&!m)){if(w){c.fastSplice(e,a),--a,--d;continue}if(h.push(r("array.includes",{pos:a,value:o},s.localize(y))),n.abortEarly)return h}}return i.length&&c.fillMissedErrors(t,h,i,e,s,n),l.length&&(c.fillOrderedErrors(t,h,l,e,s,n),h.length||c.fillDefault(l,e,s,n)),h.length?h:e},priority:!0,manifest:!1},length:{method(e){return this.$_addRule({name:"length",args:{limit:e},operator:"="})},validate:(e,t,{limit:r},{name:s,operator:n,args:a})=>o.compare(e.length,r,n)?e:t.error("array."+s,{limit:a.limit,value:e}),args:[{name:"limit",ref:!0,assert:o.limit,message:"must be a positive integer"}]},max:{method(e){return this.$_addRule({name:"max",method:"length",args:{limit:e},operator:"<="})}},min:{method(e){return this.$_addRule({name:"min",method:"length",args:{limit:e},operator:">="})}},ordered:{method(...e){o.verifyFlat(e,"ordered");const t=this.$_addRule("items");for(let r=0;r<e.length;++r){const s=o.tryWithPath((()=>this.$_compile(e[r])),r,{append:!0});c.validateSingle(s,t),t.$_mutateRegister(s),t.$_terms.ordered.push(s)}return t.$_mutateRebuild()}},single:{method(e){const t=void 0===e||!!e;return s(!t||!this._flags._arrayItems,"Cannot specify single rule when array has array items"),this.$_setFlag("single",t)}},sort:{method(e={}){o.assertOptions(e,["by","order"]);const t={order:e.order||"ascending"};return e.by&&(t.by=l.ref(e.by,{ancestor:0}),s(!t.by.ancestor,"Cannot sort by ancestor")),this.$_addRule({name:"sort",args:{options:t}})},validate(e,{error:t,state:r,prefs:s,schema:n},{options:a}){const{value:i,errors:o}=c.sort(n,e,a,r,s);if(o)return o;for(let r=0;r<e.length;++r)if(e[r]!==i[r])return t("array.sort",{order:a.order,by:a.by?a.by.key:"value"});return e},convert:!0},sparse:{method(e){const t=void 0===e||!!e;if(this._flags.sparse===t)return this;return(t?this.clone():this.$_addRule("items")).$_setFlag("sparse",t,{clone:!1})}},unique:{method(e,t={}){s(!e||"function"==typeof e||"string"==typeof e,"comparator must be a function or a string"),o.assertOptions(t,["ignoreUndefined","separator"]);const r={name:"unique",args:{options:t,comparator:e}};if(e)if("string"==typeof e){const s=o.default(t.separator,".");r.path=s?e.split(s):[e]}else r.comparator=e;return this.$_addRule(r)},validate(e,{state:t,error:r,schema:i},{comparator:o,options:l},{comparator:c,path:u}){const p={string:Object.create(null),number:Object.create(null),undefined:Object.create(null),boolean:Object.create(null),object:new Map,function:new Map,custom:new Map},h=c||n,d=l.ignoreUndefined;for(let n=0;n<e.length;++n){const i=u?a(e[n],u):e[n],l=c?p.custom:p[typeof i];if(s(l,"Failed to find unique map container for type",typeof i),l instanceof Map){const s=l.entries();let a;for(;!(a=s.next()).done;)if(h(a.value[0],i)){const s=t.localize([...t.path,n],[e,...t.ancestors]),i={pos:n,value:e[n],dupePos:a.value[1],dupeValue:e[a.value[1]]};return u&&(i.path=o),r("array.unique",i,s)}l.set(i,n)}else{if((!d||void 0!==i)&&void 0!==l[i]){const s={pos:n,value:e[n],dupePos:l[i],dupeValue:e[l[i]]};u&&(s.path=o);return r("array.unique",s,t.localize([...t.path,n],[e,...t.ancestors]))}l[i]=n}}return e},args:["comparator","options"],multi:!0}},cast:{set:{from:Array.isArray,to:(e,t)=>new Set(e)}},rebuild(e){e.$_terms._inclusions=[],e.$_terms._exclusions=[],e.$_terms._requireds=[];for(const t of e.$_terms.items)c.validateSingle(t,e),"required"===t._flags.presence?e.$_terms._requireds.push(t):"forbidden"===t._flags.presence?e.$_terms._exclusions.push(t):e.$_terms._inclusions.push(t);for(const t of e.$_terms.ordered)c.validateSingle(t,e)},manifest:{build:(e,t)=>(t.items&&(e=e.items(...t.items)),t.ordered&&(e=e.ordered(...t.ordered)),e)},messages:{"array.base":"{{#label}} must be an array","array.excludes":"{{#label}} contains an excluded value","array.hasKnown":"{{#label}} does not contain at least one required match for type {:#patternLabel}","array.hasUnknown":"{{#label}} does not contain at least one required match","array.includes":"{{#label}} does not match any of the allowed types","array.includesRequiredBoth":"{{#label}} does not contain {{#knownMisses}} and {{#unknownMisses}} other required value(s)","array.includesRequiredKnowns":"{{#label}} does not contain {{#knownMisses}}","array.includesRequiredUnknowns":"{{#label}} does not contain {{#unknownMisses}} required value(s)","array.length":"{{#label}} must contain {{#limit}} items","array.max":"{{#label}} must contain less than or equal to {{#limit}} items","array.min":"{{#label}} must contain at least {{#limit}} items","array.orderedLength":"{{#label}} must contain at most {{#limit}} items","array.sort":"{{#label}} must be sorted in {#order} order by {{#by}}","array.sort.mismatching":"{{#label}} cannot be sorted due to mismatching types","array.sort.unsupported":"{{#label}} cannot be sorted due to unsupported type {#type}","array.sparse":"{{#label}} must not be a sparse array item","array.unique":"{{#label}} contains a duplicate value"}}),c.fillMissedErrors=function(e,t,r,s,n,a){const i=[];let o=0;for(const e of r){const t=e._flags.label;t?i.push(t):++o}i.length?o?t.push(e.$_createError("array.includesRequiredBoth",s,{knownMisses:i,unknownMisses:o},n,a)):t.push(e.$_createError("array.includesRequiredKnowns",s,{knownMisses:i},n,a)):t.push(e.$_createError("array.includesRequiredUnknowns",s,{unknownMisses:o},n,a))},c.fillOrderedErrors=function(e,t,r,s,n,a){const i=[];for(const e of r)"required"===e._flags.presence&&i.push(e);i.length&&c.fillMissedErrors(e,t,i,s,n,a)},c.fillDefault=function(e,t,r,s){const n=[];let a=!0;for(let i=e.length-1;i>=0;--i){const o=e[i],l=[t,...r.ancestors],c=o.$_validate(void 0,r.localize(r.path,l,o),s).value;if(a){if(void 0===c)continue;a=!1}n.unshift(c)}n.length&&t.push(...n)},c.fastSplice=function(e,t){let r=t;for(;r<e.length;)e[r++]=e[r];--e.length},c.validateSingle=function(e,t){("array"===e.type||e._flags._arrayItems)&&(s(!t._flags.single,"Cannot specify array item with single rule enabled"),t.$_setFlag("_arrayItems",!0,{clone:!1}))},c.sort=function(e,t,r,s,n){const a="ascending"===r.order?1:-1,i=-1*a,o=a,l=(l,u)=>{let p=c.compare(l,u,i,o);if(null!==p)return p;if(r.by&&(l=r.by.resolve(l,s,n),u=r.by.resolve(u,s,n)),p=c.compare(l,u,i,o),null!==p)return p;const h=typeof l;if(h!==typeof u)throw e.$_createError("array.sort.mismatching",t,null,s,n);if("number"!==h&&"string"!==h)throw e.$_createError("array.sort.unsupported",t,{type:h},s,n);return"number"===h?(l-u)*a:l<u?i:o};try{return{value:t.slice().sort(l)}}catch(e){return{errors:e}}},c.compare=function(e,t,r,s){return e===t?0:void 0===e?1:void 0===t?-1:null===e?s:null===t?r:null}},(e,t,r)=>{const s=r(27),n=r(115),a=r(100),i=r(120),o={isBool:function(e){return"boolean"==typeof e}};e.exports=n.extend({type:"boolean",flags:{sensitive:{default:!1}},terms:{falsy:{init:null,manifest:"values"},truthy:{init:null,manifest:"values"}},coerce(e,{schema:t}){if("boolean"!=typeof e){if("string"==typeof e){const r=t._flags.sensitive?e:e.toLowerCase();e="true"===r||"false"!==r&&e}return"boolean"!=typeof e&&(e=t.$_terms.truthy&&t.$_terms.truthy.has(e,null,null,!t._flags.sensitive)||(!t.$_terms.falsy||!t.$_terms.falsy.has(e,null,null,!t._flags.sensitive))&&e),{value:e}}},validate(e,{error:t}){if("boolean"!=typeof e)return{value:e,errors:t("boolean.base")}},rules:{truthy:{method(...e){a.verifyFlat(e,"truthy");const t=this.clone();t.$_terms.truthy=t.$_terms.truthy||new i;for(let r=0;r<e.length;++r){const n=e[r];s(void 0!==n,"Cannot call truthy with undefined"),t.$_terms.truthy.add(n)}return t}},falsy:{method(...e){a.verifyFlat(e,"falsy");const t=this.clone();t.$_terms.falsy=t.$_terms.falsy||new i;for(let r=0;r<e.length;++r){const n=e[r];s(void 0!==n,"Cannot call falsy with undefined"),t.$_terms.falsy.add(n)}return t}},sensitive:{method(e=!0){return this.$_setFlag("sensitive",e)}}},cast:{number:{from:o.isBool,to:(e,t)=>e?1:0},string:{from:o.isBool,to:(e,t)=>e?"true":"false"}},manifest:{build:(e,t)=>(t.truthy&&(e=e.truthy(...t.truthy)),t.falsy&&(e=e.falsy(...t.falsy)),e)},messages:{"boolean.base":"{{#label}} must be a boolean"}})},(e,t,r)=>{const s=r(27),n=r(115),a=r(100),i=r(104),o={isDate:function(e){return e instanceof Date}};e.exports=n.extend({type:"date",coerce:{from:["number","string"],method:(e,{schema:t})=>({value:o.parse(e,t._flags.format)||e})},validate(e,{schema:t,error:r,prefs:s}){if(e instanceof Date&&!isNaN(e.getTime()))return;const n=t._flags.format;return s.convert&&n&&"string"==typeof e?{value:e,errors:r("date.format",{format:n})}:{value:e,errors:r("date.base")}},rules:{compare:{method:!1,validate(e,t,{date:r},{name:s,operator:n,args:i}){const o="now"===r?Date.now():r.getTime();return a.compare(e.getTime(),o,n)?e:t.error("date."+s,{limit:i.date,value:e})},args:[{name:"date",ref:!0,normalize:e=>"now"===e?e:o.parse(e),assert:e=>null!==e,message:"must have a valid date format"}]},format:{method(e){return s(["iso","javascript","unix"].includes(e),"Unknown date format",e),this.$_setFlag("format",e)}},greater:{method(e){return this.$_addRule({name:"greater",method:"compare",args:{date:e},operator:">"})}},iso:{method(){return this.format("iso")}},less:{method(e){return this.$_addRule({name:"less",method:"compare",args:{date:e},operator:"<"})}},max:{method(e){return this.$_addRule({name:"max",method:"compare",args:{date:e},operator:"<="})}},min:{method(e){return this.$_addRule({name:"min",method:"compare",args:{date:e},operator:">="})}},timestamp:{method(e="javascript"){return s(["javascript","unix"].includes(e),'"type" must be one of "javascript, unix"'),this.format(e)}}},cast:{number:{from:o.isDate,to:(e,t)=>e.getTime()},string:{from:o.isDate,to:(e,{prefs:t})=>i.date(e,t)}},messages:{"date.base":"{{#label}} must be a valid date","date.format":'{{#label}} must be in {msg("date.format." + #format) || #format} format',"date.greater":"{{#label}} must be greater than {{:#limit}}","date.less":"{{#label}} must be less than {{:#limit}}","date.max":"{{#label}} must be less than or equal to {{:#limit}}","date.min":"{{#label}} must be greater than or equal to {{:#limit}}","date.format.iso":"ISO 8601 date","date.format.javascript":"timestamp or number of milliseconds","date.format.unix":"timestamp or number of seconds"}}),o.parse=function(e,t){if(e instanceof Date)return e;if("string"!=typeof e&&(isNaN(e)||!isFinite(e)))return null;if(/^\s*$/.test(e))return null;if("iso"===t)return a.isIsoDate(e)?o.date(e.toString()):null;const r=e;if("string"==typeof e&&/^[+-]?\d+(\.\d+)?$/.test(e)&&(e=parseFloat(e)),t){if("javascript"===t)return o.date(1*e);if("unix"===t)return o.date(1e3*e);if("string"==typeof r)return null}return o.date(e)},o.date=function(e){const t=new Date(e);return isNaN(t.getTime())?null:t}},(e,t,r)=>{const s=r(27),n=r(125);e.exports=n.extend({type:"function",properties:{typeof:"function"},rules:{arity:{method(e){return s(Number.isSafeInteger(e)&&e>=0,"n must be a positive integer"),this.$_addRule({name:"arity",args:{n:e}})},validate:(e,t,{n:r})=>e.length===r?e:t.error("function.arity",{n:r})},class:{method(){return this.$_addRule("class")},validate:(e,t)=>/^\s*class\s/.test(e.toString())?e:t.error("function.class",{value:e})},minArity:{method(e){return s(Number.isSafeInteger(e)&&e>0,"n must be a strict positive integer"),this.$_addRule({name:"minArity",args:{n:e}})},validate:(e,t,{n:r})=>e.length>=r?e:t.error("function.minArity",{n:r})},maxArity:{method(e){return s(Number.isSafeInteger(e)&&e>=0,"n must be a positive integer"),this.$_addRule({name:"maxArity",args:{n:e}})},validate:(e,t,{n:r})=>e.length<=r?e:t.error("function.maxArity",{n:r})}},messages:{"function.arity":"{{#label}} must have an arity of {{#n}}","function.class":"{{#label}} must be a class","function.maxArity":"{{#label}} must have an arity lesser or equal to {{#n}}","function.minArity":"{{#label}} must have an arity greater or equal to {{#n}}"}})},(e,t,r)=>{const s=r(26),n=r(27),a=r(30),i=r(73),o=r(115),l=r(100),c=r(109),u=r(106),p=r(108),h=r(104),d={renameDefaults:{alias:!1,multiple:!1,override:!1}};e.exports=o.extend({type:"_keys",properties:{typeof:"object"},flags:{unknown:{default:!1}},terms:{dependencies:{init:null},keys:{init:null,manifest:{mapped:{from:"schema",to:"key"}}},patterns:{init:null},renames:{init:null}},args:(e,t)=>e.keys(t),validate(e,{schema:t,error:r,state:s,prefs:n}){if(!e||typeof e!==t.$_property("typeof")||Array.isArray(e))return{value:e,errors:r("object.base",{type:t.$_property("typeof")})};if(!(t.$_terms.renames||t.$_terms.dependencies||t.$_terms.keys||t.$_terms.patterns||t.$_terms.externals))return;e=d.clone(e,n);const a=[];if(t.$_terms.renames&&!d.rename(t,e,s,n,a))return{value:e,errors:a};if(!t.$_terms.keys&&!t.$_terms.patterns&&!t.$_terms.dependencies)return{value:e,errors:a};const i=new Set(Object.keys(e));if(t.$_terms.keys){const r=[e,...s.ancestors];for(const o of t.$_terms.keys){const t=o.key,l=e[t];i.delete(t);const c=s.localize([...s.path,t],r,o),u=o.schema.$_validate(l,c,n);if(u.errors){if(n.abortEarly)return{value:e,errors:u.errors};void 0!==u.value&&(e[t]=u.value),a.push(...u.errors)}else"strip"===o.schema._flags.result||void 0===u.value&&void 0!==l?delete e[t]:void 0!==u.value&&(e[t]=u.value)}}if(i.size||t._flags._hasPatternMatch){const r=d.unknown(t,e,i,a,s,n);if(r)return r}if(t.$_terms.dependencies)for(const r of t.$_terms.dependencies){if(null!==r.key&&!1===d.isPresent(r.options)(r.key.resolve(e,s,n,null,{shadow:!1})))continue;const i=d.dependencies[r.rel](t,r,e,s,n);if(i){const r=t.$_createError(i.code,e,i.context,s,n);if(n.abortEarly)return{value:e,errors:r};a.push(r)}}return{value:e,errors:a}},rules:{and:{method(...e){return l.verifyFlat(e,"and"),d.dependency(this,"and",null,e)}},append:{method(e){return null==e||0===Object.keys(e).length?this:this.keys(e)}},assert:{method(e,t,r){h.isTemplate(e)||(e=c.ref(e)),n(void 0===r||"string"==typeof r,"Message must be a string"),t=this.$_compile(t,{appendPath:!0});const s=this.$_addRule({name:"assert",args:{subject:e,schema:t,message:r}});return s.$_mutateRegister(e),s.$_mutateRegister(t),s},validate(e,{error:t,prefs:r,state:s},{subject:n,schema:a,message:i}){const o=n.resolve(e,s,r),l=p.isRef(n)?n.absolute(s):[];return a.$_match(o,s.localize(l,[e,...s.ancestors],a),r)?e:t("object.assert",{subject:n,message:i})},args:["subject","schema","message"],multi:!0},instance:{method(e,t){return n("function"==typeof e,"constructor must be a function"),t=t||e.name,this.$_addRule({name:"instance",args:{constructor:e,name:t}})},validate:(e,t,{constructor:r,name:s})=>e instanceof r?e:t.error("object.instance",{type:s,value:e}),args:["constructor","name"]},keys:{method(e){n(void 0===e||"object"==typeof e,"Object schema must be a valid object"),n(!l.isSchema(e),"Object schema cannot be a joi schema");const t=this.clone();if(e)if(Object.keys(e).length){t.$_terms.keys=t.$_terms.keys?t.$_terms.keys.filter((t=>!e.hasOwnProperty(t.key))):new d.Keys;for(const r in e)l.tryWithPath((()=>t.$_terms.keys.push({key:r,schema:this.$_compile(e[r])})),r)}else t.$_terms.keys=new d.Keys;else t.$_terms.keys=null;return t.$_mutateRebuild()}},length:{method(e){return this.$_addRule({name:"length",args:{limit:e},operator:"="})},validate:(e,t,{limit:r},{name:s,operator:n,args:a})=>l.compare(Object.keys(e).length,r,n)?e:t.error("object."+s,{limit:a.limit,value:e}),args:[{name:"limit",ref:!0,assert:l.limit,message:"must be a positive integer"}]},max:{method(e){return this.$_addRule({name:"max",method:"length",args:{limit:e},operator:"<="})}},min:{method(e){return this.$_addRule({name:"min",method:"length",args:{limit:e},operator:">="})}},nand:{method(...e){return l.verifyFlat(e,"nand"),d.dependency(this,"nand",null,e)}},or:{method(...e){return l.verifyFlat(e,"or"),d.dependency(this,"or",null,e)}},oxor:{method(...e){return d.dependency(this,"oxor",null,e)}},pattern:{method(e,t,r={}){const s=e instanceof RegExp;s||(e=this.$_compile(e,{appendPath:!0})),n(void 0!==t,"Invalid rule"),l.assertOptions(r,["fallthrough","matches"]),s&&n(!e.flags.includes("g")&&!e.flags.includes("y"),"pattern should not use global or sticky mode"),t=this.$_compile(t,{appendPath:!0});const a=this.clone();a.$_terms.patterns=a.$_terms.patterns||[];const i={[s?"regex":"schema"]:e,rule:t};return r.matches&&(i.matches=this.$_compile(r.matches),"array"!==i.matches.type&&(i.matches=i.matches.$_root.array().items(i.matches)),a.$_mutateRegister(i.matches),a.$_setFlag("_hasPatternMatch",!0,{clone:!1})),r.fallthrough&&(i.fallthrough=!0),a.$_terms.patterns.push(i),a.$_mutateRegister(t),a}},ref:{method(){return this.$_addRule("ref")},validate:(e,t)=>p.isRef(e)?e:t.error("object.refType",{value:e})},regex:{method(){return this.$_addRule("regex")},validate:(e,t)=>e instanceof RegExp?e:t.error("object.regex",{value:e})},rename:{method(e,t,r={}){n("string"==typeof e||e instanceof RegExp,"Rename missing the from argument"),n("string"==typeof t||t instanceof h,"Invalid rename to argument"),n(t!==e,"Cannot rename key to same name:",e),l.assertOptions(r,["alias","ignoreUndefined","override","multiple"]);const a=this.clone();a.$_terms.renames=a.$_terms.renames||[];for(const t of a.$_terms.renames)n(t.from!==e,"Cannot rename the same key multiple times");return t instanceof h&&a.$_mutateRegister(t),a.$_terms.renames.push({from:e,to:t,options:s(d.renameDefaults,r)}),a}},schema:{method(e="any"){return this.$_addRule({name:"schema",args:{type:e}})},validate:(e,t,{type:r})=>!l.isSchema(e)||"any"!==r&&e.type!==r?t.error("object.schema",{type:r}):e},unknown:{method(e){return this.$_setFlag("unknown",!1!==e)}},with:{method(e,t,r={}){return d.dependency(this,"with",e,t,r)}},without:{method(e,t,r={}){return d.dependency(this,"without",e,t,r)}},xor:{method(...e){return l.verifyFlat(e,"xor"),d.dependency(this,"xor",null,e)}}},overrides:{default(e,t){return void 0===e&&(e=l.symbols.deepDefault),this.$_parent("default",e,t)}},rebuild(e){if(e.$_terms.keys){const t=new i.Sorter;for(const r of e.$_terms.keys)l.tryWithPath((()=>t.add(r,{after:r.schema.$_rootReferences(),group:r.key})),r.key);e.$_terms.keys=new d.Keys(...t.nodes)}},manifest:{build(e,t){if(t.keys&&(e=e.keys(t.keys)),t.dependencies)for(const{rel:r,key:s=null,peers:n,options:a}of t.dependencies)e=d.dependency(e,r,s,n,a);if(t.patterns)for(const{regex:r,schema:s,rule:n,fallthrough:a,matches:i}of t.patterns)e=e.pattern(r||s,n,{fallthrough:a,matches:i});if(t.renames)for(const{from:r,to:s,options:n}of t.renames)e=e.rename(r,s,n);return e}},messages:{"object.and":"{{#label}} contains {{#presentWithLabels}} without its required peers {{#missingWithLabels}}","object.assert":'{{#label}} is invalid because {if(#subject.key, `"` + #subject.key + `" failed to ` + (#message || "pass the assertion test"), #message || "the assertion failed")}',"object.base":"{{#label}} must be of type {{#type}}","object.instance":"{{#label}} must be an instance of {{:#type}}","object.length":'{{#label}} must have {{#limit}} key{if(#limit == 1, "", "s")}',"object.max":'{{#label}} must have less than or equal to {{#limit}} key{if(#limit == 1, "", "s")}',"object.min":'{{#label}} must have at least {{#limit}} key{if(#limit == 1, "", "s")}',"object.missing":"{{#label}} must contain at least one of {{#peersWithLabels}}","object.nand":"{{:#mainWithLabel}} must not exist simultaneously with {{#peersWithLabels}}","object.oxor":"{{#label}} contains a conflict between optional exclusive peers {{#peersWithLabels}}","object.pattern.match":"{{#label}} keys failed to match pattern requirements","object.refType":"{{#label}} must be a Joi reference","object.regex":"{{#label}} must be a RegExp object","object.rename.multiple":"{{#label}} cannot rename {{:#from}} because multiple renames are disabled and another key was already renamed to {{:#to}}","object.rename.override":"{{#label}} cannot rename {{:#from}} because override is disabled and target {{:#to}} exists","object.schema":"{{#label}} must be a Joi schema of {{#type}} type","object.unknown":"{{#label}} is not allowed","object.with":"{{:#mainWithLabel}} missing required peer {{:#peerWithLabel}}","object.without":"{{:#mainWithLabel}} conflict with forbidden peer {{:#peerWithLabel}}","object.xor":"{{#label}} contains a conflict between exclusive peers {{#peersWithLabels}}"}}),d.clone=function(e,t){if("object"==typeof e){if(t.nonEnumerables)return a(e,{shallow:!0});const r=Object.create(Object.getPrototypeOf(e));return Object.assign(r,e),r}const r=function(...t){return e.apply(this,t)};return r.prototype=a(e.prototype),Object.defineProperty(r,"name",{value:e.name,writable:!1}),Object.defineProperty(r,"length",{value:e.length,writable:!1}),Object.assign(r,e),r},d.dependency=function(e,t,r,s,a){n(null===r||"string"==typeof r,t,"key must be a strings"),a||(a=s.length>1&&"object"==typeof s[s.length-1]?s.pop():{}),l.assertOptions(a,["separator","isPresent"]),s=[].concat(s);const i=l.default(a.separator,"."),o=[];for(const e of s)n("string"==typeof e,t,"peers must be strings"),o.push(c.ref(e,{separator:i,ancestor:0,prefix:!1}));null!==r&&(r=c.ref(r,{separator:i,ancestor:0,prefix:!1}));const u=e.clone();return u.$_terms.dependencies=u.$_terms.dependencies||[],u.$_terms.dependencies.push(new d.Dependency(t,r,o,s,a)),u},d.dependencies={and(e,t,r,s,n){const a=[],i=[],o=t.peers.length,l=d.isPresent(t.options);for(const e of t.peers)!1===l(e.resolve(r,s,n,null,{shadow:!1}))?a.push(e.key):i.push(e.key);if(a.length!==o&&i.length!==o)return{code:"object.and",context:{present:i,presentWithLabels:d.keysToLabels(e,i),missing:a,missingWithLabels:d.keysToLabels(e,a)}}},nand(e,t,r,s,n){const a=[],i=d.isPresent(t.options);for(const e of t.peers)i(e.resolve(r,s,n,null,{shadow:!1}))&&a.push(e.key);if(a.length!==t.peers.length)return;const o=t.paths[0],l=t.paths.slice(1);return{code:"object.nand",context:{main:o,mainWithLabel:d.keysToLabels(e,o),peers:l,peersWithLabels:d.keysToLabels(e,l)}}},or(e,t,r,s,n){const a=d.isPresent(t.options);for(const e of t.peers)if(a(e.resolve(r,s,n,null,{shadow:!1})))return;return{code:"object.missing",context:{peers:t.paths,peersWithLabels:d.keysToLabels(e,t.paths)}}},oxor(e,t,r,s,n){const a=[],i=d.isPresent(t.options);for(const e of t.peers)i(e.resolve(r,s,n,null,{shadow:!1}))&&a.push(e.key);if(!a.length||1===a.length)return;const o={peers:t.paths,peersWithLabels:d.keysToLabels(e,t.paths)};return o.present=a,o.presentWithLabels=d.keysToLabels(e,a),{code:"object.oxor",context:o}},with(e,t,r,s,n){const a=d.isPresent(t.options);for(const i of t.peers)if(!1===a(i.resolve(r,s,n,null,{shadow:!1})))return{code:"object.with",context:{main:t.key.key,mainWithLabel:d.keysToLabels(e,t.key.key),peer:i.key,peerWithLabel:d.keysToLabels(e,i.key)}}},without(e,t,r,s,n){const a=d.isPresent(t.options);for(const i of t.peers)if(a(i.resolve(r,s,n,null,{shadow:!1})))return{code:"object.without",context:{main:t.key.key,mainWithLabel:d.keysToLabels(e,t.key.key),peer:i.key,peerWithLabel:d.keysToLabels(e,i.key)}}},xor(e,t,r,s,n){const a=[],i=d.isPresent(t.options);for(const e of t.peers)i(e.resolve(r,s,n,null,{shadow:!1}))&&a.push(e.key);if(1===a.length)return;const o={peers:t.paths,peersWithLabels:d.keysToLabels(e,t.paths)};return 0===a.length?{code:"object.missing",context:o}:(o.present=a,o.presentWithLabels=d.keysToLabels(e,a),{code:"object.xor",context:o})}},d.keysToLabels=function(e,t){return Array.isArray(t)?t.map((t=>e.$_mapLabels(t))):e.$_mapLabels(t)},d.isPresent=function(e){return"function"==typeof e.isPresent?e.isPresent:e=>void 0!==e},d.rename=function(e,t,r,s,n){const a={};for(const i of e.$_terms.renames){const o=[],l="string"!=typeof i.from;if(l)for(const e in t){if(void 0===t[e]&&i.options.ignoreUndefined)continue;if(e===i.to)continue;const r=i.from.exec(e);r&&o.push({from:e,to:i.to,match:r})}else!Object.prototype.hasOwnProperty.call(t,i.from)||void 0===t[i.from]&&i.options.ignoreUndefined||o.push(i);for(const c of o){const o=c.from;let u=c.to;if(u instanceof h&&(u=u.render(t,r,s,c.match)),o!==u){if(!i.options.multiple&&a[u]&&(n.push(e.$_createError("object.rename.multiple",t,{from:o,to:u,pattern:l},r,s)),s.abortEarly))return!1;if(Object.prototype.hasOwnProperty.call(t,u)&&!i.options.override&&!a[u]&&(n.push(e.$_createError("object.rename.override",t,{from:o,to:u,pattern:l},r,s)),s.abortEarly))return!1;void 0===t[o]?delete t[u]:t[u]=t[o],a[u]=!0,i.options.alias||delete t[o]}}}return!0},d.unknown=function(e,t,r,s,n,a){if(e.$_terms.patterns){let i=!1;const o=e.$_terms.patterns.map((e=>{if(e.matches)return i=!0,[]})),l=[t,...n.ancestors];for(const i of r){const c=t[i],u=[...n.path,i];for(let p=0;p<e.$_terms.patterns.length;++p){const h=e.$_terms.patterns[p];if(h.regex){const e=h.regex.test(i);if(n.mainstay.tracer.debug(n,"rule",`pattern.${p}`,e?"pass":"error"),!e)continue}else if(!h.schema.$_match(i,n.nest(h.schema,`pattern.${p}`),a))continue;r.delete(i);const d=n.localize(u,l,{schema:h.rule,key:i}),f=h.rule.$_validate(c,d,a);if(f.errors){if(a.abortEarly)return{value:t,errors:f.errors};s.push(...f.errors)}if(h.matches&&o[p].push(i),t[i]=f.value,!h.fallthrough)break}}if(i)for(let r=0;r<o.length;++r){const i=o[r];if(!i)continue;const c=e.$_terms.patterns[r].matches,p=n.localize(n.path,l,c),h=c.$_validate(i,p,a);if(h.errors){const r=u.details(h.errors,{override:!1});r.matches=i;const o=e.$_createError("object.pattern.match",t,r,n,a);if(a.abortEarly)return{value:t,errors:o};s.push(o)}}}if(!r.size||!e.$_terms.keys&&!e.$_terms.patterns)return;if(a.stripUnknown&&!e._flags.unknown||a.skipFunctions){const e=!!a.stripUnknown&&(!0===a.stripUnknown||!!a.stripUnknown.objects);for(const s of r)e?(delete t[s],r.delete(s)):"function"==typeof t[s]&&r.delete(s)}if(!l.default(e._flags.unknown,a.allowUnknown))for(const i of r){const r=n.localize([...n.path,i],[]),o=e.$_createError("object.unknown",t[i],{child:i},r,a,{flags:!1});if(a.abortEarly)return{value:t,errors:o};s.push(o)}},d.Dependency=class{constructor(e,t,r,s,n){this.rel=e,this.key=t,this.peers=r,this.paths=s,this.options=n}describe(){const e={rel:this.rel,peers:this.paths};return null!==this.key&&(e.key=this.key.key),"."!==this.peers[0].separator&&(e.options={...e.options,separator:this.peers[0].separator}),this.options.isPresent&&(e.options={...e.options,isPresent:this.options.isPresent}),e}},d.Keys=class extends Array{concat(e){const t=this.slice(),r=new Map;for(let e=0;e<t.length;++e)r.set(t[e].key,e);for(const s of e){const e=s.key,n=r.get(e);void 0!==n?t[n]={key:e,schema:t[n].schema.concat(s.schema)}:t.push(s)}return t}}},(e,t,r)=>{const s=r(27),n=r(115),a=r(100),i=r(109),o=r(106),l={};e.exports=n.extend({type:"link",properties:{schemaChain:!0},terms:{link:{init:null,manifest:"single",register:!1}},args:(e,t)=>e.ref(t),validate(e,{schema:t,state:r,prefs:n}){s(t.$_terms.link,"Uninitialized link schema");const a=l.generate(t,e,r,n),i=t.$_terms.link[0].ref;return a.$_validate(e,r.nest(a,`link:${i.display}:${a.type}`),n)},generate:(e,t,r,s)=>l.generate(e,t,r,s),rules:{ref:{method(e){s(!this.$_terms.link,"Cannot reinitialize schema"),e=i.ref(e),s("value"===e.type||"local"===e.type,"Invalid reference type:",e.type),s("local"===e.type||"root"===e.ancestor||e.ancestor>0,"Link cannot reference itself");const t=this.clone();return t.$_terms.link=[{ref:e}],t}},relative:{method(e=!0){return this.$_setFlag("relative",e)}}},overrides:{concat(e){s(this.$_terms.link,"Uninitialized link schema"),s(a.isSchema(e),"Invalid schema object"),s("link"!==e.type,"Cannot merge type link with another link");const t=this.clone();return t.$_terms.whens||(t.$_terms.whens=[]),t.$_terms.whens.push({concat:e}),t.$_mutateRebuild()}},manifest:{build:(e,t)=>(s(t.link,"Invalid link description missing link"),e.ref(t.link))}}),l.generate=function(e,t,r,s){let n=r.mainstay.links.get(e);if(n)return n._generate(t,r,s).schema;const a=e.$_terms.link[0].ref,{perspective:i,path:o}=l.perspective(a,r);l.assert(i,"which is outside of schema boundaries",a,e,r,s);try{n=o.length?i.$_reach(o):i}catch(t){l.assert(!1,"to non-existing schema",a,e,r,s)}return l.assert("link"!==n.type,"which is another link",a,e,r,s),e._flags.relative||r.mainstay.links.set(e,n),n._generate(t,r,s).schema},l.perspective=function(e,t){if("local"===e.type){for(const{schema:r,key:s}of t.schemas){if((r._flags.id||s)===e.path[0])return{perspective:r,path:e.path.slice(1)};if(r.$_terms.shared)for(const t of r.$_terms.shared)if(t._flags.id===e.path[0])return{perspective:t,path:e.path.slice(1)}}return{perspective:null,path:null}}return"root"===e.ancestor?{perspective:t.schemas[t.schemas.length-1].schema,path:e.path}:{perspective:t.schemas[e.ancestor]&&t.schemas[e.ancestor].schema,path:e.path}},l.assert=function(e,t,r,n,a,i){e||s(!1,`"${o.label(n._flags,a,i)}" contains link reference "${r.display}" ${t}`)}},(e,t,r)=>{const s=r(27),n=r(115),a=r(100),i={numberRx:/^\s*[+-]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:e([+-]?\d+))?\s*$/i,precisionRx:/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/,exponentialPartRegex:/[eE][+-]?\d+$/,leadingSignAndZerosRegex:/^[+-]?(0*)?/,dotRegex:/\./,trailingZerosRegex:/0+$/,decimalPlaces(e){const t=e.toString(),r=t.indexOf("."),s=t.indexOf("e");return(r<0?0:(s<0?t.length:s)-r-1)+(s<0?0:Math.max(0,-parseInt(t.slice(s+1))))}};e.exports=n.extend({type:"number",flags:{unsafe:{default:!1}},coerce:{from:"string",method(e,{schema:t,error:r}){if(!e.match(i.numberRx))return;e=e.trim();const s={value:parseFloat(e)};if(0===s.value&&(s.value=0),!t._flags.unsafe)if(e.match(/e/i)){if(i.extractSignificantDigits(e)!==i.extractSignificantDigits(String(s.value)))return s.errors=r("number.unsafe"),s}else{const t=s.value.toString();if(t.match(/e/i))return s;if(t!==i.normalizeDecimal(e))return s.errors=r("number.unsafe"),s}return s}},validate(e,{schema:t,error:r,prefs:s}){if(e===1/0||e===-1/0)return{value:e,errors:r("number.infinity")};if(!a.isNumber(e))return{value:e,errors:r("number.base")};const n={value:e};if(s.convert){const e=t.$_getRule("precision");if(e){const t=Math.pow(10,e.args.limit);n.value=Math.round(n.value*t)/t}}return 0===n.value&&(n.value=0),!t._flags.unsafe&&(e>Number.MAX_SAFE_INTEGER||e<Number.MIN_SAFE_INTEGER)&&(n.errors=r("number.unsafe")),n},rules:{compare:{method:!1,validate:(e,t,{limit:r},{name:s,operator:n,args:i})=>a.compare(e,r,n)?e:t.error("number."+s,{limit:i.limit,value:e}),args:[{name:"limit",ref:!0,assert:a.isNumber,message:"must be a number"}]},greater:{method(e){return this.$_addRule({name:"greater",method:"compare",args:{limit:e},operator:">"})}},integer:{method(){return this.$_addRule("integer")},validate:(e,t)=>Math.trunc(e)-e==0?e:t.error("number.integer")},less:{method(e){return this.$_addRule({name:"less",method:"compare",args:{limit:e},operator:"<"})}},max:{method(e){return this.$_addRule({name:"max",method:"compare",args:{limit:e},operator:"<="})}},min:{method(e){return this.$_addRule({name:"min",method:"compare",args:{limit:e},operator:">="})}},multiple:{method(e){const t="number"==typeof e?i.decimalPlaces(e):null,r=Math.pow(10,t);return this.$_addRule({name:"multiple",args:{base:e,baseDecimalPlace:t,pfactor:r}})},validate:(e,t,{base:r,baseDecimalPlace:s,pfactor:n},a)=>i.decimalPlaces(e)>s?t.error("number.multiple",{multiple:a.args.base,value:e}):Math.round(n*e)%Math.round(n*r)==0?e:t.error("number.multiple",{multiple:a.args.base,value:e}),args:[{name:"base",ref:!0,assert:e=>"number"==typeof e&&isFinite(e)&&e>0,message:"must be a positive number"},"baseDecimalPlace","pfactor"],multi:!0},negative:{method(){return this.sign("negative")}},port:{method(){return this.$_addRule("port")},validate:(e,t)=>Number.isSafeInteger(e)&&e>=0&&e<=65535?e:t.error("number.port")},positive:{method(){return this.sign("positive")}},precision:{method(e){return s(Number.isSafeInteger(e),"limit must be an integer"),this.$_addRule({name:"precision",args:{limit:e}})},validate(e,t,{limit:r}){const s=e.toString().match(i.precisionRx);return Math.max((s[1]?s[1].length:0)-(s[2]?parseInt(s[2],10):0),0)<=r?e:t.error("number.precision",{limit:r,value:e})},convert:!0},sign:{method(e){return s(["negative","positive"].includes(e),"Invalid sign",e),this.$_addRule({name:"sign",args:{sign:e}})},validate:(e,t,{sign:r})=>"negative"===r&&e<0||"positive"===r&&e>0?e:t.error(`number.${r}`)},unsafe:{method(e=!0){return s("boolean"==typeof e,"enabled must be a boolean"),this.$_setFlag("unsafe",e)}}},cast:{string:{from:e=>"number"==typeof e,to:(e,t)=>e.toString()}},messages:{"number.base":"{{#label}} must be a number","number.greater":"{{#label}} must be greater than {{#limit}}","number.infinity":"{{#label}} cannot be infinity","number.integer":"{{#label}} must be an integer","number.less":"{{#label}} must be less than {{#limit}}","number.max":"{{#label}} must be less than or equal to {{#limit}}","number.min":"{{#label}} must be greater than or equal to {{#limit}}","number.multiple":"{{#label}} must be a multiple of {{#multiple}}","number.negative":"{{#label}} must be a negative number","number.port":"{{#label}} must be a valid port","number.positive":"{{#label}} must be a positive number","number.precision":"{{#label}} must have no more than {{#limit}} decimal places","number.unsafe":"{{#label}} must be a safe number"}}),i.extractSignificantDigits=function(e){return e.replace(i.exponentialPartRegex,"").replace(i.dotRegex,"").replace(i.trailingZerosRegex,"").replace(i.leadingSignAndZerosRegex,"")},i.normalizeDecimal=function(e){return(e=e.replace(/^\+/,"").replace(/\.0*$/,"").replace(/^(-?)\.([^\.]*)$/,"$10.$2").replace(/^(-?)0+([0-9])/,"$1$2")).includes(".")&&e.endsWith("0")&&(e=e.replace(/0+$/,"")),"-0"===e?"0":e}},(e,t,r)=>{const s=r(125);e.exports=s.extend({type:"object",cast:{map:{from:e=>e&&"object"==typeof e,to:(e,t)=>new Map(Object.entries(e))}}})},(e,t,r)=>{var s=r(14).Buffer;const n=r(27),a=r(130),i=r(132),o=r(133),l=r(40),c=r(135),u=r(134),p=r(115),h=r(100),d={tlds:c instanceof Set&&{tlds:{allow:c,deny:null}},base64Regex:{true:{true:/^(?:[\w\-]{2}[\w\-]{2})*(?:[\w\-]{2}==|[\w\-]{3}=)?$/,false:/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/},false:{true:/^(?:[\w\-]{2}[\w\-]{2})*(?:[\w\-]{2}(==)?|[\w\-]{3}=?)?$/,false:/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}(==)?|[A-Za-z0-9+\/]{3}=?)?$/}},dataUriRegex:/^data:[\w+.-]+\/[\w+.-]+;((charset=[\w-]+|base64),)?(.*)$/,hexRegex:{withPrefix:/^0x[0-9a-f]+$/i,withOptionalPrefix:/^(?:0x)?[0-9a-f]+$/i,withoutPrefix:/^[0-9a-f]+$/i},ipRegex:o.regex({cidr:"forbidden"}).regex,isoDurationRegex:/^P(?!$)(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?$/,guidBrackets:{"{":"}","[":"]","(":")","":""},guidVersions:{uuidv1:"1",uuidv2:"2",uuidv3:"3",uuidv4:"4",uuidv5:"5",uuidv6:"6",uuidv7:"7",uuidv8:"8"},guidSeparators:new Set([void 0,!0,!1,"-",":"]),normalizationForms:["NFC","NFD","NFKC","NFKD"]};e.exports=p.extend({type:"string",flags:{insensitive:{default:!1},truncate:{default:!1}},terms:{replacements:{init:null}},coerce:{from:"string",method(e,{schema:t,state:r,prefs:s}){const n=t.$_getRule("normalize");n&&(e=e.normalize(n.args.form));const a=t.$_getRule("case");a&&(e="upper"===a.args.direction?e.toLocaleUpperCase():e.toLocaleLowerCase());const i=t.$_getRule("trim");if(i&&i.args.enabled&&(e=e.trim()),t.$_terms.replacements)for(const r of t.$_terms.replacements)e=e.replace(r.pattern,r.replacement);const o=t.$_getRule("hex");if(o&&o.args.options.byteAligned&&e.length%2!=0&&(e=`0${e}`),t.$_getRule("isoDate")){const t=d.isoDate(e);t&&(e=t)}if(t._flags.truncate){const n=t.$_getRule("max");if(n){let a=n.args.limit;if(h.isResolvable(a)&&(a=a.resolve(e,r,s),!h.limit(a)))return{value:e,errors:t.$_createError("any.ref",a,{ref:n.args.limit,arg:"limit",reason:"must be a positive integer"},r,s)};e=e.slice(0,a)}}return{value:e}}},validate(e,{schema:t,error:r}){if("string"!=typeof e)return{value:e,errors:r("string.base")};if(""===e){const s=t.$_getRule("min");if(s&&0===s.args.limit)return;return{value:e,errors:r("string.empty")}}},rules:{alphanum:{method(){return this.$_addRule("alphanum")},validate:(e,t)=>/^[a-zA-Z0-9]+$/.test(e)?e:t.error("string.alphanum")},base64:{method(e={}){return h.assertOptions(e,["paddingRequired","urlSafe"]),e={urlSafe:!1,paddingRequired:!0,...e},n("boolean"==typeof e.paddingRequired,"paddingRequired must be boolean"),n("boolean"==typeof e.urlSafe,"urlSafe must be boolean"),this.$_addRule({name:"base64",args:{options:e}})},validate:(e,t,{options:r})=>d.base64Regex[r.paddingRequired][r.urlSafe].test(e)?e:t.error("string.base64")},case:{method(e){return n(["lower","upper"].includes(e),"Invalid case:",e),this.$_addRule({name:"case",args:{direction:e}})},validate:(e,t,{direction:r})=>"lower"===r&&e===e.toLocaleLowerCase()||"upper"===r&&e===e.toLocaleUpperCase()?e:t.error(`string.${r}case`),convert:!0},creditCard:{method(){return this.$_addRule("creditCard")},validate(e,t){let r=e.length,s=0,n=1;for(;r--;){const t=e.charAt(r)*n;s+=t-9*(t>9),n^=3}return s>0&&s%10==0?e:t.error("string.creditCard")}},dataUri:{method(e={}){return h.assertOptions(e,["paddingRequired"]),e={paddingRequired:!0,...e},n("boolean"==typeof e.paddingRequired,"paddingRequired must be boolean"),this.$_addRule({name:"dataUri",args:{options:e}})},validate(e,t,{options:r}){const s=e.match(d.dataUriRegex);if(s){if(!s[2])return e;if("base64"!==s[2])return e;if(d.base64Regex[r.paddingRequired].false.test(s[3]))return e}return t.error("string.dataUri")}},domain:{method(e){e&&h.assertOptions(e,["allowFullyQualified","allowUnicode","maxDomainSegments","minDomainSegments","tlds"]);const t=d.addressOptions(e);return this.$_addRule({name:"domain",args:{options:e},address:t})},validate:(e,t,r,{address:s})=>a.isValid(e,s)?e:t.error("string.domain")},email:{method(e={}){h.assertOptions(e,["allowFullyQualified","allowUnicode","ignoreLength","maxDomainSegments","minDomainSegments","multiple","separator","tlds"]),n(void 0===e.multiple||"boolean"==typeof e.multiple,"multiple option must be an boolean");const t=d.addressOptions(e),r=new RegExp(`\\s*[${e.separator?l(e.separator):","}]\\s*`);return this.$_addRule({name:"email",args:{options:e},regex:r,address:t})},validate(e,t,{options:r},{regex:s,address:n}){const a=r.multiple?e.split(s):[e],o=[];for(const e of a)i.isValid(e,n)||o.push(e);return o.length?t.error("string.email",{value:e,invalids:o}):e}},guid:{alias:"uuid",method(e={}){h.assertOptions(e,["version","separator"]);let t="";if(e.version){const r=[].concat(e.version);n(r.length>=1,"version must have at least 1 valid version specified");const s=new Set;for(let e=0;e<r.length;++e){const a=r[e];n("string"==typeof a,"version at position "+e+" must be a string");const i=d.guidVersions[a.toLowerCase()];n(i,"version at position "+e+" must be one of "+Object.keys(d.guidVersions).join(", ")),n(!s.has(i),"version at position "+e+" must not be a duplicate"),t+=i,s.add(i)}}n(d.guidSeparators.has(e.separator),'separator must be one of true, false, "-", or ":"');const r=void 0===e.separator?"[:-]?":!0===e.separator?"[:-]":!1===e.separator?"[]?":`\\${e.separator}`,s=new RegExp(`^([\\[{\\(]?)[0-9A-F]{8}(${r})[0-9A-F]{4}\\2?[${t||"0-9A-F"}][0-9A-F]{3}\\2?[${t?"89AB":"0-9A-F"}][0-9A-F]{3}\\2?[0-9A-F]{12}([\\]}\\)]?)$`,"i");return this.$_addRule({name:"guid",args:{options:e},regex:s})},validate(e,t,r,{regex:s}){const n=s.exec(e);return n?d.guidBrackets[n[1]]!==n[n.length-1]?t.error("string.guid"):e:t.error("string.guid")}},hex:{method(e={}){return h.assertOptions(e,["byteAligned","prefix"]),e={byteAligned:!1,prefix:!1,...e},n("boolean"==typeof e.byteAligned,"byteAligned must be boolean"),n("boolean"==typeof e.prefix||"optional"===e.prefix,'prefix must be boolean or "optional"'),this.$_addRule({name:"hex",args:{options:e}})},validate:(e,t,{options:r})=>("optional"===r.prefix?d.hexRegex.withOptionalPrefix:!0===r.prefix?d.hexRegex.withPrefix:d.hexRegex.withoutPrefix).test(e)?r.byteAligned&&e.length%2!=0?t.error("string.hexAlign"):e:t.error("string.hex")},hostname:{method(){return this.$_addRule("hostname")},validate:(e,t)=>a.isValid(e,{minDomainSegments:1})||d.ipRegex.test(e)?e:t.error("string.hostname")},insensitive:{method(){return this.$_setFlag("insensitive",!0)}},ip:{method(e={}){h.assertOptions(e,["cidr","version"]);const{cidr:t,versions:r,regex:s}=o.regex(e),n=e.version?r:void 0;return this.$_addRule({name:"ip",args:{options:{cidr:t,version:n}},regex:s})},validate:(e,t,{options:r},{regex:s})=>s.test(e)?e:r.version?t.error("string.ipVersion",{value:e,cidr:r.cidr,version:r.version}):t.error("string.ip",{value:e,cidr:r.cidr})},isoDate:{method(){return this.$_addRule("isoDate")},validate:(e,{error:t})=>d.isoDate(e)?e:t("string.isoDate")},isoDuration:{method(){return this.$_addRule("isoDuration")},validate:(e,t)=>d.isoDurationRegex.test(e)?e:t.error("string.isoDuration")},length:{method(e,t){return d.length(this,"length",e,"=",t)},validate(e,t,{limit:r,encoding:n},{name:a,operator:i,args:o}){const l=n?s&&s.byteLength(e,n):e.length;return h.compare(l,r,i)?e:t.error("string."+a,{limit:o.limit,value:e,encoding:n})},args:[{name:"limit",ref:!0,assert:h.limit,message:"must be a positive integer"},"encoding"]},lowercase:{method(){return this.case("lower")}},max:{method(e,t){return d.length(this,"max",e,"<=",t)},args:["limit","encoding"]},min:{method(e,t){return d.length(this,"min",e,">=",t)},args:["limit","encoding"]},normalize:{method(e="NFC"){return n(d.normalizationForms.includes(e),"normalization form must be one of "+d.normalizationForms.join(", ")),this.$_addRule({name:"normalize",args:{form:e}})},validate:(e,{error:t},{form:r})=>e===e.normalize(r)?e:t("string.normalize",{value:e,form:r}),convert:!0},pattern:{alias:"regex",method(e,t={}){n(e instanceof RegExp,"regex must be a RegExp"),n(!e.flags.includes("g")&&!e.flags.includes("y"),"regex should not use global or sticky mode"),"string"==typeof t&&(t={name:t}),h.assertOptions(t,["invert","name"]);const r=["string.pattern",t.invert?".invert":"",t.name?".name":".base"].join("");return this.$_addRule({name:"pattern",args:{regex:e,options:t},errorCode:r})},validate:(e,t,{regex:r,options:s},{errorCode:n})=>r.test(e)^s.invert?e:t.error(n,{name:s.name,regex:r,value:e}),args:["regex","options"],multi:!0},replace:{method(e,t){"string"==typeof e&&(e=new RegExp(l(e),"g")),n(e instanceof RegExp,"pattern must be a RegExp"),n("string"==typeof t,"replacement must be a String");const r=this.clone();return r.$_terms.replacements||(r.$_terms.replacements=[]),r.$_terms.replacements.push({pattern:e,replacement:t}),r}},token:{method(){return this.$_addRule("token")},validate:(e,t)=>/^\w+$/.test(e)?e:t.error("string.token")},trim:{method(e=!0){return n("boolean"==typeof e,"enabled must be a boolean"),this.$_addRule({name:"trim",args:{enabled:e}})},validate:(e,t,{enabled:r})=>r&&e!==e.trim()?t.error("string.trim"):e,convert:!0},truncate:{method(e=!0){return n("boolean"==typeof e,"enabled must be a boolean"),this.$_setFlag("truncate",e)}},uppercase:{method(){return this.case("upper")}},uri:{method(e={}){h.assertOptions(e,["allowRelative","allowQuerySquareBrackets","domain","relativeOnly","scheme"]),e.domain&&h.assertOptions(e.domain,["allowFullyQualified","allowUnicode","maxDomainSegments","minDomainSegments","tlds"]);const{regex:t,scheme:r}=u.regex(e),s=e.domain?d.addressOptions(e.domain):null;return this.$_addRule({name:"uri",args:{options:e},regex:t,domain:s,scheme:r})},validate(e,t,{options:r},{regex:s,domain:n,scheme:i}){if(["http:/","https:/"].includes(e))return t.error("string.uri");const o=s.exec(e);if(o){const s=o[1]||o[2];return!n||r.allowRelative&&!s||a.isValid(s,n)?e:t.error("string.domain",{value:s})}return r.relativeOnly?t.error("string.uriRelativeOnly"):r.scheme?t.error("string.uriCustomScheme",{scheme:i,value:e}):t.error("string.uri")}}},manifest:{build(e,t){if(t.replacements)for(const{pattern:r,replacement:s}of t.replacements)e=e.replace(r,s);return e}},messages:{"string.alphanum":"{{#label}} must only contain alpha-numeric characters","string.base":"{{#label}} must be a string","string.base64":"{{#label}} must be a valid base64 string","string.creditCard":"{{#label}} must be a credit card","string.dataUri":"{{#label}} must be a valid dataUri string","string.domain":"{{#label}} must contain a valid domain name","string.email":"{{#label}} must be a valid email","string.empty":"{{#label}} is not allowed to be empty","string.guid":"{{#label}} must be a valid GUID","string.hex":"{{#label}} must only contain hexadecimal characters","string.hexAlign":"{{#label}} hex decoded representation must be byte aligned","string.hostname":"{{#label}} must be a valid hostname","string.ip":"{{#label}} must be a valid ip address with a {{#cidr}} CIDR","string.ipVersion":"{{#label}} must be a valid ip address of one of the following versions {{#version}} with a {{#cidr}} CIDR","string.isoDate":"{{#label}} must be in iso format","string.isoDuration":"{{#label}} must be a valid ISO 8601 duration","string.length":"{{#label}} length must be {{#limit}} characters long","string.lowercase":"{{#label}} must only contain lowercase characters","string.max":"{{#label}} length must be less than or equal to {{#limit}} characters long","string.min":"{{#label}} length must be at least {{#limit}} characters long","string.normalize":"{{#label}} must be unicode normalized in the {{#form}} form","string.token":"{{#label}} must only contain alpha-numeric and underscore characters","string.pattern.base":"{{#label}} with value {:[.]} fails to match the required pattern: {{#regex}}","string.pattern.name":"{{#label}} with value {:[.]} fails to match the {{#name}} pattern","string.pattern.invert.base":"{{#label}} with value {:[.]} matches the inverted pattern: {{#regex}}","string.pattern.invert.name":"{{#label}} with value {:[.]} matches the inverted {{#name}} pattern","string.trim":"{{#label}} must not have leading or trailing whitespace","string.uri":"{{#label}} must be a valid uri","string.uriCustomScheme":"{{#label}} must be a valid uri with a scheme matching the {{#scheme}} pattern","string.uriRelativeOnly":"{{#label}} must be a valid relative uri","string.uppercase":"{{#label}} must only contain uppercase characters"}}),d.addressOptions=function(e){if(!e)return d.tlds||e;if(n(void 0===e.minDomainSegments||Number.isSafeInteger(e.minDomainSegments)&&e.minDomainSegments>0,"minDomainSegments must be a positive integer"),n(void 0===e.maxDomainSegments||Number.isSafeInteger(e.maxDomainSegments)&&e.maxDomainSegments>0,"maxDomainSegments must be a positive integer"),!1===e.tlds)return e;if(!0===e.tlds||void 0===e.tlds)return n(d.tlds,"Built-in TLD list disabled"),Object.assign({},e,d.tlds);n("object"==typeof e.tlds,"tlds must be true, false, or an object");const t=e.tlds.deny;if(t)return Array.isArray(t)&&(e=Object.assign({},e,{tlds:{deny:new Set(t)}})),n(e.tlds.deny instanceof Set,"tlds.deny must be an array, Set, or boolean"),n(!e.tlds.allow,"Cannot specify both tlds.allow and tlds.deny lists"),d.validateTlds(e.tlds.deny,"tlds.deny"),e;const r=e.tlds.allow;return r?!0===r?(n(d.tlds,"Built-in TLD list disabled"),Object.assign({},e,d.tlds)):(Array.isArray(r)&&(e=Object.assign({},e,{tlds:{allow:new Set(r)}})),n(e.tlds.allow instanceof Set,"tlds.allow must be an array, Set, or boolean"),d.validateTlds(e.tlds.allow,"tlds.allow"),e):e},d.validateTlds=function(e,t){for(const r of e)n(a.isValid(r,{minDomainSegments:1,maxDomainSegments:1}),`${t} must contain valid top level domain names`)},d.isoDate=function(e){if(!h.isIsoDate(e))return null;/.*T.*[+-]\d\d$/.test(e)&&(e+="00");const t=new Date(e);return isNaN(t.getTime())?null:t.toISOString()},d.length=function(e,t,r,a,i){return n(!i||s&&s.isEncoding(i),"Invalid encoding:",i),e.$_addRule({name:t,method:"length",args:{limit:r,encoding:i},operator:a})}},(e,t,r)=>{const s=r(9),n=r(131),a={minDomainSegments:2,nonAsciiRx:/[^\x00-\x7f]/,domainControlRx:/[\x00-\x20@\:\/\\#!\$&\'\(\)\*\+,;=\?]/,tldSegmentRx:/^[a-zA-Z](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,domainSegmentRx:/^[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,URL:s.URL||URL};t.analyze=function(e,t={}){if(!e)return n.code("DOMAIN_NON_EMPTY_STRING");if("string"!=typeof e)throw new Error("Invalid input: domain must be a string");if(e.length>256)return n.code("DOMAIN_TOO_LONG");if(!!a.nonAsciiRx.test(e)){if(!1===t.allowUnicode)return n.code("DOMAIN_INVALID_UNICODE_CHARS");e=e.normalize("NFC")}if(a.domainControlRx.test(e))return n.code("DOMAIN_INVALID_CHARS");e=a.punycode(e),t.allowFullyQualified&&"."===e[e.length-1]&&(e=e.slice(0,-1));const r=t.minDomainSegments||a.minDomainSegments,s=e.split(".");if(s.length<r)return n.code("DOMAIN_SEGMENTS_COUNT");if(t.maxDomainSegments&&s.length>t.maxDomainSegments)return n.code("DOMAIN_SEGMENTS_COUNT_MAX");const i=t.tlds;if(i){const e=s[s.length-1].toLowerCase();if(i.deny&&i.deny.has(e)||i.allow&&!i.allow.has(e))return n.code("DOMAIN_FORBIDDEN_TLDS")}for(let e=0;e<s.length;++e){const t=s[e];if(!t.length)return n.code("DOMAIN_EMPTY_SEGMENT");if(t.length>63)return n.code("DOMAIN_LONG_SEGMENT");if(e<s.length-1){if(!a.domainSegmentRx.test(t))return n.code("DOMAIN_INVALID_CHARS")}else if(!a.tldSegmentRx.test(t))return n.code("DOMAIN_INVALID_TLDS_CHARS")}return null},t.isValid=function(e,r){return!t.analyze(e,r)},a.punycode=function(e){e.includes("%")&&(e=e.replace(/%/g,"%25"));try{return new a.URL(`http://${e}`).host}catch(t){return e}}},(e,t)=>{t.codes={EMPTY_STRING:"Address must be a non-empty string",FORBIDDEN_UNICODE:"Address contains forbidden Unicode characters",MULTIPLE_AT_CHAR:"Address cannot contain more than one @ character",MISSING_AT_CHAR:"Address must contain one @ character",EMPTY_LOCAL:"Address local part cannot be empty",ADDRESS_TOO_LONG:"Address too long",LOCAL_TOO_LONG:"Address local part too long",EMPTY_LOCAL_SEGMENT:"Address local part contains empty dot-separated segment",INVALID_LOCAL_CHARS:"Address local part contains invalid character",DOMAIN_NON_EMPTY_STRING:"Domain must be a non-empty string",DOMAIN_TOO_LONG:"Domain too long",DOMAIN_INVALID_UNICODE_CHARS:"Domain contains forbidden Unicode characters",DOMAIN_INVALID_CHARS:"Domain contains invalid character",DOMAIN_INVALID_TLDS_CHARS:"Domain contains invalid tld character",DOMAIN_SEGMENTS_COUNT:"Domain lacks the minimum required number of segments",DOMAIN_SEGMENTS_COUNT_MAX:"Domain contains too many segments",DOMAIN_FORBIDDEN_TLDS:"Domain uses forbidden TLD",DOMAIN_EMPTY_SEGMENT:"Domain contains empty dot-separated segment",DOMAIN_LONG_SEGMENT:"Domain contains dot-separated segment that is too long"},t.code=function(e){return{code:e,error:t.codes[e]}}},(e,t,r)=>{const s=r(88),n=r(130),a=r(131),i={nonAsciiRx:/[^\x00-\x7f]/,encoder:new(s.TextEncoder||TextEncoder)};t.analyze=function(e,t){return i.email(e,t)},t.isValid=function(e,t){return!i.email(e,t)},i.email=function(e,t={}){if("string"!=typeof e)throw new Error("Invalid input: email must be a string");if(!e)return a.code("EMPTY_STRING");const r=!i.nonAsciiRx.test(e);if(!r){if(!1===t.allowUnicode)return a.code("FORBIDDEN_UNICODE");e=e.normalize("NFC")}const s=e.split("@");if(2!==s.length)return s.length>2?a.code("MULTIPLE_AT_CHAR"):a.code("MISSING_AT_CHAR");const[o,l]=s;if(!o)return a.code("EMPTY_LOCAL");if(!t.ignoreLength){if(e.length>254)return a.code("ADDRESS_TOO_LONG");if(i.encoder.encode(o).length>64)return a.code("LOCAL_TOO_LONG")}return i.local(o,r)||n.analyze(l,t)},i.local=function(e,t){const r=e.split(".");for(const e of r){if(!e.length)return a.code("EMPTY_LOCAL_SEGMENT");if(t){if(!i.atextRx.test(e))return a.code("INVALID_LOCAL_CHARS")}else for(const t of e){if(i.atextRx.test(t))continue;const e=i.binary(t);if(!i.atomRx.test(e))return a.code("INVALID_LOCAL_CHARS")}}},i.binary=function(e){return Array.from(i.encoder.encode(e)).map((e=>String.fromCharCode(e))).join("")},i.atextRx=/^[\w!#\$%&'\*\+\-/=\?\^`\{\|\}~]+$/,i.atomRx=new RegExp(["(?:[\\xc2-\\xdf][\\x80-\\xbf])","(?:\\xe0[\\xa0-\\xbf][\\x80-\\xbf])|(?:[\\xe1-\\xec][\\x80-\\xbf]{2})|(?:\\xed[\\x80-\\x9f][\\x80-\\xbf])|(?:[\\xee-\\xef][\\x80-\\xbf]{2})","(?:\\xf0[\\x90-\\xbf][\\x80-\\xbf]{2})|(?:[\\xf1-\\xf3][\\x80-\\xbf]{3})|(?:\\xf4[\\x80-\\x8f][\\x80-\\xbf]{2})"].join("|"))},(e,t,r)=>{const s=r(27),n=r(134);t.regex=function(e={}){s(void 0===e.cidr||"string"==typeof e.cidr,"options.cidr must be a string");const t=e.cidr?e.cidr.toLowerCase():"optional";s(["required","optional","forbidden"].includes(t),"options.cidr must be one of required, optional, forbidden"),s(void 0===e.version||"string"==typeof e.version||Array.isArray(e.version),"options.version must be a string or an array of string");let r=e.version||["ipv4","ipv6","ipvfuture"];Array.isArray(r)||(r=[r]),s(r.length>=1,"options.version must have at least 1 version specified");for(let e=0;e<r.length;++e)s("string"==typeof r[e],"options.version must only contain strings"),r[e]=r[e].toLowerCase(),s(["ipv4","ipv6","ipvfuture"].includes(r[e]),"options.version contains unknown version "+r[e]+" - must be one of ipv4, ipv6, ipvfuture");r=Array.from(new Set(r));const a=`(?:${r.map((e=>{if("forbidden"===t)return n.ip[e];const r=`\\/${"ipv4"===e?n.ip.v4Cidr:n.ip.v6Cidr}`;return"required"===t?`${n.ip[e]}${r}`:`${n.ip[e]}(?:${r})?`})).join("|")})`,i=new RegExp(`^${a}$`);return{cidr:t,versions:r,regex:i,raw:a}}},(e,t,r)=>{const s=r(27),n=r(40),a={generate:function(){const e={},t="\\dA-Fa-f",r="["+t+"]",s="\\w-\\.~",n="!\\$&'\\(\\)\\*\\+,;=",a="%"+t,i=s+a+n+":@",o="["+i+"]",l="(?:0{0,2}\\d|0?[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])";e.ipv4address="(?:"+l+"\\.){3}"+l;const c=r+"{1,4}",u="(?:"+c+":"+c+"|"+e.ipv4address+")",p="(?:"+c+":){6}"+u,h="::(?:"+c+":){5}"+u,d="(?:"+c+")?::(?:"+c+":){4}"+u,f="(?:(?:"+c+":){0,1}"+c+")?::(?:"+c+":){3}"+u,m="(?:(?:"+c+":){0,2}"+c+")?::(?:"+c+":){2}"+u,g="(?:(?:"+c+":){0,3}"+c+")?::"+c+":"+u,y="(?:(?:"+c+":){0,4}"+c+")?::"+u,b="(?:(?:"+c+":){0,5}"+c+")?::"+c,v="(?:(?:"+c+":){0,6}"+c+")?::";e.ipv4Cidr="(?:\\d|[1-2]\\d|3[0-2])",e.ipv6Cidr="(?:0{0,2}\\d|0?[1-9]\\d|1[01]\\d|12[0-8])",e.ipv6address="(?:"+p+"|"+h+"|"+d+"|"+f+"|"+m+"|"+g+"|"+y+"|"+b+"|"+v+")",e.ipvFuture="v"+r+"+\\.["+s+n+":]+",e.scheme="[a-zA-Z][a-zA-Z\\d+-\\.]*",e.schemeRegex=new RegExp(e.scheme);const _="["+s+a+n+":]*",w="["+s+a+n+"]{1,255}",A="(?:"+("\\[(?:"+e.ipv6address+"|"+e.ipvFuture+")\\]")+"|"+e.ipv4address+"|"+w+")",E="(?:"+_+"@)?"+A+"(?::\\d*)?",R="(?:"+_+"@)?("+A+")(?::\\d*)?",S=o+"*",$=o+"+",x="(?:\\/"+S+")*",O="\\/(?:"+$+x+")?",I=$+x,T="["+s+a+n+"@]+"+x,C="(?:\\/\\/\\/"+S+x+")";return e.hierPart="(?:(?:\\/\\/"+E+x+")|"+O+"|"+I+"|"+C+")",e.hierPartCapture="(?:(?:\\/\\/"+R+x+")|"+O+"|"+I+")",e.relativeRef="(?:(?:\\/\\/"+E+x+")|"+O+"|"+T+"|)",e.relativeRefCapture="(?:(?:\\/\\/"+R+x+")|"+O+"|"+T+"|)",e.query="["+i+"\\/\\?]*(?=#|$)",e.queryWithSquareBrackets="["+i+"\\[\\]\\/\\?]*(?=#|$)",e.fragment="["+i+"\\/\\?]*",e}};a.rfc3986=a.generate(),t.ip={v4Cidr:a.rfc3986.ipv4Cidr,v6Cidr:a.rfc3986.ipv6Cidr,ipv4:a.rfc3986.ipv4address,ipv6:a.rfc3986.ipv6address,ipvfuture:a.rfc3986.ipvFuture},a.createRegex=function(e){const t=a.rfc3986,r="(?:\\?"+(e.allowQuerySquareBrackets?t.queryWithSquareBrackets:t.query)+")?(?:#"+t.fragment+")?",i=e.domain?t.relativeRefCapture:t.relativeRef;if(e.relativeOnly)return a.wrap(i+r);let o="";if(e.scheme){s(e.scheme instanceof RegExp||"string"==typeof e.scheme||Array.isArray(e.scheme),"scheme must be a RegExp, String, or Array");const r=[].concat(e.scheme);s(r.length>=1,"scheme must have at least 1 scheme specified");const a=[];for(let e=0;e<r.length;++e){const i=r[e];s(i instanceof RegExp||"string"==typeof i,"scheme at position "+e+" must be a RegExp or String"),i instanceof RegExp?a.push(i.source.toString()):(s(t.schemeRegex.test(i),"scheme at position "+e+" must be a valid scheme"),a.push(n(i)))}o=a.join("|")}const l="(?:"+(o?"(?:"+o+")":t.scheme)+":"+(e.domain?t.hierPartCapture:t.hierPart)+")",c=e.allowRelative?"(?:"+l+"|"+i+")":l;return a.wrap(c+r,o)},a.wrap=function(e,t){return{raw:e=`(?=.)(?!https?:/(?:$|[^/]))(?!https?:///)(?!https?:[^/])${e}`,regex:new RegExp(`^${e}$`),scheme:t}},a.uriRegex=a.createRegex({}),t.regex=function(e={}){return e.scheme||e.allowRelative||e.relativeOnly||e.allowQuerySquareBrackets||e.domain?a.createRegex(e):a.uriRegex}},e=>{const t={tlds:["AAA","AARP","ABB","ABBOTT","ABBVIE","ABC","ABLE","ABOGADO","ABUDHABI","AC","ACADEMY","ACCENTURE","ACCOUNTANT","ACCOUNTANTS","ACO","ACTOR","AD","ADS","ADULT","AE","AEG","AERO","AETNA","AF","AFL","AFRICA","AG","AGAKHAN","AGENCY","AI","AIG","AIRBUS","AIRFORCE","AIRTEL","AKDN","AL","ALIBABA","ALIPAY","ALLFINANZ","ALLSTATE","ALLY","ALSACE","ALSTOM","AM","AMAZON","AMERICANEXPRESS","AMERICANFAMILY","AMEX","AMFAM","AMICA","AMSTERDAM","ANALYTICS","ANDROID","ANQUAN","ANZ","AO","AOL","APARTMENTS","APP","APPLE","AQ","AQUARELLE","AR","ARAB","ARAMCO","ARCHI","ARMY","ARPA","ART","ARTE","AS","ASDA","ASIA","ASSOCIATES","AT","ATHLETA","ATTORNEY","AU","AUCTION","AUDI","AUDIBLE","AUDIO","AUSPOST","AUTHOR","AUTO","AUTOS","AVIANCA","AW","AWS","AX","AXA","AZ","AZURE","BA","BABY","BAIDU","BANAMEX","BAND","BANK","BAR","BARCELONA","BARCLAYCARD","BARCLAYS","BAREFOOT","BARGAINS","BASEBALL","BASKETBALL","BAUHAUS","BAYERN","BB","BBC","BBT","BBVA","BCG","BCN","BD","BE","BEATS","BEAUTY","BEER","BENTLEY","BERLIN","BEST","BESTBUY","BET","BF","BG","BH","BHARTI","BI","BIBLE","BID","BIKE","BING","BINGO","BIO","BIZ","BJ","BLACK","BLACKFRIDAY","BLOCKBUSTER","BLOG","BLOOMBERG","BLUE","BM","BMS","BMW","BN","BNPPARIBAS","BO","BOATS","BOEHRINGER","BOFA","BOM","BOND","BOO","BOOK","BOOKING","BOSCH","BOSTIK","BOSTON","BOT","BOUTIQUE","BOX","BR","BRADESCO","BRIDGESTONE","BROADWAY","BROKER","BROTHER","BRUSSELS","BS","BT","BUILD","BUILDERS","BUSINESS","BUY","BUZZ","BV","BW","BY","BZ","BZH","CA","CAB","CAFE","CAL","CALL","CALVINKLEIN","CAM","CAMERA","CAMP","CANON","CAPETOWN","CAPITAL","CAPITALONE","CAR","CARAVAN","CARDS","CARE","CAREER","CAREERS","CARS","CASA","CASE","CASH","CASINO","CAT","CATERING","CATHOLIC","CBA","CBN","CBRE","CC","CD","CENTER","CEO","CERN","CF","CFA","CFD","CG","CH","CHANEL","CHANNEL","CHARITY","CHASE","CHAT","CHEAP","CHINTAI","CHRISTMAS","CHROME","CHURCH","CI","CIPRIANI","CIRCLE","CISCO","CITADEL","CITI","CITIC","CITY","CK","CL","CLAIMS","CLEANING","CLICK","CLINIC","CLINIQUE","CLOTHING","CLOUD","CLUB","CLUBMED","CM","CN","CO","COACH","CODES","COFFEE","COLLEGE","COLOGNE","COM","COMCAST","COMMBANK","COMMUNITY","COMPANY","COMPARE","COMPUTER","COMSEC","CONDOS","CONSTRUCTION","CONSULTING","CONTACT","CONTRACTORS","COOKING","COOL","COOP","CORSICA","COUNTRY","COUPON","COUPONS","COURSES","CPA","CR","CREDIT","CREDITCARD","CREDITUNION","CRICKET","CROWN","CRS","CRUISE","CRUISES","CU","CUISINELLA","CV","CW","CX","CY","CYMRU","CYOU","CZ","DABUR","DAD","DANCE","DATA","DATE","DATING","DATSUN","DAY","DCLK","DDS","DE","DEAL","DEALER","DEALS","DEGREE","DELIVERY","DELL","DELOITTE","DELTA","DEMOCRAT","DENTAL","DENTIST","DESI","DESIGN","DEV","DHL","DIAMONDS","DIET","DIGITAL","DIRECT","DIRECTORY","DISCOUNT","DISCOVER","DISH","DIY","DJ","DK","DM","DNP","DO","DOCS","DOCTOR","DOG","DOMAINS","DOT","DOWNLOAD","DRIVE","DTV","DUBAI","DUNLOP","DUPONT","DURBAN","DVAG","DVR","DZ","EARTH","EAT","EC","ECO","EDEKA","EDU","EDUCATION","EE","EG","EMAIL","EMERCK","ENERGY","ENGINEER","ENGINEERING","ENTERPRISES","EPSON","EQUIPMENT","ER","ERICSSON","ERNI","ES","ESQ","ESTATE","ET","EU","EUROVISION","EUS","EVENTS","EXCHANGE","EXPERT","EXPOSED","EXPRESS","EXTRASPACE","FAGE","FAIL","FAIRWINDS","FAITH","FAMILY","FAN","FANS","FARM","FARMERS","FASHION","FAST","FEDEX","FEEDBACK","FERRARI","FERRERO","FI","FIDELITY","FIDO","FILM","FINAL","FINANCE","FINANCIAL","FIRE","FIRESTONE","FIRMDALE","FISH","FISHING","FIT","FITNESS","FJ","FK","FLICKR","FLIGHTS","FLIR","FLORIST","FLOWERS","FLY","FM","FO","FOO","FOOD","FOOTBALL","FORD","FOREX","FORSALE","FORUM","FOUNDATION","FOX","FR","FREE","FRESENIUS","FRL","FROGANS","FRONTIER","FTR","FUJITSU","FUN","FUND","FURNITURE","FUTBOL","FYI","GA","GAL","GALLERY","GALLO","GALLUP","GAME","GAMES","GAP","GARDEN","GAY","GB","GBIZ","GD","GDN","GE","GEA","GENT","GENTING","GEORGE","GF","GG","GGEE","GH","GI","GIFT","GIFTS","GIVES","GIVING","GL","GLASS","GLE","GLOBAL","GLOBO","GM","GMAIL","GMBH","GMO","GMX","GN","GODADDY","GOLD","GOLDPOINT","GOLF","GOO","GOODYEAR","GOOG","GOOGLE","GOP","GOT","GOV","GP","GQ","GR","GRAINGER","GRAPHICS","GRATIS","GREEN","GRIPE","GROCERY","GROUP","GS","GT","GU","GUARDIAN","GUCCI","GUGE","GUIDE","GUITARS","GURU","GW","GY","HAIR","HAMBURG","HANGOUT","HAUS","HBO","HDFC","HDFCBANK","HEALTH","HEALTHCARE","HELP","HELSINKI","HERE","HERMES","HIPHOP","HISAMITSU","HITACHI","HIV","HK","HKT","HM","HN","HOCKEY","HOLDINGS","HOLIDAY","HOMEDEPOT","HOMEGOODS","HOMES","HOMESENSE","HONDA","HORSE","HOSPITAL","HOST","HOSTING","HOT","HOTELS","HOTMAIL","HOUSE","HOW","HR","HSBC","HT","HU","HUGHES","HYATT","HYUNDAI","IBM","ICBC","ICE","ICU","ID","IE","IEEE","IFM","IKANO","IL","IM","IMAMAT","IMDB","IMMO","IMMOBILIEN","IN","INC","INDUSTRIES","INFINITI","INFO","ING","INK","INSTITUTE","INSURANCE","INSURE","INT","INTERNATIONAL","INTUIT","INVESTMENTS","IO","IPIRANGA","IQ","IR","IRISH","IS","ISMAILI","IST","ISTANBUL","IT","ITAU","ITV","JAGUAR","JAVA","JCB","JE","JEEP","JETZT","JEWELRY","JIO","JLL","JM","JMP","JNJ","JO","JOBS","JOBURG","JOT","JOY","JP","JPMORGAN","JPRS","JUEGOS","JUNIPER","KAUFEN","KDDI","KE","KERRYHOTELS","KERRYLOGISTICS","KERRYPROPERTIES","KFH","KG","KH","KI","KIA","KIDS","KIM","KINDLE","KITCHEN","KIWI","KM","KN","KOELN","KOMATSU","KOSHER","KP","KPMG","KPN","KR","KRD","KRED","KUOKGROUP","KW","KY","KYOTO","KZ","LA","LACAIXA","LAMBORGHINI","LAMER","LANCASTER","LAND","LANDROVER","LANXESS","LASALLE","LAT","LATINO","LATROBE","LAW","LAWYER","LB","LC","LDS","LEASE","LECLERC","LEFRAK","LEGAL","LEGO","LEXUS","LGBT","LI","LIDL","LIFE","LIFEINSURANCE","LIFESTYLE","LIGHTING","LIKE","LILLY","LIMITED","LIMO","LINCOLN","LINK","LIPSY","LIVE","LIVING","LK","LLC","LLP","LOAN","LOANS","LOCKER","LOCUS","LOL","LONDON","LOTTE","LOTTO","LOVE","LPL","LPLFINANCIAL","LR","LS","LT","LTD","LTDA","LU","LUNDBECK","LUXE","LUXURY","LV","LY","MA","MADRID","MAIF","MAISON","MAKEUP","MAN","MANAGEMENT","MANGO","MAP","MARKET","MARKETING","MARKETS","MARRIOTT","MARSHALLS","MATTEL","MBA","MC","MCKINSEY","MD","ME","MED","MEDIA","MEET","MELBOURNE","MEME","MEMORIAL","MEN","MENU","MERCKMSD","MG","MH","MIAMI","MICROSOFT","MIL","MINI","MINT","MIT","MITSUBISHI","MK","ML","MLB","MLS","MM","MMA","MN","MO","MOBI","MOBILE","MODA","MOE","MOI","MOM","MONASH","MONEY","MONSTER","MORMON","MORTGAGE","MOSCOW","MOTO","MOTORCYCLES","MOV","MOVIE","MP","MQ","MR","MS","MSD","MT","MTN","MTR","MU","MUSEUM","MUSIC","MV","MW","MX","MY","MZ","NA","NAB","NAGOYA","NAME","NATURA","NAVY","NBA","NC","NE","NEC","NET","NETBANK","NETFLIX","NETWORK","NEUSTAR","NEW","NEWS","NEXT","NEXTDIRECT","NEXUS","NF","NFL","NG","NGO","NHK","NI","NICO","NIKE","NIKON","NINJA","NISSAN","NISSAY","NL","NO","NOKIA","NORTON","NOW","NOWRUZ","NOWTV","NP","NR","NRA","NRW","NTT","NU","NYC","NZ","OBI","OBSERVER","OFFICE","OKINAWA","OLAYAN","OLAYANGROUP","OLLO","OM","OMEGA","ONE","ONG","ONL","ONLINE","OOO","OPEN","ORACLE","ORANGE","ORG","ORGANIC","ORIGINS","OSAKA","OTSUKA","OTT","OVH","PA","PAGE","PANASONIC","PARIS","PARS","PARTNERS","PARTS","PARTY","PAY","PCCW","PE","PET","PF","PFIZER","PG","PH","PHARMACY","PHD","PHILIPS","PHONE","PHOTO","PHOTOGRAPHY","PHOTOS","PHYSIO","PICS","PICTET","PICTURES","PID","PIN","PING","PINK","PIONEER","PIZZA","PK","PL","PLACE","PLAY","PLAYSTATION","PLUMBING","PLUS","PM","PN","PNC","POHL","POKER","POLITIE","PORN","POST","PR","PRAMERICA","PRAXI","PRESS","PRIME","PRO","PROD","PRODUCTIONS","PROF","PROGRESSIVE","PROMO","PROPERTIES","PROPERTY","PROTECTION","PRU","PRUDENTIAL","PS","PT","PUB","PW","PWC","PY","QA","QPON","QUEBEC","QUEST","RACING","RADIO","RE","READ","REALESTATE","REALTOR","REALTY","RECIPES","RED","REDSTONE","REDUMBRELLA","REHAB","REISE","REISEN","REIT","RELIANCE","REN","RENT","RENTALS","REPAIR","REPORT","REPUBLICAN","REST","RESTAURANT","REVIEW","REVIEWS","REXROTH","RICH","RICHARDLI","RICOH","RIL","RIO","RIP","RO","ROCKS","RODEO","ROGERS","ROOM","RS","RSVP","RU","RUGBY","RUHR","RUN","RW","RWE","RYUKYU","SA","SAARLAND","SAFE","SAFETY","SAKURA","SALE","SALON","SAMSCLUB","SAMSUNG","SANDVIK","SANDVIKCOROMANT","SANOFI","SAP","SARL","SAS","SAVE","SAXO","SB","SBI","SBS","SC","SCB","SCHAEFFLER","SCHMIDT","SCHOLARSHIPS","SCHOOL","SCHULE","SCHWARZ","SCIENCE","SCOT","SD","SE","SEARCH","SEAT","SECURE","SECURITY","SEEK","SELECT","SENER","SERVICES","SEVEN","SEW","SEX","SEXY","SFR","SG","SH","SHANGRILA","SHARP","SHAW","SHELL","SHIA","SHIKSHA","SHOES","SHOP","SHOPPING","SHOUJI","SHOW","SI","SILK","SINA","SINGLES","SITE","SJ","SK","SKI","SKIN","SKY","SKYPE","SL","SLING","SM","SMART","SMILE","SN","SNCF","SO","SOCCER","SOCIAL","SOFTBANK","SOFTWARE","SOHU","SOLAR","SOLUTIONS","SONG","SONY","SOY","SPA","SPACE","SPORT","SPOT","SR","SRL","SS","ST","STADA","STAPLES","STAR","STATEBANK","STATEFARM","STC","STCGROUP","STOCKHOLM","STORAGE","STORE","STREAM","STUDIO","STUDY","STYLE","SU","SUCKS","SUPPLIES","SUPPLY","SUPPORT","SURF","SURGERY","SUZUKI","SV","SWATCH","SWISS","SX","SY","SYDNEY","SYSTEMS","SZ","TAB","TAIPEI","TALK","TAOBAO","TARGET","TATAMOTORS","TATAR","TATTOO","TAX","TAXI","TC","TCI","TD","TDK","TEAM","TECH","TECHNOLOGY","TEL","TEMASEK","TENNIS","TEVA","TF","TG","TH","THD","THEATER","THEATRE","TIAA","TICKETS","TIENDA","TIPS","TIRES","TIROL","TJ","TJMAXX","TJX","TK","TKMAXX","TL","TM","TMALL","TN","TO","TODAY","TOKYO","TOOLS","TOP","TORAY","TOSHIBA","TOTAL","TOURS","TOWN","TOYOTA","TOYS","TR","TRADE","TRADING","TRAINING","TRAVEL","TRAVELERS","TRAVELERSINSURANCE","TRUST","TRV","TT","TUBE","TUI","TUNES","TUSHU","TV","TVS","TW","TZ","UA","UBANK","UBS","UG","UK","UNICOM","UNIVERSITY","UNO","UOL","UPS","US","UY","UZ","VA","VACATIONS","VANA","VANGUARD","VC","VE","VEGAS","VENTURES","VERISIGN","VERSICHERUNG","VET","VG","VI","VIAJES","VIDEO","VIG","VIKING","VILLAS","VIN","VIP","VIRGIN","VISA","VISION","VIVA","VIVO","VLAANDEREN","VN","VODKA","VOLVO","VOTE","VOTING","VOTO","VOYAGE","VU","WALES","WALMART","WALTER","WANG","WANGGOU","WATCH","WATCHES","WEATHER","WEATHERCHANNEL","WEBCAM","WEBER","WEBSITE","WED","WEDDING","WEIBO","WEIR","WF","WHOSWHO","WIEN","WIKI","WILLIAMHILL","WIN","WINDOWS","WINE","WINNERS","WME","WOLTERSKLUWER","WOODSIDE","WORK","WORKS","WORLD","WOW","WS","WTC","WTF","XBOX","XEROX","XFINITY","XIHUAN","XIN","XN--11B4C3D","XN--1CK2E1B","XN--1QQW23A","XN--2SCRJ9C","XN--30RR7Y","XN--3BST00M","XN--3DS443G","XN--3E0B707E","XN--3HCRJ9C","XN--3PXU8K","XN--42C2D9A","XN--45BR5CYL","XN--45BRJ9C","XN--45Q11C","XN--4DBRK0CE","XN--4GBRIM","XN--54B7FTA0CC","XN--55QW42G","XN--55QX5D","XN--5SU34J936BGSG","XN--5TZM5G","XN--6FRZ82G","XN--6QQ986B3XL","XN--80ADXHKS","XN--80AO21A","XN--80AQECDR1A","XN--80ASEHDB","XN--80ASWG","XN--8Y0A063A","XN--90A3AC","XN--90AE","XN--90AIS","XN--9DBQ2A","XN--9ET52U","XN--9KRT00A","XN--B4W605FERD","XN--BCK1B9A5DRE4C","XN--C1AVG","XN--C2BR7G","XN--CCK2B3B","XN--CCKWCXETD","XN--CG4BKI","XN--CLCHC0EA0B2G2A9GCD","XN--CZR694B","XN--CZRS0T","XN--CZRU2D","XN--D1ACJ3B","XN--D1ALF","XN--E1A4C","XN--ECKVDTC9D","XN--EFVY88H","XN--FCT429K","XN--FHBEI","XN--FIQ228C5HS","XN--FIQ64B","XN--FIQS8S","XN--FIQZ9S","XN--FJQ720A","XN--FLW351E","XN--FPCRJ9C3D","XN--FZC2C9E2C","XN--FZYS8D69UVGM","XN--G2XX48C","XN--GCKR3F0F","XN--GECRJ9C","XN--GK3AT1E","XN--H2BREG3EVE","XN--H2BRJ9C","XN--H2BRJ9C8C","XN--HXT814E","XN--I1B6B1A6A2E","XN--IMR513N","XN--IO0A7I","XN--J1AEF","XN--J1AMH","XN--J6W193G","XN--JLQ480N2RG","XN--JVR189M","XN--KCRX77D1X4A","XN--KPRW13D","XN--KPRY57D","XN--KPUT3I","XN--L1ACC","XN--LGBBAT1AD8J","XN--MGB9AWBF","XN--MGBA3A3EJT","XN--MGBA3A4F16A","XN--MGBA7C0BBN0A","XN--MGBAAM7A8H","XN--MGBAB2BD","XN--MGBAH1A3HJKRD","XN--MGBAI9AZGQP6J","XN--MGBAYH7GPA","XN--MGBBH1A","XN--MGBBH1A71E","XN--MGBC0A9AZCG","XN--MGBCA7DZDO","XN--MGBCPQ6GPA1A","XN--MGBERP4A5D4AR","XN--MGBGU82A","XN--MGBI4ECEXP","XN--MGBPL2FH","XN--MGBT3DHD","XN--MGBTX2B","XN--MGBX4CD0AB","XN--MIX891F","XN--MK1BU44C","XN--MXTQ1M","XN--NGBC5AZD","XN--NGBE9E0A","XN--NGBRX","XN--NODE","XN--NQV7F","XN--NQV7FS00EMA","XN--NYQY26A","XN--O3CW4H","XN--OGBPF8FL","XN--OTU796D","XN--P1ACF","XN--P1AI","XN--PGBS0DH","XN--PSSY2U","XN--Q7CE6A","XN--Q9JYB4C","XN--QCKA1PMC","XN--QXA6A","XN--QXAM","XN--RHQV96G","XN--ROVU88B","XN--RVC1E0AM3E","XN--S9BRJ9C","XN--SES554G","XN--T60B56A","XN--TCKWE","XN--TIQ49XQYJ","XN--UNUP4Y","XN--VERMGENSBERATER-CTB","XN--VERMGENSBERATUNG-PWB","XN--VHQUV","XN--VUQ861B","XN--W4R85EL8FHU5DNRA","XN--W4RS40L","XN--WGBH1C","XN--WGBL6A","XN--XHQ521B","XN--XKC2AL3HYE2A","XN--XKC2DL3A5EE0H","XN--Y9A3AQ","XN--YFRO4I67O","XN--YGBI2AMMX","XN--ZFR164B","XXX","XYZ","YACHTS","YAHOO","YAMAXUN","YANDEX","YE","YODOBASHI","YOGA","YOKOHAMA","YOU","YOUTUBE","YT","YUN","ZA","ZAPPOS","ZARA","ZERO","ZIP","ZM","ZONE","ZUERICH","ZW"]};e.exports=new Set(t.tlds.map((e=>e.toLowerCase())))},(e,t,r)=>{const s=r(27),n=r(115),a={};a.Map=class extends Map{slice(){return new a.Map(this)}},e.exports=n.extend({type:"symbol",terms:{map:{init:new a.Map}},coerce:{method(e,{schema:t,error:r}){const s=t.$_terms.map.get(e);return s&&(e=s),t._flags.only&&"symbol"!=typeof e?{value:e,errors:r("symbol.map",{map:t.$_terms.map})}:{value:e}}},validate(e,{error:t}){if("symbol"!=typeof e)return{value:e,errors:t("symbol.base")}},rules:{map:{method(e){e&&!e[Symbol.iterator]&&"object"==typeof e&&(e=Object.entries(e)),s(e&&e[Symbol.iterator],"Iterable must be an iterable or object");const t=this.clone(),r=[];for(const n of e){s(n&&n[Symbol.iterator],"Entry must be an iterable");const[e,a]=n;s("object"!=typeof e&&"function"!=typeof e&&"symbol"!=typeof e,"Key must not be of type object, function, or Symbol"),s("symbol"==typeof a,"Value must be a Symbol"),t.$_terms.map.set(e,a),r.push(a)}return t.valid(...r)}}},manifest:{build:(e,t)=>(t.map&&(e=e.map(t.map)),e)},messages:{"symbol.base":"{{#label}} must be a symbol","symbol.map":"{{#label}} must be one of {{#map}}"}})},(e,t,r)=>{var s=r(14).Buffer;const n=r(27),a=r(115),i=r(100);e.exports=a.extend({type:"binary",coerce:{from:["string","object"],method(e,{schema:t}){if("string"==typeof e||null!==e&&"Buffer"===e.type)try{return{value:s.from(e,t._flags.encoding)}}catch(e){}}},validate(e,{error:t}){if(!s.isBuffer(e))return{value:e,errors:t("binary.base")}},rules:{encoding:{method(e){return n(s.isEncoding(e),"Invalid encoding:",e),this.$_setFlag("encoding",e)}},length:{method(e){return this.$_addRule({name:"length",method:"length",args:{limit:e},operator:"="})},validate:(e,t,{limit:r},{name:s,operator:n,args:a})=>i.compare(e.length,r,n)?e:t.error("binary."+s,{limit:a.limit,value:e}),args:[{name:"limit",ref:!0,assert:i.limit,message:"must be a positive integer"}]},max:{method(e){return this.$_addRule({name:"max",method:"length",args:{limit:e},operator:"<="})}},min:{method(e){return this.$_addRule({name:"min",method:"length",args:{limit:e},operator:">="})}}},cast:{string:{from:e=>s.isBuffer(e),to:(e,t)=>e.toString()}},messages:{"binary.base":"{{#label}} must be a buffer or a string","binary.length":"{{#label}} must be {{#limit}} bytes","binary.max":"{{#label}} must be less than or equal to {{#limit}} bytes","binary.min":"{{#label}} must be at least {{#limit}} bytes"}})},(e,t,r)=>{const{authPlugin:s}=r(139),{assetsPlugin:n}=r(144),{handlersPlugin:a}=r(145),{htmlPlugin:i}=r(147),{routesPlugin:o}=r(150),{storagePlugin:l}=r(230),c=[s,n,a,i,o,l];e.exports=c},(e,t,r)=>{r.r(t),r.d(t,{authPlugin:()=>g});var s=r(88),n=r(2),a=r.n(n),i=r(87),o=r.n(i),l=r(140),c=r.n(l),u=r(141),p=r.n(u),h=r(5),d=r.n(h),f=r(142),m=r(143);const g={register:async e=>{e.auth.scheme("extension-secret",(()=>({authenticate:(e,t)=>{const r=e.headers["x-api-key"];return e.storage.getApiKey().then((e=>{if(r&&r===(e=>o().createHmac("sha256",`${e} + ${d()("AUTH0_CLIENT_SECRET")}`).update(d()("EXTENSION_SECRET")).digest("hex"))(e))return t.authenticated({credentials:{user:"rule"}});throw a().unauthorized("Invalid API Key")}))}}))),e.auth.strategy("extension-secret","extension-secret");const t={dashboardAdmin:{key:d()("EXTENSION_SECRET"),verifyOptions:{audience:"urn:api-authz",issuer:d()("PUBLIC_WT_URL"),algorithms:["HS256"]}},resourceServer:{key:c().hapiJwt2Key({cache:!0,rateLimit:!0,jwksRequestsPerMinute:2,jwksUri:`https://${d()("AUTH0_DOMAIN")}/.well-known/jwks.json`}),verifyOptions:{audience:"urn:auth0-authz-api",issuer:`https://${d()("AUTH0_DOMAIN")}/`,algorithms:["RS256"]}}};e.auth.strategy("jwt","jwt",{complete:!0,verify:async(e,r)=>{try{if(!e)return{isValid:!1};const n=r.headers.authorization;if(!n||0===!n.indexOf("Bearer "))return{isValid:!1};const a=n.split(" ")[1],i=e&&e.payload&&e.payload.iss===`https://${d()("AUTH0_DOMAIN")}/`,o=e&&e.payload&&e.payload.iss===d()("PUBLIC_WT_URL"),l=(0,s.promisify)(t.resourceServer.key),c=(0,s.promisify)(p().verify);if(i){if(e.payload.gty&&"client-credentials"!==e.payload.gty)return{isValid:!1};if(!e.payload.sub.endsWith("@clients"))return{isValid:!1};const r=await l(e);return r?(await c(a,r,t.resourceServer.verifyOptions),e.payload.scope&&"string"==typeof e.payload.scope&&(e.payload.scope=e.payload.scope.split(" ")),{credentials:e.payload,isValid:!0}):{isValid:!1}}if(o)return e.payload.access_token&&e.payload.access_token.length?(await c(a,t.dashboardAdmin.key,t.dashboardAdmin.verifyOptions),e.payload.scope=f.scopes.map((e=>e.value)),{credentials:e.payload,isValid:!0}):{isValid:!1}}catch(e){return{isValid:!1}}}}),e.auth.default("jwt");const r={plugin:m.plugin,options:{stateKey:"authz-state",nonceKey:"authz-nonce",sessionStorageKey:"authz:apiToken",rta:d()("AUTH0_RTA").replace("https://",""),domain:d()("AUTH0_DOMAIN"),scopes:"read:resource_servers create:resource_servers update:resource_servers delete:resource_servers read:clients read:connections read:rules create:rules update:rules update:rules_configs read:users read:configuration",baseUrl:d()("PUBLIC_WT_URL"),audience:"urn:api-authz",secret:d()("EXTENSION_SECRET"),clientName:"Authorization Extension",onLoginSuccess:(e,t)=>{if(e)return e.scope=f.scopes.map((e=>e.value)),e;throw a().unauthorized("Invalid token","Token")}}};e.register(r)},name:"auth"}},e=>{e.exports=require("[email protected]")},e=>{e.exports=require("[email protected]")},(e,t,r)=>{r.r(t),r.d(t,{createApi:()=>h,deleteApi:()=>f,getApi:()=>p,scopes:()=>m,updateApi:()=>d});var s=r(3),n=r.n(s),a=r(4),i=r(5),o=r.n(i);const l="urn:auth0-authz-api",c=[{value:"read:users"},{value:"read:applications"},{value:"read:connections"},{value:"read:configuration"},{value:"update:configuration"},{value:"read:groups"},{value:"create:groups"},{value:"update:groups"},{value:"delete:groups"},{value:"read:roles"},{value:"create:roles"},{value:"update:roles"},{value:"delete:roles"},{value:"read:permissions"},{value:"create:permissions"},{value:"update:permissions"},{value:"delete:permissions"},{value:"read:resource-server"},{value:"create:resource-server"},{value:"update:resource-server"},{value:"delete:resource-server"}],u=(e,t,r,s)=>new Promise(((i,l)=>(e=>e.auth&&e.auth.credentials&&e.auth.credentials.access_token&&e.auth.credentials.access_token.length?Promise.resolve(e.auth.credentials.access_token):a.managementApi.getAccessTokenCached(o()("AUTH0_DOMAIN"),o()("AUTH0_CLIENT_ID"),o()("AUTH0_CLIENT_SECRET")))(e).then((e=>{n()(r,`https://${o()("AUTH0_DOMAIN")}/api/v2/${t}`).send(s||{}).set("Content-Type","application/json").set("Authorization",`Bearer ${e}`).end(((e,t)=>e?l(e):i(t.body)))})))),p=e=>u(e,`resource-servers/${l}`,"GET").catch((()=>({}))),h=(e,t)=>u(e,"resource-servers","POST",{name:"auth0-authorization-extension-api",identifier:l,signing_alg:"RS256",scopes:c,token_lifetime:t}),d=(e,t)=>p(e).then((r=>r.id?u(e,`resource-servers/${r.id}`,"PATCH",{token_lifetime:t||86400}):h(e,t||86400))),f=(e,t)=>p(e).then((r=>r.id?u(e,`resource-servers/${r.id}`,"DELETE"):r.id||t?Promise.resolve():Promise.reject(new Error("Unable to disable resource-server. Is it enabled?")))),m=c},(e,t,r)=>{r.r(t),r.d(t,{plugin:()=>m});const{promisify:s}=r(88),n=r(2),a=r(19),i=r(87),o=r(141),l=r(4),c=r(140),{getBasePath:u,getBaseUrl:p}=r(8),h=r(5),d=function(e){return a.join.apply(null,e).replace(/\\/g,"/").replace("http:/","http://").replace("https:/","https://")},f=function(e,t){return Array.isArray(e)?-1===e.indexOf(t):e!==t},m={register:async function(e,t){if(!t||"object"!=typeof t)return new l.ArgumentError("Must provide the options");if(null===t.onLoginSuccess||void 0===t.onLoginSuccess)return new l.ArgumentError("Must provide a valid login callback");if(null===t.secret||void 0===t.secret)return new l.ArgumentError("Must provide a valid secret");if("string"!=typeof t.secret||0===t.secret.length)return new l.ArgumentError("The provided secret is invalid: "+t.secret);if(null===t.audience||void 0===t.audience)return new l.ArgumentError("Must provide a valid audience");if("string"!=typeof t.audience||0===t.audience.length)return new l.ArgumentError("The provided audience is invalid: "+t.audience);if(null===t.rta||void 0===t.rta)return new l.ArgumentError("Must provide a valid rta");if("string"!=typeof t.rta||0===t.rta.length)return new l.ArgumentError("The provided rta is invalid: "+t.rta);if(null===t.domain||void 0===t.domain)return new l.ArgumentError("Must provide a valid domain");if("string"!=typeof t.domain||0===t.domain.length)return new l.ArgumentError("The provided domain is invalid: "+t.domain);if(null===t.baseUrl||void 0===t.baseUrl)return new l.ArgumentError("Must provide a valid base URL");if("string"!=typeof t.baseUrl||0===t.baseUrl.length)return new l.ArgumentError("The provided base URL is invalid: "+t.baseUrl);if(null===t.clientName||void 0===t.clientName)return new l.ArgumentError("Must provide a valid client name");if("string"!=typeof t.clientName||0===t.clientName.length)return new l.ArgumentError("The provided client name is invalid: "+t.clientName);const r=t.stateKey||"state",a=t.nonceKey||"nonce",m=t.urlPrefix||"",g=t.sessionStorageKey||"apiToken",y=t.sessionManager||new l.SessionManager(t.rta,t.domain,t.baseUrl),b={isHttpOnly:!0};e.state(a,Object.assign({},b,{isSameSite:"None",isSecure:!0})),e.state(r,Object.assign({},b,{isSameSite:"None",isSecure:!0})),e.state(a+"_compat",b),e.state(r+"_compat",b),e.route({method:"GET",path:m+"/login",options:{auth:!1},handler:function(e,s){const n=i.randomBytes(16).toString("hex"),o=i.randomBytes(16).toString("hex"),l=y.createAuthorizeUrl({redirectUri:d([p(e),m,"/login/callback"]),scopes:t.scopes,expiration:t.expiration,nonce:o,state:n});return s.redirect(l).state(a,o,{path:u(e)}).state(r,n,{path:u(e)}).state(a+"_compat",o,{path:u(e)}).state(r+"_compat",n,{path:u(e)})}}),e.route({method:"POST",path:m+"/login/callback",options:{auth:!1},handler:async function(i,l){var m;const b=s(o.verify),v=i.payload.id_token;try{m=o.decode(v,{complete:!0});const e=c.hapiJwt2Key({cache:!0,rateLimit:!0,jwksRequestsPerMinute:2,jwksUri:`${h("AUTH0_RTA")}/.well-known/jwks.json`}),t=s(e),r=await t(m);if(!r)return n.unauthorized("Invalid token");const a={audience:h("PUBLIC_WT_URL"),issuer:`${h("AUTH0_RTA")}/`,algorithms:["RS256"]};await b(v,r,a)}catch(e){m=null}if(!m)return n.unauthorized("Invalid token");if(i.state&&i.state[a]&&f(i.state[a],m.payload.nonce)||i.state&&i.state[a+"_compat"]&&f(i.state[a+"_compat"],m.payload.nonce))return n.badRequest("Nonce mismatch");if(i.state&&i.state[r]&&f(i.state[r],i.payload.state)||i.state&&i.state[r+"_compat"]&&f(i.state[r+"_compat"],i.payload.state))return n.badRequest("State mismatch");let _;try{_=await y.create(i.payload.id_token,i.payload.access_token,{secret:t.secret,issuer:t.baseUrl,audience:t.audience})}catch(t){return e.log(["error"],"Login callback failed",t),n.boomify(t)}return l.response('<html><head><script type="text/javascript">sessionStorage.setItem("'+g+'", "'+_+'");window.location.href = "'+d([p(i),"/"])+'";<\/script></head></html>').unstate(a,{path:u(i)}).unstate(r,{path:u(i)}).unstate(a+"_compat",{path:u(i)}).unstate(r+"_compat",{path:u(i)})}}),e.route({method:"GET",path:m+"/logout",options:{auth:!1},handler:function(e,s){const n=encodeURIComponent(d([p(e),"/"]));return s.response('<html><head><script type="text/javascript">sessionStorage.removeItem("'+g+'");window.location.href = "https://'+t.rta+"/v2/logout/?returnTo="+n+"&client_id="+n+'";<\/script></head></html>').unstate(a,{path:u(e)}).unstate(r,{path:u(e)}).unstate(a+"_compat",{path:u(e)}).unstate(r+"_compat",{path:u(e)})}}),e.route({method:"GET",path:"/.well-known/oauth2-client-configuration",options:{auth:!1},handler:function(e,r){return r.response({redirect_uris:[d([p(e),m,"/login/callback"])],client_name:t.clientName,post_logout_redirect_uris:[d([p(e),"/"])]})}}),e.auth.strategy("auth0-admins-jwt","jwt",{key:t.secret,validate:t.onLoginSuccess,verifyOptions:{audience:t.audience,issuer:t.baseUrl,algorithms:["HS256"]}})},name:"dashboard-admin-session"}},(e,t,r)=>{r.r(t),r.d(t,{assetsPlugin:()=>i,register:()=>a});var s=r(19),n=r.n(s);const a=async e=>{e.route({method:"GET",path:"/app/{param*}",options:{auth:!1},handler:{directory:{path:n().join(__dirname,"../../dist"),redirectToSlash:!0}}})},i={register:a,name:"assets"}},(e,t,r)=>{r.r(t),r.d(t,{handlersPlugin:()=>h});var s=r(4),n=r(2),a=r.n(n),i=r(5),o=r.n(i),l=r(6),c=r.n(l),u=r(146);const p=(e,t,r)=>{if(null==e)throw new s.ArgumentError("Must provide the domain");if("string"!=typeof e||0===e.length)throw new s.ArgumentError(`The provided domain is invalid: ${e}`);if(null==t)throw new s.ArgumentError("Must provide the webtaskUrl");if("string"!=typeof t||0===t.length)throw new s.ArgumentError(`The provided webtaskUrl is invalid: ${t}`);if(null==r)throw new s.ArgumentError("Must provide the extensionSecret");if("string"!=typeof r||0===r.length)throw new s.ArgumentError(`The provided extensionSecret is invalid: ${r}`);return n=>{if(null==n)throw new s.ArgumentError("Must provide the hookPath");if("string"!=typeof n||0===n.length)throw new s.ArgumentError(`The provided hookPath is invalid: ${n}`);return{method(i,o){if(i.headers.authorization&&"Bearer"===i.headers.authorization.split(" ")[0]){const l=i.headers.authorization.split(" ")[1];try{if(c().info(`Validating hook token with signature: ${r.substring(0,4)}...`),s.validateHookToken(e,t,n,r,l))return o.continue}catch(e){throw c().error("Invalid token:",l),a()(e,{statusCode:401,message:e.message})}}const l=new s.HookTokenError(`Hook token missing for the call to: ${n}`);throw a().unauthorized(l,401,l.message)}}}},h={register:async e=>{e.decorate("server","handlers",{managementClient:(0,u.default)({domain:o()("AUTH0_DOMAIN"),clientId:o()("AUTH0_CLIENT_ID"),clientSecret:o()("AUTH0_CLIENT_SECRET"),logger:c().error}),validateHookToken:p(o()("AUTH0_DOMAIN"),o()("WT_URL"),o()("EXTENSION_SECRET"))})},name:"handlers"}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});const s=r(4);function n(e){if(!e||"object"!=typeof e)throw new s.ArgumentError("Must provide the options");if("string"!=typeof e.domain||0===e.domain.length)throw new s.ArgumentError("The provided domain is invalid: "+e.domain);return{method:async function(t,r){const n=t.auth&&t.auth.credentials&&t.auth.credentials.access_token&&t.auth.credentials.access_token.length?{domain:e.domain,accessToken:t.auth.credentials.access_token}:e;return await s.managementApi.getClient(n)},assign:"auth0"}}},(e,t,r)=>{r.r(t),r.d(t,{htmlPlugin:()=>b,register:()=>y});var s=r(93),n=r.n(s),a=r(88),i=r(148),o=r.n(i),l=r(19),c=r.n(l),u=r(8),p=r(5),h=r.n(p),d=r(149),f=r.n(d);const m=(0,a.promisify)(n().readFile),g=["/","/api","/configuration","/configuration/rule","/configuration/api","/roles","/roles/{id}","/groups","/groups/{id}","/permissions","/permissions/{id}","/users","/users/{id}","/import-export"],y=async e=>{g.map((t=>e.route((e=>({method:"GET",path:e,options:{description:"Render HTML",auth:!1},handler:async(e,t)=>{const r={AUTH0_DOMAIN:h()("AUTH0_DOMAIN"),AUTH0_CLIENT_ID:h()("AUTH0_CLIENT_ID"),BASE_URL:(0,u.getBaseUrl)(e),API_BASE:(0,u.getBaseUrl)(e),BASE_PATH:(0,u.getBasePath)(e),EXTENSION_VERSION:"2.13.0",SEARCH_ENGINE:"auth0.auth0.com"===h()("AUTH0_RTA").replace("https://","")||h()("IS_LAYER0_TEST_SPACE")?"v3":"v2"},s=h()("CLIENT_VERSION");if(s)return t.response(o().render(f(),{config:r,assets:{version:s}}));const n=await m(c().join(__dirname,"../../dist/manifest.json"),"utf8"),a={config:r,assets:{app:"/app/bundle.js"}};return n&&(a.assets=JSON.parse(n),a.assets.app&&(a.assets.app=`/app/${a.assets.app}`),a.assets.vendors&&(a.assets.vendors=`/app/${a.assets.vendors}`),a.assets.style&&(a.assets.style=`/app/${a.assets.style}`)),t.response(o().render(f(),a))}}))(t))))},b={register:y,name:"html"}},e=>{e.exports=require("[email protected]")},e=>{e.exports='<!DOCTYPE html>\n<html lang="en">\n<head>\n <title>Auth0 - Authorization</title>\n <meta charset="UTF-8" />\n <meta http-equiv="X-UA-Compatible" content="IE=Edge" />\n <meta name="viewport" content="width=device-width, initial-scale=1.0" />\n <link rel="shortcut icon" href="https://cdn.auth0.com/styleguide/4.8.10/lib/logos/img/favicon.png">\n <meta name="viewport" content="width=device-width, initial-scale=1">\n <link rel="stylesheet" type="text/css" href="https://cdn.auth0.com/styles/zocial.min.css">\n <link rel="stylesheet" type="text/css" href="https://cdn.auth0.com/styleguide/4.8.10/index.min.css" />\n <link rel="stylesheet" type="text/css" href="https://cdn.auth0.com/manage/v0.3.1672/css/index.min.css">\n <% if (assets.style) { %><link rel="stylesheet" type="text/css" href="<%= assets.style %>"><% } %>\n <% if (assets.version) { %><link rel="stylesheet" type="text/css" href="//cdn.auth0.com/extensions/auth0-authz/assets/auth0-authz.ui.<%= assets.version %>.css"><% } %>\n</head>\n<body>\n <div id="app"></div>\n <script type="text/javascript" src="//cdn.auth0.com/manage/v0.3.1672/js/bundle.js"><\/script>\n <script type="text/javascript">window.config = <%- JSON.stringify(config) %>;<\/script>\n <% if (assets.vendors) { %><script type="text/javascript" src="<%= assets.vendors %>"><\/script><% } %>\n <% if (assets.app) { %><script type="text/javascript" src="<%= assets.app %>"><\/script><% } %>\n <% if (assets.version) { %>\n <script type="text/javascript" src="//cdn.auth0.com/extensions/auth0-authz/assets/auth0-authz.ui.vendors.<%= assets.version %>.js"><\/script>\n <script type="text/javascript" src="//cdn.auth0.com/extensions/auth0-authz/assets/auth0-authz.ui.<%= assets.version %>.js"><\/script>\n <% } %>\n</body>\n</html>'},(e,t,r)=>{r.r(t),r.d(t,{routesPlugin:()=>o});var s=r(13),n=r.n(s),a=r(5),i=r.n(a);const o={register:e=>{[r(151).default(e),r(159).default(e),r(160).default(e),r(161).default(e),r(162).default(e),r(163).default(e),r(164).default(e),r(167).default(e),r(171).default(e),r(172).default(e),r(173).default(e),r(174).default(e),r(175).default(e),r(176).default(e),r(177).default(e),r(178).default(e),r(179).default(e),r(180).default(e),r(181).default(e),r(182).default(e),r(184).default(e),r(185).default(e),r(186).default(e),r(187).default(e),r(188).default(e),r(190).default(e),r(191).default(e),r(192).default(e),r(193).default(e),r(194).default(e),r(196).default(e),r(197).default(e),r(198).default(e),r(199).default(e),r(200).default(e),r(201).default(e),r(203).default(e),r(204).default(e),r(205).default(e),r(206).default(e),r(208).default(e),r(212).default(e),r(214).default(e),r(217).default(e),r(218).default(e),r(219).default(e),r(221).default(e),r(222).default(e),r(223).default(e),r(224).default(e),r(225).default(e),r(226).default(e),r(227).default(e),r(228).default(e),r(229).default(e)].forEach((t=>{const r=n().set(t,"options.validate.failAction",(async(e,t,r)=>r));e.route(r)})),e.route({method:"GET",path:"/admins/login",options:{auth:!1},handler:(e,t)=>t.response("Redirecting to login page...").redirect(`${i()("PUBLIC_WT_URL")}/login`)})},name:"routes"}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var s=r(98),n=r.n(s),a=r(2),i=r.n(a),o=r(152),l=r(153);const c=()=>({method:"POST",path:"/api/users/{userId}/policy/{clientId}",options:{auth:{strategies:["jwt","extension-secret"]},description:"Execute the authorization policy for a user in the context of a client. This will return the user's groups but also roles and permissions that apply to the current client.",tags:["api"],validate:{params:n().object({userId:n().string().required(),clientId:n().string().required()}),payload:o.default}},handler:async(e,t)=>{const{userId:r,clientId:s}=e.params,{connectionName:n,groups:a}=e.payload;if(e.storage.provider&&e.storage.provider.storageContext&&e.storage.provider.storageContext.read){const i=await(0,l.getUserData)(e.storage,r,s,n,a);return t.response(i)}throw i().badRequest("Storage error")}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=n().object().keys({connectionName:n().string().required(),groups:n().array().items(n().string())})},(e,t,r)=>{r.r(t),r.d(t,{getChildGroups:()=>A,getConnectionsCached:()=>y,getDynamicUserGroups:()=>T,getGroupExpanded:()=>N,getGroupsCached:()=>_,getGroupsExpanded:()=>k,getMappingsWithNames:()=>w,getMembers:()=>O,getParentGroups:()=>E,getPermissionsByRoles:()=>x,getPermissionsCached:()=>b,getPermissionsForRoles:()=>$,getRolesCached:()=>v,getRolesForGroups:()=>R,getRolesForUser:()=>S,getUserData:()=>j,getUserGroups:()=>C});var s=r(88),n=r(13),a=r.n(n),i=r(154),o=r.n(i),l=r(155),c=r.n(l),u=r(2),p=r.n(u),h=r(156),d=r(5),f=r.n(d);const m=e=>(...t)=>new Promise(((r,s)=>{setImmediate((()=>{try{r(e(...t))}catch(e){s(e)}}))})),g=e=>({_id:e._id,name:e.name,description:e.description}),y=c()({load:(e,t)=>{(0,h.default)(e,"connections",{fields:"id,name,strategy"}).then((e=>a().chain(e).sortBy((e=>e.name.toLowerCase())).value())).then((e=>t(null,e))).catch((e=>t(e)))},hash:e=>e.hash||"connections",max:100,maxAge:o().get("DATA_CACHE_MAX_AGE"),disable:f()("IS_LAYER0_TEST_SPACE")}),b=c()({load:(e,t)=>{e.getPermissions().then((e=>{t(null,e)})).catch((e=>t(e)))},hash:e=>e.hash||"permissions",max:100,maxAge:o().get("DATA_CACHE_MAX_AGE"),disable:f()("IS_LAYER0_TEST_SPACE")}),v=c()({load:(e,t)=>{e.getRoles().then((e=>{t(null,e)})).catch((e=>t(e)))},hash:e=>e.hash||"roles",max:100,maxAge:o().get("DATA_CACHE_MAX_AGE"),disable:f()("IS_LAYER0_TEST_SPACE")}),_=c()({load:(e,t)=>{e.getGroups().then((e=>{t(null,e)})).catch((e=>t(e)))},hash:e=>e.hash||"groups",max:100,maxAge:o().get("DATA_CACHE_MAX_AGE"),disable:f()("IS_LAYER0_TEST_SPACE")}),w=(e,t)=>new Promise(((r,s)=>{y(e,((e,n)=>{if(e)return s(e);const i=[];return t.forEach((e=>{const t=a().find(n,{name:e.connectionName});if(t){const r=e;r.connectionName=`${t.name} (${t.strategy})`,i.push(r)}})),r(i)}))})),A=(e,t)=>{const r=[],s=t=>{if(-1===r.indexOf(t)){r.push(t);const n=a().find(e,{_id:t});n&&n.nested&&a().forEach(n.nested,(e=>{s(e)}))}};return t.forEach((e=>s(e._id))),a().filter(e,(e=>r.indexOf(e._id)>-1))},E=(e,t)=>{const r=[],s=t=>{if(-1===r.indexOf(t)){r.push(t);a().filter(e,(e=>a().includes(e.nested||[],t))).forEach((e=>s(e._id)))}};return t.forEach((e=>s(e._id))),a().filter(e,(e=>r.indexOf(e._id)>-1))},R=(e,t)=>{const r=[],s={};return e.forEach((e=>{e.roles&&e.roles.forEach((t=>{s[t]||(s[t]=e)}))})),t.forEach((e=>{s[e._id]&&r.push({role:e,group:s[e._id]})})),r},S=async(e,t)=>{const r=await e.getGroups(),s=a().filter(r,(e=>a().includes(e.members,t))),n=E(r,s).filter((e=>e.roles&&e.roles.length)).map((e=>e.roles)),i=a().uniq(a().flattenDeep(n)),o=await e.getRoles(),l=a().filter(o,(e=>a().includes(i,e._id))),c=a().filter(o,(e=>e.users&&a().includes(e.users,t)));return a().uniq([...l,...c],"_id")},$=(e,t)=>e.getPermissions().then((e=>{const r=a().flattenDeep(a().map(t,(e=>e.permissions)));return e.filter((e=>a().includes(r,e._id)))})),x=(e,t)=>new Promise(((r,s)=>{b(e,((e,n)=>{if(e)return s(e);const i=[];return a().forEach(t,(e=>{const t=n.filter((t=>a().includes(e.permissions,t._id)));i.push({...e,permissions:a().map(t,(e=>({_id:e._id,name:e.name,description:e.description})))})})),r(i)}))})),O=e=>{const t={};return e.forEach((e=>{e.members&&e.members.forEach((r=>{t[r]||(t[r]=e)}))})),Object.keys(t).map((e=>({userId:e,group:t[e]})))},I=(e,t,r)=>e&&a().filter(e,(e=>((e,t,r)=>e.connectionName===t&&r.indexOf(e.groupName)>-1)(e,t,r))).length>0;function T(e,t,r,s){return new Promise(((n,i)=>{if(!t)return n([]);if(!r||0===r.length)return n([]);return o=(e,s)=>{if(e)return i(e);const o=a().filter(s,(e=>I(e.mappings,t,r)));return n(o)},s&&s.length?o(null,s):_(e,o);var o}))}function C(e,t,r,s){return Array.isArray(s)&&null!=s||(s=[]),new Promise(((n,i)=>{_(e,((o,l)=>{if(o)return i(o);const c=a().filter(l,(e=>a().includes(e.members,t)));return T(e,r,[...s,...c.map((e=>e.name))],l).then((e=>{const t=E(l,a().union(c,e));return n(t)})).catch(i)}))}))}async function N(e,t){const r=(0,s.promisify)(_),n=(0,s.promisify)(v),i=await r(e);if(!i||0===i.length)throw p().badRequest("No groups found");const o=await n(e),l=a().find(i,{_id:t});if(!l)throw p().badRequest("Current group not found");const c=E(i,[l]).filter((e=>e._id!==l._id)),u=R([l,...c],o).map((e=>e.role)),h=await x(e,u);return{_id:l._id,name:l.name,description:l.description,roles:h.map((e=>({_id:e._id,name:e.name,description:e.description,applicationId:e.applicationId,applicationType:e.applicationType,permissions:e.permissions&&e.permissions.map(g)})))}}function k(e,t){return new Promise(((r,s)=>{_(e,((n,a)=>n?s(n):v(e,((n,i)=>{if(n)return s(n);const o=E(a,t),l=R(o,i).map((e=>e.role)),c=e=>({_id:e._id,name:e.name,description:e.description,applicationId:e.applicationId,applicationType:e.applicationType,permissions:e.permissions&&e.permissions.map(g)});return x(e,l).then((e=>r({groups:o.map(g),roles:e.map(c)})))}))))}))}function j(e,t,r,s,n){const i={groups:[],roles:[]};return e.provider.storageContext.read().then((o=>{const{groups:l=[],roles:c=[],permissions:u=[]}=o,p=a().filter(l,(e=>a().includes(e.members,t)));return Array.isArray(n)||(n=[]),m(T)(e,s,[...n,...p.map((e=>e.name))],l).then(m((e=>{const t=E(l,a().union(p,e));return i.groups=a().uniq(t.map((e=>e.name))),t}))).then(m((e=>{const s=[...R(e,c).map((e=>e.role)),...c.filter((e=>e.users&&e.users.indexOf(t)>-1))].filter((e=>e.applicationId===r));return i.roles=a().uniq(s.map((e=>e.name))),s}))).then(m((e=>{const t=a().flattenDeep(a().map(e,(e=>e.permissions))),r=u.filter((e=>a().includes(t,e._id)));return i.permissions=a().uniq(r.map((e=>e.name))),i})))}))}},e=>{e.exports=require("[email protected]")},e=>{e.exports=require("[email protected]")},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(4),n=r(157),a=r(158);async function i(e,t,r={},i=100,o=3){if(null==e)throw new s.ArgumentError("Must provide a auth0 client object.");if(!t&&!e[t])throw new s.ArgumentError("Must provide a valid entity for auth0 client.");const l=e[t].getAll,c=Object.assign({},r,{per_page:i}),u=[];let p=0,h=0;const d=async r=>{const s=await(0,a.default)(e[t],l,[Object.assign({},c,{page:r})]);return console.log({function:"getPage",data:JSON.stringify(s),page:JSON.stringify(r)}),s.forEach((e=>u.push(e))),null};return(async()=>{if(await(async()=>{const r=await(0,a.default)(e[t],l,[Object.assign({},c,{include_totals:!0,page:0})]);return console.log({function:"getTotals",response:JSON.stringify(r)}),p=r.total||0,h=Math.ceil(p/i),(r[t]||r||[]).forEach((e=>u.push(e))),null})(),0===p||u.length>=p)return u;const r=[];for(let e=1;e<=h;e++)r.push(e);const s=await(0,n.promiseMap)(r,d,{concurrency:o});return console.log({function:"getAll",getAllResult:JSON.stringify(s),pages:JSON.stringify(r)}),s})()}},(e,t,r)=>{r.r(t),r.d(t,{promiseEach:()=>s,promiseMap:()=>n});const s=async(e,t)=>{for(const r of e)await t(r)},n=async(e,t)=>{const r=[];for(const s of e)await t(s),r.push(s);return r}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});const s=(e,t,r,s=2)=>{let n=s;const a=()=>t.apply(e,r).then((e=>Promise.resolve(e))).catch((e=>{const t=e.originalError||{},r=t.response&&t.response.header&&t.response.header["x-ratelimit-reset"]||0,s=Math.round((new Date).getTime()/1e3);let i=parseInt(r,10)-s;return 429===t.status&&n>0&&r&&i<=10?(n--,i<=0&&(i=1),(e=>new Promise((t=>setTimeout((()=>t()),1e3*e))))(i).then(a)):Promise.reject(e)}));return a()}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=e=>({method:"GET",path:"/api/applications/{clientId}",options:{auth:{strategies:["jwt"],scope:["read:applications"]},description:"Get a single application based on its Client ID.",validate:{params:n().object({clientId:n().string().required()})},pre:[e.handlers.managementClient]},handler:async(e,t)=>{const r=await e.pre.auth0.clients.get({client_id:e.params.clientId});return t.response(r)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(13),n=r.n(s),a=r(156);const i=e=>({method:"GET",path:"/api/applications",options:{auth:{strategies:["jwt"],scope:["read:applications"]},pre:[e.handlers.managementClient]},handler:async(e,t)=>{const r=await(0,a.default)(e.pre.auth0,"clients",{is_global:!1,fields:"client_id,name,callbacks,app_type"});console.log({clientsLength:r.length});const s=n().chain(r).filter((e=>"spa"===e.app_type||"native"===e.app_type||"regular_web"===e.app_type)).sortBy((e=>e.name.toLowerCase())).value();return t.response(s)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(13),n=r.n(s),a=r(156);const i=e=>({method:"GET",path:"/api/configuration/status",options:{auth:{strategies:["jwt"],scope:["read:configuration"]},pre:[e.handlers.managementClient]},handler:async(e,t)=>{const r=await(0,a.default)(e.pre.auth0,"rules",{fields:"name,enabled"}),s=n().find(r,{name:"auth0-authorization-extension"}),i={exists:!!s,enabled:!!s&&s.enabled};try{const r=await e.storage.getStatus();return t.response({rule:i,database:r})}catch(e){return t.response({rule:i,database:{size:0,type:"unknown"}})}}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});const s=()=>({method:"GET",path:"/api/configuration",options:{auth:{strategies:["jwt"],scope:["read:configuration"]}},handler:async(e,t)=>{const r=await e.storage.getConfiguration();return t.response(r)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});const s=()=>({method:"GET",path:"/api/configuration/export",options:{auth:{strategies:["jwt"],scope:["read:configuration"]}},handler:async(e,t)=>{if(!e.storage.provider||!e.storage.provider.storageContext||"function"!=typeof e.storage.provider.storageContext.read)throw new Error('Unable to use "export" without proper storage');const r=await e.storage.provider.storageContext.read();return t.response(r)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(88),n=r(165);const a=()=>({method:"POST",path:"/api/configuration/import",options:{auth:{strategies:["jwt"],scope:["update:configuration"]},validate:{payload:n.default}},handler:async(e,t)=>{if(!e.storage.provider||!e.storage.provider.storageContext||"function"!=typeof e.storage.provider.storageContext.write)throw new Error('Unable to use "import" without proper storage');if(e.storage.provider.storageContext.storage&&e.storage.provider.storageContext.storage.set){const r=(0,s.promisify)(e.storage.provider.storageContext.storage.set);return await r(e.payload,{force:!0}),t.response().code(204)}return await e.storage.provider.storageContext.write(e.payload),t.response().code(204)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(98),n=r.n(s),a=r(166);const i=n().object().keys({configuration:n().array().items((o=a.default,o.keys({_id:n().string().required()}))),groups:n().array().items(n().object()),roles:n().array().items(n().object()),permissions:n().array().items(n().object()),applications:n().array().items(n().object()),rules:n().array().items(n().object())});var o},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(98),n=r.n(s);const a=n().boolean().truthy("yes").falsy("no"),i=n().object().keys({groupsInToken:a,rolesInToken:a,permissionsInToken:a,persistGroups:a,persistRoles:a,persistPermissions:a,groupsPassthrough:a,rolesPassthrough:a,permissionsPassthrough:a})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var s=r(13),n=r.n(s),a=r(166),i=r(168),o=r(156);const l=e=>({method:"PATCH",path:"/api/configuration",options:{auth:{strategies:["jwt"],scope:["update:configuration"]},pre:[e.handlers.managementClient],validate:{options:{allowUnknown:!1},payload:a.default}},handler:async(e,t)=>{const r=e.payload,s=await(0,i.default)(e.storage,e.pre.auth0,r,e.auth.credentials.email||"unknown"),a=await(0,o.default)(e.pre.auth0,"rules",{fields:"name,id"}),l={name:"auth0-authorization-extension",enabled:!0,script:s},c=n().find(a,{name:l.name});c?await e.pre.auth0.rules.update({id:c.id},l):await e.pre.auth0.rules.create({stage:"login_success",...l});const u=await e.storage.updateConfiguration(r);return t.response(u)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var s=r(148),n=r.n(s),a=r(5),i=r.n(a),o=r(169),l=r(170),c=r.n(l);const u=(e,t,r={},s="")=>e.getApiKey().then((r=>r?null:(0,o.default)(e,t))).then((()=>n().render(c(),{extensionUrl:i()("PUBLIC_WT_URL").replace(/\/$/g,""),updateTime:()=>(new Date).toISOString(),config:r,userName:s})))},(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var s=r(87),n=r.n(s),a=r(5),i=r.n(a);const o=(e,t)=>{const r=n().randomBytes(32).toString("hex"),s=(e=>n().createHmac("sha256",`${e} + ${i()("AUTH0_CLIENT_SECRET")}`).update(i()("EXTENSION_SECRET")).digest("hex"))(r);return t.rulesConfigs.set({key:"AUTHZ_EXT_API_KEY"},{value:s}).then((()=>e.updateApiKey(r))).then((()=>s))}},e=>{e.exports="/*\n* This rule been automatically generated by auth0-authz-extension\n* Updated by <%= userName %>, <%= updateTime() %>\n */\nfunction (user, context, callback) {\n var _ = require('lodash');\n var EXTENSION_URL = \"<%= extensionUrl %>\";\n\n var audience = '';\n audience = audience || (context.request && context.request.query && context.request.query.audience);\n if (audience === 'urn:auth0-authz-api') {\n return callback(new UnauthorizedError('no_end_users'));\n }\n\n audience = audience || (context.request && context.request.body && context.request.body.audience);\n if (audience === 'urn:auth0-authz-api') {\n return callback(new UnauthorizedError('no_end_users'));\n }\n\n getPolicy(user, context, function(err, res, data) {\n if (err) {\n console.log('Error from Authorization Extension:', err);\n return callback(new UnauthorizedError('Authorization Extension: ' + err.message));\n }\n\n if (res.statusCode !== 200) {\n console.log('Error from Authorization Extension:', res.body || res.statusCode);\n return callback(\n new UnauthorizedError('Authorization Extension: ' + ((res.body && (res.body.message || res.body) || res.statusCode)))\n );\n }\n\n // Update the user object.<% if (config.groupsInToken && !config.groupsPassthrough) { %>\n user.groups = data.groups;<% } %><% if (config.groupsInToken && config.groupsPassthrough) { %>\n user.groups = mergeRecords(user.groups, data.groups);<% } %><% if (config.rolesInToken && !config.rolesPassthrough) { %>\n user.roles = data.roles;<% } %><% if (config.rolesInToken && config.rolesPassthrough) { %>\n user.roles = mergeRecords(user.roles, data.roles);<% } %><% if (config.permissionsInToken && !config.permissionsPassthrough) { %>\n user.permissions = data.permissions;<% } %><% if (config.permissionsInToken && config.permissionsPassthrough) { %>\n user.permissions = mergeRecords(user.permissions, data.permissions);<% } %>\n<% if (config.persistGroups || config.persistRoles || config.persistPermissions) { %>\n // Store this in the user profile (app_metadata).\n saveToMetadata(user, data.groups, data.roles, data.permissions, function(err) {\n return callback(err, user, context);\n });\n<% } else { %>\n return callback(null, user, context);\n<% } %> });\n \n // Convert groups to array\n function parseGroups(data) {\n if (typeof data === 'string') {\n // split groups represented as string by spaces and/or comma\n return data.replace(/,/g, ' ').replace(/\\s+/g, ' ').split(' ');\n }\n return data;\n }\n\n // Get the policy for the user.\n function getPolicy(user, context, cb) {\n request.post({\n url: EXTENSION_URL + \"/api/users/\" + user.user_id + \"/policy/\" + context.clientID,\n headers: {\n \"x-api-key\": configuration.AUTHZ_EXT_API_KEY\n },\n json: {\n connectionName: context.connection || user.identities[0].connection,\n groups: parseGroups(user.groups)\n },\n timeout: 5000\n }, cb);\n }<% if (config.persistGroups || config.persistRoles || config.persistPermissions) { %>\n\n // Store authorization data in the user profile so we can query it later.\n function saveToMetadata(user, groups, roles, permissions, cb) {\n user.app_metadata = user.app_metadata || {};\n user.app_metadata.authorization = {<% if (config.persistGroups && !config.groupsPassthrough) { %>\n groups: groups,<% } %><% if (config.persistGroups && config.groupsPassthrough) { %>\n groups: mergeRecords(user.groups, groups),<% } %><% if (config.persistRoles && !config.rolesPassthrough) { %>\n roles: roles,<% } %><% if (config.persistRoles && config.rolesPassthrough) { %>\n roles: mergeRecords(user.roles, roles),<% } %><% if (config.persistPermissions && !config.permissionsPassthrough) { %>\n permissions: permissions<% } %><% if (config.persistPermissions && config.permissionsPassthrough) { %>\n permissions: mergeRecords(user.permissions, permissions)<% } %>\n };\n\n auth0.users.updateAppMetadata(user.user_id, user.app_metadata)\n .then(function() {\n cb();\n })\n .catch(function(err){\n cb(err);\n });\n }<% } %><% if (config.groupsPassthrough || config.rolesPassthrough || config.permissionsPassthrough) { %>\n\n // Merge the IdP records with the records of the extension.\n function mergeRecords(idpRecords, extensionRecords) {\n idpRecords = idpRecords || [ ];\n extensionRecords = extensionRecords || [ ];\n\n if (!Array.isArray(idpRecords)) {\n idpRecords = idpRecords.replace(/,/g, ' ').replace(/\\s+/g, ' ').split(' ');\n }\n\n return _.uniq(_.union(idpRecords, extensionRecords));\n }<% } %>\n}"},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var s=r(169);const n=e=>({method:"PATCH",path:"/api/configuration/rotate-apikey",options:{auth:{strategies:["jwt"],scope:["update:configuration"]},pre:[e.handlers.managementClient]},handler:async(e,t)=>{const r=await(0,s.default)(e.storage,e.pre.auth0);return t.response({hash:r})}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var s=r(142);const n=()=>({method:"GET",path:"/api/configuration/resource-server",options:{auth:{strategies:["jwt"],scope:["read:resource-server"]}},handler:async(e,t)=>{const r=await(0,s.getApi)(e);return t.response({apiAccess:!!r.identifier,token_lifetime:r.token_lifetime})}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(98),n=r.n(s),a=r(142);const i=()=>({method:"PATCH",path:"/api/configuration/resource-server",options:{auth:{strategies:["jwt"],scope:["update:resource-server"]},validate:{payload:n().object({apiAccess:n().boolean().required(),token_lifetime:n().number().integer()})}},handler:async(e,t)=>{if(!e.payload.apiAccess)return await(0,a.deleteApi)(e),t.response().code(204);return await(0,a.getApi)(e)?await(0,a.updateApi)(e,e.payload.token_lifetime):await(0,a.createApi)(e,e.payload.token_lifetime),t.response().code(204)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var s=r(142);const n=()=>({method:"POST",path:"/api/configuration/resource-server",options:{auth:{strategies:["jwt"],scope:["create:resource-server"]}},handler:async(e,t)=>{const r=await(0,s.createApi)(e);return t.response(r)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var s=r(142);const n=()=>({method:"DELETE",path:"/api/configuration/resource-server",options:{auth:{strategies:["jwt"],scope:["delete:resource-server"]}},handler:async(e,t)=>(await(0,s.deleteApi)(e),t.response().code(204))})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(13),n=r.n(s),a=r(156);const i=e=>({method:"GET",path:"/api/connections",options:{auth:{strategies:["jwt"],scope:["read:connections"]},pre:[e.handlers.managementClient]},handler:async(e,t)=>{const r=await(0,a.default)(e.pre.auth0,"connections",{fields:"id,name,strategy"}),s=n().chain(r).sortBy((e=>e.name.toLowerCase())).value();return t.response(s)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var s=r(13),n=r.n(s),a=r(5),i=r.n(a),o=r(142),l=r(156);const c=e=>({method:"DELETE",path:"/.extensions/on-uninstall",options:{auth:!1,pre:[e.handlers.validateHookToken("/.extensions/on-uninstall"),e.handlers.managementClient]},handler:async(e,t)=>{const r=await(0,l.default)(e.pre.auth0,"rules",{fields:"name,id"}),s=n().find(r,{name:"auth0-authorization-extension"});return s&&await e.pre.auth0.rules.delete({id:s.id}),await(0,o.deleteApi)(e,!0),await e.pre.auth0.clients.delete({client_id:i()("AUTH0_CLIENT_ID")}),t.response().code(204)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});const s=e=>({method:"PUT",path:"/.extensions/on-update",options:{auth:!1,pre:[e.handlers.validateHookToken("/.extensions/on-update"),e.handlers.managementClient]},handler:async(e,t)=>t.response().code(204)})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=()=>({method:"DELETE",path:"/api/permissions/{id}",options:{auth:{strategies:["jwt"],scope:["delete:permissions"]},description:"Delete a permission.",tags:["api"],validate:{options:{allowUnknown:!1},params:n().object({id:n().string().guid().required()})}},handler:async(e,t)=>(await e.storage.deletePermission(e.params.id),t.response().code(204))})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=()=>({method:"GET",path:"/api/permissions/{id}",options:{auth:{strategies:["jwt"],scope:["read:permissions"]},description:"Get a single permission based on its unique identifier.",tags:["api"],validate:{params:n().object({id:n().string().guid().required()})}},handler:async(e,t)=>{const r=await e.storage.getPermission(e.params.id);return t.response({_id:r._id,name:r.name,description:r.description})}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var s=r(13),n=r.n(s),a=r(98),i=r.n(a);const o=()=>({method:"GET",path:"/api/permissions",options:{auth:{strategies:["jwt"],scope:["read:permissions"]},description:"Get all permissions in the system.",tags:["api"],validate:{query:i().object({q:i().string().max(1e3).allow("").default(""),field:i().string().max(1e3).allow("").default("")})}},handler:async(e,t)=>{const r=await e.storage.getPermissions(),s={permissions:n().filter(r,(t=>{const r=e.query.q;if(!r)return!0;const s=e.query.field;return n().includes(t[s].toLowerCase(),r.toLowerCase())})),total:r.length};return t.response(s)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var s=r(183);const n=()=>({method:"POST",path:"/api/permissions",options:{auth:{strategies:["jwt"],scope:["create:permissions"]},description:"Create a new permission.",tags:["api"],validate:{options:{allowUnknown:!1},payload:s.default}},handler:async(e,t)=>{const r=e.payload,s=await e.storage.createPermission(r);return t.response(s)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=n().object().keys({name:n().string().min(1).max(100).required(),description:n().string().min(1).max(500).required(),applicationType:n().string().valid("client","resource_server").required(),applicationId:n().string().min(1).max(500).required()})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(98),n=r.n(s),a=r(183);const i=()=>({method:"PUT",path:"/api/permissions/{id}",options:{auth:{strategies:["jwt"],scope:["update:permissions"]},description:"Update a permission.",tags:["api"],validate:{options:{allowUnknown:!1},params:n().object({id:n().string().guid().required()}),payload:a.default}},handler:async(e,t)=>{const r=e.payload,s=await e.storage.updatePermission(e.params.id,r);return t.response(s)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=()=>({method:"DELETE",path:"/api/roles/{id}",options:{auth:{strategies:["jwt"],scope:["delete:roles"]},description:"Delete a role.",tags:["api"],validate:{options:{allowUnknown:!1},params:n().object({id:n().string().guid().required()})}},handler:async(e,t)=>(await e.storage.deleteRole(e.params.id),t.response().code(204))})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=()=>({method:"GET",path:"/api/roles/{id}",options:{auth:{strategies:["jwt"],scope:["read:roles"]},description:"Get a single role based on its unique identifier.",tags:["api"],validate:{params:n().object({id:n().string().guid().required()})}},handler:async(e,t)=>{const r=await e.storage.getRole(e.params.id);return t.response({_id:r._id,name:r.name,description:r.description})}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var s=r(13),n=r.n(s),a=r(98),i=r.n(a);const o=()=>({method:"GET",path:"/api/roles",options:{auth:{strategies:["jwt"],scope:["read:roles"]},description:"Get all roles in the system.",tags:["api"],validate:{query:i().object({q:i().string().max(1e3).allow("").default(""),field:i().string().max(1e3).allow("").default("")})}},handler:async(e,t)=>{const r=await e.storage.getRoles(),s={roles:n().filter(r,(t=>{const r=e.query.q;if(!r)return!0;const s=e.query.field;return n().includes(t[s].toLowerCase(),r.toLowerCase())})),total:r.length};return t.response(s)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(13),n=r.n(s),a=r(189);const i=()=>({method:"POST",path:"/api/roles",options:{auth:{strategies:["jwt"],scope:["create:roles"]},description:"Create a new role.",tags:["api"],validate:{options:{allowUnknown:!1},payload:a.default}},handler:async(e,t)=>{const r=e.payload,s=await e.storage.getPermissions();r.permissions.forEach((e=>{const t=n().find(s,{_id:e});if(t&&t.applicationId!==r.applicationId)throw new Error(`The permission '${t.name}' is linked to a different application.`)}));const a=await e.storage.createRole(r);return t.response(a)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=n().object().keys({name:n().string().min(1).max(50).required(),description:n().string().min(1).max(500).required(),applicationType:n().string().valid("client","resource_server").required(),applicationId:n().string().min(1).max(500).required(),permissions:n().array().items(n().string().guid()).default([])})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var s=r(13),n=r.n(s),a=r(98),i=r.n(a),o=r(189);const l=()=>({method:"PUT",path:"/api/roles/{id}",options:{auth:{strategies:["jwt"],scope:["update:roles"]},description:"Update a role.",tags:["api"],validate:{options:{allowUnknown:!1},params:i().object({id:i().string().guid().required()}),payload:o.default}},handler:async(e,t)=>{const r=e.payload,s=await e.storage.getPermissions();r.permissions.forEach((e=>{const t=n().find(s,{_id:e});if(t&&t.applicationId!==r.applicationId)throw new Error(`The permission '${t.name}' is linked to a different application.`)}));if((await e.storage.getRole(e.params.id)).applicationId!==r.applicationId)throw new Error("The 'applicationId' of a role cannot be changed.");const a=await e.storage.updateRole(e.params.id,r);return t.response(a)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=()=>({method:"DELETE",path:"/api/groups/{id}",options:{auth:{strategies:["jwt"],scope:["delete:groups"]},description:"Delete a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:n().object({id:n().string().guid().required()})}},handler:async(e,t)=>(await e.storage.deleteGroup(e.params.id),t.response().code(204))})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(98),n=r.n(s),a=r(153);const i=()=>({method:"GET",path:"/api/groups/{id}",options:{auth:{strategies:["jwt"],scope:["read:groups"]},description:'Get a single group based on its unique identifier. Add "?expand" to also load all roles and permissions for this group.',tags:["api"],validate:{query:n().object({expand:n().boolean()}),params:n().object({id:n().string().guid().required()})}},handler:async(e,t)=>{if(e.query.expand){const r=await(0,a.getGroupExpanded)(e.storage,e.params.id);return t.response(r)}const r=await e.storage.getGroup(e.params.id);return t.response({_id:r._id,name:r.name,description:r.description})}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var s=r(13),n=r.n(s),a=r(98),i=r.n(a);const o=()=>({method:"GET",path:"/api/groups",options:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Get all groups in the system.",tags:["api"],validate:{query:i().object({q:i().string().max(1e3).allow("").default(""),field:i().string().max(1e3).allow("").default("")})}},handler:async(e,t)=>{const r=(await e.storage.getGroups()).map((e=>{const t=e;return t.mappings=t.mappings||[],t.members=t.members||[],t})),s={groups:n().filter(r,(t=>{const r=e.query.q;if(!r)return!0;const s=e.query.field;return n().includes(t[s].toLowerCase(),r.toLowerCase())})),total:r.length};return t.response(s)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var s=r(195);const n=()=>({method:"POST",path:"/api/groups",options:{auth:{strategies:["jwt"],scope:["create:groups"]},description:"Create a new group.",tags:["api"],validate:{options:{allowUnknown:!1},payload:s.default}},handler:async(e,t)=>{const r=e.payload,s=await e.storage.createGroup(r);return t.response(s).code(200)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=n().object().keys({name:n().string().min(1).max(50).required(),description:n().string().min(1).max(500).required()})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(98),n=r.n(s),a=r(195);const i=()=>({method:"PUT",path:"/api/groups/{id}",options:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Update a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:n().object({id:n().string().guid().required()}),payload:a.default}},handler:async(e,t)=>{const r=e.payload,s=await e.storage.updateGroup(e.params.id,r);return t.response(s).code(200)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=()=>({method:"DELETE",path:"/api/groups/{id}/roles",options:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Delete one or more roles from a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:n().object({id:n().string().guid().required()}),payload:n().array().items(n().string().guid()).required().min(1)}},handler:async(e,t)=>{const r=e.payload,s=await e.storage.getGroup(e.params.id);return r.forEach((e=>{const t=s.roles.indexOf(e);t>-1&&s.roles.splice(t,1)})),await e.storage.updateGroup(e.params.id,s),t.response().code(204)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=e=>({method:"GET",path:"/api/groups/{id}/roles",options:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Get the roles for a group.",tags:["api"],pre:[e.handlers.managementClient],validate:{params:n().object({id:n().string().guid().required()})}},handler:async(e,t)=>{const r=(await e.storage.getGroup(e.params.id)).roles||[],s=(await e.storage.getRoles()).filter((e=>r.indexOf(e._id)>-1));return t.response(s)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var s=r(13),n=r.n(s),a=r(98),i=r.n(a),o=r(153);const l=e=>({method:"GET",path:"/api/groups/{id}/roles/nested",options:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Get the nested roles for a group.",tags:["api"],pre:[e.handlers.managementClient],validate:{params:i().object({id:i().string().guid().required()})}},handler:async(e,t)=>{const r=await e.storage.getGroups(),s=n().find(r,{_id:e.params.id}),a=await(0,o.getParentGroups)(r,[s]),i=await e.storage.getRoles(),l=(0,o.getRolesForGroups)(a,i);return t.response(l)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var s=r(98),n=r.n(s),a=r(13),i=r.n(a);const o=()=>({method:"PATCH",path:"/api/groups/{id}/roles",options:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Add one or more roles to a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:n().object({id:n().string().guid().required()}),payload:n().array().items(n().string().guid()).required().min(1)}},handler:async(e,t)=>{const r=e.payload,s=await e.storage.getGroup(e.params.id);s.roles||(s.roles=[]);const n=i().uniq([...s.roles,...r]);return await e.storage.updateGroup(e.params.id,{...s,roles:n}),t.response().code(204)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(98),n=r.n(s),a=r(202);const i=()=>({method:"DELETE",path:"/api/groups/{id}/nested",options:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Delete one or more nested groups from a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:n().object({id:n().string().guid().required()}),payload:a.default}},handler:async(e,t)=>{const r=e.payload,s=await e.storage.getGroup(e.params.id);return r.forEach((e=>{const t=s.nested.indexOf(e);t>-1&&s.nested.splice(t,1)})),await e.storage.updateGroup(e.params.id,s),t.response().code(204)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=n().array().items(n().string().guid()).required().min(1)},(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var s=r(98),n=r.n(s),a=r(13),i=r.n(a);const o=()=>({method:"GET",path:"/api/groups/{id}/nested",options:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Get the nested groups for a group.",tags:["api"],validate:{params:n().object({id:n().string().guid().required()})}},handler:async(e,t)=>{const r=await e.storage.getGroups(),s=i().find(r,{_id:e.params.id});s.nested||(s.nested=[]);const n=i().filter(r,(e=>s.nested.indexOf(e._id)>-1)),a=i().sortBy(n,["name"]);return t.response(a)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(98),n=r.n(s),a=r(202);const i=()=>({method:"PATCH",path:"/api/groups/{id}/nested",options:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Add one or more nested groups in a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:n().object({id:n().string().guid().required()}),payload:a.default}},handler:async(e,t)=>{const r=e.payload,s=await e.storage.getGroup(e.params.id);return s.nested||(s.nested=[]),r.forEach((t=>{-1===s.nested.indexOf(t)&&t!==e.params.id&&s.nested.push(t)})),await e.storage.updateGroup(e.params.id,s),t.response().code(204)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(98),n=r.n(s),a=r(153);const i=e=>({method:"GET",path:"/api/groups/{id}/mappings",options:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Get the mappings for a group.",tags:["api"],pre:[e.handlers.managementClient],validate:{params:n().object({id:n().string().guid().required()})}},handler:async(e,t)=>{const r=(await e.storage.getGroup(e.params.id)).mappings||[],s=await(0,a.getMappingsWithNames)(e.pre.auth0,r);return t.response(s)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var s=r(13),n=r.n(s),a=r(98),i=r.n(a),o=r(207);const l=()=>({method:"DELETE",path:"/api/groups/{id}/mappings",options:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Delete one or more group mappings from a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:i().object({id:i().string().guid().required()}),payload:o.default}},handler:async(e,t)=>{const r=e.payload,s=await e.storage.getGroup(e.params.id);return r.forEach((e=>{const t=n().find(s.mappings,{_id:e});t&&s.mappings.splice(s.mappings.indexOf(t),1)})),await e.storage.updateGroup(e.params.id,s),t.response().code(204)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=n().array().items(n().string().guid()).required().min(1)},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(209),n=r.n(s),a=r(210);const i=()=>({method:"PATCH",path:"/api/groups/{id}/mappings",options:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Create one or more mappings in a group.",tags:["api"],validate:{options:{allowUnknown:!1},payload:a.default}},handler:async(e,t)=>{const r=e.payload,s=await e.storage.getGroup(e.params.id);return s.mappings||(s.mappings=[]),r.forEach((e=>{s.mappings.push({_id:n().v4(),groupName:e.groupName,connectionName:e.connectionName})})),await e.storage.updateGroup(e.params.id,s),t.response().code(204)}})},e=>{e.exports=require("[email protected]")},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(98),n=r.n(s),a=r(211);const i=n().array().items(a.default).required().min(1)},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=n().object().keys({groupName:n().string().min(1).max(50).required(),connectionName:n().string().min(1).max(50).required()})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(98),n=r.n(s),a=r(213);const i=()=>({method:"DELETE",path:"/api/groups/{id}/members",options:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Delete one or more members from a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:n().object({id:n().string().guid().required()}),payload:a.default}},handler:async(e,t)=>{const r=e.payload,s=await e.storage.getGroup(e.params.id);return r.forEach((e=>{const t=s.members.indexOf(e);t>-1&&s.members.splice(t,1)})),await e.storage.updateGroup(e.params.id,s),t.response().code(204)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=n().array().items(n().string()).required().min(1)},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(98),n=r.n(s),a=r(215);const i=e=>({method:"GET",path:"/api/groups/{id}/members",options:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Get the members for a group.",tags:["api"],pre:[e.handlers.managementClient],validate:{params:n().object({id:n().string().guid().required()}),query:n().object({per_page:n().number().integer().min(1).max(25).default(25),page:n().number().integer().min(0).default(0)})}},handler:async(e,t)=>{const r=await e.storage.getGroup(e.params.id),s=await(0,a.getUsersById)(e.pre.auth0,r.members||[],e.query.page,e.query.per_page);return t.response(s)}})},(e,t,r)=>{r.r(t),r.d(t,{getUsersById:()=>l});var s=r(13),n=r.n(s),a=r(216),i=r.n(a),o=r(158);function l(e,t,r,s){return new Promise(((a,l)=>{const c=[],u=t.length;r=r-1<0?0:r-1,t=t.splice(r*s,s),i().eachLimit(t,10,((t,r)=>{(0,o.default)(e,e.users.get,[{id:t}]).then((e=>{c.push(e),r()})).catch((e=>{const s=e&&(e.name||e.statusCode);return c.push({user_id:t,name:`<Error: ${s}>`,email:t,identities:[{connection:"N/A"}]}),r()}))}),(e=>{if(e)return l(e);const t=n().sortBy(c,["user_id"]);return a({total:u,users:t})}))}))}},e=>{e.exports=require("[email protected]")},(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var s=r(13),n=r.n(s),a=r(98),i=r.n(a),o=r(215),l=r(153);const c=e=>({method:"GET",path:"/api/groups/{id}/members/nested",options:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Get the nested members for a group.",tags:["api"],pre:[e.handlers.managementClient],validate:{params:i().object({id:i().string().guid().required()}),query:i().object({per_page:i().number().integer().min(1).max(25).default(25),page:i().number().integer().min(0).default(0)})}},handler:async(e,t)=>{const r=await e.storage.getGroups(),s=n().find(r,{_id:e.params.id}),a=(0,l.getChildGroups)(r,[s]),i=await(0,l.getMembers)(a),c=i?i.map((e=>e.userId)):[],u=await(0,o.getUsersById)(e.pre.auth0,c,e.query.page,e.query.per_page),p=i.length,h=u.users.map((e=>{let t=n().find(i,{userId:e.user_id});return t&&(t={_id:t.group._id,name:t.group.name,description:t.group.description}),{user:{user_id:e.user_id,name:e.name,nickname:e.nickname,email:e.email},group:t}})),d={total:p,nested:n().sortBy(h,["user.name"])};return t.response(d)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(98),n=r.n(s),a=r(213);const i=()=>({method:"PATCH",path:"/api/groups/{id}/members",options:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Add one or more members in a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:n().object({id:n().string().guid().required()}),payload:a.default}},handler:async(e,t)=>{const r=e.payload,s=await e.storage.getGroup(e.params.id);return s.members||(s.members=[]),r.forEach((e=>{-1===s.members.indexOf(e)&&s.members.push(e)})),await e.storage.updateGroup(e.params.id,s),t.response().code(204)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var s=r(220);const n=()=>({method:"GET",path:"/meta",options:{auth:!1},handler:async(e,t)=>t.response(s)})},e=>{e.exports=JSON.parse('{"title":"Auth0 Authorization","name":"auth0-authz","version":"2.13.0","author":"auth0","description":"This extension gives Auth0 customers the possibility to manage group memberships for their users.","type":"application","logoUrl":"https://cdn.auth0.com/extensions/auth0-authz/assets/logo.svg","initialUrlPath":"/admins/login","updateConfirmMessage":"Warning! Read the documentation about breaking changes (https://auth0.com/docs/extensions/authorization-extension) before updating the extension. If you are upgrading from 2.5 or older, you have to rotate your Api Key and republish the rule upon upgrade.","uninstallConfirmMessage":"You are about to uninstall the \\"Authorization Extension\\". If you proceed all your data in this extension will be lost. Do you want to continue?","repository":"https://github.com/auth0/auth0-authorization-extension","keywords":["auth0","extension"],"auth0":{"createClient":true,"onUninstallPath":"/.extensions/on-uninstall","onUpdatePath":"/.extensions/on-update","scopes":"read:connections read:resource_servers update:resource_servers delete:resource_servers read:clients delete:clients read:users read:rules create:rules update:rules_configs update:rules delete:rules"},"secrets":{"STORAGE_TYPE":{"description":"Choose the storage type for the database","type":"select","required":true,"default":"webtask","allowMultiple":false,"options":[{"value":"webtask","text":"Webtask Storage"},{"value":"s3","text":"Amazon S3"}]},"S3_BUCKET":{"description":"Your S3 Bucket","example":"my-bucket","required":true,"visibleIf":{"STORAGE_TYPE":"s3"}},"S3_PATH":{"description":"Path to the JSON file","required":true,"example":"/auth0-authz.json","default":"/auth0-authz.json","visibleIf":{"STORAGE_TYPE":"s3"}},"S3_KEY":{"description":"Your S3 Key ID","required":true,"example":"AKIAJL.........","visibleIf":{"STORAGE_TYPE":"s3"}},"S3_SECRET":{"description":"Your S3 Key Secret","required":true,"example":"r3UOMBA......................","visibleIf":{"STORAGE_TYPE":"s3"}},"USER_SEARCH_ENGINE":{"description":"User search engine. Cloud only supports V3","type":"select","default":"v3","allowMultiple":false,"options":[{"value":"v3","text":"v3"},{"value":"v2","text":"v2"}]}}}')},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(98),n=r.n(s);const a=e=>({method:"GET",path:"/api/users/{id}",options:{auth:{strategies:["jwt"],scope:["read:users"]},description:"Get a single user based on its unique identifier.",validate:{params:n().object({id:n().string().required()})},pre:[e.handlers.managementClient]},handler:async(e,t)=>{const r=await e.pre.auth0.users.get({id:e.params.id});return t.response(r)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var s=r(98),n=r.n(s),a=r(5),i=r.n(a);const o=e=>({method:"GET",path:"/api/users",options:{auth:{strategies:["jwt"],scope:["read:users"]},description:"Get all users.",validate:{query:n().object({q:n().string().max(1e3).allow("").default(""),field:n().string().max(1e3).allow("").default(""),per_page:n().number().integer().min(1).max(100).default(100),page:n().number().integer().min(0).default(0)})},pre:[e.handlers.managementClient]},handler:async(e,t)=>{const r=e.query.page-1<0?0:e.query.page-1,s={sort:"last_login:-1",q:e.query.field?`${e.query.field}:${e.query.q}`:e.query.q,per_page:e.query.per_page||100,page:r||0,include_totals:!0,fields:"user_id,name,email,identities,picture,last_login,logins_count,multifactor,blocked",search_engine:i()("USER_SEARCH_ENGINE")||"v3"},n=await e.pre.auth0.users.getAll(s);return t.response(n)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var s=r(98),n=r.n(s),a=r(13),i=r.n(a),o=r(153);const l=()=>({method:"GET",path:"/api/users/{id}/groups",options:{auth:{strategies:["jwt"],scope:["read:groups"]},description:'Get the groups for a user. Add "?expand" to also load all roles and permissions for these groups.',tags:["api"],validate:{params:n().object({id:n().string().required()})}},handler:async(e,t)=>{if(e.query.expand){const r=await e.storage.getGroups(),s=i().filter(r,(t=>i().includes(t.members,e.params.id))),n=await(0,o.getGroupsExpanded)(e.storage,s);return t.response(n)}const r=await e.storage.getGroups(),s=i().filter(r,(t=>i().includes(t.members,e.params.id))).map((e=>({_id:e._id,name:e.name,description:e.description})));return t.response(s)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var s=r(98),n=r.n(s),a=r(13),i=r.n(a),o=r(153);const l=()=>({method:"GET",path:"/api/users/{id}/groups/calculate",options:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Calculate the group memberships for a user (including nested groups).",tags:["api"],validate:{params:n().object({id:n().string().required()})}},handler:async(e,t)=>{const r=await e.storage.getGroups(),s=(await(0,o.getParentGroups)(r,i().filter(r,(t=>i().includes(t.members,e.params.id))))).map((e=>({_id:e._id,name:e.name,description:e.description})));return t.response(s)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var s=r(98),n=r.n(s),a=r(13),i=r.n(a),o=r(157);const l=()=>({method:"PATCH",path:"/api/users/{id}/groups",options:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Add a single user to groups.",tags:["api"],validate:{params:n().object({id:n().string().required()}),payload:n().array().items(n().string()).required().min(1)}},handler:async(e,t)=>{const r=e.payload,s=/^(\{{0,1}([0-9a-fA-F]){8}-?([0-9a-fA-F]){4}-?([0-9a-fA-F]){4}-?([0-9a-fA-F]){4}-?([0-9a-fA-F]){12}\}{0,1})$/.test(r[0])?"_id":"name",n=await e.storage.getGroups(),a=i().filter(n,(e=>i().includes(r,e[s])));return await(0,o.promiseEach)(a,(async t=>{t.members||(t.members=[]),-1===t.members.indexOf(e.params.id)&&t.members.push(e.params.id),await e.storage.updateGroup(t._id,t)})),t.response().code(204)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var s=r(98),n=r.n(s),a=r(13),i=r.n(a);const o=()=>({method:"GET",path:"/api/users/{id}/roles",options:{auth:{strategies:["jwt"],scope:["read:roles"]},description:"Get the roles for a user.",tags:["api"],validate:{params:n().object({id:n().string().required()})}},handler:async(e,t)=>{const r=await e.storage.getRoles(),s=i().filter(r,(t=>i().includes(t.users,e.params.id))).map((e=>({_id:e._id,name:e.name,applicationId:e.applicationId,description:e.description})));return t.response(s)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(98),n=r.n(s),a=r(153);const i=()=>({method:"GET",path:"/api/users/{id}/roles/calculate",options:{auth:{strategies:["jwt"],scope:["read:roles"]},description:"Calculate the roles assigned to the user (including through group memberships).",tags:["api"],validate:{params:n().object({id:n().string().required()})}},handler:async(e,t)=>{const r=(await(0,a.getRolesForUser)(e.storage,e.params.id)).map((e=>({_id:e._id,name:e.name,applicationId:e.applicationId,description:e.description})));return t.response(r)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var s=r(98),n=r.n(s),a=r(157);const i=()=>({method:"DELETE",path:"/api/users/{id}/roles",options:{auth:{strategies:["jwt"],scope:["update:roles"]},description:"Remove a single user from roles.",tags:["api"],validate:{params:n().object({id:n().string().required()}),payload:n().array().items(n().string().guid()).required().min(1)}},handler:async(e,t)=>{const r=e.payload;return await(0,a.promiseEach)(r,(async t=>{const r=await e.storage.getRole(t);r.users||(r.users=[]);const s=r.users.indexOf(e.params.id);s>-1&&r.users.splice(s,1),await e.storage.updateRole(t,r)})),t.response().code(204)}})},(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var s=r(13),n=r.n(s),a=r(98),i=r.n(a),o=r(157);const l=()=>({method:"PATCH",path:"/api/users/{id}/roles",options:{auth:{strategies:["jwt"],scope:["update:roles"]},description:"Add a single user to roles.",tags:["api"],validate:{params:i().object({id:i().string().required()}),payload:i().array().items(i().string()).required().min(1)}},handler:async(e,t)=>{const r=e.payload,s=/^(\{{0,1}([0-9a-fA-F]){8}-?([0-9a-fA-F]){4}-?([0-9a-fA-F]){4}-?([0-9a-fA-F]){4}-?([0-9a-fA-F]){12}\}{0,1})$/.test(r[0])?"_id":"name",a=await e.storage.getRoles(),i=n().filter(a,(e=>n().includes(r,e[s])));return await(0,o.promiseEach)(i,(async t=>{t.users||(t.users=[]),-1===t.users.indexOf(e.params.id)&&t.users.push(e.params.id),await e.storage.updateRole(t._id,t)})),t.response().code(204)}})},(e,t,r)=>{r.r(t),r.d(t,{storagePlugin:()=>n});var s=r(17);const n={register:async e=>{const t=(0,s.getDb)();e.decorate("server","storage",t),e.decorate("request","storage",t)},name:"storage"}},e=>{e.exports=require("@hapi/[email protected]")}],__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(0);module.exports=__webpack_exports__; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment