@hyperjump/json-schema-core
Advanced tools
Comparing version 0.14.0 to 0.14.1
@@ -1148,6 +1148,6 @@ define(['exports'], function (exports) { 'use strict'; | ||
// recursiveAnchor | ||
const recursiveAnchors = {}; | ||
const dynamicAnchors = {}; | ||
const recursiveAnchorToken = getConfig(schemaVersion, "recursiveAnchorToken"); | ||
if (schema[recursiveAnchorToken] === true) { | ||
recursiveAnchors["#"] = id; | ||
dynamicAnchors["#"] = id; | ||
schema[anchorToken] = ""; | ||
@@ -1175,5 +1175,5 @@ delete schema[recursiveAnchorToken]; | ||
schemaVersion: schemaVersion, | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, recursiveAnchors), | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, dynamicAnchors), | ||
anchors: anchors, | ||
recursiveAnchors: recursiveAnchors, | ||
dynamicAnchors: dynamicAnchors, | ||
vocabulary: vocabulary, | ||
@@ -1184,3 +1184,3 @@ validated: false | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, recursiveAnchors) => { | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, dynamicAnchors) => { | ||
if (jsonTypeOf$2(subject, "object")) { | ||
@@ -1200,3 +1200,3 @@ const embeddedSchemaVersion = typeof subject["$schema"] === "string" ? splitUrl$1(subject["$schema"])[0] : schemaVersion; | ||
if (typeof subject[dynamicAnchorToken] === "string") { | ||
recursiveAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
dynamicAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
subject[anchorToken] = subject[dynamicAnchorToken]; | ||
@@ -1218,7 +1218,5 @@ delete subject[dynamicAnchorToken]; | ||
subject = Object.entries(subject) | ||
.reduce((acc, [key, value]) => { | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
return acc; | ||
}, {}); | ||
for (let key in subject) { | ||
subject[key] = processSchema(subject[key], id, schemaVersion, jsonPointer.append(key, pointer), anchors, dynamicAnchors); | ||
} | ||
@@ -1237,3 +1235,3 @@ const jsrefToken = getConfig(schemaVersion, "jsrefToken"); | ||
} else if (Array.isArray(subject)) { | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, dynamicAnchors)); | ||
} else { | ||
@@ -1252,6 +1250,6 @@ return subject; | ||
// Schema Retrieval | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchors: {} }); | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, dynamicAnchors: {} }); | ||
const get$1 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const contextUrl = recursive && contextDoc.dynamicAnchors[url] ? contextDoc.dynamicAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
@@ -1286,3 +1284,3 @@ const [id, fragment] = splitUrl$1(resolvedUrl); | ||
value: jsonPointer.get(pointer, storedSchema.schema), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
dynamicAnchors: { ...storedSchema.dynamicAnchors, ...contextDoc.dynamicAnchors }, | ||
validated: storedSchema.validated | ||
@@ -1333,3 +1331,3 @@ }); | ||
value: value$2(doc)[key], | ||
recursiveAnchors: doc.recursiveAnchors, | ||
dynamicAnchors: doc.dynamicAnchors, | ||
validated: storedSchema.validated | ||
@@ -1336,0 +1334,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
define(["exports"],(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};const v={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e};var m={jsonTypeOf:(e,t)=>v[t](e),splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const b=Symbol("$__value"),w=Symbol("$__href"),g=Symbol("$__isDynamic");var O=(e,t,r=!1)=>Object.freeze({[w]:e,[b]:t,[g]:r}),E=e=>e&&void 0!==e[w],j=e=>e[w],$=e=>e[b],A=e=>e[g];const{jsonTypeOf:P}=m,x=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),S=e=>E(e.value)?$(e.value):e.value,T=n((e,t)=>P(S(e),t)),I=(e,t)=>Object.freeze({...t,pointer:y.append(e,t.pointer),value:S(t)[e]}),V=n((e,t)=>S(t).map((r,n,o,i)=>e(I(n,t),n,o,i))),k=n((e,t)=>S(t).map((e,r,n,o)=>I(r,t)).filter((t,r,n,o)=>e(t,r,n,o))),z=n((e,t,r)=>S(r).reduce((t,n,o)=>e(t,I(o,r),o),t)),K=n((e,t)=>S(t).every((r,n,o,i)=>e(I(n,t),n,o,i))),L=n((e,t)=>S(t).some((r,n,o,i)=>e(I(n,t),n,o,i)));var _={cons:(e,t="")=>Object.freeze({...x,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:S,typeOf:T,step:I,entries:e=>Object.keys(S(e)).map(t=>[t,I(t,e)]),keys:e=>Object.keys(S(e)),map:V,filter:k,reduce:z,every:K,some:L,length:e=>S(e).length},C=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,q=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,U=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
define(["exports"],(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};const m={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e};var v={jsonTypeOf:(e,t)=>m[t](e),splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const b=Symbol("$__value"),w=Symbol("$__href"),g=Symbol("$__isDynamic");var O=(e,t,r=!1)=>Object.freeze({[w]:e,[b]:t,[g]:r}),E=e=>e&&void 0!==e[w],j=e=>e[w],$=e=>e[b],A=e=>e[g];const{jsonTypeOf:P}=v,x=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),S=e=>E(e.value)?$(e.value):e.value,T=n((e,t)=>P(S(e),t)),I=(e,t)=>Object.freeze({...t,pointer:y.append(e,t.pointer),value:S(t)[e]}),V=n((e,t)=>S(t).map((r,n,o,i)=>e(I(n,t),n,o,i))),k=n((e,t)=>S(t).map((e,r,n,o)=>I(r,t)).filter((t,r,n,o)=>e(t,r,n,o))),z=n((e,t,r)=>S(r).reduce((t,n,o)=>e(t,I(o,r),o),t)),K=n((e,t)=>S(t).every((r,n,o,i)=>e(I(n,t),n,o,i))),L=n((e,t)=>S(t).some((r,n,o,i)=>e(I(n,t),n,o,i)));var _={cons:(e,t="")=>Object.freeze({...x,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:S,typeOf:T,step:I,entries:e=>Object.keys(S(e)).map(t=>[t,I(t,e)]),keys:e=>Object.keys(S(e)),map:V,filter:k,reduce:z,every:K,some:L,length:e=>S(e).length},C=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,q=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,U=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function W(e){var t=String(e);if(R.test(t))return t;if(t.length>0&&!q.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function F(e){this.parameters=Object.create(null),this.type=e}var M={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!D.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!R.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+W(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!D.test(n))throw new TypeError("invalid media type");var o=new F(n.toLowerCase());if(-1!==r){var i,a,s;for(C.lastIndex=r;a=C.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(U,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},N=async e=>Object.entries(await e),Z=n(async(e,t)=>(await t).map(e)),J=n(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),G=n(async(e,t,r={})=>J(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),H=n(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).some(e=>e)}),Q=n(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).every(e=>e)}),X=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),Y={entries:N,map:Z,filter:G,reduce:J,some:H,every:Q,pipeline:X,all:e=>Promise.all(e),allValues:e=>X([N,J(async(e,[t,r])=>(e[t]=await r,e),{})],e)},ee=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(ne.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?te(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+re(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=re(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:te(e)}};function te(e){return e+("/"===e[e.length-1]?"":"/")}function re(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const ne=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var oe=fetch;const{jsonTypeOf:ie,splitUrl:ae}=m,se={},ce={},ue=(e,t)=>{const r=e in ce?ce[e]:e;if(r in se)return se[r][t]},le={},fe={},de=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ae(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ue(n,"baseToken"),i=ue(n,"anchorToken"),a=ae(t)[0];if(!a&&!ae(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=be(a,e[o]||""),[c,u]=ae(s);delete e[o],u&&o===i&&(e[i]=i!==o?encodeURI(u):"#"+encodeURI(u)),a&&(fe[a]=c);const l={},f=ue(n,"recursiveAnchorToken");let d;!0===e[f]&&(l["#"]=c,e[i]="",delete e[f]);const p=ue(n,"vocabularyToken");ie(e[p],"object")?(ce[c]=n,d=e[p],delete e[p]):d=c===n?{[n]:!0}:{};const h={};le[c]={id:c,schemaVersion:n,schema:pe(e,c,n,y.nil,h,l),anchors:h,recursiveAnchors:l,vocabulary:d,validated:!1}},pe=(e,t,r,n,o,i)=>{if(ie(e,"object")){const a="string"==typeof e.$schema?ae(e.$schema)[0]:r,s=ue(a,"embeddedToken"),c=ue(a,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=be(t,e[s]);return e[s]=n,de(e,n,r),O(e[s],e)}const u=ue(r,"anchorToken"),l=ue(r,"dynamicAnchorToken");"string"==typeof e[l]&&(i["#"+e[l]]=t,e[u]=e[l],delete e[l]);const f=ue(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=ue(r,"jrefToken");if("string"==typeof e[d])return O(e[d],e);e=Object.entries(e).reduce((e,[a,s])=>(e[a]=pe(s,t,r,y.append(a,n),o,i),e),{});const p=ue(r,"jsrefToken");"string"==typeof e[p]&&(e[p]=O(e[p],e[p]));const h=ue(r,"dynamicJsrefToken");return"string"==typeof e[h]&&(e[h]=O(e[h],e[h],!0)),e}return Array.isArray(e)?e.map((e,a)=>pe(e,t,r,y.append(a,n),o,i)):e},he=e=>le[fe[e]]||le[e],ye=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ve=async(e,t=ye,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:Oe(t),o=be(n,e),[i,a]=ae(o);if(!(e=>e in le||e in fe)(i)){const e=await oe(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=M.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}de(await e.json(),i)}const s=he(i),c=a&&"/"!==a[0]?ge(s,a):a,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:y.get(c,s.schema),recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated});return me(u)},me=e=>E(e.value)?ve(j(e.value),e,A(e.value)):e,be=(e,t)=>{const r=ee(e,t),n=ae(e)[0];if(n&&"file"===we(r)&&"file"!==we(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},we=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},ge=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},Oe=e=>`${e.id}#${encodeURI(e.pointer)}`,Ee=e=>E(e.value)?$(e.value):e.value,je=(e,t)=>{const r=he(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:y.append(e,t.pointer),schema:r.schema,value:Ee(t)[e],recursiveAnchors:t.recursiveAnchors,validated:r.validated});return me(n)},$e=n((e,t)=>Y.pipeline([Ee,Y.map(async(r,n)=>e(await je(n,t),n)),Y.all],t));var Ae={setConfig:(e,t,r)=>{se[e]||(se[e]={}),se[e][t]=r},getConfig:ue,add:de,get:ve,markValidated:e=>{le[e].validated=!0},uri:Oe,value:Ee,typeOf:(e,t)=>ie(Ee(e),t),has:(e,t)=>e in Ee(t),step:je,keys:e=>Object.keys(Ee(e)),entries:e=>Y.pipeline([Ee,Object.keys,Y.map(async t=>[t,await je(t,e)]),Y.all],e),map:$e,length:e=>Ee(e).length};class Pe extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var xe=Pe;const Se="FLAG",Te="BASIC",Ie="DETAILED",Ve="VERBOSE";let ke=Ie,ze=!0;const Ke=(e,t)=>(n,o=Se)=>{if(![Se,Te,Ie,Ve].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Le(o,i));return We(t,n,e),r.unsubscribe(a),i[0]},Le=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&_e(r[r.length-1],i);){const t=r.pop();let n=[];e===Te&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n)}(e===Ve||e!==Se&&!i.valid)&&r.push(i),t[0]=i}},_e=(e,t)=>e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||t.keyword.endsWith("#validate")&&e.instanceLocation===t.instanceLocation,Ce={},qe=e=>Ce[e],Re=e=>e in Ce,Ue={},Be={},De=async(e,t)=>{if(!Re(e.schemaVersion+"#validate")){const t=await Ae.get(e.schemaVersion);(Ae.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ue)Object.entries(Ue[e]).forEach(([e,r])=>{((e,t)=>{Ce[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ze&&!e.validated){if(Ae.markValidated(e.id),!(e.schemaVersion in Be)){const t=await Ae.get(e.schemaVersion),r={},n=await De(t,r);Be[t.id]=Ke(r,n)}const t=_.cons(e.schema,e.id),r=Be[e.schemaVersion](t,ke);if(!r.valid)throw new xe(r)}return await qe(e.schemaVersion+"#validate").compile(e,t),Ae.uri(e)},We=(e,t,r)=>{const[n]=r[e];return qe(n).interpret(e,t,r)};var Fe={validate:async(e,t,r)=>{const n={},o=await De(e,n),i=(e,t=Se)=>Ke(n,o)(_.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ke=e},setShouldMetaValidate:e=>{ze=e},FLAG:Se,BASIC:Te,DETAILED:Ie,VERBOSE:Ve,getKeyword:qe,hasKeyword:Re,defineVocabulary:(e,t)=>{Ue[e]=t},compileSchema:De,interpretSchema:We,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return qe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return qe(o).collectEvaluatedItems(e,t,r,n)}};var Me={compile:async(e,t)=>{const r=Ae.uri(e);if(!(r in t)){t[r]=!1;const n=Ae.value(e);t[r]=[e.schemaVersion+"#validate",Ae.uri(e),"boolean"==typeof n?n:await Y.pipeline([Ae.entries,Y.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),Y.filter(([t])=>Fe.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),Y.map(async([r,n])=>{const o=await Fe.getKeyword(r).compile(n,t,e);return[r,Ae.uri(n),o]}),Y.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Fe.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:_.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:_.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Fe.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Fe.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ne={Core:Fe,Schema:Ae,Instance:_,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Me}},Ze=Ne.Core,Je=Ne.Schema,Ge=Ne.Instance,He=Ne.Keywords;e.Core=Ze,e.Instance=Ge,e.Keywords=He,e.Schema=Je,e.default=Ne,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
*/function W(e){var t=String(e);if(R.test(t))return t;if(t.length>0&&!q.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function F(e){this.parameters=Object.create(null),this.type=e}var M={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!D.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!R.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+W(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!D.test(n))throw new TypeError("invalid media type");var o=new F(n.toLowerCase());if(-1!==r){var i,a,s;for(C.lastIndex=r;a=C.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(U,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},N=async e=>Object.entries(await e),Z=n(async(e,t)=>(await t).map(e)),J=n(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),G=n(async(e,t,r={})=>J(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),H=n(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).some(e=>e)}),Q=n(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).every(e=>e)}),X=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),Y={entries:N,map:Z,filter:G,reduce:J,some:H,every:Q,pipeline:X,all:e=>Promise.all(e),allValues:e=>X([N,J(async(e,[t,r])=>(e[t]=await r,e),{})],e)},ee=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(ne.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?te(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+re(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=re(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:te(e)}};function te(e){return e+("/"===e[e.length-1]?"":"/")}function re(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const ne=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var oe=fetch;const{jsonTypeOf:ie,splitUrl:ae}=v,se={},ce={},ue=(e,t)=>{const r=e in ce?ce[e]:e;if(r in se)return se[r][t]},le={},fe={},de=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ae(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ue(n,"baseToken"),i=ue(n,"anchorToken"),a=ae(t)[0];if(!a&&!ae(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=be(a,e[o]||""),[c,u]=ae(s);delete e[o],u&&o===i&&(e[i]=i!==o?encodeURI(u):"#"+encodeURI(u)),a&&(fe[a]=c);const l={},f=ue(n,"recursiveAnchorToken");let d;!0===e[f]&&(l["#"]=c,e[i]="",delete e[f]);const p=ue(n,"vocabularyToken");ie(e[p],"object")?(ce[c]=n,d=e[p],delete e[p]):d=c===n?{[n]:!0}:{};const h={};le[c]={id:c,schemaVersion:n,schema:pe(e,c,n,y.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1}},pe=(e,t,r,n,o,i)=>{if(ie(e,"object")){const a="string"==typeof e.$schema?ae(e.$schema)[0]:r,s=ue(a,"embeddedToken"),c=ue(a,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=be(t,e[s]);return e[s]=n,de(e,n,r),O(e[s],e)}const u=ue(r,"anchorToken"),l=ue(r,"dynamicAnchorToken");"string"==typeof e[l]&&(i["#"+e[l]]=t,e[u]=e[l],delete e[l]);const f=ue(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=ue(r,"jrefToken");if("string"==typeof e[d])return O(e[d],e);for(let a in e)e[a]=pe(e[a],t,r,y.append(a,n),o,i);const p=ue(r,"jsrefToken");"string"==typeof e[p]&&(e[p]=O(e[p],e[p]));const h=ue(r,"dynamicJsrefToken");return"string"==typeof e[h]&&(e[h]=O(e[h],e[h],!0)),e}return Array.isArray(e)?e.map((e,a)=>pe(e,t,r,y.append(a,n),o,i)):e},he=e=>le[fe[e]]||le[e],ye=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,dynamicAnchors:{}}),me=async(e,t=ye,r=!1)=>{const n=r&&t.dynamicAnchors[e]?t.dynamicAnchors[e]:Oe(t),o=be(n,e),[i,a]=ae(o);if(!(e=>e in le||e in fe)(i)){const e=await oe(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=M.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}de(await e.json(),i)}const s=he(i),c=a&&"/"!==a[0]?ge(s,a):a,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:y.get(c,s.schema),dynamicAnchors:{...s.dynamicAnchors,...t.dynamicAnchors},validated:s.validated});return ve(u)},ve=e=>E(e.value)?me(j(e.value),e,A(e.value)):e,be=(e,t)=>{const r=ee(e,t),n=ae(e)[0];if(n&&"file"===we(r)&&"file"!==we(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},we=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},ge=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},Oe=e=>`${e.id}#${encodeURI(e.pointer)}`,Ee=e=>E(e.value)?$(e.value):e.value,je=(e,t)=>{const r=he(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:y.append(e,t.pointer),schema:r.schema,value:Ee(t)[e],dynamicAnchors:t.dynamicAnchors,validated:r.validated});return ve(n)},$e=n((e,t)=>Y.pipeline([Ee,Y.map(async(r,n)=>e(await je(n,t),n)),Y.all],t));var Ae={setConfig:(e,t,r)=>{se[e]||(se[e]={}),se[e][t]=r},getConfig:ue,add:de,get:me,markValidated:e=>{le[e].validated=!0},uri:Oe,value:Ee,typeOf:(e,t)=>ie(Ee(e),t),has:(e,t)=>e in Ee(t),step:je,keys:e=>Object.keys(Ee(e)),entries:e=>Y.pipeline([Ee,Object.keys,Y.map(async t=>[t,await je(t,e)]),Y.all],e),map:$e,length:e=>Ee(e).length};class Pe extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var xe=Pe;const Se="FLAG",Te="BASIC",Ie="DETAILED",Ve="VERBOSE";let ke=Ie,ze=!0;const Ke=(e,t)=>(n,o=Se)=>{if(![Se,Te,Ie,Ve].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Le(o,i));return We(t,n,e),r.unsubscribe(a),i[0]},Le=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&_e(r[r.length-1],i);){const t=r.pop();let n=[];e===Te&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n)}(e===Ve||e!==Se&&!i.valid)&&r.push(i),t[0]=i}},_e=(e,t)=>e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||t.keyword.endsWith("#validate")&&e.instanceLocation===t.instanceLocation,Ce={},qe=e=>Ce[e],Re=e=>e in Ce,Ue={},Be={},De=async(e,t)=>{if(!Re(e.schemaVersion+"#validate")){const t=await Ae.get(e.schemaVersion);(Ae.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ue)Object.entries(Ue[e]).forEach(([e,r])=>{((e,t)=>{Ce[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ze&&!e.validated){if(Ae.markValidated(e.id),!(e.schemaVersion in Be)){const t=await Ae.get(e.schemaVersion),r={},n=await De(t,r);Be[t.id]=Ke(r,n)}const t=_.cons(e.schema,e.id),r=Be[e.schemaVersion](t,ke);if(!r.valid)throw new xe(r)}return await qe(e.schemaVersion+"#validate").compile(e,t),Ae.uri(e)},We=(e,t,r)=>{const[n]=r[e];return qe(n).interpret(e,t,r)};var Fe={validate:async(e,t,r)=>{const n={},o=await De(e,n),i=(e,t=Se)=>Ke(n,o)(_.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ke=e},setShouldMetaValidate:e=>{ze=e},FLAG:Se,BASIC:Te,DETAILED:Ie,VERBOSE:Ve,getKeyword:qe,hasKeyword:Re,defineVocabulary:(e,t)=>{Ue[e]=t},compileSchema:De,interpretSchema:We,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return qe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return qe(o).collectEvaluatedItems(e,t,r,n)}};var Me={compile:async(e,t)=>{const r=Ae.uri(e);if(!(r in t)){t[r]=!1;const n=Ae.value(e);t[r]=[e.schemaVersion+"#validate",Ae.uri(e),"boolean"==typeof n?n:await Y.pipeline([Ae.entries,Y.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),Y.filter(([t])=>Fe.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),Y.map(async([r,n])=>{const o=await Fe.getKeyword(r).compile(n,t,e);return[r,Ae.uri(n),o]}),Y.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Fe.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:_.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:_.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Fe.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Fe.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ne={Core:Fe,Schema:Ae,Instance:_,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Me}},Ze=Ne.Core,Je=Ne.Schema,Ge=Ne.Instance,He=Ne.Keywords;e.Core=Ze,e.Instance=Ge,e.Keywords=He,e.Schema=Je,e.default=Ne,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=json-schema-core-amd.min.js.map |
@@ -1150,6 +1150,6 @@ 'use strict'; | ||
// recursiveAnchor | ||
const recursiveAnchors = {}; | ||
const dynamicAnchors = {}; | ||
const recursiveAnchorToken = getConfig(schemaVersion, "recursiveAnchorToken"); | ||
if (schema[recursiveAnchorToken] === true) { | ||
recursiveAnchors["#"] = id; | ||
dynamicAnchors["#"] = id; | ||
schema[anchorToken] = ""; | ||
@@ -1177,5 +1177,5 @@ delete schema[recursiveAnchorToken]; | ||
schemaVersion: schemaVersion, | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, recursiveAnchors), | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, dynamicAnchors), | ||
anchors: anchors, | ||
recursiveAnchors: recursiveAnchors, | ||
dynamicAnchors: dynamicAnchors, | ||
vocabulary: vocabulary, | ||
@@ -1186,3 +1186,3 @@ validated: false | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, recursiveAnchors) => { | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, dynamicAnchors) => { | ||
if (jsonTypeOf$2(subject, "object")) { | ||
@@ -1202,3 +1202,3 @@ const embeddedSchemaVersion = typeof subject["$schema"] === "string" ? splitUrl$1(subject["$schema"])[0] : schemaVersion; | ||
if (typeof subject[dynamicAnchorToken] === "string") { | ||
recursiveAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
dynamicAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
subject[anchorToken] = subject[dynamicAnchorToken]; | ||
@@ -1220,7 +1220,5 @@ delete subject[dynamicAnchorToken]; | ||
subject = Object.entries(subject) | ||
.reduce((acc, [key, value]) => { | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
return acc; | ||
}, {}); | ||
for (let key in subject) { | ||
subject[key] = processSchema(subject[key], id, schemaVersion, jsonPointer.append(key, pointer), anchors, dynamicAnchors); | ||
} | ||
@@ -1239,3 +1237,3 @@ const jsrefToken = getConfig(schemaVersion, "jsrefToken"); | ||
} else if (Array.isArray(subject)) { | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, dynamicAnchors)); | ||
} else { | ||
@@ -1254,6 +1252,6 @@ return subject; | ||
// Schema Retrieval | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchors: {} }); | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, dynamicAnchors: {} }); | ||
const get$1 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const contextUrl = recursive && contextDoc.dynamicAnchors[url] ? contextDoc.dynamicAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
@@ -1288,3 +1286,3 @@ const [id, fragment] = splitUrl$1(resolvedUrl); | ||
value: jsonPointer.get(pointer, storedSchema.schema), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
dynamicAnchors: { ...storedSchema.dynamicAnchors, ...contextDoc.dynamicAnchors }, | ||
validated: storedSchema.validated | ||
@@ -1335,3 +1333,3 @@ }); | ||
value: value$2(doc)[key], | ||
recursiveAnchors: doc.recursiveAnchors, | ||
dynamicAnchors: doc.dynamicAnchors, | ||
validated: storedSchema.validated | ||
@@ -1338,0 +1336,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(t,r){!function(e,n){var o={};e.PubSub=o;var i=e.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==t&&t.exports&&(r=t.exports=o),r.PubSub=o,t.exports=r=o)}("object"==typeof window&&window||e)})),r=(t.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const n=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(l)},o=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const i=e.shift();return{...t,[i]:o(e,d(t,i,n),r,c(i,n))}}if(Array.isArray(t)){const n=[...t];return n[f(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:d(t,e[0],n)},i=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||p(t)){const o=e.shift();i(e,d(t,o,n),r,c(o,n))}else{t[f(t,e[0])]=r}},a=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=d(t,n,r);return{...t,[n]:a(e,o,c(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return d(t,e[0],r)}},s=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=d(t,n,r);s(e,o,c(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:d(t,e[0],r)},c=r((e,t)=>t+"/"+u(e)),u=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),f=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,d=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(p(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[f(e,t)]},p=e=>null===e||"object"!=typeof e;var h={nil:"",append:c,get:(e,t)=>{const r=n(e),o=e=>r.reduce(([e,t],r)=>[d(e,r,t),c(r,t)],[e,""])[0];return void 0===t?o:o(t)},set:(e,t,i)=>{const a=n(e),s=r((e,t)=>o(a,e,t,""));return void 0===t?s:s(t,i)},assign:(e,t,o)=>{const a=n(e),s=r((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,o)},unset:(e,t)=>{const r=n(e),o=e=>a(r,e,"");return void 0===t?o:o(t)},delete:(e,t)=>{const r=n(e),o=e=>s(r,e,"");return void 0===t?o:o(t)}};const y={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e};var v={jsonTypeOf:(e,t)=>y[t](e),splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const m=Symbol("$__value"),b=Symbol("$__href"),w=Symbol("$__isDynamic");var g=(e,t,r=!1)=>Object.freeze({[b]:e,[m]:t,[w]:r}),O=e=>e&&void 0!==e[b],E=e=>e[b],j=e=>e[m],x=e=>e[w];const{jsonTypeOf:$}=v,A=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),P=e=>O(e.value)?j(e.value):e.value,S=r((e,t)=>$(P(e),t)),T=(e,t)=>Object.freeze({...t,pointer:h.append(e,t.pointer),value:P(t)[e]}),I=r((e,t)=>P(t).map((r,n,o,i)=>e(T(n,t),n,o,i))),V=r((e,t)=>P(t).map((e,r,n,o)=>T(r,t)).filter((t,r,n,o)=>e(t,r,n,o))),k=r((e,t,r)=>P(r).reduce((t,n,o)=>e(t,T(o,r),o),t)),z=r((e,t)=>P(t).every((r,n,o,i)=>e(T(n,t),n,o,i))),K=r((e,t)=>P(t).some((r,n,o,i)=>e(T(n,t),n,o,i)));var L={cons:(e,t="")=>Object.freeze({...A,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:P,typeOf:S,step:T,entries:e=>Object.keys(P(e)).map(t=>[t,T(t,e)]),keys:e=>Object.keys(P(e)),map:I,filter:V,reduce:k,every:z,some:K,length:e=>P(e).length},_=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,C=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,q=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,R=/\\([\u000b\u0020-\u00ff])/g,U=/([\\"])/g,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(t,r){!function(e,n){var o={};e.PubSub=o;var a=e.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function a(e,t,r){e(t,r)}function i(e,r,n,i){var s,c=t[r],u=i?a:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,a){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(i(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),i(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,a);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),a=r.lastIndexOf(".");!o&&-1!==a;)a=(r=r.substr(0,a)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!i&&"string"==typeof r,c="function"==typeof r,u=!1;if(!i){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(a in o)o.hasOwnProperty(a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof a&&a.amd?a((function(){return o})):(void 0!==t&&t.exports&&(r=t.exports=o),r.PubSub=o,t.exports=r=o)}("object"==typeof window&&window||e)})),r=(t.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const n=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(l)},o=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const a=e.shift();return{...t,[a]:o(e,d(t,a,n),r,c(a,n))}}if(Array.isArray(t)){const n=[...t];return n[f(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:d(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||p(t)){const o=e.shift();a(e,d(t,o,n),r,c(o,n))}else{t[f(t,e[0])]=r}},i=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=d(t,n,r);return{...t,[n]:i(e,o,c(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return d(t,e[0],r)}},s=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=d(t,n,r);s(e,o,c(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:d(t,e[0],r)},c=r((e,t)=>t+"/"+u(e)),u=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),f=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,d=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(p(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[f(e,t)]},p=e=>null===e||"object"!=typeof e;var h={nil:"",append:c,get:(e,t)=>{const r=n(e),o=e=>r.reduce(([e,t],r)=>[d(e,r,t),c(r,t)],[e,""])[0];return void 0===t?o:o(t)},set:(e,t,a)=>{const i=n(e),s=r((e,t)=>o(i,e,t,""));return void 0===t?s:s(t,a)},assign:(e,t,o)=>{const i=n(e),s=r((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,o)},unset:(e,t)=>{const r=n(e),o=e=>i(r,e,"");return void 0===t?o:o(t)},delete:(e,t)=>{const r=n(e),o=e=>s(r,e,"");return void 0===t?o:o(t)}};const y={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e};var m={jsonTypeOf:(e,t)=>y[t](e),splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const v=Symbol("$__value"),b=Symbol("$__href"),w=Symbol("$__isDynamic");var g=(e,t,r=!1)=>Object.freeze({[b]:e,[v]:t,[w]:r}),O=e=>e&&void 0!==e[b],E=e=>e[b],j=e=>e[v],x=e=>e[w];const{jsonTypeOf:$}=m,A=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),P=e=>O(e.value)?j(e.value):e.value,S=r((e,t)=>$(P(e),t)),T=(e,t)=>Object.freeze({...t,pointer:h.append(e,t.pointer),value:P(t)[e]}),I=r((e,t)=>P(t).map((r,n,o,a)=>e(T(n,t),n,o,a))),V=r((e,t)=>P(t).map((e,r,n,o)=>T(r,t)).filter((t,r,n,o)=>e(t,r,n,o))),k=r((e,t,r)=>P(r).reduce((t,n,o)=>e(t,T(o,r),o),t)),z=r((e,t)=>P(t).every((r,n,o,a)=>e(T(n,t),n,o,a))),K=r((e,t)=>P(t).some((r,n,o,a)=>e(T(n,t),n,o,a)));var L={cons:(e,t="")=>Object.freeze({...A,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:P,typeOf:S,step:T,entries:e=>Object.keys(P(e)).map(t=>[t,T(t,e)]),keys:e=>Object.keys(P(e)),map:I,filter:V,reduce:k,every:z,some:K,length:e=>P(e).length},_=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,C=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,q=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,R=/\\([\u000b\u0020-\u00ff])/g,U=/([\\"])/g,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function D(e){var t=String(e);if(q.test(t))return t;if(t.length>0&&!C.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(U,"\\$1")+'"'}function W(e){this.parameters=Object.create(null),this.type=e}var F={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!B.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!q.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+D(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!B.test(n))throw new TypeError("invalid media type");var o=new W(n.toLowerCase());if(-1!==r){var i,a,s;for(_.lastIndex=r;a=_.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(R,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},M=async e=>Object.entries(await e),N=r(async(e,t)=>(await t).map(e)),Z=r(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),J=r(async(e,t,r={})=>Z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),G=r(async(e,t)=>{const r=await N(e,t);return(await Promise.all(r)).some(e=>e)}),H=r(async(e,t)=>{const r=await N(e,t);return(await Promise.all(r)).every(e=>e)}),Q=r((e,t)=>e.reduce(async(e,t)=>t(await e),t)),X={entries:M,map:N,filter:J,reduce:Z,some:G,every:H,pipeline:Q,all:e=>Promise.all(e),allValues:e=>Q([M,Z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},Y=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(re.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?ee(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+te(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=te(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:ee(e)}};function ee(e){return e+("/"===e[e.length-1]?"":"/")}function te(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const re=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var ne=fetch;const{jsonTypeOf:oe,splitUrl:ie}=v,ae={},se={},ce=(e,t)=>{const r=e in se?se[e]:e;if(r in ae)return ae[r][t]},ue={},le={},fe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ie(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ce(n,"baseToken"),i=ce(n,"anchorToken"),a=ie(t)[0];if(!a&&!ie(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=me(a,e[o]||""),[c,u]=ie(s);delete e[o],u&&o===i&&(e[i]=i!==o?encodeURI(u):"#"+encodeURI(u)),a&&(le[a]=c);const l={},f=ce(n,"recursiveAnchorToken");let d;!0===e[f]&&(l["#"]=c,e[i]="",delete e[f]);const p=ce(n,"vocabularyToken");oe(e[p],"object")?(se[c]=n,d=e[p],delete e[p]):d=c===n?{[n]:!0}:{};const y={};ue[c]={id:c,schemaVersion:n,schema:de(e,c,n,h.nil,y,l),anchors:y,recursiveAnchors:l,vocabulary:d,validated:!1}},de=(e,t,r,n,o,i)=>{if(oe(e,"object")){const a="string"==typeof e.$schema?ie(e.$schema)[0]:r,s=ce(a,"embeddedToken"),c=ce(a,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=me(t,e[s]);return e[s]=n,fe(e,n,r),g(e[s],e)}const u=ce(r,"anchorToken"),l=ce(r,"dynamicAnchorToken");"string"==typeof e[l]&&(i["#"+e[l]]=t,e[u]=e[l],delete e[l]);const f=ce(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=ce(r,"jrefToken");if("string"==typeof e[d])return g(e[d],e);e=Object.entries(e).reduce((e,[a,s])=>(e[a]=de(s,t,r,h.append(a,n),o,i),e),{});const p=ce(r,"jsrefToken");"string"==typeof e[p]&&(e[p]=g(e[p],e[p]));const y=ce(r,"dynamicJsrefToken");return"string"==typeof e[y]&&(e[y]=g(e[y],e[y],!0)),e}return Array.isArray(e)?e.map((e,a)=>de(e,t,r,h.append(a,n),o,i)):e},pe=e=>ue[le[e]]||ue[e],he=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ye=async(e,t=he,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:ge(t),o=me(n,e),[i,a]=ie(o);if(!(e=>e in ue||e in le)(i)){const e=await ne(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=F.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}fe(await e.json(),i)}const s=pe(i),c=a&&"/"!==a[0]?we(s,a):a,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:h.get(c,s.schema),recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated});return ve(u)},ve=e=>O(e.value)?ye(E(e.value),e,x(e.value)):e,me=(e,t)=>{const r=Y(e,t),n=ie(e)[0];if(n&&"file"===be(r)&&"file"!==be(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},be=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},we=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ge=e=>`${e.id}#${encodeURI(e.pointer)}`,Oe=e=>O(e.value)?j(e.value):e.value,Ee=(e,t)=>{const r=pe(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:h.append(e,t.pointer),schema:r.schema,value:Oe(t)[e],recursiveAnchors:t.recursiveAnchors,validated:r.validated});return ve(n)},je=r((e,t)=>X.pipeline([Oe,X.map(async(r,n)=>e(await Ee(n,t),n)),X.all],t));var xe={setConfig:(e,t,r)=>{ae[e]||(ae[e]={}),ae[e][t]=r},getConfig:ce,add:fe,get:ye,markValidated:e=>{ue[e].validated=!0},uri:ge,value:Oe,typeOf:(e,t)=>oe(Oe(e),t),has:(e,t)=>e in Oe(t),step:Ee,keys:e=>Object.keys(Oe(e)),entries:e=>X.pipeline([Oe,Object.keys,X.map(async t=>[t,await Ee(t,e)]),X.all],e),map:je,length:e=>Oe(e).length};class $e extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Ae=$e;const Pe="FLAG",Se="BASIC",Te="DETAILED",Ie="VERBOSE";let Ve=Te,ke=!0;const ze=(e,r)=>(n,o=Pe)=>{if(![Pe,Se,Te,Ie].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=t.subscribe("result",Ke(o,i));return De(r,n,e),t.unsubscribe(a),i[0]},Ke=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Le(r[r.length-1],i);){const t=r.pop();let n=[];e===Se&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n)}(e===Ie||e!==Pe&&!i.valid)&&r.push(i),t[0]=i}},Le=(e,t)=>e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||t.keyword.endsWith("#validate")&&e.instanceLocation===t.instanceLocation,_e={},Ce=e=>_e[e],qe=e=>e in _e,Re={},Ue={},Be=async(e,t)=>{if(!qe(e.schemaVersion+"#validate")){const t=await xe.get(e.schemaVersion);(xe.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Re)Object.entries(Re[e]).forEach(([e,r])=>{((e,t)=>{_e[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ke&&!e.validated){if(xe.markValidated(e.id),!(e.schemaVersion in Ue)){const t=await xe.get(e.schemaVersion),r={},n=await Be(t,r);Ue[t.id]=ze(r,n)}const t=L.cons(e.schema,e.id),r=Ue[e.schemaVersion](t,Ve);if(!r.valid)throw new Ae(r)}return await Ce(e.schemaVersion+"#validate").compile(e,t),xe.uri(e)},De=(e,t,r)=>{const[n]=r[e];return Ce(n).interpret(e,t,r)};var We={validate:async(e,t,r)=>{const n={},o=await Be(e,n),i=(e,t=Pe)=>ze(n,o)(L.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{Ve=e},setShouldMetaValidate:e=>{ke=e},FLAG:Pe,BASIC:Se,DETAILED:Te,VERBOSE:Ie,getKeyword:Ce,hasKeyword:qe,defineVocabulary:(e,t)=>{Re[e]=t},compileSchema:Be,interpretSchema:De,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Ce(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Ce(o).collectEvaluatedItems(e,t,r,n)}};var Fe={compile:async(e,t)=>{const r=xe.uri(e);if(!(r in t)){t[r]=!1;const n=xe.value(e);t[r]=[e.schemaVersion+"#validate",xe.uri(e),"boolean"==typeof n?n:await X.pipeline([xe.entries,X.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),X.filter(([t])=>We.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),X.map(async([r,n])=>{const o=await We.getKeyword(r).compile(n,t,e);return[r,xe.uri(n),o]}),X.all],e)]}},interpret:(e,r,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=We.getKeyword(e).interpret(i,r,n);return t.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:L.uri(r),valid:a}),a});return t.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:L.uri(r),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&We.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&We.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Me={Core:We,Schema:xe,Instance:L,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Fe}},Ne=Me.Core,Ze=Me.Schema,Je=Me.Instance,Ge=Me.Keywords;exports.Core=Ne,exports.Instance=Je,exports.Keywords=Ge,exports.Schema=Ze,exports.default=Me; | ||
*/function D(e){var t=String(e);if(q.test(t))return t;if(t.length>0&&!C.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(U,"\\$1")+'"'}function W(e){this.parameters=Object.create(null),this.type=e}var F={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!B.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!q.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+D(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!B.test(n))throw new TypeError("invalid media type");var o=new W(n.toLowerCase());if(-1!==r){var a,i,s;for(_.lastIndex=r;i=_.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(R,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},M=async e=>Object.entries(await e),N=r(async(e,t)=>(await t).map(e)),Z=r(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),J=r(async(e,t,r={})=>Z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),G=r(async(e,t)=>{const r=await N(e,t);return(await Promise.all(r)).some(e=>e)}),H=r(async(e,t)=>{const r=await N(e,t);return(await Promise.all(r)).every(e=>e)}),Q=r((e,t)=>e.reduce(async(e,t)=>t(await e),t)),X={entries:M,map:N,filter:J,reduce:Z,some:G,every:H,pipeline:Q,all:e=>Promise.all(e),allValues:e=>Q([M,Z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},Y=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(re.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?ee(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+te(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,i=r.path,s=r.host;return 0===e.length?a=i:(i=i.substring(0,i.lastIndexOf("/")),a=te(i+"/"+e)),s+=""!==a||t||o?a+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:ee(e)}};function ee(e){return e+("/"===e[e.length-1]?"":"/")}function te(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const re=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var ne=fetch;const{jsonTypeOf:oe,splitUrl:ae}=m,ie={},se={},ce=(e,t)=>{const r=e in se?se[e]:e;if(r in ie)return ie[r][t]},ue={},le={},fe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ae(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ce(n,"baseToken"),a=ce(n,"anchorToken"),i=ae(t)[0];if(!i&&!ae(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ve(i,e[o]||""),[c,u]=ae(s);delete e[o],u&&o===a&&(e[a]=a!==o?encodeURI(u):"#"+encodeURI(u)),i&&(le[i]=c);const l={},f=ce(n,"recursiveAnchorToken");let d;!0===e[f]&&(l["#"]=c,e[a]="",delete e[f]);const p=ce(n,"vocabularyToken");oe(e[p],"object")?(se[c]=n,d=e[p],delete e[p]):d=c===n?{[n]:!0}:{};const y={};ue[c]={id:c,schemaVersion:n,schema:de(e,c,n,h.nil,y,l),anchors:y,dynamicAnchors:l,vocabulary:d,validated:!1}},de=(e,t,r,n,o,a)=>{if(oe(e,"object")){const i="string"==typeof e.$schema?ae(e.$schema)[0]:r,s=ce(i,"embeddedToken"),c=ce(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ve(t,e[s]);return e[s]=n,fe(e,n,r),g(e[s],e)}const u=ce(r,"anchorToken"),l=ce(r,"dynamicAnchorToken");"string"==typeof e[l]&&(a["#"+e[l]]=t,e[u]=e[l],delete e[l]);const f=ce(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=ce(r,"jrefToken");if("string"==typeof e[d])return g(e[d],e);for(let i in e)e[i]=de(e[i],t,r,h.append(i,n),o,a);const p=ce(r,"jsrefToken");"string"==typeof e[p]&&(e[p]=g(e[p],e[p]));const y=ce(r,"dynamicJsrefToken");return"string"==typeof e[y]&&(e[y]=g(e[y],e[y],!0)),e}return Array.isArray(e)?e.map((e,i)=>de(e,t,r,h.append(i,n),o,a)):e},pe=e=>ue[le[e]]||ue[e],he=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,dynamicAnchors:{}}),ye=async(e,t=he,r=!1)=>{const n=r&&t.dynamicAnchors[e]?t.dynamicAnchors[e]:ge(t),o=ve(n,e),[a,i]=ae(o);if(!(e=>e in ue||e in le)(a)){const e=await ne(a,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+a);if(e.headers.has("content-type")){const t=F.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${a} is not a schema. Found a document with media type: ${t}`)}fe(await e.json(),a)}const s=pe(a),c=i&&"/"!==i[0]?we(s,i):i,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:h.get(c,s.schema),dynamicAnchors:{...s.dynamicAnchors,...t.dynamicAnchors},validated:s.validated});return me(u)},me=e=>O(e.value)?ye(E(e.value),e,x(e.value)):e,ve=(e,t)=>{const r=Y(e,t),n=ae(e)[0];if(n&&"file"===be(r)&&"file"!==be(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},be=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},we=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ge=e=>`${e.id}#${encodeURI(e.pointer)}`,Oe=e=>O(e.value)?j(e.value):e.value,Ee=(e,t)=>{const r=pe(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:h.append(e,t.pointer),schema:r.schema,value:Oe(t)[e],dynamicAnchors:t.dynamicAnchors,validated:r.validated});return me(n)},je=r((e,t)=>X.pipeline([Oe,X.map(async(r,n)=>e(await Ee(n,t),n)),X.all],t));var xe={setConfig:(e,t,r)=>{ie[e]||(ie[e]={}),ie[e][t]=r},getConfig:ce,add:fe,get:ye,markValidated:e=>{ue[e].validated=!0},uri:ge,value:Oe,typeOf:(e,t)=>oe(Oe(e),t),has:(e,t)=>e in Oe(t),step:Ee,keys:e=>Object.keys(Oe(e)),entries:e=>X.pipeline([Oe,Object.keys,X.map(async t=>[t,await Ee(t,e)]),X.all],e),map:je,length:e=>Oe(e).length};class $e extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Ae=$e;const Pe="FLAG",Se="BASIC",Te="DETAILED",Ie="VERBOSE";let Ve=Te,ke=!0;const ze=(e,r)=>(n,o=Pe)=>{if(![Pe,Se,Te,Ie].includes(o))throw Error(`The '${o}' error format is not supported`);let a=[];const i=t.subscribe("result",Ke(o,a));return De(r,n,e),t.unsubscribe(i),a[0]},Ke=(e,t)=>{const r=[];return(n,o)=>{const a={...o,errors:[]};for(;r.length>0&&Le(r[r.length-1],a);){const t=r.pop();let n=[];e===Se&&(n=t.errors,delete t.errors),a.errors.unshift(t,...n)}(e===Ie||e!==Pe&&!a.valid)&&r.push(a),t[0]=a}},Le=(e,t)=>e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||t.keyword.endsWith("#validate")&&e.instanceLocation===t.instanceLocation,_e={},Ce=e=>_e[e],qe=e=>e in _e,Re={},Ue={},Be=async(e,t)=>{if(!qe(e.schemaVersion+"#validate")){const t=await xe.get(e.schemaVersion);(xe.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Re)Object.entries(Re[e]).forEach(([e,r])=>{((e,t)=>{_e[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ke&&!e.validated){if(xe.markValidated(e.id),!(e.schemaVersion in Ue)){const t=await xe.get(e.schemaVersion),r={},n=await Be(t,r);Ue[t.id]=ze(r,n)}const t=L.cons(e.schema,e.id),r=Ue[e.schemaVersion](t,Ve);if(!r.valid)throw new Ae(r)}return await Ce(e.schemaVersion+"#validate").compile(e,t),xe.uri(e)},De=(e,t,r)=>{const[n]=r[e];return Ce(n).interpret(e,t,r)};var We={validate:async(e,t,r)=>{const n={},o=await Be(e,n),a=(e,t=Pe)=>ze(n,o)(L.cons(e),t);return void 0===t?a:a(t,r)},setMetaOutputFormat:e=>{Ve=e},setShouldMetaValidate:e=>{ke=e},FLAG:Pe,BASIC:Se,DETAILED:Te,VERBOSE:Ie,getKeyword:Ce,hasKeyword:qe,defineVocabulary:(e,t)=>{Re[e]=t},compileSchema:Be,interpretSchema:De,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Ce(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Ce(o).collectEvaluatedItems(e,t,r,n)}};var Fe={compile:async(e,t)=>{const r=xe.uri(e);if(!(r in t)){t[r]=!1;const n=xe.value(e);t[r]=[e.schemaVersion+"#validate",xe.uri(e),"boolean"==typeof n?n:await X.pipeline([xe.entries,X.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),X.filter(([t])=>We.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),X.map(async([r,n])=>{const o=await We.getKeyword(r).compile(n,t,e);return[r,xe.uri(n),o]}),X.all],e)]}},interpret:(e,r,n)=>{const[o,a,i]=n[e],s="boolean"==typeof i?i:i.every(([e,o,a])=>{const i=We.getKeyword(e).interpret(a,r,n);return t.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:L.uri(r),valid:i}),i});return t.publishSync("result",{keyword:o,absoluteKeywordLocation:a,instanceLocation:L.uri(r),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const a=e&&We.getKeyword(n).collectEvaluatedProperties(o,t,r);return a&&e.concat(a)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const a=!1!==e&&We.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==a&&Math.max(e,a)},0)}},Me={Core:We,Schema:xe,Instance:L,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Fe}},Ne=Me.Core,Ze=Me.Schema,Je=Me.Instance,Ge=Me.Keywords;exports.Core=Ne,exports.Instance=Je,exports.Keywords=Ge,exports.Schema=Ze,exports.default=Me; | ||
//# sourceMappingURL=json-schema-core-cjs.min.js.map |
@@ -1146,6 +1146,6 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
// recursiveAnchor | ||
const recursiveAnchors = {}; | ||
const dynamicAnchors = {}; | ||
const recursiveAnchorToken = getConfig(schemaVersion, "recursiveAnchorToken"); | ||
if (schema[recursiveAnchorToken] === true) { | ||
recursiveAnchors["#"] = id; | ||
dynamicAnchors["#"] = id; | ||
schema[anchorToken] = ""; | ||
@@ -1173,5 +1173,5 @@ delete schema[recursiveAnchorToken]; | ||
schemaVersion: schemaVersion, | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, recursiveAnchors), | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, dynamicAnchors), | ||
anchors: anchors, | ||
recursiveAnchors: recursiveAnchors, | ||
dynamicAnchors: dynamicAnchors, | ||
vocabulary: vocabulary, | ||
@@ -1182,3 +1182,3 @@ validated: false | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, recursiveAnchors) => { | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, dynamicAnchors) => { | ||
if (jsonTypeOf$2(subject, "object")) { | ||
@@ -1198,3 +1198,3 @@ const embeddedSchemaVersion = typeof subject["$schema"] === "string" ? splitUrl$1(subject["$schema"])[0] : schemaVersion; | ||
if (typeof subject[dynamicAnchorToken] === "string") { | ||
recursiveAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
dynamicAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
subject[anchorToken] = subject[dynamicAnchorToken]; | ||
@@ -1216,7 +1216,5 @@ delete subject[dynamicAnchorToken]; | ||
subject = Object.entries(subject) | ||
.reduce((acc, [key, value]) => { | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
return acc; | ||
}, {}); | ||
for (let key in subject) { | ||
subject[key] = processSchema(subject[key], id, schemaVersion, jsonPointer.append(key, pointer), anchors, dynamicAnchors); | ||
} | ||
@@ -1235,3 +1233,3 @@ const jsrefToken = getConfig(schemaVersion, "jsrefToken"); | ||
} else if (Array.isArray(subject)) { | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, dynamicAnchors)); | ||
} else { | ||
@@ -1250,6 +1248,6 @@ return subject; | ||
// Schema Retrieval | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchors: {} }); | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, dynamicAnchors: {} }); | ||
const get$1 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const contextUrl = recursive && contextDoc.dynamicAnchors[url] ? contextDoc.dynamicAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
@@ -1284,3 +1282,3 @@ const [id, fragment] = splitUrl$1(resolvedUrl); | ||
value: jsonPointer.get(pointer, storedSchema.schema), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
dynamicAnchors: { ...storedSchema.dynamicAnchors, ...contextDoc.dynamicAnchors }, | ||
validated: storedSchema.validated | ||
@@ -1331,3 +1329,3 @@ }); | ||
value: value$2(doc)[key], | ||
recursiveAnchors: doc.recursiveAnchors, | ||
dynamicAnchors: doc.dynamicAnchors, | ||
validated: storedSchema.validated | ||
@@ -1334,0 +1332,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(t,r){!function(e,n){var o={};e.PubSub=o;var i=e.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==t&&t.exports&&(r=t.exports=o),r.PubSub=o,t.exports=r=o)}("object"==typeof window&&window||e)})),r=(t.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const n=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(l)},o=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const i=e.shift();return{...t,[i]:o(e,d(t,i,n),r,c(i,n))}}if(Array.isArray(t)){const n=[...t];return n[f(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:d(t,e[0],n)},i=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||p(t)){const o=e.shift();i(e,d(t,o,n),r,c(o,n))}else{t[f(t,e[0])]=r}},a=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=d(t,n,r);return{...t,[n]:a(e,o,c(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return d(t,e[0],r)}},s=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=d(t,n,r);s(e,o,c(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:d(t,e[0],r)},c=r((e,t)=>t+"/"+u(e)),u=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),f=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,d=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(p(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[f(e,t)]},p=e=>null===e||"object"!=typeof e;var h={nil:"",append:c,get:(e,t)=>{const r=n(e),o=e=>r.reduce(([e,t],r)=>[d(e,r,t),c(r,t)],[e,""])[0];return void 0===t?o:o(t)},set:(e,t,i)=>{const a=n(e),s=r((e,t)=>o(a,e,t,""));return void 0===t?s:s(t,i)},assign:(e,t,o)=>{const a=n(e),s=r((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,o)},unset:(e,t)=>{const r=n(e),o=e=>a(r,e,"");return void 0===t?o:o(t)},delete:(e,t)=>{const r=n(e),o=e=>s(r,e,"");return void 0===t?o:o(t)}};const y={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e};var v={jsonTypeOf:(e,t)=>y[t](e),splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const m=Symbol("$__value"),b=Symbol("$__href"),w=Symbol("$__isDynamic");var g=(e,t,r=!1)=>Object.freeze({[b]:e,[m]:t,[w]:r}),O=e=>e&&void 0!==e[b],E=e=>e[b],j=e=>e[m],$=e=>e[w];const{jsonTypeOf:A}=v,x=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),P=e=>O(e.value)?j(e.value):e.value,S=r((e,t)=>A(P(e),t)),T=(e,t)=>Object.freeze({...t,pointer:h.append(e,t.pointer),value:P(t)[e]}),I=r((e,t)=>P(t).map((r,n,o,i)=>e(T(n,t),n,o,i))),V=r((e,t)=>P(t).map((e,r,n,o)=>T(r,t)).filter((t,r,n,o)=>e(t,r,n,o))),k=r((e,t,r)=>P(r).reduce((t,n,o)=>e(t,T(o,r),o),t)),z=r((e,t)=>P(t).every((r,n,o,i)=>e(T(n,t),n,o,i))),K=r((e,t)=>P(t).some((r,n,o,i)=>e(T(n,t),n,o,i)));var L={cons:(e,t="")=>Object.freeze({...x,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:P,typeOf:S,step:T,entries:e=>Object.keys(P(e)).map(t=>[t,T(t,e)]),keys:e=>Object.keys(P(e)),map:I,filter:V,reduce:k,every:z,some:K,length:e=>P(e).length},C=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,q=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,_=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,R=/\\([\u000b\u0020-\u00ff])/g,U=/([\\"])/g,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(t,r){!function(e,n){var o={};e.PubSub=o;var a=e.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function a(e,t,r){e(t,r)}function i(e,r,n,i){var s,c=t[r],u=i?a:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,a){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(i(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),i(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,a);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),a=r.lastIndexOf(".");!o&&-1!==a;)a=(r=r.substr(0,a)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!i&&"string"==typeof r,c="function"==typeof r,u=!1;if(!i){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(a in o)o.hasOwnProperty(a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof a&&a.amd?a((function(){return o})):(void 0!==t&&t.exports&&(r=t.exports=o),r.PubSub=o,t.exports=r=o)}("object"==typeof window&&window||e)})),r=(t.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const n=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(l)},o=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const a=e.shift();return{...t,[a]:o(e,d(t,a,n),r,c(a,n))}}if(Array.isArray(t)){const n=[...t];return n[f(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:d(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||p(t)){const o=e.shift();a(e,d(t,o,n),r,c(o,n))}else{t[f(t,e[0])]=r}},i=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=d(t,n,r);return{...t,[n]:i(e,o,c(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return d(t,e[0],r)}},s=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=d(t,n,r);s(e,o,c(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:d(t,e[0],r)},c=r((e,t)=>t+"/"+u(e)),u=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),f=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,d=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(p(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[f(e,t)]},p=e=>null===e||"object"!=typeof e;var h={nil:"",append:c,get:(e,t)=>{const r=n(e),o=e=>r.reduce(([e,t],r)=>[d(e,r,t),c(r,t)],[e,""])[0];return void 0===t?o:o(t)},set:(e,t,a)=>{const i=n(e),s=r((e,t)=>o(i,e,t,""));return void 0===t?s:s(t,a)},assign:(e,t,o)=>{const i=n(e),s=r((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,o)},unset:(e,t)=>{const r=n(e),o=e=>i(r,e,"");return void 0===t?o:o(t)},delete:(e,t)=>{const r=n(e),o=e=>s(r,e,"");return void 0===t?o:o(t)}};const y={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e};var m={jsonTypeOf:(e,t)=>y[t](e),splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const v=Symbol("$__value"),b=Symbol("$__href"),w=Symbol("$__isDynamic");var g=(e,t,r=!1)=>Object.freeze({[b]:e,[v]:t,[w]:r}),O=e=>e&&void 0!==e[b],E=e=>e[b],j=e=>e[v],$=e=>e[w];const{jsonTypeOf:A}=m,x=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),P=e=>O(e.value)?j(e.value):e.value,S=r((e,t)=>A(P(e),t)),T=(e,t)=>Object.freeze({...t,pointer:h.append(e,t.pointer),value:P(t)[e]}),I=r((e,t)=>P(t).map((r,n,o,a)=>e(T(n,t),n,o,a))),V=r((e,t)=>P(t).map((e,r,n,o)=>T(r,t)).filter((t,r,n,o)=>e(t,r,n,o))),k=r((e,t,r)=>P(r).reduce((t,n,o)=>e(t,T(o,r),o),t)),z=r((e,t)=>P(t).every((r,n,o,a)=>e(T(n,t),n,o,a))),K=r((e,t)=>P(t).some((r,n,o,a)=>e(T(n,t),n,o,a)));var L={cons:(e,t="")=>Object.freeze({...x,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:P,typeOf:S,step:T,entries:e=>Object.keys(P(e)).map(t=>[t,T(t,e)]),keys:e=>Object.keys(P(e)),map:I,filter:V,reduce:k,every:z,some:K,length:e=>P(e).length},C=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,q=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,_=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,R=/\\([\u000b\u0020-\u00ff])/g,U=/([\\"])/g,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function D(e){var t=String(e);if(_.test(t))return t;if(t.length>0&&!q.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(U,"\\$1")+'"'}function W(e){this.parameters=Object.create(null),this.type=e}var F={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!B.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!_.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+D(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!B.test(n))throw new TypeError("invalid media type");var o=new W(n.toLowerCase());if(-1!==r){var i,a,s;for(C.lastIndex=r;a=C.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(R,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},N=async e=>Object.entries(await e),Z=r(async(e,t)=>(await t).map(e)),J=r(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),M=r(async(e,t,r={})=>J(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),G=r(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).some(e=>e)}),H=r(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).every(e=>e)}),Q=r((e,t)=>e.reduce(async(e,t)=>t(await e),t)),X={entries:N,map:Z,filter:M,reduce:J,some:G,every:H,pipeline:Q,all:e=>Promise.all(e),allValues:e=>Q([N,J(async(e,[t,r])=>(e[t]=await r,e),{})],e)},Y=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(re.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?ee(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+te(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=te(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:ee(e)}};function ee(e){return e+("/"===e[e.length-1]?"":"/")}function te(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const re=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var ne=fetch;const{jsonTypeOf:oe,splitUrl:ie}=v,ae={},se={},ce=(e,t)=>{const r=e in se?se[e]:e;if(r in ae)return ae[r][t]},ue={},le={},fe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ie(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ce(n,"baseToken"),i=ce(n,"anchorToken"),a=ie(t)[0];if(!a&&!ie(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=me(a,e[o]||""),[c,u]=ie(s);delete e[o],u&&o===i&&(e[i]=i!==o?encodeURI(u):"#"+encodeURI(u)),a&&(le[a]=c);const l={},f=ce(n,"recursiveAnchorToken");let d;!0===e[f]&&(l["#"]=c,e[i]="",delete e[f]);const p=ce(n,"vocabularyToken");oe(e[p],"object")?(se[c]=n,d=e[p],delete e[p]):d=c===n?{[n]:!0}:{};const y={};ue[c]={id:c,schemaVersion:n,schema:de(e,c,n,h.nil,y,l),anchors:y,recursiveAnchors:l,vocabulary:d,validated:!1}},de=(e,t,r,n,o,i)=>{if(oe(e,"object")){const a="string"==typeof e.$schema?ie(e.$schema)[0]:r,s=ce(a,"embeddedToken"),c=ce(a,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=me(t,e[s]);return e[s]=n,fe(e,n,r),g(e[s],e)}const u=ce(r,"anchorToken"),l=ce(r,"dynamicAnchorToken");"string"==typeof e[l]&&(i["#"+e[l]]=t,e[u]=e[l],delete e[l]);const f=ce(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=ce(r,"jrefToken");if("string"==typeof e[d])return g(e[d],e);e=Object.entries(e).reduce((e,[a,s])=>(e[a]=de(s,t,r,h.append(a,n),o,i),e),{});const p=ce(r,"jsrefToken");"string"==typeof e[p]&&(e[p]=g(e[p],e[p]));const y=ce(r,"dynamicJsrefToken");return"string"==typeof e[y]&&(e[y]=g(e[y],e[y],!0)),e}return Array.isArray(e)?e.map((e,a)=>de(e,t,r,h.append(a,n),o,i)):e},pe=e=>ue[le[e]]||ue[e],he=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ye=async(e,t=he,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:ge(t),o=me(n,e),[i,a]=ie(o);if(!(e=>e in ue||e in le)(i)){const e=await ne(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=F.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}fe(await e.json(),i)}const s=pe(i),c=a&&"/"!==a[0]?we(s,a):a,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:h.get(c,s.schema),recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated});return ve(u)},ve=e=>O(e.value)?ye(E(e.value),e,$(e.value)):e,me=(e,t)=>{const r=Y(e,t),n=ie(e)[0];if(n&&"file"===be(r)&&"file"!==be(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},be=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},we=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ge=e=>`${e.id}#${encodeURI(e.pointer)}`,Oe=e=>O(e.value)?j(e.value):e.value,Ee=(e,t)=>{const r=pe(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:h.append(e,t.pointer),schema:r.schema,value:Oe(t)[e],recursiveAnchors:t.recursiveAnchors,validated:r.validated});return ve(n)},je=r((e,t)=>X.pipeline([Oe,X.map(async(r,n)=>e(await Ee(n,t),n)),X.all],t));var $e={setConfig:(e,t,r)=>{ae[e]||(ae[e]={}),ae[e][t]=r},getConfig:ce,add:fe,get:ye,markValidated:e=>{ue[e].validated=!0},uri:ge,value:Oe,typeOf:(e,t)=>oe(Oe(e),t),has:(e,t)=>e in Oe(t),step:Ee,keys:e=>Object.keys(Oe(e)),entries:e=>X.pipeline([Oe,Object.keys,X.map(async t=>[t,await Ee(t,e)]),X.all],e),map:je,length:e=>Oe(e).length};class Ae extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var xe=Ae;const Pe="FLAG",Se="BASIC",Te="DETAILED",Ie="VERBOSE";let Ve=Te,ke=!0;const ze=(e,r)=>(n,o=Pe)=>{if(![Pe,Se,Te,Ie].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=t.subscribe("result",Ke(o,i));return De(r,n,e),t.unsubscribe(a),i[0]},Ke=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Le(r[r.length-1],i);){const t=r.pop();let n=[];e===Se&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n)}(e===Ie||e!==Pe&&!i.valid)&&r.push(i),t[0]=i}},Le=(e,t)=>e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||t.keyword.endsWith("#validate")&&e.instanceLocation===t.instanceLocation,Ce={},qe=e=>Ce[e],_e=e=>e in Ce,Re={},Ue={},Be=async(e,t)=>{if(!_e(e.schemaVersion+"#validate")){const t=await $e.get(e.schemaVersion);($e.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Re)Object.entries(Re[e]).forEach(([e,r])=>{((e,t)=>{Ce[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ke&&!e.validated){if($e.markValidated(e.id),!(e.schemaVersion in Ue)){const t=await $e.get(e.schemaVersion),r={},n=await Be(t,r);Ue[t.id]=ze(r,n)}const t=L.cons(e.schema,e.id),r=Ue[e.schemaVersion](t,Ve);if(!r.valid)throw new xe(r)}return await qe(e.schemaVersion+"#validate").compile(e,t),$e.uri(e)},De=(e,t,r)=>{const[n]=r[e];return qe(n).interpret(e,t,r)};var We={validate:async(e,t,r)=>{const n={},o=await Be(e,n),i=(e,t=Pe)=>ze(n,o)(L.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{Ve=e},setShouldMetaValidate:e=>{ke=e},FLAG:Pe,BASIC:Se,DETAILED:Te,VERBOSE:Ie,getKeyword:qe,hasKeyword:_e,defineVocabulary:(e,t)=>{Re[e]=t},compileSchema:Be,interpretSchema:De,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return qe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return qe(o).collectEvaluatedItems(e,t,r,n)}};var Fe={compile:async(e,t)=>{const r=$e.uri(e);if(!(r in t)){t[r]=!1;const n=$e.value(e);t[r]=[e.schemaVersion+"#validate",$e.uri(e),"boolean"==typeof n?n:await X.pipeline([$e.entries,X.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),X.filter(([t])=>We.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),X.map(async([r,n])=>{const o=await We.getKeyword(r).compile(n,t,e);return[r,$e.uri(n),o]}),X.all],e)]}},interpret:(e,r,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=We.getKeyword(e).interpret(i,r,n);return t.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:L.uri(r),valid:a}),a});return t.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:L.uri(r),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&We.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&We.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ne={Core:We,Schema:$e,Instance:L,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Fe}},Ze=Ne.Core,Je=Ne.Schema,Me=Ne.Instance,Ge=Ne.Keywords;export default Ne;export{Ze as Core,Me as Instance,Ge as Keywords,Je as Schema}; | ||
*/function D(e){var t=String(e);if(_.test(t))return t;if(t.length>0&&!q.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(U,"\\$1")+'"'}function W(e){this.parameters=Object.create(null),this.type=e}var F={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!B.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!_.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+D(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!B.test(n))throw new TypeError("invalid media type");var o=new W(n.toLowerCase());if(-1!==r){var a,i,s;for(C.lastIndex=r;i=C.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(R,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},N=async e=>Object.entries(await e),Z=r(async(e,t)=>(await t).map(e)),J=r(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),M=r(async(e,t,r={})=>J(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),G=r(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).some(e=>e)}),H=r(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).every(e=>e)}),Q=r((e,t)=>e.reduce(async(e,t)=>t(await e),t)),X={entries:N,map:Z,filter:M,reduce:J,some:G,every:H,pipeline:Q,all:e=>Promise.all(e),allValues:e=>Q([N,J(async(e,[t,r])=>(e[t]=await r,e),{})],e)},Y=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(re.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?ee(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+te(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,i=r.path,s=r.host;return 0===e.length?a=i:(i=i.substring(0,i.lastIndexOf("/")),a=te(i+"/"+e)),s+=""!==a||t||o?a+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:ee(e)}};function ee(e){return e+("/"===e[e.length-1]?"":"/")}function te(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const re=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var ne=fetch;const{jsonTypeOf:oe,splitUrl:ae}=m,ie={},se={},ce=(e,t)=>{const r=e in se?se[e]:e;if(r in ie)return ie[r][t]},ue={},le={},fe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ae(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ce(n,"baseToken"),a=ce(n,"anchorToken"),i=ae(t)[0];if(!i&&!ae(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ve(i,e[o]||""),[c,u]=ae(s);delete e[o],u&&o===a&&(e[a]=a!==o?encodeURI(u):"#"+encodeURI(u)),i&&(le[i]=c);const l={},f=ce(n,"recursiveAnchorToken");let d;!0===e[f]&&(l["#"]=c,e[a]="",delete e[f]);const p=ce(n,"vocabularyToken");oe(e[p],"object")?(se[c]=n,d=e[p],delete e[p]):d=c===n?{[n]:!0}:{};const y={};ue[c]={id:c,schemaVersion:n,schema:de(e,c,n,h.nil,y,l),anchors:y,dynamicAnchors:l,vocabulary:d,validated:!1}},de=(e,t,r,n,o,a)=>{if(oe(e,"object")){const i="string"==typeof e.$schema?ae(e.$schema)[0]:r,s=ce(i,"embeddedToken"),c=ce(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ve(t,e[s]);return e[s]=n,fe(e,n,r),g(e[s],e)}const u=ce(r,"anchorToken"),l=ce(r,"dynamicAnchorToken");"string"==typeof e[l]&&(a["#"+e[l]]=t,e[u]=e[l],delete e[l]);const f=ce(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=ce(r,"jrefToken");if("string"==typeof e[d])return g(e[d],e);for(let i in e)e[i]=de(e[i],t,r,h.append(i,n),o,a);const p=ce(r,"jsrefToken");"string"==typeof e[p]&&(e[p]=g(e[p],e[p]));const y=ce(r,"dynamicJsrefToken");return"string"==typeof e[y]&&(e[y]=g(e[y],e[y],!0)),e}return Array.isArray(e)?e.map((e,i)=>de(e,t,r,h.append(i,n),o,a)):e},pe=e=>ue[le[e]]||ue[e],he=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,dynamicAnchors:{}}),ye=async(e,t=he,r=!1)=>{const n=r&&t.dynamicAnchors[e]?t.dynamicAnchors[e]:ge(t),o=ve(n,e),[a,i]=ae(o);if(!(e=>e in ue||e in le)(a)){const e=await ne(a,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+a);if(e.headers.has("content-type")){const t=F.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${a} is not a schema. Found a document with media type: ${t}`)}fe(await e.json(),a)}const s=pe(a),c=i&&"/"!==i[0]?we(s,i):i,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:h.get(c,s.schema),dynamicAnchors:{...s.dynamicAnchors,...t.dynamicAnchors},validated:s.validated});return me(u)},me=e=>O(e.value)?ye(E(e.value),e,$(e.value)):e,ve=(e,t)=>{const r=Y(e,t),n=ae(e)[0];if(n&&"file"===be(r)&&"file"!==be(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},be=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},we=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ge=e=>`${e.id}#${encodeURI(e.pointer)}`,Oe=e=>O(e.value)?j(e.value):e.value,Ee=(e,t)=>{const r=pe(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:h.append(e,t.pointer),schema:r.schema,value:Oe(t)[e],dynamicAnchors:t.dynamicAnchors,validated:r.validated});return me(n)},je=r((e,t)=>X.pipeline([Oe,X.map(async(r,n)=>e(await Ee(n,t),n)),X.all],t));var $e={setConfig:(e,t,r)=>{ie[e]||(ie[e]={}),ie[e][t]=r},getConfig:ce,add:fe,get:ye,markValidated:e=>{ue[e].validated=!0},uri:ge,value:Oe,typeOf:(e,t)=>oe(Oe(e),t),has:(e,t)=>e in Oe(t),step:Ee,keys:e=>Object.keys(Oe(e)),entries:e=>X.pipeline([Oe,Object.keys,X.map(async t=>[t,await Ee(t,e)]),X.all],e),map:je,length:e=>Oe(e).length};class Ae extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var xe=Ae;const Pe="FLAG",Se="BASIC",Te="DETAILED",Ie="VERBOSE";let Ve=Te,ke=!0;const ze=(e,r)=>(n,o=Pe)=>{if(![Pe,Se,Te,Ie].includes(o))throw Error(`The '${o}' error format is not supported`);let a=[];const i=t.subscribe("result",Ke(o,a));return De(r,n,e),t.unsubscribe(i),a[0]},Ke=(e,t)=>{const r=[];return(n,o)=>{const a={...o,errors:[]};for(;r.length>0&&Le(r[r.length-1],a);){const t=r.pop();let n=[];e===Se&&(n=t.errors,delete t.errors),a.errors.unshift(t,...n)}(e===Ie||e!==Pe&&!a.valid)&&r.push(a),t[0]=a}},Le=(e,t)=>e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||t.keyword.endsWith("#validate")&&e.instanceLocation===t.instanceLocation,Ce={},qe=e=>Ce[e],_e=e=>e in Ce,Re={},Ue={},Be=async(e,t)=>{if(!_e(e.schemaVersion+"#validate")){const t=await $e.get(e.schemaVersion);($e.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Re)Object.entries(Re[e]).forEach(([e,r])=>{((e,t)=>{Ce[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ke&&!e.validated){if($e.markValidated(e.id),!(e.schemaVersion in Ue)){const t=await $e.get(e.schemaVersion),r={},n=await Be(t,r);Ue[t.id]=ze(r,n)}const t=L.cons(e.schema,e.id),r=Ue[e.schemaVersion](t,Ve);if(!r.valid)throw new xe(r)}return await qe(e.schemaVersion+"#validate").compile(e,t),$e.uri(e)},De=(e,t,r)=>{const[n]=r[e];return qe(n).interpret(e,t,r)};var We={validate:async(e,t,r)=>{const n={},o=await Be(e,n),a=(e,t=Pe)=>ze(n,o)(L.cons(e),t);return void 0===t?a:a(t,r)},setMetaOutputFormat:e=>{Ve=e},setShouldMetaValidate:e=>{ke=e},FLAG:Pe,BASIC:Se,DETAILED:Te,VERBOSE:Ie,getKeyword:qe,hasKeyword:_e,defineVocabulary:(e,t)=>{Re[e]=t},compileSchema:Be,interpretSchema:De,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return qe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return qe(o).collectEvaluatedItems(e,t,r,n)}};var Fe={compile:async(e,t)=>{const r=$e.uri(e);if(!(r in t)){t[r]=!1;const n=$e.value(e);t[r]=[e.schemaVersion+"#validate",$e.uri(e),"boolean"==typeof n?n:await X.pipeline([$e.entries,X.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),X.filter(([t])=>We.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),X.map(async([r,n])=>{const o=await We.getKeyword(r).compile(n,t,e);return[r,$e.uri(n),o]}),X.all],e)]}},interpret:(e,r,n)=>{const[o,a,i]=n[e],s="boolean"==typeof i?i:i.every(([e,o,a])=>{const i=We.getKeyword(e).interpret(a,r,n);return t.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:L.uri(r),valid:i}),i});return t.publishSync("result",{keyword:o,absoluteKeywordLocation:a,instanceLocation:L.uri(r),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const a=e&&We.getKeyword(n).collectEvaluatedProperties(o,t,r);return a&&e.concat(a)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const a=!1!==e&&We.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==a&&Math.max(e,a)},0)}},Ne={Core:We,Schema:$e,Instance:L,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Fe}},Ze=Ne.Core,Je=Ne.Schema,Me=Ne.Instance,Ge=Ne.Keywords;export default Ne;export{Ze as Core,Me as Instance,Ge as Keywords,Je as Schema}; | ||
//# sourceMappingURL=json-schema-core-esm.min.js.map |
@@ -1149,6 +1149,6 @@ var JSC = (function (exports) { | ||
// recursiveAnchor | ||
const recursiveAnchors = {}; | ||
const dynamicAnchors = {}; | ||
const recursiveAnchorToken = getConfig(schemaVersion, "recursiveAnchorToken"); | ||
if (schema[recursiveAnchorToken] === true) { | ||
recursiveAnchors["#"] = id; | ||
dynamicAnchors["#"] = id; | ||
schema[anchorToken] = ""; | ||
@@ -1176,5 +1176,5 @@ delete schema[recursiveAnchorToken]; | ||
schemaVersion: schemaVersion, | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, recursiveAnchors), | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, dynamicAnchors), | ||
anchors: anchors, | ||
recursiveAnchors: recursiveAnchors, | ||
dynamicAnchors: dynamicAnchors, | ||
vocabulary: vocabulary, | ||
@@ -1185,3 +1185,3 @@ validated: false | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, recursiveAnchors) => { | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, dynamicAnchors) => { | ||
if (jsonTypeOf$2(subject, "object")) { | ||
@@ -1201,3 +1201,3 @@ const embeddedSchemaVersion = typeof subject["$schema"] === "string" ? splitUrl$1(subject["$schema"])[0] : schemaVersion; | ||
if (typeof subject[dynamicAnchorToken] === "string") { | ||
recursiveAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
dynamicAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
subject[anchorToken] = subject[dynamicAnchorToken]; | ||
@@ -1219,7 +1219,5 @@ delete subject[dynamicAnchorToken]; | ||
subject = Object.entries(subject) | ||
.reduce((acc, [key, value]) => { | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
return acc; | ||
}, {}); | ||
for (let key in subject) { | ||
subject[key] = processSchema(subject[key], id, schemaVersion, jsonPointer.append(key, pointer), anchors, dynamicAnchors); | ||
} | ||
@@ -1238,3 +1236,3 @@ const jsrefToken = getConfig(schemaVersion, "jsrefToken"); | ||
} else if (Array.isArray(subject)) { | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, dynamicAnchors)); | ||
} else { | ||
@@ -1253,6 +1251,6 @@ return subject; | ||
// Schema Retrieval | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchors: {} }); | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, dynamicAnchors: {} }); | ||
const get$1 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const contextUrl = recursive && contextDoc.dynamicAnchors[url] ? contextDoc.dynamicAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
@@ -1287,3 +1285,3 @@ const [id, fragment] = splitUrl$1(resolvedUrl); | ||
value: jsonPointer.get(pointer, storedSchema.schema), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
dynamicAnchors: { ...storedSchema.dynamicAnchors, ...contextDoc.dynamicAnchors }, | ||
validated: storedSchema.validated | ||
@@ -1334,3 +1332,3 @@ }); | ||
value: value$2(doc)[key], | ||
recursiveAnchors: doc.recursiveAnchors, | ||
dynamicAnchors: doc.dynamicAnchors, | ||
validated: storedSchema.validated | ||
@@ -1337,0 +1335,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
var JSC=function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};const v={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e};var m={jsonTypeOf:(e,t)=>v[t](e),splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const b=Symbol("$__value"),w=Symbol("$__href"),g=Symbol("$__isDynamic");var O=(e,t,r=!1)=>Object.freeze({[w]:e,[b]:t,[g]:r}),E=e=>e&&void 0!==e[w],j=e=>e[w],$=e=>e[b],A=e=>e[g];const{jsonTypeOf:S}=m,P=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),x=e=>E(e.value)?$(e.value):e.value,T=n((e,t)=>S(x(e),t)),I=(e,t)=>Object.freeze({...t,pointer:y.append(e,t.pointer),value:x(t)[e]}),V=n((e,t)=>x(t).map((r,n,o,i)=>e(I(n,t),n,o,i))),k=n((e,t)=>x(t).map((e,r,n,o)=>I(r,t)).filter((t,r,n,o)=>e(t,r,n,o))),z=n((e,t,r)=>x(r).reduce((t,n,o)=>e(t,I(o,r),o),t)),C=n((e,t)=>x(t).every((r,n,o,i)=>e(I(n,t),n,o,i))),K=n((e,t)=>x(t).some((r,n,o,i)=>e(I(n,t),n,o,i)));var L={cons:(e,t="")=>Object.freeze({...P,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:x,typeOf:T,step:I,entries:e=>Object.keys(x(e)).map(t=>[t,I(t,e)]),keys:e=>Object.keys(x(e)),map:V,filter:k,reduce:z,every:C,some:K,length:e=>x(e).length},q=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,_=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,U=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
var JSC=function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var a=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function a(e,t,r){e(t,r)}function i(e,r,n,i){var s,c=t[r],u=i?a:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,a){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(i(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),i(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,a);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),a=r.lastIndexOf(".");!o&&-1!==a;)a=(r=r.substr(0,a)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!i&&"string"==typeof r,c="function"==typeof r,u=!1;if(!i){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(a in o)o.hasOwnProperty(a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof a&&a.amd?a((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},a=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:a(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},i=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();i(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};const m={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e};var v={jsonTypeOf:(e,t)=>m[t](e),splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const b=Symbol("$__value"),w=Symbol("$__href"),g=Symbol("$__isDynamic");var O=(e,t,r=!1)=>Object.freeze({[w]:e,[b]:t,[g]:r}),E=e=>e&&void 0!==e[w],j=e=>e[w],$=e=>e[b],A=e=>e[g];const{jsonTypeOf:S}=v,P=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),x=e=>E(e.value)?$(e.value):e.value,T=n((e,t)=>S(x(e),t)),I=(e,t)=>Object.freeze({...t,pointer:y.append(e,t.pointer),value:x(t)[e]}),V=n((e,t)=>x(t).map((r,n,o,a)=>e(I(n,t),n,o,a))),k=n((e,t)=>x(t).map((e,r,n,o)=>I(r,t)).filter((t,r,n,o)=>e(t,r,n,o))),z=n((e,t,r)=>x(r).reduce((t,n,o)=>e(t,I(o,r),o),t)),C=n((e,t)=>x(t).every((r,n,o,a)=>e(I(n,t),n,o,a))),K=n((e,t)=>x(t).some((r,n,o,a)=>e(I(n,t),n,o,a)));var L={cons:(e,t="")=>Object.freeze({...P,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:x,typeOf:T,step:I,entries:e=>Object.keys(x(e)).map(t=>[t,I(t,e)]),keys:e=>Object.keys(x(e)),map:V,filter:k,reduce:z,every:C,some:K,length:e=>x(e).length},q=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,_=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,U=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function W(e){var t=String(e);if(R.test(t))return t;if(t.length>0&&!_.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function F(e){this.parameters=Object.create(null),this.type=e}var J={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!D.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!R.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+W(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!D.test(n))throw new TypeError("invalid media type");var o=new F(n.toLowerCase());if(-1!==r){var i,a,s;for(q.lastIndex=r;a=q.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(U,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},N=async e=>Object.entries(await e),Z=n(async(e,t)=>(await t).map(e)),M=n(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),G=n(async(e,t,r={})=>M(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),H=n(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).some(e=>e)}),Q=n(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).every(e=>e)}),X=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),Y={entries:N,map:Z,filter:G,reduce:M,some:H,every:Q,pipeline:X,all:e=>Promise.all(e),allValues:e=>X([N,M(async(e,[t,r])=>(e[t]=await r,e),{})],e)},ee=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(ne.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?te(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+re(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=re(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:te(e)}};function te(e){return e+("/"===e[e.length-1]?"":"/")}function re(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const ne=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var oe=fetch;const{jsonTypeOf:ie,splitUrl:ae}=m,se={},ce={},ue=(e,t)=>{const r=e in ce?ce[e]:e;if(r in se)return se[r][t]},le={},fe={},de=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ae(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ue(n,"baseToken"),i=ue(n,"anchorToken"),a=ae(t)[0];if(!a&&!ae(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=be(a,e[o]||""),[c,u]=ae(s);delete e[o],u&&o===i&&(e[i]=i!==o?encodeURI(u):"#"+encodeURI(u)),a&&(fe[a]=c);const l={},f=ue(n,"recursiveAnchorToken");let d;!0===e[f]&&(l["#"]=c,e[i]="",delete e[f]);const p=ue(n,"vocabularyToken");ie(e[p],"object")?(ce[c]=n,d=e[p],delete e[p]):d=c===n?{[n]:!0}:{};const h={};le[c]={id:c,schemaVersion:n,schema:pe(e,c,n,y.nil,h,l),anchors:h,recursiveAnchors:l,vocabulary:d,validated:!1}},pe=(e,t,r,n,o,i)=>{if(ie(e,"object")){const a="string"==typeof e.$schema?ae(e.$schema)[0]:r,s=ue(a,"embeddedToken"),c=ue(a,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=be(t,e[s]);return e[s]=n,de(e,n,r),O(e[s],e)}const u=ue(r,"anchorToken"),l=ue(r,"dynamicAnchorToken");"string"==typeof e[l]&&(i["#"+e[l]]=t,e[u]=e[l],delete e[l]);const f=ue(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=ue(r,"jrefToken");if("string"==typeof e[d])return O(e[d],e);e=Object.entries(e).reduce((e,[a,s])=>(e[a]=pe(s,t,r,y.append(a,n),o,i),e),{});const p=ue(r,"jsrefToken");"string"==typeof e[p]&&(e[p]=O(e[p],e[p]));const h=ue(r,"dynamicJsrefToken");return"string"==typeof e[h]&&(e[h]=O(e[h],e[h],!0)),e}return Array.isArray(e)?e.map((e,a)=>pe(e,t,r,y.append(a,n),o,i)):e},he=e=>le[fe[e]]||le[e],ye=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ve=async(e,t=ye,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:Oe(t),o=be(n,e),[i,a]=ae(o);if(!(e=>e in le||e in fe)(i)){const e=await oe(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=J.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}de(await e.json(),i)}const s=he(i),c=a&&"/"!==a[0]?ge(s,a):a,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:y.get(c,s.schema),recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated});return me(u)},me=e=>E(e.value)?ve(j(e.value),e,A(e.value)):e,be=(e,t)=>{const r=ee(e,t),n=ae(e)[0];if(n&&"file"===we(r)&&"file"!==we(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},we=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},ge=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},Oe=e=>`${e.id}#${encodeURI(e.pointer)}`,Ee=e=>E(e.value)?$(e.value):e.value,je=(e,t)=>{const r=he(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:y.append(e,t.pointer),schema:r.schema,value:Ee(t)[e],recursiveAnchors:t.recursiveAnchors,validated:r.validated});return me(n)},$e=n((e,t)=>Y.pipeline([Ee,Y.map(async(r,n)=>e(await je(n,t),n)),Y.all],t));var Ae={setConfig:(e,t,r)=>{se[e]||(se[e]={}),se[e][t]=r},getConfig:ue,add:de,get:ve,markValidated:e=>{le[e].validated=!0},uri:Oe,value:Ee,typeOf:(e,t)=>ie(Ee(e),t),has:(e,t)=>e in Ee(t),step:je,keys:e=>Object.keys(Ee(e)),entries:e=>Y.pipeline([Ee,Object.keys,Y.map(async t=>[t,await je(t,e)]),Y.all],e),map:$e,length:e=>Ee(e).length};class Se extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Pe=Se;const xe="FLAG",Te="BASIC",Ie="DETAILED",Ve="VERBOSE";let ke=Ie,ze=!0;const Ce=(e,t)=>(n,o=xe)=>{if(![xe,Te,Ie,Ve].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Ke(o,i));return We(t,n,e),r.unsubscribe(a),i[0]},Ke=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Le(r[r.length-1],i);){const t=r.pop();let n=[];e===Te&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n)}(e===Ve||e!==xe&&!i.valid)&&r.push(i),t[0]=i}},Le=(e,t)=>e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||t.keyword.endsWith("#validate")&&e.instanceLocation===t.instanceLocation,qe={},_e=e=>qe[e],Re=e=>e in qe,Ue={},Be={},De=async(e,t)=>{if(!Re(e.schemaVersion+"#validate")){const t=await Ae.get(e.schemaVersion);(Ae.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ue)Object.entries(Ue[e]).forEach(([e,r])=>{((e,t)=>{qe[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ze&&!e.validated){if(Ae.markValidated(e.id),!(e.schemaVersion in Be)){const t=await Ae.get(e.schemaVersion),r={},n=await De(t,r);Be[t.id]=Ce(r,n)}const t=L.cons(e.schema,e.id),r=Be[e.schemaVersion](t,ke);if(!r.valid)throw new Pe(r)}return await _e(e.schemaVersion+"#validate").compile(e,t),Ae.uri(e)},We=(e,t,r)=>{const[n]=r[e];return _e(n).interpret(e,t,r)};var Fe={validate:async(e,t,r)=>{const n={},o=await De(e,n),i=(e,t=xe)=>Ce(n,o)(L.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ke=e},setShouldMetaValidate:e=>{ze=e},FLAG:xe,BASIC:Te,DETAILED:Ie,VERBOSE:Ve,getKeyword:_e,hasKeyword:Re,defineVocabulary:(e,t)=>{Ue[e]=t},compileSchema:De,interpretSchema:We,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return _e(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return _e(o).collectEvaluatedItems(e,t,r,n)}};var Je={compile:async(e,t)=>{const r=Ae.uri(e);if(!(r in t)){t[r]=!1;const n=Ae.value(e);t[r]=[e.schemaVersion+"#validate",Ae.uri(e),"boolean"==typeof n?n:await Y.pipeline([Ae.entries,Y.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),Y.filter(([t])=>Fe.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),Y.map(async([r,n])=>{const o=await Fe.getKeyword(r).compile(n,t,e);return[r,Ae.uri(n),o]}),Y.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Fe.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:L.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:L.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Fe.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Fe.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ne={Core:Fe,Schema:Ae,Instance:L,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Je}},Ze=Ne.Core,Me=Ne.Schema,Ge=Ne.Instance,He=Ne.Keywords;return e.Core=Ze,e.Instance=Ge,e.Keywords=He,e.Schema=Me,e.default=Ne,e}({}); | ||
*/function W(e){var t=String(e);if(R.test(t))return t;if(t.length>0&&!_.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function F(e){this.parameters=Object.create(null),this.type=e}var J={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!D.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!R.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+W(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!D.test(n))throw new TypeError("invalid media type");var o=new F(n.toLowerCase());if(-1!==r){var a,i,s;for(q.lastIndex=r;i=q.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(U,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},N=async e=>Object.entries(await e),Z=n(async(e,t)=>(await t).map(e)),M=n(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),G=n(async(e,t,r={})=>M(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),H=n(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).some(e=>e)}),Q=n(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).every(e=>e)}),X=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),Y={entries:N,map:Z,filter:G,reduce:M,some:H,every:Q,pipeline:X,all:e=>Promise.all(e),allValues:e=>X([N,M(async(e,[t,r])=>(e[t]=await r,e),{})],e)},ee=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(ne.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?te(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+re(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,i=r.path,s=r.host;return 0===e.length?a=i:(i=i.substring(0,i.lastIndexOf("/")),a=re(i+"/"+e)),s+=""!==a||t||o?a+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:te(e)}};function te(e){return e+("/"===e[e.length-1]?"":"/")}function re(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const ne=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var oe=fetch;const{jsonTypeOf:ae,splitUrl:ie}=v,se={},ce={},ue=(e,t)=>{const r=e in ce?ce[e]:e;if(r in se)return se[r][t]},le={},fe={},de=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ie(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ue(n,"baseToken"),a=ue(n,"anchorToken"),i=ie(t)[0];if(!i&&!ie(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=be(i,e[o]||""),[c,u]=ie(s);delete e[o],u&&o===a&&(e[a]=a!==o?encodeURI(u):"#"+encodeURI(u)),i&&(fe[i]=c);const l={},f=ue(n,"recursiveAnchorToken");let d;!0===e[f]&&(l["#"]=c,e[a]="",delete e[f]);const p=ue(n,"vocabularyToken");ae(e[p],"object")?(ce[c]=n,d=e[p],delete e[p]):d=c===n?{[n]:!0}:{};const h={};le[c]={id:c,schemaVersion:n,schema:pe(e,c,n,y.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1}},pe=(e,t,r,n,o,a)=>{if(ae(e,"object")){const i="string"==typeof e.$schema?ie(e.$schema)[0]:r,s=ue(i,"embeddedToken"),c=ue(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=be(t,e[s]);return e[s]=n,de(e,n,r),O(e[s],e)}const u=ue(r,"anchorToken"),l=ue(r,"dynamicAnchorToken");"string"==typeof e[l]&&(a["#"+e[l]]=t,e[u]=e[l],delete e[l]);const f=ue(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=ue(r,"jrefToken");if("string"==typeof e[d])return O(e[d],e);for(let i in e)e[i]=pe(e[i],t,r,y.append(i,n),o,a);const p=ue(r,"jsrefToken");"string"==typeof e[p]&&(e[p]=O(e[p],e[p]));const h=ue(r,"dynamicJsrefToken");return"string"==typeof e[h]&&(e[h]=O(e[h],e[h],!0)),e}return Array.isArray(e)?e.map((e,i)=>pe(e,t,r,y.append(i,n),o,a)):e},he=e=>le[fe[e]]||le[e],ye=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,dynamicAnchors:{}}),me=async(e,t=ye,r=!1)=>{const n=r&&t.dynamicAnchors[e]?t.dynamicAnchors[e]:Oe(t),o=be(n,e),[a,i]=ie(o);if(!(e=>e in le||e in fe)(a)){const e=await oe(a,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+a);if(e.headers.has("content-type")){const t=J.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${a} is not a schema. Found a document with media type: ${t}`)}de(await e.json(),a)}const s=he(a),c=i&&"/"!==i[0]?ge(s,i):i,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:y.get(c,s.schema),dynamicAnchors:{...s.dynamicAnchors,...t.dynamicAnchors},validated:s.validated});return ve(u)},ve=e=>E(e.value)?me(j(e.value),e,A(e.value)):e,be=(e,t)=>{const r=ee(e,t),n=ie(e)[0];if(n&&"file"===we(r)&&"file"!==we(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},we=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},ge=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},Oe=e=>`${e.id}#${encodeURI(e.pointer)}`,Ee=e=>E(e.value)?$(e.value):e.value,je=(e,t)=>{const r=he(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:y.append(e,t.pointer),schema:r.schema,value:Ee(t)[e],dynamicAnchors:t.dynamicAnchors,validated:r.validated});return ve(n)},$e=n((e,t)=>Y.pipeline([Ee,Y.map(async(r,n)=>e(await je(n,t),n)),Y.all],t));var Ae={setConfig:(e,t,r)=>{se[e]||(se[e]={}),se[e][t]=r},getConfig:ue,add:de,get:me,markValidated:e=>{le[e].validated=!0},uri:Oe,value:Ee,typeOf:(e,t)=>ae(Ee(e),t),has:(e,t)=>e in Ee(t),step:je,keys:e=>Object.keys(Ee(e)),entries:e=>Y.pipeline([Ee,Object.keys,Y.map(async t=>[t,await je(t,e)]),Y.all],e),map:$e,length:e=>Ee(e).length};class Se extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Pe=Se;const xe="FLAG",Te="BASIC",Ie="DETAILED",Ve="VERBOSE";let ke=Ie,ze=!0;const Ce=(e,t)=>(n,o=xe)=>{if(![xe,Te,Ie,Ve].includes(o))throw Error(`The '${o}' error format is not supported`);let a=[];const i=r.subscribe("result",Ke(o,a));return We(t,n,e),r.unsubscribe(i),a[0]},Ke=(e,t)=>{const r=[];return(n,o)=>{const a={...o,errors:[]};for(;r.length>0&&Le(r[r.length-1],a);){const t=r.pop();let n=[];e===Te&&(n=t.errors,delete t.errors),a.errors.unshift(t,...n)}(e===Ve||e!==xe&&!a.valid)&&r.push(a),t[0]=a}},Le=(e,t)=>e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||t.keyword.endsWith("#validate")&&e.instanceLocation===t.instanceLocation,qe={},_e=e=>qe[e],Re=e=>e in qe,Ue={},Be={},De=async(e,t)=>{if(!Re(e.schemaVersion+"#validate")){const t=await Ae.get(e.schemaVersion);(Ae.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ue)Object.entries(Ue[e]).forEach(([e,r])=>{((e,t)=>{qe[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ze&&!e.validated){if(Ae.markValidated(e.id),!(e.schemaVersion in Be)){const t=await Ae.get(e.schemaVersion),r={},n=await De(t,r);Be[t.id]=Ce(r,n)}const t=L.cons(e.schema,e.id),r=Be[e.schemaVersion](t,ke);if(!r.valid)throw new Pe(r)}return await _e(e.schemaVersion+"#validate").compile(e,t),Ae.uri(e)},We=(e,t,r)=>{const[n]=r[e];return _e(n).interpret(e,t,r)};var Fe={validate:async(e,t,r)=>{const n={},o=await De(e,n),a=(e,t=xe)=>Ce(n,o)(L.cons(e),t);return void 0===t?a:a(t,r)},setMetaOutputFormat:e=>{ke=e},setShouldMetaValidate:e=>{ze=e},FLAG:xe,BASIC:Te,DETAILED:Ie,VERBOSE:Ve,getKeyword:_e,hasKeyword:Re,defineVocabulary:(e,t)=>{Ue[e]=t},compileSchema:De,interpretSchema:We,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return _e(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return _e(o).collectEvaluatedItems(e,t,r,n)}};var Je={compile:async(e,t)=>{const r=Ae.uri(e);if(!(r in t)){t[r]=!1;const n=Ae.value(e);t[r]=[e.schemaVersion+"#validate",Ae.uri(e),"boolean"==typeof n?n:await Y.pipeline([Ae.entries,Y.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),Y.filter(([t])=>Fe.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),Y.map(async([r,n])=>{const o=await Fe.getKeyword(r).compile(n,t,e);return[r,Ae.uri(n),o]}),Y.all],e)]}},interpret:(e,t,n)=>{const[o,a,i]=n[e],s="boolean"==typeof i?i:i.every(([e,o,a])=>{const i=Fe.getKeyword(e).interpret(a,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:L.uri(t),valid:i}),i});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:a,instanceLocation:L.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const a=e&&Fe.getKeyword(n).collectEvaluatedProperties(o,t,r);return a&&e.concat(a)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const a=!1!==e&&Fe.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==a&&Math.max(e,a)},0)}},Ne={Core:Fe,Schema:Ae,Instance:L,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Je}},Ze=Ne.Core,Me=Ne.Schema,Ge=Ne.Instance,He=Ne.Keywords;return e.Core=Ze,e.Instance=Ge,e.Keywords=He,e.Schema=Me,e.default=Ne,e}({}); | ||
//# sourceMappingURL=json-schema-core-iife.min.js.map |
@@ -1151,6 +1151,6 @@ System.register('JSC', [], function (exports) { | ||
// recursiveAnchor | ||
const recursiveAnchors = {}; | ||
const dynamicAnchors = {}; | ||
const recursiveAnchorToken = getConfig(schemaVersion, "recursiveAnchorToken"); | ||
if (schema[recursiveAnchorToken] === true) { | ||
recursiveAnchors["#"] = id; | ||
dynamicAnchors["#"] = id; | ||
schema[anchorToken] = ""; | ||
@@ -1178,5 +1178,5 @@ delete schema[recursiveAnchorToken]; | ||
schemaVersion: schemaVersion, | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, recursiveAnchors), | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, dynamicAnchors), | ||
anchors: anchors, | ||
recursiveAnchors: recursiveAnchors, | ||
dynamicAnchors: dynamicAnchors, | ||
vocabulary: vocabulary, | ||
@@ -1187,3 +1187,3 @@ validated: false | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, recursiveAnchors) => { | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, dynamicAnchors) => { | ||
if (jsonTypeOf$2(subject, "object")) { | ||
@@ -1203,3 +1203,3 @@ const embeddedSchemaVersion = typeof subject["$schema"] === "string" ? splitUrl$1(subject["$schema"])[0] : schemaVersion; | ||
if (typeof subject[dynamicAnchorToken] === "string") { | ||
recursiveAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
dynamicAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
subject[anchorToken] = subject[dynamicAnchorToken]; | ||
@@ -1221,7 +1221,5 @@ delete subject[dynamicAnchorToken]; | ||
subject = Object.entries(subject) | ||
.reduce((acc, [key, value]) => { | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
return acc; | ||
}, {}); | ||
for (let key in subject) { | ||
subject[key] = processSchema(subject[key], id, schemaVersion, jsonPointer.append(key, pointer), anchors, dynamicAnchors); | ||
} | ||
@@ -1240,3 +1238,3 @@ const jsrefToken = getConfig(schemaVersion, "jsrefToken"); | ||
} else if (Array.isArray(subject)) { | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, dynamicAnchors)); | ||
} else { | ||
@@ -1255,6 +1253,6 @@ return subject; | ||
// Schema Retrieval | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchors: {} }); | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, dynamicAnchors: {} }); | ||
const get$1 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const contextUrl = recursive && contextDoc.dynamicAnchors[url] ? contextDoc.dynamicAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
@@ -1289,3 +1287,3 @@ const [id, fragment] = splitUrl$1(resolvedUrl); | ||
value: jsonPointer.get(pointer, storedSchema.schema), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
dynamicAnchors: { ...storedSchema.dynamicAnchors, ...contextDoc.dynamicAnchors }, | ||
validated: storedSchema.validated | ||
@@ -1336,3 +1334,3 @@ }); | ||
value: value$2(doc)[key], | ||
recursiveAnchors: doc.recursiveAnchors, | ||
dynamicAnchors: doc.dynamicAnchors, | ||
validated: storedSchema.validated | ||
@@ -1339,0 +1337,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
System.register("JSC",[],(function(e){"use strict";return{execute:function(){var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};const v={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e};var m={jsonTypeOf:(e,t)=>v[t](e),splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const b=Symbol("$__value"),w=Symbol("$__href"),g=Symbol("$__isDynamic");var O=(e,t,r=!1)=>Object.freeze({[w]:e,[b]:t,[g]:r}),E=e=>e&&void 0!==e[w],j=e=>e[w],$=e=>e[b],A=e=>e[g];const{jsonTypeOf:S}=m,x=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),P=e=>E(e.value)?$(e.value):e.value,T=n((e,t)=>S(P(e),t)),I=(e,t)=>Object.freeze({...t,pointer:y.append(e,t.pointer),value:P(t)[e]}),V=n((e,t)=>P(t).map((r,n,o,i)=>e(I(n,t),n,o,i))),k=n((e,t)=>P(t).map((e,r,n,o)=>I(r,t)).filter((t,r,n,o)=>e(t,r,n,o))),z=n((e,t,r)=>P(r).reduce((t,n,o)=>e(t,I(o,r),o),t)),C=n((e,t)=>P(t).every((r,n,o,i)=>e(I(n,t),n,o,i))),K=n((e,t)=>P(t).some((r,n,o,i)=>e(I(n,t),n,o,i)));var L={cons:(e,t="")=>Object.freeze({...x,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:P,typeOf:T,step:I,entries:e=>Object.keys(P(e)).map(t=>[t,I(t,e)]),keys:e=>Object.keys(P(e)),map:V,filter:k,reduce:z,every:C,some:K,length:e=>P(e).length},q=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,_=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,U=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
System.register("JSC",[],(function(e){"use strict";return{execute:function(){var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};const m={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e};var v={jsonTypeOf:(e,t)=>m[t](e),splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const b=Symbol("$__value"),w=Symbol("$__href"),g=Symbol("$__isDynamic");var O=(e,t,r=!1)=>Object.freeze({[w]:e,[b]:t,[g]:r}),E=e=>e&&void 0!==e[w],j=e=>e[w],$=e=>e[b],A=e=>e[g];const{jsonTypeOf:S}=v,x=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),P=e=>E(e.value)?$(e.value):e.value,T=n((e,t)=>S(P(e),t)),I=(e,t)=>Object.freeze({...t,pointer:y.append(e,t.pointer),value:P(t)[e]}),V=n((e,t)=>P(t).map((r,n,o,i)=>e(I(n,t),n,o,i))),k=n((e,t)=>P(t).map((e,r,n,o)=>I(r,t)).filter((t,r,n,o)=>e(t,r,n,o))),z=n((e,t,r)=>P(r).reduce((t,n,o)=>e(t,I(o,r),o),t)),C=n((e,t)=>P(t).every((r,n,o,i)=>e(I(n,t),n,o,i))),K=n((e,t)=>P(t).some((r,n,o,i)=>e(I(n,t),n,o,i)));var L={cons:(e,t="")=>Object.freeze({...x,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:P,typeOf:T,step:I,entries:e=>Object.keys(P(e)).map(t=>[t,I(t,e)]),keys:e=>Object.keys(P(e)),map:V,filter:k,reduce:z,every:C,some:K,length:e=>P(e).length},q=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,_=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,U=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function W(e){var t=String(e);if(R.test(t))return t;if(t.length>0&&!_.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function F(e){this.parameters=Object.create(null),this.type=e}var J={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!D.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!R.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+W(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!D.test(n))throw new TypeError("invalid media type");var o=new F(n.toLowerCase());if(-1!==r){var i,a,s;for(q.lastIndex=r;a=q.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(U,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},N=async e=>Object.entries(await e),Z=n(async(e,t)=>(await t).map(e)),M=n(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),G=n(async(e,t,r={})=>M(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),H=n(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).some(e=>e)}),Q=n(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).every(e=>e)}),X=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),Y={entries:N,map:Z,filter:G,reduce:M,some:H,every:Q,pipeline:X,all:e=>Promise.all(e),allValues:e=>X([N,M(async(e,[t,r])=>(e[t]=await r,e),{})],e)},ee=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(ne.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?te(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+re(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=re(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:te(e)}};function te(e){return e+("/"===e[e.length-1]?"":"/")}function re(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const ne=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var oe=fetch;const{jsonTypeOf:ie,splitUrl:ae}=m,se={},ce={},ue=(e,t)=>{const r=e in ce?ce[e]:e;if(r in se)return se[r][t]},le={},fe={},de=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ae(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ue(n,"baseToken"),i=ue(n,"anchorToken"),a=ae(t)[0];if(!a&&!ae(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=be(a,e[o]||""),[c,u]=ae(s);delete e[o],u&&o===i&&(e[i]=i!==o?encodeURI(u):"#"+encodeURI(u)),a&&(fe[a]=c);const l={},f=ue(n,"recursiveAnchorToken");let d;!0===e[f]&&(l["#"]=c,e[i]="",delete e[f]);const p=ue(n,"vocabularyToken");ie(e[p],"object")?(ce[c]=n,d=e[p],delete e[p]):d=c===n?{[n]:!0}:{};const h={};le[c]={id:c,schemaVersion:n,schema:pe(e,c,n,y.nil,h,l),anchors:h,recursiveAnchors:l,vocabulary:d,validated:!1}},pe=(e,t,r,n,o,i)=>{if(ie(e,"object")){const a="string"==typeof e.$schema?ae(e.$schema)[0]:r,s=ue(a,"embeddedToken"),c=ue(a,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=be(t,e[s]);return e[s]=n,de(e,n,r),O(e[s],e)}const u=ue(r,"anchorToken"),l=ue(r,"dynamicAnchorToken");"string"==typeof e[l]&&(i["#"+e[l]]=t,e[u]=e[l],delete e[l]);const f=ue(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=ue(r,"jrefToken");if("string"==typeof e[d])return O(e[d],e);e=Object.entries(e).reduce((e,[a,s])=>(e[a]=pe(s,t,r,y.append(a,n),o,i),e),{});const p=ue(r,"jsrefToken");"string"==typeof e[p]&&(e[p]=O(e[p],e[p]));const h=ue(r,"dynamicJsrefToken");return"string"==typeof e[h]&&(e[h]=O(e[h],e[h],!0)),e}return Array.isArray(e)?e.map((e,a)=>pe(e,t,r,y.append(a,n),o,i)):e},he=e=>le[fe[e]]||le[e],ye=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ve=async(e,t=ye,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:Oe(t),o=be(n,e),[i,a]=ae(o);if(!(e=>e in le||e in fe)(i)){const e=await oe(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=J.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}de(await e.json(),i)}const s=he(i),c=a&&"/"!==a[0]?ge(s,a):a,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:y.get(c,s.schema),recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated});return me(u)},me=e=>E(e.value)?ve(j(e.value),e,A(e.value)):e,be=(e,t)=>{const r=ee(e,t),n=ae(e)[0];if(n&&"file"===we(r)&&"file"!==we(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},we=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},ge=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},Oe=e=>`${e.id}#${encodeURI(e.pointer)}`,Ee=e=>E(e.value)?$(e.value):e.value,je=(e,t)=>{const r=he(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:y.append(e,t.pointer),schema:r.schema,value:Ee(t)[e],recursiveAnchors:t.recursiveAnchors,validated:r.validated});return me(n)},$e=n((e,t)=>Y.pipeline([Ee,Y.map(async(r,n)=>e(await je(n,t),n)),Y.all],t));var Ae={setConfig:(e,t,r)=>{se[e]||(se[e]={}),se[e][t]=r},getConfig:ue,add:de,get:ve,markValidated:e=>{le[e].validated=!0},uri:Oe,value:Ee,typeOf:(e,t)=>ie(Ee(e),t),has:(e,t)=>e in Ee(t),step:je,keys:e=>Object.keys(Ee(e)),entries:e=>Y.pipeline([Ee,Object.keys,Y.map(async t=>[t,await je(t,e)]),Y.all],e),map:$e,length:e=>Ee(e).length};class Se extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var xe=Se;const Pe="FLAG",Te="BASIC",Ie="DETAILED",Ve="VERBOSE";let ke=Ie,ze=!0;const Ce=(e,t)=>(n,o=Pe)=>{if(![Pe,Te,Ie,Ve].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Ke(o,i));return We(t,n,e),r.unsubscribe(a),i[0]},Ke=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Le(r[r.length-1],i);){const t=r.pop();let n=[];e===Te&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n)}(e===Ve||e!==Pe&&!i.valid)&&r.push(i),t[0]=i}},Le=(e,t)=>e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||t.keyword.endsWith("#validate")&&e.instanceLocation===t.instanceLocation,qe={},_e=e=>qe[e],Re=e=>e in qe,Ue={},Be={},De=async(e,t)=>{if(!Re(e.schemaVersion+"#validate")){const t=await Ae.get(e.schemaVersion);(Ae.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ue)Object.entries(Ue[e]).forEach(([e,r])=>{((e,t)=>{qe[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ze&&!e.validated){if(Ae.markValidated(e.id),!(e.schemaVersion in Be)){const t=await Ae.get(e.schemaVersion),r={},n=await De(t,r);Be[t.id]=Ce(r,n)}const t=L.cons(e.schema,e.id),r=Be[e.schemaVersion](t,ke);if(!r.valid)throw new xe(r)}return await _e(e.schemaVersion+"#validate").compile(e,t),Ae.uri(e)},We=(e,t,r)=>{const[n]=r[e];return _e(n).interpret(e,t,r)};var Fe={validate:async(e,t,r)=>{const n={},o=await De(e,n),i=(e,t=Pe)=>Ce(n,o)(L.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ke=e},setShouldMetaValidate:e=>{ze=e},FLAG:Pe,BASIC:Te,DETAILED:Ie,VERBOSE:Ve,getKeyword:_e,hasKeyword:Re,defineVocabulary:(e,t)=>{Ue[e]=t},compileSchema:De,interpretSchema:We,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return _e(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return _e(o).collectEvaluatedItems(e,t,r,n)}};var Je={compile:async(e,t)=>{const r=Ae.uri(e);if(!(r in t)){t[r]=!1;const n=Ae.value(e);t[r]=[e.schemaVersion+"#validate",Ae.uri(e),"boolean"==typeof n?n:await Y.pipeline([Ae.entries,Y.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),Y.filter(([t])=>Fe.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),Y.map(async([r,n])=>{const o=await Fe.getKeyword(r).compile(n,t,e);return[r,Ae.uri(n),o]}),Y.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Fe.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:L.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:L.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Fe.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Fe.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ne=e("default",{Core:Fe,Schema:Ae,Instance:L,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Je}});e("Core",Ne.Core),e("Schema",Ne.Schema),e("Instance",Ne.Instance),e("Keywords",Ne.Keywords)}}})); | ||
*/function W(e){var t=String(e);if(R.test(t))return t;if(t.length>0&&!_.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function F(e){this.parameters=Object.create(null),this.type=e}var J={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!D.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!R.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+W(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!D.test(n))throw new TypeError("invalid media type");var o=new F(n.toLowerCase());if(-1!==r){var i,a,s;for(q.lastIndex=r;a=q.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(U,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},N=async e=>Object.entries(await e),Z=n(async(e,t)=>(await t).map(e)),M=n(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),G=n(async(e,t,r={})=>M(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),H=n(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).some(e=>e)}),Q=n(async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).every(e=>e)}),X=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),Y={entries:N,map:Z,filter:G,reduce:M,some:H,every:Q,pipeline:X,all:e=>Promise.all(e),allValues:e=>X([N,M(async(e,[t,r])=>(e[t]=await r,e),{})],e)},ee=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(ne.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?te(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+re(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=re(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:te(e)}};function te(e){return e+("/"===e[e.length-1]?"":"/")}function re(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const ne=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var oe=fetch;const{jsonTypeOf:ie,splitUrl:ae}=v,se={},ce={},ue=(e,t)=>{const r=e in ce?ce[e]:e;if(r in se)return se[r][t]},le={},fe={},de=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ae(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ue(n,"baseToken"),i=ue(n,"anchorToken"),a=ae(t)[0];if(!a&&!ae(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=be(a,e[o]||""),[c,u]=ae(s);delete e[o],u&&o===i&&(e[i]=i!==o?encodeURI(u):"#"+encodeURI(u)),a&&(fe[a]=c);const l={},f=ue(n,"recursiveAnchorToken");let d;!0===e[f]&&(l["#"]=c,e[i]="",delete e[f]);const p=ue(n,"vocabularyToken");ie(e[p],"object")?(ce[c]=n,d=e[p],delete e[p]):d=c===n?{[n]:!0}:{};const h={};le[c]={id:c,schemaVersion:n,schema:pe(e,c,n,y.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1}},pe=(e,t,r,n,o,i)=>{if(ie(e,"object")){const a="string"==typeof e.$schema?ae(e.$schema)[0]:r,s=ue(a,"embeddedToken"),c=ue(a,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=be(t,e[s]);return e[s]=n,de(e,n,r),O(e[s],e)}const u=ue(r,"anchorToken"),l=ue(r,"dynamicAnchorToken");"string"==typeof e[l]&&(i["#"+e[l]]=t,e[u]=e[l],delete e[l]);const f=ue(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=ue(r,"jrefToken");if("string"==typeof e[d])return O(e[d],e);for(let a in e)e[a]=pe(e[a],t,r,y.append(a,n),o,i);const p=ue(r,"jsrefToken");"string"==typeof e[p]&&(e[p]=O(e[p],e[p]));const h=ue(r,"dynamicJsrefToken");return"string"==typeof e[h]&&(e[h]=O(e[h],e[h],!0)),e}return Array.isArray(e)?e.map((e,a)=>pe(e,t,r,y.append(a,n),o,i)):e},he=e=>le[fe[e]]||le[e],ye=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,dynamicAnchors:{}}),me=async(e,t=ye,r=!1)=>{const n=r&&t.dynamicAnchors[e]?t.dynamicAnchors[e]:Oe(t),o=be(n,e),[i,a]=ae(o);if(!(e=>e in le||e in fe)(i)){const e=await oe(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=J.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}de(await e.json(),i)}const s=he(i),c=a&&"/"!==a[0]?ge(s,a):a,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:y.get(c,s.schema),dynamicAnchors:{...s.dynamicAnchors,...t.dynamicAnchors},validated:s.validated});return ve(u)},ve=e=>E(e.value)?me(j(e.value),e,A(e.value)):e,be=(e,t)=>{const r=ee(e,t),n=ae(e)[0];if(n&&"file"===we(r)&&"file"!==we(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},we=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},ge=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},Oe=e=>`${e.id}#${encodeURI(e.pointer)}`,Ee=e=>E(e.value)?$(e.value):e.value,je=(e,t)=>{const r=he(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:y.append(e,t.pointer),schema:r.schema,value:Ee(t)[e],dynamicAnchors:t.dynamicAnchors,validated:r.validated});return ve(n)},$e=n((e,t)=>Y.pipeline([Ee,Y.map(async(r,n)=>e(await je(n,t),n)),Y.all],t));var Ae={setConfig:(e,t,r)=>{se[e]||(se[e]={}),se[e][t]=r},getConfig:ue,add:de,get:me,markValidated:e=>{le[e].validated=!0},uri:Oe,value:Ee,typeOf:(e,t)=>ie(Ee(e),t),has:(e,t)=>e in Ee(t),step:je,keys:e=>Object.keys(Ee(e)),entries:e=>Y.pipeline([Ee,Object.keys,Y.map(async t=>[t,await je(t,e)]),Y.all],e),map:$e,length:e=>Ee(e).length};class Se extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var xe=Se;const Pe="FLAG",Te="BASIC",Ie="DETAILED",Ve="VERBOSE";let ke=Ie,ze=!0;const Ce=(e,t)=>(n,o=Pe)=>{if(![Pe,Te,Ie,Ve].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Ke(o,i));return We(t,n,e),r.unsubscribe(a),i[0]},Ke=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Le(r[r.length-1],i);){const t=r.pop();let n=[];e===Te&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n)}(e===Ve||e!==Pe&&!i.valid)&&r.push(i),t[0]=i}},Le=(e,t)=>e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||t.keyword.endsWith("#validate")&&e.instanceLocation===t.instanceLocation,qe={},_e=e=>qe[e],Re=e=>e in qe,Ue={},Be={},De=async(e,t)=>{if(!Re(e.schemaVersion+"#validate")){const t=await Ae.get(e.schemaVersion);(Ae.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ue)Object.entries(Ue[e]).forEach(([e,r])=>{((e,t)=>{qe[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ze&&!e.validated){if(Ae.markValidated(e.id),!(e.schemaVersion in Be)){const t=await Ae.get(e.schemaVersion),r={},n=await De(t,r);Be[t.id]=Ce(r,n)}const t=L.cons(e.schema,e.id),r=Be[e.schemaVersion](t,ke);if(!r.valid)throw new xe(r)}return await _e(e.schemaVersion+"#validate").compile(e,t),Ae.uri(e)},We=(e,t,r)=>{const[n]=r[e];return _e(n).interpret(e,t,r)};var Fe={validate:async(e,t,r)=>{const n={},o=await De(e,n),i=(e,t=Pe)=>Ce(n,o)(L.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ke=e},setShouldMetaValidate:e=>{ze=e},FLAG:Pe,BASIC:Te,DETAILED:Ie,VERBOSE:Ve,getKeyword:_e,hasKeyword:Re,defineVocabulary:(e,t)=>{Ue[e]=t},compileSchema:De,interpretSchema:We,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return _e(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return _e(o).collectEvaluatedItems(e,t,r,n)}};var Je={compile:async(e,t)=>{const r=Ae.uri(e);if(!(r in t)){t[r]=!1;const n=Ae.value(e);t[r]=[e.schemaVersion+"#validate",Ae.uri(e),"boolean"==typeof n?n:await Y.pipeline([Ae.entries,Y.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),Y.filter(([t])=>Fe.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),Y.map(async([r,n])=>{const o=await Fe.getKeyword(r).compile(n,t,e);return[r,Ae.uri(n),o]}),Y.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Fe.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:L.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:L.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Fe.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Fe.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ne=e("default",{Core:Fe,Schema:Ae,Instance:L,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Je}});e("Core",Ne.Core),e("Schema",Ne.Schema),e("Instance",Ne.Instance),e("Keywords",Ne.Keywords)}}})); | ||
//# sourceMappingURL=json-schema-core-system.min.js.map |
@@ -1152,6 +1152,6 @@ (function (global, factory) { | ||
// recursiveAnchor | ||
const recursiveAnchors = {}; | ||
const dynamicAnchors = {}; | ||
const recursiveAnchorToken = getConfig(schemaVersion, "recursiveAnchorToken"); | ||
if (schema[recursiveAnchorToken] === true) { | ||
recursiveAnchors["#"] = id; | ||
dynamicAnchors["#"] = id; | ||
schema[anchorToken] = ""; | ||
@@ -1179,5 +1179,5 @@ delete schema[recursiveAnchorToken]; | ||
schemaVersion: schemaVersion, | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, recursiveAnchors), | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, dynamicAnchors), | ||
anchors: anchors, | ||
recursiveAnchors: recursiveAnchors, | ||
dynamicAnchors: dynamicAnchors, | ||
vocabulary: vocabulary, | ||
@@ -1188,3 +1188,3 @@ validated: false | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, recursiveAnchors) => { | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, dynamicAnchors) => { | ||
if (jsonTypeOf$2(subject, "object")) { | ||
@@ -1204,3 +1204,3 @@ const embeddedSchemaVersion = typeof subject["$schema"] === "string" ? splitUrl$1(subject["$schema"])[0] : schemaVersion; | ||
if (typeof subject[dynamicAnchorToken] === "string") { | ||
recursiveAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
dynamicAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
subject[anchorToken] = subject[dynamicAnchorToken]; | ||
@@ -1222,7 +1222,5 @@ delete subject[dynamicAnchorToken]; | ||
subject = Object.entries(subject) | ||
.reduce((acc, [key, value]) => { | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
return acc; | ||
}, {}); | ||
for (let key in subject) { | ||
subject[key] = processSchema(subject[key], id, schemaVersion, jsonPointer.append(key, pointer), anchors, dynamicAnchors); | ||
} | ||
@@ -1241,3 +1239,3 @@ const jsrefToken = getConfig(schemaVersion, "jsrefToken"); | ||
} else if (Array.isArray(subject)) { | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, dynamicAnchors)); | ||
} else { | ||
@@ -1256,6 +1254,6 @@ return subject; | ||
// Schema Retrieval | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchors: {} }); | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, dynamicAnchors: {} }); | ||
const get$1 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const contextUrl = recursive && contextDoc.dynamicAnchors[url] ? contextDoc.dynamicAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
@@ -1290,3 +1288,3 @@ const [id, fragment] = splitUrl$1(resolvedUrl); | ||
value: jsonPointer.get(pointer, storedSchema.schema), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
dynamicAnchors: { ...storedSchema.dynamicAnchors, ...contextDoc.dynamicAnchors }, | ||
validated: storedSchema.validated | ||
@@ -1337,3 +1335,3 @@ }); | ||
value: value$2(doc)[key], | ||
recursiveAnchors: doc.recursiveAnchors, | ||
dynamicAnchors: doc.dynamicAnchors, | ||
validated: storedSchema.validated | ||
@@ -1340,0 +1338,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).JSC={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};const v={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e};var m={jsonTypeOf:(e,t)=>v[t](e),splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const b=Symbol("$__value"),w=Symbol("$__href"),g=Symbol("$__isDynamic");var O=(e,t,r=!1)=>Object.freeze({[w]:e,[b]:t,[g]:r}),E=e=>e&&void 0!==e[w],j=e=>e[w],$=e=>e[b],x=e=>e[g];const{jsonTypeOf:A}=m,P=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),S=e=>E(e.value)?$(e.value):e.value,T=n((e,t)=>A(S(e),t)),I=(e,t)=>Object.freeze({...t,pointer:y.append(e,t.pointer),value:S(t)[e]}),V=n((e,t)=>S(t).map((r,n,o,i)=>e(I(n,t),n,o,i))),k=n((e,t)=>S(t).map((e,r,n,o)=>I(r,t)).filter((t,r,n,o)=>e(t,r,n,o))),z=n((e,t,r)=>S(r).reduce((t,n,o)=>e(t,I(o,r),o),t)),C=n((e,t)=>S(t).every((r,n,o,i)=>e(I(n,t),n,o,i))),K=n((e,t)=>S(t).some((r,n,o,i)=>e(I(n,t),n,o,i)));var L={cons:(e,t="")=>Object.freeze({...P,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:S,typeOf:T,step:I,entries:e=>Object.keys(S(e)).map(t=>[t,I(t,e)]),keys:e=>Object.keys(S(e)),map:V,filter:k,reduce:z,every:C,some:K,length:e=>S(e).length},_=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,q=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,U=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).JSC={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};const m={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e};var v={jsonTypeOf:(e,t)=>m[t](e),splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const b=Symbol("$__value"),w=Symbol("$__href"),g=Symbol("$__isDynamic");var O=(e,t,r=!1)=>Object.freeze({[w]:e,[b]:t,[g]:r}),E=e=>e&&void 0!==e[w],j=e=>e[w],$=e=>e[b],x=e=>e[g];const{jsonTypeOf:A}=v,P=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),S=e=>E(e.value)?$(e.value):e.value,T=n((e,t)=>A(S(e),t)),I=(e,t)=>Object.freeze({...t,pointer:y.append(e,t.pointer),value:S(t)[e]}),V=n((e,t)=>S(t).map((r,n,o,i)=>e(I(n,t),n,o,i))),k=n((e,t)=>S(t).map((e,r,n,o)=>I(r,t)).filter((t,r,n,o)=>e(t,r,n,o))),z=n((e,t,r)=>S(r).reduce((t,n,o)=>e(t,I(o,r),o),t)),C=n((e,t)=>S(t).every((r,n,o,i)=>e(I(n,t),n,o,i))),K=n((e,t)=>S(t).some((r,n,o,i)=>e(I(n,t),n,o,i)));var L={cons:(e,t="")=>Object.freeze({...P,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:S,typeOf:T,step:I,entries:e=>Object.keys(S(e)).map(t=>[t,I(t,e)]),keys:e=>Object.keys(S(e)),map:V,filter:k,reduce:z,every:C,some:K,length:e=>S(e).length},_=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,q=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,U=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function W(e){var t=String(e);if(R.test(t))return t;if(t.length>0&&!q.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function F(e){this.parameters=Object.create(null),this.type=e}var J={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!D.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!R.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+W(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!D.test(n))throw new TypeError("invalid media type");var o=new F(n.toLowerCase());if(-1!==r){var i,a,s;for(_.lastIndex=r;a=_.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(U,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},M=async e=>Object.entries(await e),N=n(async(e,t)=>(await t).map(e)),Z=n(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),G=n(async(e,t,r={})=>Z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),H=n(async(e,t)=>{const r=await N(e,t);return(await Promise.all(r)).some(e=>e)}),Q=n(async(e,t)=>{const r=await N(e,t);return(await Promise.all(r)).every(e=>e)}),X=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),Y={entries:M,map:N,filter:G,reduce:Z,some:H,every:Q,pipeline:X,all:e=>Promise.all(e),allValues:e=>X([M,Z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},ee=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(ne.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?te(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+re(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=re(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:te(e)}};function te(e){return e+("/"===e[e.length-1]?"":"/")}function re(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const ne=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var oe=fetch;const{jsonTypeOf:ie,splitUrl:ae}=m,se={},ce={},ue=(e,t)=>{const r=e in ce?ce[e]:e;if(r in se)return se[r][t]},le={},fe={},de=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ae(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ue(n,"baseToken"),i=ue(n,"anchorToken"),a=ae(t)[0];if(!a&&!ae(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=be(a,e[o]||""),[c,u]=ae(s);delete e[o],u&&o===i&&(e[i]=i!==o?encodeURI(u):"#"+encodeURI(u)),a&&(fe[a]=c);const l={},f=ue(n,"recursiveAnchorToken");let d;!0===e[f]&&(l["#"]=c,e[i]="",delete e[f]);const p=ue(n,"vocabularyToken");ie(e[p],"object")?(ce[c]=n,d=e[p],delete e[p]):d=c===n?{[n]:!0}:{};const h={};le[c]={id:c,schemaVersion:n,schema:pe(e,c,n,y.nil,h,l),anchors:h,recursiveAnchors:l,vocabulary:d,validated:!1}},pe=(e,t,r,n,o,i)=>{if(ie(e,"object")){const a="string"==typeof e.$schema?ae(e.$schema)[0]:r,s=ue(a,"embeddedToken"),c=ue(a,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=be(t,e[s]);return e[s]=n,de(e,n,r),O(e[s],e)}const u=ue(r,"anchorToken"),l=ue(r,"dynamicAnchorToken");"string"==typeof e[l]&&(i["#"+e[l]]=t,e[u]=e[l],delete e[l]);const f=ue(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=ue(r,"jrefToken");if("string"==typeof e[d])return O(e[d],e);e=Object.entries(e).reduce((e,[a,s])=>(e[a]=pe(s,t,r,y.append(a,n),o,i),e),{});const p=ue(r,"jsrefToken");"string"==typeof e[p]&&(e[p]=O(e[p],e[p]));const h=ue(r,"dynamicJsrefToken");return"string"==typeof e[h]&&(e[h]=O(e[h],e[h],!0)),e}return Array.isArray(e)?e.map((e,a)=>pe(e,t,r,y.append(a,n),o,i)):e},he=e=>le[fe[e]]||le[e],ye=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ve=async(e,t=ye,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:Oe(t),o=be(n,e),[i,a]=ae(o);if(!(e=>e in le||e in fe)(i)){const e=await oe(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=J.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}de(await e.json(),i)}const s=he(i),c=a&&"/"!==a[0]?ge(s,a):a,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:y.get(c,s.schema),recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated});return me(u)},me=e=>E(e.value)?ve(j(e.value),e,x(e.value)):e,be=(e,t)=>{const r=ee(e,t),n=ae(e)[0];if(n&&"file"===we(r)&&"file"!==we(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},we=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},ge=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},Oe=e=>`${e.id}#${encodeURI(e.pointer)}`,Ee=e=>E(e.value)?$(e.value):e.value,je=(e,t)=>{const r=he(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:y.append(e,t.pointer),schema:r.schema,value:Ee(t)[e],recursiveAnchors:t.recursiveAnchors,validated:r.validated});return me(n)},$e=n((e,t)=>Y.pipeline([Ee,Y.map(async(r,n)=>e(await je(n,t),n)),Y.all],t));var xe={setConfig:(e,t,r)=>{se[e]||(se[e]={}),se[e][t]=r},getConfig:ue,add:de,get:ve,markValidated:e=>{le[e].validated=!0},uri:Oe,value:Ee,typeOf:(e,t)=>ie(Ee(e),t),has:(e,t)=>e in Ee(t),step:je,keys:e=>Object.keys(Ee(e)),entries:e=>Y.pipeline([Ee,Object.keys,Y.map(async t=>[t,await je(t,e)]),Y.all],e),map:$e,length:e=>Ee(e).length};class Ae extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Pe=Ae;const Se="FLAG",Te="BASIC",Ie="DETAILED",Ve="VERBOSE";let ke=Ie,ze=!0;const Ce=(e,t)=>(n,o=Se)=>{if(![Se,Te,Ie,Ve].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Ke(o,i));return We(t,n,e),r.unsubscribe(a),i[0]},Ke=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Le(r[r.length-1],i);){const t=r.pop();let n=[];e===Te&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n)}(e===Ve||e!==Se&&!i.valid)&&r.push(i),t[0]=i}},Le=(e,t)=>e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||t.keyword.endsWith("#validate")&&e.instanceLocation===t.instanceLocation,_e={},qe=e=>_e[e],Re=e=>e in _e,Ue={},Be={},De=async(e,t)=>{if(!Re(e.schemaVersion+"#validate")){const t=await xe.get(e.schemaVersion);(xe.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ue)Object.entries(Ue[e]).forEach(([e,r])=>{((e,t)=>{_e[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ze&&!e.validated){if(xe.markValidated(e.id),!(e.schemaVersion in Be)){const t=await xe.get(e.schemaVersion),r={},n=await De(t,r);Be[t.id]=Ce(r,n)}const t=L.cons(e.schema,e.id),r=Be[e.schemaVersion](t,ke);if(!r.valid)throw new Pe(r)}return await qe(e.schemaVersion+"#validate").compile(e,t),xe.uri(e)},We=(e,t,r)=>{const[n]=r[e];return qe(n).interpret(e,t,r)};var Fe={validate:async(e,t,r)=>{const n={},o=await De(e,n),i=(e,t=Se)=>Ce(n,o)(L.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ke=e},setShouldMetaValidate:e=>{ze=e},FLAG:Se,BASIC:Te,DETAILED:Ie,VERBOSE:Ve,getKeyword:qe,hasKeyword:Re,defineVocabulary:(e,t)=>{Ue[e]=t},compileSchema:De,interpretSchema:We,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return qe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return qe(o).collectEvaluatedItems(e,t,r,n)}};var Je={compile:async(e,t)=>{const r=xe.uri(e);if(!(r in t)){t[r]=!1;const n=xe.value(e);t[r]=[e.schemaVersion+"#validate",xe.uri(e),"boolean"==typeof n?n:await Y.pipeline([xe.entries,Y.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),Y.filter(([t])=>Fe.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),Y.map(async([r,n])=>{const o=await Fe.getKeyword(r).compile(n,t,e);return[r,xe.uri(n),o]}),Y.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Fe.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:L.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:L.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Fe.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Fe.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Me={Core:Fe,Schema:xe,Instance:L,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Je}},Ne=Me.Core,Ze=Me.Schema,Ge=Me.Instance,He=Me.Keywords;e.Core=Ne,e.Instance=Ge,e.Keywords=He,e.Schema=Ze,e.default=Me,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
*/function W(e){var t=String(e);if(R.test(t))return t;if(t.length>0&&!q.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function F(e){this.parameters=Object.create(null),this.type=e}var J={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!D.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!R.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+W(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!D.test(n))throw new TypeError("invalid media type");var o=new F(n.toLowerCase());if(-1!==r){var i,a,s;for(_.lastIndex=r;a=_.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(U,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},M=async e=>Object.entries(await e),N=n(async(e,t)=>(await t).map(e)),Z=n(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),G=n(async(e,t,r={})=>Z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),H=n(async(e,t)=>{const r=await N(e,t);return(await Promise.all(r)).some(e=>e)}),Q=n(async(e,t)=>{const r=await N(e,t);return(await Promise.all(r)).every(e=>e)}),X=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),Y={entries:M,map:N,filter:G,reduce:Z,some:H,every:Q,pipeline:X,all:e=>Promise.all(e),allValues:e=>X([M,Z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},ee=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(ne.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?te(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+re(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=re(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:te(e)}};function te(e){return e+("/"===e[e.length-1]?"":"/")}function re(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const ne=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var oe=fetch;const{jsonTypeOf:ie,splitUrl:ae}=v,se={},ce={},ue=(e,t)=>{const r=e in ce?ce[e]:e;if(r in se)return se[r][t]},le={},fe={},de=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ae(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ue(n,"baseToken"),i=ue(n,"anchorToken"),a=ae(t)[0];if(!a&&!ae(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=be(a,e[o]||""),[c,u]=ae(s);delete e[o],u&&o===i&&(e[i]=i!==o?encodeURI(u):"#"+encodeURI(u)),a&&(fe[a]=c);const l={},f=ue(n,"recursiveAnchorToken");let d;!0===e[f]&&(l["#"]=c,e[i]="",delete e[f]);const p=ue(n,"vocabularyToken");ie(e[p],"object")?(ce[c]=n,d=e[p],delete e[p]):d=c===n?{[n]:!0}:{};const h={};le[c]={id:c,schemaVersion:n,schema:pe(e,c,n,y.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1}},pe=(e,t,r,n,o,i)=>{if(ie(e,"object")){const a="string"==typeof e.$schema?ae(e.$schema)[0]:r,s=ue(a,"embeddedToken"),c=ue(a,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=be(t,e[s]);return e[s]=n,de(e,n,r),O(e[s],e)}const u=ue(r,"anchorToken"),l=ue(r,"dynamicAnchorToken");"string"==typeof e[l]&&(i["#"+e[l]]=t,e[u]=e[l],delete e[l]);const f=ue(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=ue(r,"jrefToken");if("string"==typeof e[d])return O(e[d],e);for(let a in e)e[a]=pe(e[a],t,r,y.append(a,n),o,i);const p=ue(r,"jsrefToken");"string"==typeof e[p]&&(e[p]=O(e[p],e[p]));const h=ue(r,"dynamicJsrefToken");return"string"==typeof e[h]&&(e[h]=O(e[h],e[h],!0)),e}return Array.isArray(e)?e.map((e,a)=>pe(e,t,r,y.append(a,n),o,i)):e},he=e=>le[fe[e]]||le[e],ye=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,dynamicAnchors:{}}),me=async(e,t=ye,r=!1)=>{const n=r&&t.dynamicAnchors[e]?t.dynamicAnchors[e]:Oe(t),o=be(n,e),[i,a]=ae(o);if(!(e=>e in le||e in fe)(i)){const e=await oe(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=J.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}de(await e.json(),i)}const s=he(i),c=a&&"/"!==a[0]?ge(s,a):a,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:y.get(c,s.schema),dynamicAnchors:{...s.dynamicAnchors,...t.dynamicAnchors},validated:s.validated});return ve(u)},ve=e=>E(e.value)?me(j(e.value),e,x(e.value)):e,be=(e,t)=>{const r=ee(e,t),n=ae(e)[0];if(n&&"file"===we(r)&&"file"!==we(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},we=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},ge=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},Oe=e=>`${e.id}#${encodeURI(e.pointer)}`,Ee=e=>E(e.value)?$(e.value):e.value,je=(e,t)=>{const r=he(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:y.append(e,t.pointer),schema:r.schema,value:Ee(t)[e],dynamicAnchors:t.dynamicAnchors,validated:r.validated});return ve(n)},$e=n((e,t)=>Y.pipeline([Ee,Y.map(async(r,n)=>e(await je(n,t),n)),Y.all],t));var xe={setConfig:(e,t,r)=>{se[e]||(se[e]={}),se[e][t]=r},getConfig:ue,add:de,get:me,markValidated:e=>{le[e].validated=!0},uri:Oe,value:Ee,typeOf:(e,t)=>ie(Ee(e),t),has:(e,t)=>e in Ee(t),step:je,keys:e=>Object.keys(Ee(e)),entries:e=>Y.pipeline([Ee,Object.keys,Y.map(async t=>[t,await je(t,e)]),Y.all],e),map:$e,length:e=>Ee(e).length};class Ae extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Pe=Ae;const Se="FLAG",Te="BASIC",Ie="DETAILED",Ve="VERBOSE";let ke=Ie,ze=!0;const Ce=(e,t)=>(n,o=Se)=>{if(![Se,Te,Ie,Ve].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Ke(o,i));return We(t,n,e),r.unsubscribe(a),i[0]},Ke=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Le(r[r.length-1],i);){const t=r.pop();let n=[];e===Te&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n)}(e===Ve||e!==Se&&!i.valid)&&r.push(i),t[0]=i}},Le=(e,t)=>e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||t.keyword.endsWith("#validate")&&e.instanceLocation===t.instanceLocation,_e={},qe=e=>_e[e],Re=e=>e in _e,Ue={},Be={},De=async(e,t)=>{if(!Re(e.schemaVersion+"#validate")){const t=await xe.get(e.schemaVersion);(xe.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ue)Object.entries(Ue[e]).forEach(([e,r])=>{((e,t)=>{_e[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ze&&!e.validated){if(xe.markValidated(e.id),!(e.schemaVersion in Be)){const t=await xe.get(e.schemaVersion),r={},n=await De(t,r);Be[t.id]=Ce(r,n)}const t=L.cons(e.schema,e.id),r=Be[e.schemaVersion](t,ke);if(!r.valid)throw new Pe(r)}return await qe(e.schemaVersion+"#validate").compile(e,t),xe.uri(e)},We=(e,t,r)=>{const[n]=r[e];return qe(n).interpret(e,t,r)};var Fe={validate:async(e,t,r)=>{const n={},o=await De(e,n),i=(e,t=Se)=>Ce(n,o)(L.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ke=e},setShouldMetaValidate:e=>{ze=e},FLAG:Se,BASIC:Te,DETAILED:Ie,VERBOSE:Ve,getKeyword:qe,hasKeyword:Re,defineVocabulary:(e,t)=>{Ue[e]=t},compileSchema:De,interpretSchema:We,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return qe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return qe(o).collectEvaluatedItems(e,t,r,n)}};var Je={compile:async(e,t)=>{const r=xe.uri(e);if(!(r in t)){t[r]=!1;const n=xe.value(e);t[r]=[e.schemaVersion+"#validate",xe.uri(e),"boolean"==typeof n?n:await Y.pipeline([xe.entries,Y.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),Y.filter(([t])=>Fe.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),Y.map(async([r,n])=>{const o=await Fe.getKeyword(r).compile(n,t,e);return[r,xe.uri(n),o]}),Y.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Fe.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:L.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:L.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Fe.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Fe.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Me={Core:Fe,Schema:xe,Instance:L,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Je}},Ne=Me.Core,Ze=Me.Schema,Ge=Me.Instance,He=Me.Keywords;e.Core=Ne,e.Instance=Ge,e.Keywords=He,e.Schema=Ze,e.default=Me,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=json-schema-core-umd.min.js.map |
@@ -61,6 +61,6 @@ const contentTypeParser = require("content-type"); | ||
// recursiveAnchor | ||
const recursiveAnchors = {}; | ||
const dynamicAnchors = {}; | ||
const recursiveAnchorToken = getConfig(schemaVersion, "recursiveAnchorToken"); | ||
if (schema[recursiveAnchorToken] === true) { | ||
recursiveAnchors["#"] = id; | ||
dynamicAnchors["#"] = id; | ||
schema[anchorToken] = ""; | ||
@@ -88,5 +88,5 @@ delete schema[recursiveAnchorToken]; | ||
schemaVersion: schemaVersion, | ||
schema: processSchema(schema, id, schemaVersion, JsonPointer.nil, anchors, recursiveAnchors), | ||
schema: processSchema(schema, id, schemaVersion, JsonPointer.nil, anchors, dynamicAnchors), | ||
anchors: anchors, | ||
recursiveAnchors: recursiveAnchors, | ||
dynamicAnchors: dynamicAnchors, | ||
vocabulary: vocabulary, | ||
@@ -97,3 +97,3 @@ validated: false | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, recursiveAnchors) => { | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, dynamicAnchors) => { | ||
if (jsonTypeOf(subject, "object")) { | ||
@@ -113,3 +113,3 @@ const embeddedSchemaVersion = typeof subject["$schema"] === "string" ? splitUrl(subject["$schema"])[0] : schemaVersion; | ||
if (typeof subject[dynamicAnchorToken] === "string") { | ||
recursiveAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
dynamicAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
subject[anchorToken] = subject[dynamicAnchorToken]; | ||
@@ -131,7 +131,5 @@ delete subject[dynamicAnchorToken]; | ||
subject = Object.entries(subject) | ||
.reduce((acc, [key, value]) => { | ||
acc[key] = processSchema(value, id, schemaVersion, JsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
return acc; | ||
}, {}); | ||
for (let key in subject) { | ||
subject[key] = processSchema(subject[key], id, schemaVersion, JsonPointer.append(key, pointer), anchors, dynamicAnchors); | ||
} | ||
@@ -150,3 +148,3 @@ const jsrefToken = getConfig(schemaVersion, "jsrefToken"); | ||
} else if (Array.isArray(subject)) { | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, JsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, JsonPointer.append(ndx, pointer), anchors, dynamicAnchors)); | ||
} else { | ||
@@ -165,6 +163,6 @@ return subject; | ||
// Schema Retrieval | ||
const nil = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchors: {} }); | ||
const nil = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, dynamicAnchors: {} }); | ||
const get = async (url, contextDoc = nil, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri(contextDoc); | ||
const contextUrl = recursive && contextDoc.dynamicAnchors[url] ? contextDoc.dynamicAnchors[url] : uri(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
@@ -199,3 +197,3 @@ const [id, fragment] = splitUrl(resolvedUrl); | ||
value: JsonPointer.get(pointer, storedSchema.schema), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
dynamicAnchors: { ...storedSchema.dynamicAnchors, ...contextDoc.dynamicAnchors }, | ||
validated: storedSchema.validated | ||
@@ -246,3 +244,3 @@ }); | ||
value: value(doc)[key], | ||
recursiveAnchors: doc.recursiveAnchors, | ||
dynamicAnchors: doc.dynamicAnchors, | ||
validated: storedSchema.validated | ||
@@ -249,0 +247,0 @@ }); |
{ | ||
"name": "@hyperjump/json-schema-core", | ||
"version": "0.14.0", | ||
"version": "0.14.1", | ||
"description": "A framework for building JSON Schema tools", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1577704
8971