@hyperjump/json-schema-core
Advanced tools
Comparing version 0.23.1 to 0.23.2
@@ -1,7 +0,3 @@ | ||
define(['exports', 'url-resolve-browser'], (function (exports, urlResolveBrowser) { 'use strict'; | ||
define(['exports'], (function (exports) { 'use strict'; | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var urlResolveBrowser__default = /*#__PURE__*/_interopDefaultLegacy(urlResolveBrowser); | ||
var justCurryIt = curry; | ||
@@ -403,2 +399,213 @@ | ||
var urlResolveBrowser = urlResolve; | ||
/* | ||
The majority of the module is built by following RFC1808 | ||
url: https://tools.ietf.org/html/rfc1808 | ||
*/ | ||
// adds a slash at end if not present | ||
function _addSlash (url) { | ||
return url + (url[url.length-1] === '/' ? '' : '/'); | ||
} | ||
// resolve the ..'s (directory up) and such | ||
function _pathResolve (path) { | ||
let pathSplit = path.split('/'); | ||
// happens when path starts with / | ||
if (pathSplit[0] === '') { | ||
pathSplit = pathSplit.slice(1); | ||
} | ||
// let segmentCount = 0; // number of segments that have been passed | ||
let resultArray = []; | ||
pathSplit.forEach((current, index) => { | ||
// skip occurances of '.' | ||
if (current !== '.') { | ||
if (current === '..') { | ||
resultArray.pop(); // remove previous | ||
} else if (current !== '' || index === pathSplit.length - 1) { | ||
resultArray.push(current); | ||
} | ||
} | ||
}); | ||
return '/' + resultArray.join('/'); | ||
} | ||
// parses a base url string into an object containing host, path and query | ||
function _baseParse (base) { | ||
const resultObject = { | ||
host: '', | ||
path: '', | ||
query: '', | ||
protocol: '' | ||
}; | ||
let path = base; | ||
let protocolEndIndex = base.indexOf('//'); | ||
resultObject.protocol = path.substring(0, protocolEndIndex); | ||
protocolEndIndex += 2; // add two to pass double slash | ||
const pathIndex = base.indexOf('/', protocolEndIndex); | ||
const queryIndex = base.indexOf('?'); | ||
const hashIndex = base.indexOf('#'); | ||
if (hashIndex !== -1) { | ||
path = path.substring(0, hashIndex); // remove hash, not needed for base | ||
} | ||
if (queryIndex !== -1) { | ||
const query = path.substring(queryIndex); // remove query, save in return obj | ||
resultObject.query = query; | ||
path = path.substring(0, queryIndex); | ||
} | ||
if (pathIndex !== -1) { | ||
const host = path.substring(0, pathIndex); // separate host & path | ||
resultObject.host = host; | ||
path = path.substring(pathIndex); | ||
resultObject.path = path; | ||
} else { | ||
resultObject.host = path; // there was no path, therefore path is host | ||
} | ||
return resultObject; | ||
} | ||
// https://tools.ietf.org/html/rfc3986#section-3.1 | ||
const _scheme = '[a-z][a-z0-9+.-]*'; // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )] | ||
const _isAbsolute = new RegExp(`^(${_scheme}:)?//`, 'i'); | ||
// parses a relative url string into an object containing the href, | ||
// hash, query and whether it is a net path, absolute path or relative path | ||
function _relativeParse (relative) { | ||
const resultObject = { | ||
href: relative, // href is always what was passed through | ||
hash: '', | ||
query: '', | ||
netPath: false, | ||
absolutePath: false, | ||
relativePath: false | ||
}; | ||
// check for protocol | ||
// if protocol exists, is net path (absolute URL) | ||
if (_isAbsolute.test(relative)) { | ||
resultObject.netPath = true; | ||
// return, in this case the relative is the resolved url, no need to parse. | ||
return resultObject; | ||
} | ||
// if / is first, this is an absolute path, | ||
// I.E. it overwrites the base URL's path | ||
if (relative[0] === '/') { | ||
resultObject.absolutePath = true; | ||
// return resultObject | ||
} else if (relative !== '') { | ||
resultObject.relativePath = true; | ||
} | ||
let path = relative; | ||
const queryIndex = relative.indexOf('?'); | ||
const hashIndex = relative.indexOf('#'); | ||
if (hashIndex !== -1) { | ||
const hash = path.substring(hashIndex); | ||
resultObject.hash = hash; | ||
path = path.substring(0, hashIndex); | ||
} | ||
if (queryIndex !== -1) { | ||
const query = path.substring(queryIndex); | ||
resultObject.query = query; | ||
path = path.substring(0, queryIndex); | ||
} | ||
resultObject.path = path; // whatever is left is path | ||
return resultObject; | ||
} | ||
function _shouldAddSlash (url) { | ||
const protocolIndex = url.indexOf('//') + 2; | ||
const noPath = !(url.includes('/', protocolIndex)); | ||
const noQuery = !(url.includes('?', protocolIndex)); | ||
const noHash = !(url.includes('#', protocolIndex)); | ||
return (noPath && noQuery && noHash); | ||
} | ||
function _shouldAddProtocol (url) { | ||
return url.startsWith('//'); | ||
} | ||
/* | ||
* PRECONDITION: Base is a fully qualified URL. e.g. http://example.com/ | ||
* optional: path, query or hash | ||
* returns the resolved url | ||
*/ | ||
function urlResolve (base, relative) { | ||
base = base.trim(); | ||
relative = relative.trim(); | ||
// about is always absolute | ||
if (relative.startsWith('about:')) { | ||
return relative; | ||
} | ||
const baseObj = _baseParse(base); | ||
const relativeObj = _relativeParse(relative); | ||
if (!baseObj.protocol && !relativeObj.netPath) { | ||
throw new Error('Error, protocol is not specified'); | ||
} | ||
if (relativeObj.netPath) { // relative is full qualified URL | ||
if (_shouldAddProtocol(relativeObj.href)) { | ||
relativeObj.href = baseObj.protocol + relativeObj.href; | ||
} | ||
if (_shouldAddSlash(relativeObj.href)) { | ||
return _addSlash(relativeObj.href); | ||
} | ||
return relativeObj.href; | ||
} else if (relativeObj.absolutePath) { // relative is an absolute path | ||
const {path, query, hash} = relativeObj; | ||
return baseObj.host + _pathResolve(path) + query + hash; | ||
} else if (relativeObj.relativePath) { // relative is a relative path | ||
const {path, query, hash} = relativeObj; | ||
let basePath = baseObj.path; | ||
let resultString = baseObj.host; | ||
let resolvePath; | ||
if (path.length === 0) { | ||
resolvePath = basePath; | ||
} else { | ||
// remove last segment if no slash at end | ||
basePath = basePath.substring(0, basePath.lastIndexOf('/')); | ||
resolvePath = _pathResolve(basePath + '/' + path); | ||
} | ||
// if result is just the base host, add / | ||
if ((resolvePath === '') && (!query) && (!hash)) { | ||
resultString += '/'; | ||
} else { | ||
resultString += resolvePath + query + hash; | ||
} | ||
return resultString; | ||
} else { | ||
const {host, path, query} = baseObj; | ||
// when path and query aren't supplied add slash | ||
if ((!path) && (!query)) { | ||
return _addSlash(host); | ||
} | ||
return host + path + query + relativeObj.hash; | ||
} | ||
} | ||
const isObject = (value) => typeof value === "object" && !Array.isArray(value) && value !== null; | ||
@@ -431,3 +638,3 @@ const isType = { | ||
const safeResolveUrl$1 = (contextUrl, url) => { | ||
const resolvedUrl = urlResolveBrowser__default["default"](contextUrl, url); | ||
const resolvedUrl = urlResolveBrowser(contextUrl, url); | ||
const contextId = splitUrl$2(contextUrl)[0]; | ||
@@ -434,0 +641,0 @@ if (contextId && getScheme(resolvedUrl) === "file" && getScheme(contextId) !== "file") { |
@@ -1,2 +0,2 @@ | ||
define(["exports","url-resolve-browser"],(function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(t),o=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)))}}};var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var i,s=(function(e,t){var r,n;r="object"==typeof window&&window||a,n={},r.PubSub=n,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},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)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(n),void 0!==e&&e.exports&&(t=e.exports=n),t.PubSub=n,e.exports=t=n}(i={exports:{}},i.exports),i.exports);s.PubSub;const c={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},l=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)]},u=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var f={jsonTypeOf:(e,t)=>c[t](e),splitUrl:l,safeResolveUrl:(e,t)=>{const r=n.default(e,t),o=l(e)[0];if(o&&"file"===u(r)&&"file"!==u(o))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const p=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(w)},d=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:d(e,O(t,o,n),r,m(o,n))}}if(Array.isArray(t)){const n=[...t];return n[g(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:O(t,e[0],n)},y=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||j(t)){const o=e.shift();y(e,O(t,o,n),r,m(o,n))}else{t[g(t,e[0])]=r}},h=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=O(t,n,r);return{...t,[n]:h(e,o,m(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 O(t,e[0],r)}},v=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=O(t,n,r);v(e,o,m(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:O(t,e[0],r)},m=o(((e,t)=>t+"/"+b(e))),b=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),w=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),g=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,O=(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(j(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[g(e,t)]},j=e=>null===e||"object"!=typeof e;var E={nil:"",append:m,get:(e,t)=>{const r=p(e),n=e=>r.reduce((([e,t],r)=>[O(e,r,t),m(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const n=p(e),a=o(((e,t)=>d(n,e,t,"")));return void 0===t?a:a(t,r)},assign:(e,t,r)=>{const n=p(e),a=o(((e,t)=>y(n,e,t,"")));return void 0===t?a:a(t,r)},unset:(e,t)=>{const r=p(e),n=e=>h(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=p(e),n=e=>v(r,e,"");return void 0===t?n:n(t)}};E.nil,E.append,E.get,E.set,E.assign,E.unset,E.remove;const $=Symbol("$__value"),S=Symbol("$__href");var A={cons:(e,t)=>Object.freeze({[S]:e,[$]:t}),isReference:e=>e&&void 0!==e[S],href:e=>e[S],value:e=>e[$]};const{jsonTypeOf:I}=f,T=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),k=e=>A.isReference(e.value)?A.value(e.value):e.value,x=o(((e,t)=>I(k(e),t))),P=(e,t)=>Object.freeze({...t,pointer:E.append(e,t.pointer),value:k(t)[e]}),V=o(((e,t)=>k(t).map(((r,n,o,a)=>e(P(n,t),n,o,a))))),R=o(((e,t)=>k(t).map(((e,r,n,o)=>P(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),U=o(((e,t,r)=>k(r).reduce(((t,n,o)=>e(t,P(o,r),o)),t))),C=o(((e,t)=>k(t).every(((r,n,o,a)=>e(P(n,t),n,o,a))))),K=o(((e,t)=>k(t).some(((r,n,o,a)=>e(P(n,t),n,o,a)))));var L={nil:T,cons:(e,t="")=>Object.freeze({...T,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:k,has:(e,t)=>e in k(t),typeOf:x,step:P,entries:e=>Object.keys(k(e)).map((t=>[t,P(t,e)])),keys:e=>Object.keys(k(e)),map:V,filter:R,reduce:U,every:C,some:K,length:e=>k(e).length},z=/; *([!#$%&'*+.^_`|~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]+$/,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,N=/\\([\u000b\u0020-\u00ff])/g,q=/([\\"])/g,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function F(e){var t=String(e);if(D.test(t))return t;if(t.length>0&&!_.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(q,"\\$1")+'"'}function Z(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||!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],!D.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+F(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 Z(n.toLowerCase());if(-1!==r){var a,i,s;for(z.lastIndex=r;i=z.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(N,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},J=async e=>Object.entries(await e),G=o((async(e,t)=>(await t).map(e))),H=o((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),W=o((async(e,t,r={})=>H((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),Q=o((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).some((e=>e))})),X=o((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).every((e=>e))})),Y=o(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ee={entries:J,map:G,filter:W,reduce:H,some:Q,every:X,pipeline:Y,all:e=>Promise.all(e),allValues:e=>Y([J,H((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};ee.entries,ee.map,ee.filter,ee.reduce,ee.some,ee.every,ee.pipeline,ee.all,ee.allValues;var te=fetch;const{jsonTypeOf:re,splitUrl:ne,safeResolveUrl:oe}=f,ae={},ie={},se=(e,t)=>{const r=e in ie?ie[e]:e;if(r in ae)return ae[r][t]},ce={},le={},ue=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ne(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=se(n,"baseToken"),a=se(n,"anchorToken"),i=ne(t)[0];if(!i&&!ne(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=oe(i,e[o]||""),[c,l]=ne(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(le[i]=c);const u={},f=se(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=se(n,"vocabularyToken");re(e[d],"object")?(ie[c]=n,p=e[d],delete e[d]):(ie[c]=n,p={[n]:!0});const y={"":""};return ce[c]={id:c,schemaVersion:n,schema:fe(e,c,n,E.nil,y,u),anchors:y,dynamicAnchors:u,vocabulary:p,validated:!1},c},fe=(e,t,r,n,o,a)=>{if(re(e,"object")){const i="string"==typeof e.$schema?ne(e.$schema)[0]:r,s=se(i,"embeddedToken"),c=se(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=oe(t,e[s]);return e[s]=n,ue(e,n,r),A.cons(e[s],e)}const l=se(r,"anchorToken"),u=se(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=se(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=se(r,"jrefToken");if("string"==typeof e[p])return A.cons(e[p],e);for(const i in e)e[i]=fe(e[i],t,r,E.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>fe(e,t,r,E.append(i,n),o,a))):e},pe=e=>ce[le[e]]||ce[e],de=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:E.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),ye=async(e,t=de)=>{const r=oe(me(t),e),[n,o]=ne(r);if(!(e=>e in ce||e in le)(n)){const e=await te(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=M.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}ue(await e.json(),n)}const a=pe(n),i="/"!==o[0]?ve(a,o):o,s=Object.freeze({...a,pointer:i,value:E.get(i,a.schema)});return he(s)},he=e=>A.isReference(e.value)?ye(A.href(e.value),e):e,ve=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},me=e=>`${e.id}#${encodeURI(e.pointer)}`,be=e=>A.isReference(e.value)?A.value(e.value):e.value,we=(e,t)=>{const r=pe(t.id),n=Object.freeze({...t,pointer:E.append(e,t.pointer),value:be(t)[e],validated:r.validated});return he(n)},ge=o(((e,t)=>ee.pipeline([be,ee.map((async(r,n)=>e(await we(n,t),n))),ee.all],t)));var Oe={setConfig:(e,t,r)=>{ae[e]||(ae[e]={}),ae[e][t]=r},getConfig:se,add:ue,get:ye,markValidated:e=>{ce[e].validated=!0},uri:me,value:be,getAnchorPointer:ve,typeOf:(e,t)=>re(be(e),t),has:(e,t)=>e in be(t),step:we,keys:e=>Object.keys(be(e)),entries:e=>ee.pipeline([be,Object.keys,ee.map((async t=>[t,await we(t,e)])),ee.all],e),map:ge,length:e=>be(e).length};Oe.setConfig,Oe.getConfig,Oe.add,Oe.get,Oe.markValidated,Oe.uri,Oe.value,Oe.getAnchorPointer,Oe.typeOf,Oe.has,Oe.step,Oe.keys,Oe.entries,Oe.map,Oe.length;class je extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Ee=je;const{splitUrl:$e}=f,Se="FLAG",Ae="BASIC",Ie="DETAILED",Te="VERBOSE";let ke=Ie,xe=!0;const Pe=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await _e(e,t)}},Ve=o((({ast:e,schemaUri:t},r,n=Se)=>{if(![Se,Ae,Ie,Te].includes(n))throw Error(`The '${n}' error format is not supported`);const o=[],a=s.subscribe("result",Re(n,o));return Ne(t,r,e,{}),s.unsubscribe(a),o[0]})),Re=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Ae&&(o.push(...t.errors),delete t.errors),(e===Te||e!==Se&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ue={},Ce=e=>Ue[e],Ke=e=>e in Ue,Le={},ze={},_e=async(e,t)=>{if(e=await De(e),!Ke(`${e.schemaVersion}#validate`)){const t=await Oe.get(e.schemaVersion);(Oe.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 Le)Object.entries(Le[e]).forEach((([e,r])=>{((e,t)=>{Ue[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(xe&&!e.validated){if(Oe.markValidated(e.id),!(e.schemaVersion in ze)){const t=await Oe.get(e.schemaVersion),r=await Pe(t);ze[t.id]=Ve(r)}const t=L.cons(e.schema,e.id),r=ze[e.schemaVersion](t,ke);if(!r.valid)throw new Ee(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),Ce(`${e.schemaVersion}#validate`).compile(e,t)},De=async e=>Oe.typeOf(e,"string")?De(await Oe.get(Oe.value(e),e)):e,Ne=(e,t,r,n)=>{const o=qe(e,r),a=$e(e)[0];return Ce(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},qe=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Be={validate:async(e,t,r)=>{const n=await Pe(e),o=(e,t)=>Ve(n,L.cons(e),t);return void 0===t?o:o(t,r)},compile:Pe,interpret:Ve,setMetaOutputFormat:e=>{ke=e},setShouldMetaValidate:e=>{xe=e},FLAG:Se,BASIC:Ae,DETAILED:Ie,VERBOSE:Te,add:(e,t="",r="")=>{const n=Oe.add(e,t,r);delete ze[n]},getKeyword:Ce,hasKeyword:Ke,defineVocabulary:(e,t)=>{Le[e]=t},compileSchema:_e,interpretSchema:Ne,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=qe(e,r);return Ce(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=qe(e,r);return Ce(a).collectEvaluatedItems(e,t,r,n,o)}};var Fe={compile:e=>Oe.value(e),interpret:()=>!0};var Ze={compile:async(e,t)=>{const r=Oe.uri(e);if(!(r in t)){t[r]=!1;const n=Oe.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Oe.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Oe.uri(e),"boolean"==typeof n?n:await ee.pipeline([Oe.entries,ee.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ee.filter((([t])=>Be.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),ee.map((async([r,n])=>{const o=await Be.getKeyword(r).compile(n,t,e);return[r,Oe.uri(n),o]})),ee.all],e)]}return r},interpret:(e,t,r,n)=>{const[o,a,i]=r[e];s.publishSync("result.start");const c="boolean"==typeof i?i:i.every((([e,o,a])=>{s.publishSync("result.start");const i=Be.getKeyword(e).interpret(a,t,r,n);return s.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:L.uri(t),valid:i,ast:a}),s.publishSync("result.end"),i}));return s.publishSync("result",{keyword:o,absoluteKeywordLocation:a,instanceLocation:L.uri(t),valid:c,ast:e}),s.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Be.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Be.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Me={metaData:Fe,validate:Ze},Je={Core:Be,Schema:Oe,Instance:L,Reference:A,Keywords:Me,InvalidSchemaError:Ee},Ge=Je.Core,He=Je.Schema,We=Je.Instance,Qe=Je.Reference,Xe=Je.Keywords,Ye=Je.InvalidSchemaError;e.Core=Ge,e.Instance=We,e.InvalidSchemaError=Ye,e.Keywords=Xe,e.Reference=Qe,e.Schema=He,e.default=Je,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
define(["exports"],(function(e){"use strict";var t=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)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,o=(function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},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)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}(n={exports:{}},n.exports),n.exports);o.PubSub;var a=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(c.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)?i(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+s(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,i=r.path,c=r.host;return 0===e.length?a=i:(i=i.substring(0,i.lastIndexOf("/")),a=s(i+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:i(e)}};function i(e){return e+("/"===e[e.length-1]?"":"/")}function s(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 c=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const l={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},u=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)]},f=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var p={jsonTypeOf:(e,t)=>l[t](e),splitUrl:u,safeResolveUrl:(e,t)=>{const r=a(e,t),n=u(e)[0];if(n&&"file"===f(r)&&"file"!==f(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const d=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(g)},h=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:h(e,E(t,o,n),r,m(o,n))}}if(Array.isArray(t)){const n=[...t];return n[O(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:E(t,e[0],n)},y=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||j(t)){const o=e.shift();y(e,E(t,o,n),r,m(o,n))}else{t[O(t,e[0])]=r}},v=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=E(t,n,r);return{...t,[n]:v(e,o,m(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 E(t,e[0],r)}},b=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=E(t,n,r);b(e,o,m(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:E(t,e[0],r)},m=t(((e,t)=>t+"/"+w(e))),w=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),g=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),O=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,E=(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(j(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[O(e,t)]},j=e=>null===e||"object"!=typeof e;var $={nil:"",append:m,get:(e,t)=>{const r=d(e),n=e=>r.reduce((([e,t],r)=>[E(e,r,t),m(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=d(e),a=t(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=d(e),a=t(((e,t)=>y(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=d(e),n=e=>v(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=d(e),n=e=>b(r,e,"");return void 0===t?n:n(t)}};$.nil,$.append,$.get,$.set,$.assign,$.unset,$.remove;const S=Symbol("$__value"),P=Symbol("$__href");var x={cons:(e,t)=>Object.freeze({[P]:e,[S]:t}),isReference:e=>e&&void 0!==e[P],href:e=>e[P],value:e=>e[S]};const{jsonTypeOf:A}=p,I=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),T=e=>x.isReference(e.value)?x.value(e.value):e.value,k=t(((e,t)=>A(T(e),t))),V=(e,t)=>Object.freeze({...t,pointer:$.append(e,t.pointer),value:T(t)[e]}),R=t(((e,t)=>T(t).map(((r,n,o,a)=>e(V(n,t),n,o,a))))),U=t(((e,t)=>T(t).map(((e,r,n,o)=>V(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),C=t(((e,t,r)=>T(r).reduce(((t,n,o)=>e(t,V(o,r),o)),t))),z=t(((e,t)=>T(t).every(((r,n,o,a)=>e(V(n,t),n,o,a))))),K=t(((e,t)=>T(t).some(((r,n,o,a)=>e(V(n,t),n,o,a)))));var L={nil:I,cons:(e,t="")=>Object.freeze({...I,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:T,has:(e,t)=>e in T(t),typeOf:k,step:V,entries:e=>Object.keys(T(e)).map((t=>[t,V(t,e)])),keys:e=>Object.keys(T(e)),map:R,filter:U,reduce:C,every:z,some:K,length:e=>T(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]+$/,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,N=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,F=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function Z(e){var t=String(e);if(D.test(t))return t;if(t.length>0&&!_.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function M(e){this.parameters=Object.create(null),this.type=e}var W={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!F.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],!D.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+Z(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(!F.test(n))throw new TypeError("invalid media type");var o=new M(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(N,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},J=async e=>Object.entries(await e),G=t((async(e,t)=>(await t).map(e))),H=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),Q=t((async(e,t,r={})=>H((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),X=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).some((e=>e))})),Y=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).every((e=>e))})),ee=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),te={entries:J,map:G,filter:Q,reduce:H,some:X,every:Y,pipeline:ee,all:e=>Promise.all(e),allValues:e=>ee([J,H((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};te.entries,te.map,te.filter,te.reduce,te.some,te.every,te.pipeline,te.all,te.allValues;var re=fetch;const{jsonTypeOf:ne,splitUrl:oe,safeResolveUrl:ae}=p,ie={},se={},ce=(e,t)=>{const r=e in se?se[e]:e;if(r in ie)return ie[r][t]},le={},ue={},fe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=oe(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=oe(t)[0];if(!i&&!oe(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ae(i,e[o]||""),[c,l]=oe(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(ue[i]=c);const u={},f=ce(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=ce(n,"vocabularyToken");ne(e[d],"object")?(se[c]=n,p=e[d],delete e[d]):(se[c]=n,p={[n]:!0});const h={"":""};return le[c]={id:c,schemaVersion:n,schema:pe(e,c,n,$.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:p,validated:!1},c},pe=(e,t,r,n,o,a)=>{if(ne(e,"object")){const i="string"==typeof e.$schema?oe(e.$schema)[0]:r,s=ce(i,"embeddedToken"),c=ce(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ae(t,e[s]);return e[s]=n,fe(e,n,r),x.cons(e[s],e)}const l=ce(r,"anchorToken"),u=ce(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=ce(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=ce(r,"jrefToken");if("string"==typeof e[p])return x.cons(e[p],e);for(const i in e)e[i]=pe(e[i],t,r,$.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>pe(e,t,r,$.append(i,n),o,a))):e},de=e=>le[ue[e]]||le[e],he=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:$.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),ye=async(e,t=he)=>{const r=ae(me(t),e),[n,o]=oe(r);if(!(e=>e in le||e in ue)(n)){const e=await re(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=W.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}fe(await e.json(),n)}const a=de(n),i="/"!==o[0]?be(a,o):o,s=Object.freeze({...a,pointer:i,value:$.get(i,a.schema)});return ve(s)},ve=e=>x.isReference(e.value)?ye(x.href(e.value),e):e,be=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},me=e=>`${e.id}#${encodeURI(e.pointer)}`,we=e=>x.isReference(e.value)?x.value(e.value):e.value,ge=(e,t)=>{const r=de(t.id),n=Object.freeze({...t,pointer:$.append(e,t.pointer),value:we(t)[e],validated:r.validated});return ve(n)},Oe=t(((e,t)=>te.pipeline([we,te.map((async(r,n)=>e(await ge(n,t),n))),te.all],t)));var Ee={setConfig:(e,t,r)=>{ie[e]||(ie[e]={}),ie[e][t]=r},getConfig:ce,add:fe,get:ye,markValidated:e=>{le[e].validated=!0},uri:me,value:we,getAnchorPointer:be,typeOf:(e,t)=>ne(we(e),t),has:(e,t)=>e in we(t),step:ge,keys:e=>Object.keys(we(e)),entries:e=>te.pipeline([we,Object.keys,te.map((async t=>[t,await ge(t,e)])),te.all],e),map:Oe,length:e=>we(e).length};Ee.setConfig,Ee.getConfig,Ee.add,Ee.get,Ee.markValidated,Ee.uri,Ee.value,Ee.getAnchorPointer,Ee.typeOf,Ee.has,Ee.step,Ee.keys,Ee.entries,Ee.map,Ee.length;class je extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var $e=je;const{splitUrl:Se}=p,Pe="FLAG",xe="BASIC",Ae="DETAILED",Ie="VERBOSE";let Te=Ae,ke=!0;const Ve=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await _e(e,t)}},Re=t((({ast:e,schemaUri:t},r,n=Pe)=>{if(![Pe,xe,Ae,Ie].includes(n))throw Error(`The '${n}' error format is not supported`);const a=[],i=o.subscribe("result",Ue(n,a));return Ne(t,r,e,{}),o.unsubscribe(i),a[0]})),Ue=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===xe&&(o.push(...t.errors),delete t.errors),(e===Ie||e!==Pe&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ce={},ze=e=>Ce[e],Ke=e=>e in Ce,Le={},qe={},_e=async(e,t)=>{if(e=await De(e),!Ke(`${e.schemaVersion}#validate`)){const t=await Ee.get(e.schemaVersion);(Ee.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 Le)Object.entries(Le[e]).forEach((([e,r])=>{((e,t)=>{Ce[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(ke&&!e.validated){if(Ee.markValidated(e.id),!(e.schemaVersion in qe)){const t=await Ee.get(e.schemaVersion),r=await Ve(t);qe[t.id]=Re(r)}const t=L.cons(e.schema,e.id),r=qe[e.schemaVersion](t,Te);if(!r.valid)throw new $e(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),ze(`${e.schemaVersion}#validate`).compile(e,t)},De=async e=>Ee.typeOf(e,"string")?De(await Ee.get(Ee.value(e),e)):e,Ne=(e,t,r,n)=>{const o=Be(e,r),a=Se(e)[0];return ze(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Be=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Fe={validate:async(e,t,r)=>{const n=await Ve(e),o=(e,t)=>Re(n,L.cons(e),t);return void 0===t?o:o(t,r)},compile:Ve,interpret:Re,setMetaOutputFormat:e=>{Te=e},setShouldMetaValidate:e=>{ke=e},FLAG:Pe,BASIC:xe,DETAILED:Ae,VERBOSE:Ie,add:(e,t="",r="")=>{const n=Ee.add(e,t,r);delete qe[n]},getKeyword:ze,hasKeyword:Ke,defineVocabulary:(e,t)=>{Le[e]=t},compileSchema:_e,interpretSchema:Ne,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Be(e,r);return ze(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Be(e,r);return ze(a).collectEvaluatedItems(e,t,r,n,o)}};var Ze={compile:e=>Ee.value(e),interpret:()=>!0};var Me={compile:async(e,t)=>{const r=Ee.uri(e);if(!(r in t)){t[r]=!1;const n=Ee.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Ee.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Ee.uri(e),"boolean"==typeof n?n:await te.pipeline([Ee.entries,te.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),te.filter((([t])=>Fe.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),te.map((async([r,n])=>{const o=await Fe.getKeyword(r).compile(n,t,e);return[r,Ee.uri(n),o]})),te.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=Fe.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:L.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:L.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Fe.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Fe.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},We={metaData:Ze,validate:Me},Je={Core:Fe,Schema:Ee,Instance:L,Reference:x,Keywords:We,InvalidSchemaError:$e},Ge=Je.Core,He=Je.Schema,Qe=Je.Instance,Xe=Je.Reference,Ye=Je.Keywords,et=Je.InvalidSchemaError;e.Core=Ge,e.Instance=Qe,e.InvalidSchemaError=et,e.Keywords=Ye,e.Reference=Xe,e.Schema=He,e.default=Je,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=json-schema-core-amd.min.js.map |
@@ -5,8 +5,2 @@ 'use strict'; | ||
var urlResolveBrowser = require('url-resolve-browser'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var urlResolveBrowser__default = /*#__PURE__*/_interopDefaultLegacy(urlResolveBrowser); | ||
var justCurryIt = curry; | ||
@@ -408,2 +402,213 @@ | ||
var urlResolveBrowser = urlResolve; | ||
/* | ||
The majority of the module is built by following RFC1808 | ||
url: https://tools.ietf.org/html/rfc1808 | ||
*/ | ||
// adds a slash at end if not present | ||
function _addSlash (url) { | ||
return url + (url[url.length-1] === '/' ? '' : '/'); | ||
} | ||
// resolve the ..'s (directory up) and such | ||
function _pathResolve (path) { | ||
let pathSplit = path.split('/'); | ||
// happens when path starts with / | ||
if (pathSplit[0] === '') { | ||
pathSplit = pathSplit.slice(1); | ||
} | ||
// let segmentCount = 0; // number of segments that have been passed | ||
let resultArray = []; | ||
pathSplit.forEach((current, index) => { | ||
// skip occurances of '.' | ||
if (current !== '.') { | ||
if (current === '..') { | ||
resultArray.pop(); // remove previous | ||
} else if (current !== '' || index === pathSplit.length - 1) { | ||
resultArray.push(current); | ||
} | ||
} | ||
}); | ||
return '/' + resultArray.join('/'); | ||
} | ||
// parses a base url string into an object containing host, path and query | ||
function _baseParse (base) { | ||
const resultObject = { | ||
host: '', | ||
path: '', | ||
query: '', | ||
protocol: '' | ||
}; | ||
let path = base; | ||
let protocolEndIndex = base.indexOf('//'); | ||
resultObject.protocol = path.substring(0, protocolEndIndex); | ||
protocolEndIndex += 2; // add two to pass double slash | ||
const pathIndex = base.indexOf('/', protocolEndIndex); | ||
const queryIndex = base.indexOf('?'); | ||
const hashIndex = base.indexOf('#'); | ||
if (hashIndex !== -1) { | ||
path = path.substring(0, hashIndex); // remove hash, not needed for base | ||
} | ||
if (queryIndex !== -1) { | ||
const query = path.substring(queryIndex); // remove query, save in return obj | ||
resultObject.query = query; | ||
path = path.substring(0, queryIndex); | ||
} | ||
if (pathIndex !== -1) { | ||
const host = path.substring(0, pathIndex); // separate host & path | ||
resultObject.host = host; | ||
path = path.substring(pathIndex); | ||
resultObject.path = path; | ||
} else { | ||
resultObject.host = path; // there was no path, therefore path is host | ||
} | ||
return resultObject; | ||
} | ||
// https://tools.ietf.org/html/rfc3986#section-3.1 | ||
const _scheme = '[a-z][a-z0-9+.-]*'; // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )] | ||
const _isAbsolute = new RegExp(`^(${_scheme}:)?//`, 'i'); | ||
// parses a relative url string into an object containing the href, | ||
// hash, query and whether it is a net path, absolute path or relative path | ||
function _relativeParse (relative) { | ||
const resultObject = { | ||
href: relative, // href is always what was passed through | ||
hash: '', | ||
query: '', | ||
netPath: false, | ||
absolutePath: false, | ||
relativePath: false | ||
}; | ||
// check for protocol | ||
// if protocol exists, is net path (absolute URL) | ||
if (_isAbsolute.test(relative)) { | ||
resultObject.netPath = true; | ||
// return, in this case the relative is the resolved url, no need to parse. | ||
return resultObject; | ||
} | ||
// if / is first, this is an absolute path, | ||
// I.E. it overwrites the base URL's path | ||
if (relative[0] === '/') { | ||
resultObject.absolutePath = true; | ||
// return resultObject | ||
} else if (relative !== '') { | ||
resultObject.relativePath = true; | ||
} | ||
let path = relative; | ||
const queryIndex = relative.indexOf('?'); | ||
const hashIndex = relative.indexOf('#'); | ||
if (hashIndex !== -1) { | ||
const hash = path.substring(hashIndex); | ||
resultObject.hash = hash; | ||
path = path.substring(0, hashIndex); | ||
} | ||
if (queryIndex !== -1) { | ||
const query = path.substring(queryIndex); | ||
resultObject.query = query; | ||
path = path.substring(0, queryIndex); | ||
} | ||
resultObject.path = path; // whatever is left is path | ||
return resultObject; | ||
} | ||
function _shouldAddSlash (url) { | ||
const protocolIndex = url.indexOf('//') + 2; | ||
const noPath = !(url.includes('/', protocolIndex)); | ||
const noQuery = !(url.includes('?', protocolIndex)); | ||
const noHash = !(url.includes('#', protocolIndex)); | ||
return (noPath && noQuery && noHash); | ||
} | ||
function _shouldAddProtocol (url) { | ||
return url.startsWith('//'); | ||
} | ||
/* | ||
* PRECONDITION: Base is a fully qualified URL. e.g. http://example.com/ | ||
* optional: path, query or hash | ||
* returns the resolved url | ||
*/ | ||
function urlResolve (base, relative) { | ||
base = base.trim(); | ||
relative = relative.trim(); | ||
// about is always absolute | ||
if (relative.startsWith('about:')) { | ||
return relative; | ||
} | ||
const baseObj = _baseParse(base); | ||
const relativeObj = _relativeParse(relative); | ||
if (!baseObj.protocol && !relativeObj.netPath) { | ||
throw new Error('Error, protocol is not specified'); | ||
} | ||
if (relativeObj.netPath) { // relative is full qualified URL | ||
if (_shouldAddProtocol(relativeObj.href)) { | ||
relativeObj.href = baseObj.protocol + relativeObj.href; | ||
} | ||
if (_shouldAddSlash(relativeObj.href)) { | ||
return _addSlash(relativeObj.href); | ||
} | ||
return relativeObj.href; | ||
} else if (relativeObj.absolutePath) { // relative is an absolute path | ||
const {path, query, hash} = relativeObj; | ||
return baseObj.host + _pathResolve(path) + query + hash; | ||
} else if (relativeObj.relativePath) { // relative is a relative path | ||
const {path, query, hash} = relativeObj; | ||
let basePath = baseObj.path; | ||
let resultString = baseObj.host; | ||
let resolvePath; | ||
if (path.length === 0) { | ||
resolvePath = basePath; | ||
} else { | ||
// remove last segment if no slash at end | ||
basePath = basePath.substring(0, basePath.lastIndexOf('/')); | ||
resolvePath = _pathResolve(basePath + '/' + path); | ||
} | ||
// if result is just the base host, add / | ||
if ((resolvePath === '') && (!query) && (!hash)) { | ||
resultString += '/'; | ||
} else { | ||
resultString += resolvePath + query + hash; | ||
} | ||
return resultString; | ||
} else { | ||
const {host, path, query} = baseObj; | ||
// when path and query aren't supplied add slash | ||
if ((!path) && (!query)) { | ||
return _addSlash(host); | ||
} | ||
return host + path + query + relativeObj.hash; | ||
} | ||
} | ||
const isObject = (value) => typeof value === "object" && !Array.isArray(value) && value !== null; | ||
@@ -436,3 +641,3 @@ const isType = { | ||
const safeResolveUrl$1 = (contextUrl, url) => { | ||
const resolvedUrl = urlResolveBrowser__default["default"](contextUrl, url); | ||
const resolvedUrl = urlResolveBrowser(contextUrl, url); | ||
const contextId = splitUrl$2(contextUrl)[0]; | ||
@@ -439,0 +644,0 @@ if (contextId && getScheme(resolvedUrl) === "file" && getScheme(contextId) !== "file") { |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("url-resolve-browser")),r=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)))}}};var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var o,a=(function(e,t){var r;r={},("object"==typeof window&&window||n).PubSub=r,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function p(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function f(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!p(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return f(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return f(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},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)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(r),void 0!==e&&e.exports&&(t=e.exports=r),t.PubSub=r,e.exports=t=r}(o={exports:{}},o.exports),o.exports);a.PubSub;const i={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},s=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)]},c=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var l={jsonTypeOf:(e,t)=>i[t](e),splitUrl:s,safeResolveUrl:(e,r)=>{const n=t.default(e,r),o=s(e)[0];if(o&&"file"===c(n)&&"file"!==c(o))throw Error(`Can't access file '${n}' resource from network context '${e}'`);return n}};const u=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(m)},p=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:p(e,w(t,o,n),r,h(o,n))}}if(Array.isArray(t)){const n=[...t];return n[b(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:w(t,e[0],n)},f=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||g(t)){const o=e.shift();f(e,w(t,o,n),r,h(o,n))}else{t[b(t,e[0])]=r}},d=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=w(t,n,r);return{...t,[n]:d(e,o,h(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 w(t,e[0],r)}},y=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=w(t,n,r);y(e,o,h(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:w(t,e[0],r)},h=r(((e,t)=>t+"/"+v(e))),v=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),m=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),b=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,w=(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(g(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[b(e,t)]},g=e=>null===e||"object"!=typeof e;var O={nil:"",append:h,get:(e,t)=>{const r=u(e),n=e=>r.reduce((([e,t],r)=>[w(e,r,t),h(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,t,n)=>{const o=u(e),a=r(((e,t)=>p(o,e,t,"")));return void 0===t?a:a(t,n)},assign:(e,t,n)=>{const o=u(e),a=r(((e,t)=>f(o,e,t,"")));return void 0===t?a:a(t,n)},unset:(e,t)=>{const r=u(e),n=e=>d(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=u(e),n=e=>y(r,e,"");return void 0===t?n:n(t)}};O.nil,O.append,O.get,O.set,O.assign,O.unset,O.remove;const j=Symbol("$__value"),E=Symbol("$__href");var $={cons:(e,t)=>Object.freeze({[E]:e,[j]:t}),isReference:e=>e&&void 0!==e[E],href:e=>e[E],value:e=>e[j]};const{jsonTypeOf:S}=l,A=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),x=e=>$.isReference(e.value)?$.value(e.value):e.value,I=r(((e,t)=>S(x(e),t))),T=(e,t)=>Object.freeze({...t,pointer:O.append(e,t.pointer),value:x(t)[e]}),k=r(((e,t)=>x(t).map(((r,n,o,a)=>e(T(n,t),n,o,a))))),P=r(((e,t)=>x(t).map(((e,r,n,o)=>T(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),V=r(((e,t,r)=>x(r).reduce(((t,n,o)=>e(t,T(o,r),o)),t))),R=r(((e,t)=>x(t).every(((r,n,o,a)=>e(T(n,t),n,o,a))))),U=r(((e,t)=>x(t).some(((r,n,o,a)=>e(T(n,t),n,o,a)))));var C={nil:A,cons:(e,t="")=>Object.freeze({...A,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:x,has:(e,t)=>e in x(t),typeOf:I,step:T,entries:e=>Object.keys(x(e)).map((t=>[t,T(t,e)])),keys:e=>Object.keys(x(e)),map:k,filter:P,reduce:V,every:R,some:U,length:e=>x(e).length},K=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,L=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,z=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,_=/\\([\u000b\u0020-\u00ff])/g,D=/([\\"])/g,N=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function q(e){var t=String(e);if(z.test(t))return t;if(t.length>0&&!L.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(D,"\\$1")+'"'}function B(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||!N.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],!z.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+q(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(!N.test(n))throw new TypeError("invalid media type");var o=new B(n.toLowerCase());if(-1!==r){var a,i,s;for(K.lastIndex=r;i=K.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(_,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},Z=async e=>Object.entries(await e),M=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))),G=r((async(e,t,r={})=>J((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),H=r((async(e,t)=>{const r=await M(e,t);return(await Promise.all(r)).some((e=>e))})),W=r((async(e,t)=>{const r=await M(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:Z,map:M,filter:G,reduce:J,some:H,every:W,pipeline:Q,all:e=>Promise.all(e),allValues:e=>Q([Z,J((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};X.entries,X.map,X.filter,X.reduce,X.some,X.every,X.pipeline,X.all,X.allValues;var Y=fetch;const{jsonTypeOf:ee,splitUrl:te,safeResolveUrl:re}=l,ne={},oe={},ae=(e,t)=>{const r=e in oe?oe[e]:e;if(r in ne)return ne[r][t]},ie={},se={},ce=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=te(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ae(n,"baseToken"),a=ae(n,"anchorToken"),i=te(t)[0];if(!i&&!te(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=re(i,e[o]||""),[c,l]=te(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(se[i]=c);const u={},p=ae(n,"recursiveAnchorToken");let f;!0===e[p]&&(u[""]=`${c}#`,e[a]="",delete e[p]);const d=ae(n,"vocabularyToken");ee(e[d],"object")?(oe[c]=n,f=e[d],delete e[d]):(oe[c]=n,f={[n]:!0});const y={"":""};return ie[c]={id:c,schemaVersion:n,schema:le(e,c,n,O.nil,y,u),anchors:y,dynamicAnchors:u,vocabulary:f,validated:!1},c},le=(e,t,r,n,o,a)=>{if(ee(e,"object")){const i="string"==typeof e.$schema?te(e.$schema)[0]:r,s=ae(i,"embeddedToken"),c=ae(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=re(t,e[s]);return e[s]=n,ce(e,n,r),$.cons(e[s],e)}const l=ae(r,"anchorToken"),u=ae(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const p=ae(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==p?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const f=ae(r,"jrefToken");if("string"==typeof e[f])return $.cons(e[f],e);for(const i in e)e[i]=le(e[i],t,r,O.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>le(e,t,r,O.append(i,n),o,a))):e},ue=e=>ie[se[e]]||ie[e],pe=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:O.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),fe=async(e,t=pe)=>{const r=re(he(t),e),[n,o]=te(r);if(!(e=>e in ie||e in se)(n)){const e=await Y(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=F.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}ce(await e.json(),n)}const a=ue(n),i="/"!==o[0]?ye(a,o):o,s=Object.freeze({...a,pointer:i,value:O.get(i,a.schema)});return de(s)},de=e=>$.isReference(e.value)?fe($.href(e.value),e):e,ye=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},he=e=>`${e.id}#${encodeURI(e.pointer)}`,ve=e=>$.isReference(e.value)?$.value(e.value):e.value,me=(e,t)=>{const r=ue(t.id),n=Object.freeze({...t,pointer:O.append(e,t.pointer),value:ve(t)[e],validated:r.validated});return de(n)},be=r(((e,t)=>X.pipeline([ve,X.map((async(r,n)=>e(await me(n,t),n))),X.all],t)));var we={setConfig:(e,t,r)=>{ne[e]||(ne[e]={}),ne[e][t]=r},getConfig:ae,add:ce,get:fe,markValidated:e=>{ie[e].validated=!0},uri:he,value:ve,getAnchorPointer:ye,typeOf:(e,t)=>ee(ve(e),t),has:(e,t)=>e in ve(t),step:me,keys:e=>Object.keys(ve(e)),entries:e=>X.pipeline([ve,Object.keys,X.map((async t=>[t,await me(t,e)])),X.all],e),map:be,length:e=>ve(e).length};we.setConfig,we.getConfig,we.add,we.get,we.markValidated,we.uri,we.value,we.getAnchorPointer,we.typeOf,we.has,we.step,we.keys,we.entries,we.map,we.length;class ge extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Oe=ge;const{splitUrl:je}=l,Ee="FLAG",$e="BASIC",Se="DETAILED",Ae="VERBOSE";let xe=Se,Ie=!0;const Te=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Le(e,t)}},ke=r((({ast:e,schemaUri:t},r,n=Ee)=>{if(![Ee,$e,Se,Ae].includes(n))throw Error(`The '${n}' error format is not supported`);const o=[],i=a.subscribe("result",Pe(n,o));return _e(t,r,e,{}),a.unsubscribe(i),o[0]})),Pe=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===$e&&(o.push(...t.errors),delete t.errors),(e===Ae||e!==Ee&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ve={},Re=e=>Ve[e],Ue=e=>e in Ve,Ce={},Ke={},Le=async(e,t)=>{if(e=await ze(e),!Ue(`${e.schemaVersion}#validate`)){const t=await we.get(e.schemaVersion);(we.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 Ce)Object.entries(Ce[e]).forEach((([e,r])=>{((e,t)=>{Ve[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Ie&&!e.validated){if(we.markValidated(e.id),!(e.schemaVersion in Ke)){const t=await we.get(e.schemaVersion),r=await Te(t);Ke[t.id]=ke(r)}const t=C.cons(e.schema,e.id),r=Ke[e.schemaVersion](t,xe);if(!r.valid)throw new Oe(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),Re(`${e.schemaVersion}#validate`).compile(e,t)},ze=async e=>we.typeOf(e,"string")?ze(await we.get(we.value(e),e)):e,_e=(e,t,r,n)=>{const o=De(e,r),a=je(e)[0];return Re(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},De=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Ne={validate:async(e,t,r)=>{const n=await Te(e),o=(e,t)=>ke(n,C.cons(e),t);return void 0===t?o:o(t,r)},compile:Te,interpret:ke,setMetaOutputFormat:e=>{xe=e},setShouldMetaValidate:e=>{Ie=e},FLAG:Ee,BASIC:$e,DETAILED:Se,VERBOSE:Ae,add:(e,t="",r="")=>{const n=we.add(e,t,r);delete Ke[n]},getKeyword:Re,hasKeyword:Ue,defineVocabulary:(e,t)=>{Ce[e]=t},compileSchema:Le,interpretSchema:_e,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=De(e,r);return Re(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=De(e,r);return Re(a).collectEvaluatedItems(e,t,r,n,o)}};var qe={compile:e=>we.value(e),interpret:()=>!0};var Be={compile:async(e,t)=>{const r=we.uri(e);if(!(r in t)){t[r]=!1;const n=we.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${we.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,we.uri(e),"boolean"==typeof n?n:await X.pipeline([we.entries,X.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),X.filter((([t])=>Ne.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),X.map((async([r,n])=>{const o=await Ne.getKeyword(r).compile(n,t,e);return[r,we.uri(n),o]})),X.all],e)]}return r},interpret:(e,t,r,n)=>{const[o,i,s]=r[e];a.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,o,i])=>{a.publishSync("result.start");const s=Ne.getKeyword(e).interpret(i,t,r,n);return a.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:C.uri(t),valid:s,ast:i}),a.publishSync("result.end"),s}));return a.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:C.uri(t),valid:c,ast:e}),a.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Ne.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Ne.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Fe={metaData:qe,validate:Be},Ze={Core:Ne,Schema:we,Instance:C,Reference:$,Keywords:Fe,InvalidSchemaError:Oe},Me=Ze.Core,Je=Ze.Schema,Ge=Ze.Instance,He=Ze.Reference,We=Ze.Keywords,Qe=Ze.InvalidSchemaError;exports.Core=Me,exports.Instance=Ge,exports.InvalidSchemaError=Qe,exports.Keywords=We,exports.Reference=He,exports.Schema=Je,exports.default=Ze; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=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)))}}};var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r,n=(function(e,r){var n;n={},("object"==typeof window&&window||t).PubSub=n,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},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)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(n),void 0!==e&&e.exports&&(r=e.exports=n),r.PubSub=n,e.exports=r=n}(r={exports:{}},r.exports),r.exports);n.PubSub;var o=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(s.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)?a(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+i(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,s=r.path,c=r.host;return 0===e.length?a=s:(s=s.substring(0,s.lastIndexOf("/")),a=i(s+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:a(e)}};function a(e){return e+("/"===e[e.length-1]?"":"/")}function i(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 s=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const c={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},l=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)]},u=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var f={jsonTypeOf:(e,t)=>c[t](e),splitUrl:l,safeResolveUrl:(e,t)=>{const r=o(e,t),n=l(e)[0];if(n&&"file"===u(r)&&"file"!==u(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const p=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(w)},d=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:d(e,O(t,o,n),r,b(o,n))}}if(Array.isArray(t)){const n=[...t];return n[g(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:O(t,e[0],n)},h=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||E(t)){const o=e.shift();h(e,O(t,o,n),r,b(o,n))}else{t[g(t,e[0])]=r}},y=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=O(t,n,r);return{...t,[n]:y(e,o,b(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 O(t,e[0],r)}},v=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=O(t,n,r);v(e,o,b(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:O(t,e[0],r)},b=e(((e,t)=>t+"/"+m(e))),m=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),w=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),g=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,O=(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(E(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[g(e,t)]},E=e=>null===e||"object"!=typeof e;var j={nil:"",append:b,get:(e,t)=>{const r=p(e),n=e=>r.reduce((([e,t],r)=>[O(e,r,t),b(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(t,r,n)=>{const o=p(t),a=e(((e,t)=>d(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(t,r,n)=>{const o=p(t),a=e(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=p(e),n=e=>y(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=p(e),n=e=>v(r,e,"");return void 0===t?n:n(t)}};j.nil,j.append,j.get,j.set,j.assign,j.unset,j.remove;const $=Symbol("$__value"),S=Symbol("$__href");var x={cons:(e,t)=>Object.freeze({[S]:e,[$]:t}),isReference:e=>e&&void 0!==e[S],href:e=>e[S],value:e=>e[$]};const{jsonTypeOf:P}=f,A=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),I=e=>x.isReference(e.value)?x.value(e.value):e.value,T=e(((e,t)=>P(I(e),t))),k=(e,t)=>Object.freeze({...t,pointer:j.append(e,t.pointer),value:I(t)[e]}),V=e(((e,t)=>I(t).map(((r,n,o,a)=>e(k(n,t),n,o,a))))),R=e(((e,t)=>I(t).map(((e,r,n,o)=>k(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),U=e(((e,t,r)=>I(r).reduce(((t,n,o)=>e(t,k(o,r),o)),t))),C=e(((e,t)=>I(t).every(((r,n,o,a)=>e(k(n,t),n,o,a))))),z=e(((e,t)=>I(t).some(((r,n,o,a)=>e(k(n,t),n,o,a)))));var K={nil:A,cons:(e,t="")=>Object.freeze({...A,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:I,has:(e,t)=>e in I(t),typeOf:T,step:k,entries:e=>Object.keys(I(e)).map((t=>[t,k(t,e)])),keys:e=>Object.keys(I(e)),map:V,filter:R,reduce:U,every:C,some:z,length:e=>I(e).length},L=/; *([!#$%&'*+.^_`|~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-]+$/,D=/\\([\u000b\u0020-\u00ff])/g,N=/([\\"])/g,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function F(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(N,"\\$1")+'"'}function Z(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||!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+"="+F(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 Z(n.toLowerCase());if(-1!==r){var a,i,s;for(L.lastIndex=r;i=L.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(D,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},W=async e=>Object.entries(await e),J=e((async(e,t)=>(await t).map(e))),G=e((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),H=e((async(e,t,r={})=>G((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),Q=e((async(e,t)=>{const r=await J(e,t);return(await Promise.all(r)).some((e=>e))})),X=e((async(e,t)=>{const r=await J(e,t);return(await Promise.all(r)).every((e=>e))})),Y=e(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ee={entries:W,map:J,filter:H,reduce:G,some:Q,every:X,pipeline:Y,all:e=>Promise.all(e),allValues:e=>Y([W,G((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};ee.entries,ee.map,ee.filter,ee.reduce,ee.some,ee.every,ee.pipeline,ee.all,ee.allValues;var te=fetch;const{jsonTypeOf:re,splitUrl:ne,safeResolveUrl:oe}=f,ae={},ie={},se=(e,t)=>{const r=e in ie?ie[e]:e;if(r in ae)return ae[r][t]},ce={},le={},ue=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ne(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=se(n,"baseToken"),a=se(n,"anchorToken"),i=ne(t)[0];if(!i&&!ne(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=oe(i,e[o]||""),[c,l]=ne(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(le[i]=c);const u={},f=se(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=se(n,"vocabularyToken");re(e[d],"object")?(ie[c]=n,p=e[d],delete e[d]):(ie[c]=n,p={[n]:!0});const h={"":""};return ce[c]={id:c,schemaVersion:n,schema:fe(e,c,n,j.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:p,validated:!1},c},fe=(e,t,r,n,o,a)=>{if(re(e,"object")){const i="string"==typeof e.$schema?ne(e.$schema)[0]:r,s=se(i,"embeddedToken"),c=se(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=oe(t,e[s]);return e[s]=n,ue(e,n,r),x.cons(e[s],e)}const l=se(r,"anchorToken"),u=se(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=se(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=se(r,"jrefToken");if("string"==typeof e[p])return x.cons(e[p],e);for(const i in e)e[i]=fe(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>fe(e,t,r,j.append(i,n),o,a))):e},pe=e=>ce[le[e]]||ce[e],de=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),he=async(e,t=de)=>{const r=oe(be(t),e),[n,o]=ne(r);if(!(e=>e in ce||e in le)(n)){const e=await te(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=M.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}ue(await e.json(),n)}const a=pe(n),i="/"!==o[0]?ve(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return ye(s)},ye=e=>x.isReference(e.value)?he(x.href(e.value),e):e,ve=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},be=e=>`${e.id}#${encodeURI(e.pointer)}`,me=e=>x.isReference(e.value)?x.value(e.value):e.value,we=(e,t)=>{const r=pe(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:me(t)[e],validated:r.validated});return ye(n)},ge=e(((e,t)=>ee.pipeline([me,ee.map((async(r,n)=>e(await we(n,t),n))),ee.all],t)));var Oe={setConfig:(e,t,r)=>{ae[e]||(ae[e]={}),ae[e][t]=r},getConfig:se,add:ue,get:he,markValidated:e=>{ce[e].validated=!0},uri:be,value:me,getAnchorPointer:ve,typeOf:(e,t)=>re(me(e),t),has:(e,t)=>e in me(t),step:we,keys:e=>Object.keys(me(e)),entries:e=>ee.pipeline([me,Object.keys,ee.map((async t=>[t,await we(t,e)])),ee.all],e),map:ge,length:e=>me(e).length};Oe.setConfig,Oe.getConfig,Oe.add,Oe.get,Oe.markValidated,Oe.uri,Oe.value,Oe.getAnchorPointer,Oe.typeOf,Oe.has,Oe.step,Oe.keys,Oe.entries,Oe.map,Oe.length;class Ee extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var je=Ee;const{splitUrl:$e}=f,Se="FLAG",xe="BASIC",Pe="DETAILED",Ae="VERBOSE";let Ie=Pe,Te=!0;const ke=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await qe(e,t)}},Ve=e((({ast:e,schemaUri:t},r,o=Se)=>{if(![Se,xe,Pe,Ae].includes(o))throw Error(`The '${o}' error format is not supported`);const a=[],i=n.subscribe("result",Re(o,a));return De(t,r,e,{}),n.unsubscribe(i),a[0]})),Re=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===xe&&(o.push(...t.errors),delete t.errors),(e===Ae||e!==Se&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ue={},Ce=e=>Ue[e],ze=e=>e in Ue,Ke={},Le={},qe=async(e,t)=>{if(e=await _e(e),!ze(`${e.schemaVersion}#validate`)){const t=await Oe.get(e.schemaVersion);(Oe.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 Ke)Object.entries(Ke[e]).forEach((([e,r])=>{((e,t)=>{Ue[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Te&&!e.validated){if(Oe.markValidated(e.id),!(e.schemaVersion in Le)){const t=await Oe.get(e.schemaVersion),r=await ke(t);Le[t.id]=Ve(r)}const t=K.cons(e.schema,e.id),r=Le[e.schemaVersion](t,Ie);if(!r.valid)throw new je(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),Ce(`${e.schemaVersion}#validate`).compile(e,t)},_e=async e=>Oe.typeOf(e,"string")?_e(await Oe.get(Oe.value(e),e)):e,De=(e,t,r,n)=>{const o=Ne(e,r),a=$e(e)[0];return Ce(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Ne=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Be={validate:async(e,t,r)=>{const n=await ke(e),o=(e,t)=>Ve(n,K.cons(e),t);return void 0===t?o:o(t,r)},compile:ke,interpret:Ve,setMetaOutputFormat:e=>{Ie=e},setShouldMetaValidate:e=>{Te=e},FLAG:Se,BASIC:xe,DETAILED:Pe,VERBOSE:Ae,add:(e,t="",r="")=>{const n=Oe.add(e,t,r);delete Le[n]},getKeyword:Ce,hasKeyword:ze,defineVocabulary:(e,t)=>{Ke[e]=t},compileSchema:qe,interpretSchema:De,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Ne(e,r);return Ce(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Ne(e,r);return Ce(a).collectEvaluatedItems(e,t,r,n,o)}};var Fe={compile:e=>Oe.value(e),interpret:()=>!0};var Ze={compile:async(e,t)=>{const r=Oe.uri(e);if(!(r in t)){t[r]=!1;const n=Oe.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Oe.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Oe.uri(e),"boolean"==typeof n?n:await ee.pipeline([Oe.entries,ee.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ee.filter((([t])=>Be.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),ee.map((async([r,n])=>{const o=await Be.getKeyword(r).compile(n,t,e);return[r,Oe.uri(n),o]})),ee.all],e)]}return r},interpret:(e,t,r,o)=>{const[a,i,s]=r[e];n.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{n.publishSync("result.start");const s=Be.getKeyword(e).interpret(i,t,r,o);return n.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:K.uri(t),valid:s,ast:i}),n.publishSync("result.end"),s}));return n.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:K.uri(t),valid:c,ast:e}),n.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Be.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Be.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Me={metaData:Fe,validate:Ze},We={Core:Be,Schema:Oe,Instance:K,Reference:x,Keywords:Me,InvalidSchemaError:je},Je=We.Core,Ge=We.Schema,He=We.Instance,Qe=We.Reference,Xe=We.Keywords,Ye=We.InvalidSchemaError;exports.Core=Je,exports.Instance=He,exports.InvalidSchemaError=Ye,exports.Keywords=Xe,exports.Reference=Qe,exports.Schema=Ge,exports.default=We; | ||
//# sourceMappingURL=json-schema-core-cjs.min.js.map |
@@ -1,3 +0,1 @@ | ||
import urlResolveBrowser from 'url-resolve-browser'; | ||
var justCurryIt = curry; | ||
@@ -399,2 +397,213 @@ | ||
var urlResolveBrowser = urlResolve; | ||
/* | ||
The majority of the module is built by following RFC1808 | ||
url: https://tools.ietf.org/html/rfc1808 | ||
*/ | ||
// adds a slash at end if not present | ||
function _addSlash (url) { | ||
return url + (url[url.length-1] === '/' ? '' : '/'); | ||
} | ||
// resolve the ..'s (directory up) and such | ||
function _pathResolve (path) { | ||
let pathSplit = path.split('/'); | ||
// happens when path starts with / | ||
if (pathSplit[0] === '') { | ||
pathSplit = pathSplit.slice(1); | ||
} | ||
// let segmentCount = 0; // number of segments that have been passed | ||
let resultArray = []; | ||
pathSplit.forEach((current, index) => { | ||
// skip occurances of '.' | ||
if (current !== '.') { | ||
if (current === '..') { | ||
resultArray.pop(); // remove previous | ||
} else if (current !== '' || index === pathSplit.length - 1) { | ||
resultArray.push(current); | ||
} | ||
} | ||
}); | ||
return '/' + resultArray.join('/'); | ||
} | ||
// parses a base url string into an object containing host, path and query | ||
function _baseParse (base) { | ||
const resultObject = { | ||
host: '', | ||
path: '', | ||
query: '', | ||
protocol: '' | ||
}; | ||
let path = base; | ||
let protocolEndIndex = base.indexOf('//'); | ||
resultObject.protocol = path.substring(0, protocolEndIndex); | ||
protocolEndIndex += 2; // add two to pass double slash | ||
const pathIndex = base.indexOf('/', protocolEndIndex); | ||
const queryIndex = base.indexOf('?'); | ||
const hashIndex = base.indexOf('#'); | ||
if (hashIndex !== -1) { | ||
path = path.substring(0, hashIndex); // remove hash, not needed for base | ||
} | ||
if (queryIndex !== -1) { | ||
const query = path.substring(queryIndex); // remove query, save in return obj | ||
resultObject.query = query; | ||
path = path.substring(0, queryIndex); | ||
} | ||
if (pathIndex !== -1) { | ||
const host = path.substring(0, pathIndex); // separate host & path | ||
resultObject.host = host; | ||
path = path.substring(pathIndex); | ||
resultObject.path = path; | ||
} else { | ||
resultObject.host = path; // there was no path, therefore path is host | ||
} | ||
return resultObject; | ||
} | ||
// https://tools.ietf.org/html/rfc3986#section-3.1 | ||
const _scheme = '[a-z][a-z0-9+.-]*'; // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )] | ||
const _isAbsolute = new RegExp(`^(${_scheme}:)?//`, 'i'); | ||
// parses a relative url string into an object containing the href, | ||
// hash, query and whether it is a net path, absolute path or relative path | ||
function _relativeParse (relative) { | ||
const resultObject = { | ||
href: relative, // href is always what was passed through | ||
hash: '', | ||
query: '', | ||
netPath: false, | ||
absolutePath: false, | ||
relativePath: false | ||
}; | ||
// check for protocol | ||
// if protocol exists, is net path (absolute URL) | ||
if (_isAbsolute.test(relative)) { | ||
resultObject.netPath = true; | ||
// return, in this case the relative is the resolved url, no need to parse. | ||
return resultObject; | ||
} | ||
// if / is first, this is an absolute path, | ||
// I.E. it overwrites the base URL's path | ||
if (relative[0] === '/') { | ||
resultObject.absolutePath = true; | ||
// return resultObject | ||
} else if (relative !== '') { | ||
resultObject.relativePath = true; | ||
} | ||
let path = relative; | ||
const queryIndex = relative.indexOf('?'); | ||
const hashIndex = relative.indexOf('#'); | ||
if (hashIndex !== -1) { | ||
const hash = path.substring(hashIndex); | ||
resultObject.hash = hash; | ||
path = path.substring(0, hashIndex); | ||
} | ||
if (queryIndex !== -1) { | ||
const query = path.substring(queryIndex); | ||
resultObject.query = query; | ||
path = path.substring(0, queryIndex); | ||
} | ||
resultObject.path = path; // whatever is left is path | ||
return resultObject; | ||
} | ||
function _shouldAddSlash (url) { | ||
const protocolIndex = url.indexOf('//') + 2; | ||
const noPath = !(url.includes('/', protocolIndex)); | ||
const noQuery = !(url.includes('?', protocolIndex)); | ||
const noHash = !(url.includes('#', protocolIndex)); | ||
return (noPath && noQuery && noHash); | ||
} | ||
function _shouldAddProtocol (url) { | ||
return url.startsWith('//'); | ||
} | ||
/* | ||
* PRECONDITION: Base is a fully qualified URL. e.g. http://example.com/ | ||
* optional: path, query or hash | ||
* returns the resolved url | ||
*/ | ||
function urlResolve (base, relative) { | ||
base = base.trim(); | ||
relative = relative.trim(); | ||
// about is always absolute | ||
if (relative.startsWith('about:')) { | ||
return relative; | ||
} | ||
const baseObj = _baseParse(base); | ||
const relativeObj = _relativeParse(relative); | ||
if (!baseObj.protocol && !relativeObj.netPath) { | ||
throw new Error('Error, protocol is not specified'); | ||
} | ||
if (relativeObj.netPath) { // relative is full qualified URL | ||
if (_shouldAddProtocol(relativeObj.href)) { | ||
relativeObj.href = baseObj.protocol + relativeObj.href; | ||
} | ||
if (_shouldAddSlash(relativeObj.href)) { | ||
return _addSlash(relativeObj.href); | ||
} | ||
return relativeObj.href; | ||
} else if (relativeObj.absolutePath) { // relative is an absolute path | ||
const {path, query, hash} = relativeObj; | ||
return baseObj.host + _pathResolve(path) + query + hash; | ||
} else if (relativeObj.relativePath) { // relative is a relative path | ||
const {path, query, hash} = relativeObj; | ||
let basePath = baseObj.path; | ||
let resultString = baseObj.host; | ||
let resolvePath; | ||
if (path.length === 0) { | ||
resolvePath = basePath; | ||
} else { | ||
// remove last segment if no slash at end | ||
basePath = basePath.substring(0, basePath.lastIndexOf('/')); | ||
resolvePath = _pathResolve(basePath + '/' + path); | ||
} | ||
// if result is just the base host, add / | ||
if ((resolvePath === '') && (!query) && (!hash)) { | ||
resultString += '/'; | ||
} else { | ||
resultString += resolvePath + query + hash; | ||
} | ||
return resultString; | ||
} else { | ||
const {host, path, query} = baseObj; | ||
// when path and query aren't supplied add slash | ||
if ((!path) && (!query)) { | ||
return _addSlash(host); | ||
} | ||
return host + path + query + relativeObj.hash; | ||
} | ||
} | ||
const isObject = (value) => typeof value === "object" && !Array.isArray(value) && value !== null; | ||
@@ -401,0 +610,0 @@ const isType = { |
@@ -1,2 +0,2 @@ | ||
import e from"url-resolve-browser";var t=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)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,o=(function(e,t){var n;n={},("object"==typeof window&&window||r).PubSub=n,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function p(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function f(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!p(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return f(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return f(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},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)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(n),void 0!==e&&e.exports&&(t=e.exports=n),t.PubSub=n,e.exports=t=n}(n={exports:{}},n.exports),n.exports);o.PubSub;const a={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},i=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)]},s=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var c={jsonTypeOf:(e,t)=>a[t](e),splitUrl:i,safeResolveUrl:(t,r)=>{const n=e(t,r),o=i(t)[0];if(o&&"file"===s(n)&&"file"!==s(o))throw Error(`Can't access file '${n}' resource from network context '${t}'`);return n}};const l=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(v)},u=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:u(e,b(t,o,n),r,y(o,n))}}if(Array.isArray(t)){const n=[...t];return n[m(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:b(t,e[0],n)},p=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||w(t)){const o=e.shift();p(e,b(t,o,n),r,y(o,n))}else{t[m(t,e[0])]=r}},f=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=b(t,n,r);return{...t,[n]:f(e,o,y(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 b(t,e[0],r)}},d=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=b(t,n,r);d(e,o,y(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:b(t,e[0],r)},y=t(((e,t)=>t+"/"+h(e))),h=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),v=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),m=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,b=(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(w(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[m(e,t)]},w=e=>null===e||"object"!=typeof e;var g={nil:"",append:y,get:(e,t)=>{const r=l(e),n=e=>r.reduce((([e,t],r)=>[b(e,r,t),y(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=l(e),a=t(((e,t)=>u(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=l(e),a=t(((e,t)=>p(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=l(e),n=e=>f(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=l(e),n=e=>d(r,e,"");return void 0===t?n:n(t)}};g.nil,g.append,g.get,g.set,g.assign,g.unset,g.remove;const O=Symbol("$__value"),E=Symbol("$__href");var j={cons:(e,t)=>Object.freeze({[E]:e,[O]:t}),isReference:e=>e&&void 0!==e[E],href:e=>e[E],value:e=>e[O]};const{jsonTypeOf:$}=c,S=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),A=e=>j.isReference(e.value)?j.value(e.value):e.value,I=t(((e,t)=>$(A(e),t))),T=(e,t)=>Object.freeze({...t,pointer:g.append(e,t.pointer),value:A(t)[e]}),k=t(((e,t)=>A(t).map(((r,n,o,a)=>e(T(n,t),n,o,a))))),x=t(((e,t)=>A(t).map(((e,r,n,o)=>T(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),P=t(((e,t,r)=>A(r).reduce(((t,n,o)=>e(t,T(o,r),o)),t))),V=t(((e,t)=>A(t).every(((r,n,o,a)=>e(T(n,t),n,o,a))))),R=t(((e,t)=>A(t).some(((r,n,o,a)=>e(T(n,t),n,o,a)))));var U={nil:S,cons:(e,t="")=>Object.freeze({...S,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:A,has:(e,t)=>e in A(t),typeOf:I,step:T,entries:e=>Object.keys(A(e)).map((t=>[t,T(t,e)])),keys:e=>Object.keys(A(e)),map:k,filter:x,reduce:P,every:V,some:R,length:e=>A(e).length},C=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,K=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,L=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,z=/\\([\u000b\u0020-\u00ff])/g,_=/([\\"])/g,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function N(e){var t=String(e);if(L.test(t))return t;if(t.length>0&&!K.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(_,"\\$1")+'"'}function q(e){this.parameters=Object.create(null),this.type=e}var B={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],!L.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+N(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 q(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(z,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},F=async e=>Object.entries(await e),Z=t((async(e,t)=>(await t).map(e))),J=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),M=t((async(e,t,r={})=>J((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),G=t((async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).some((e=>e))})),H=t((async(e,t)=>{const r=await Z(e,t);return(await Promise.all(r)).every((e=>e))})),W=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),Q={entries:F,map:Z,filter:M,reduce:J,some:G,every:H,pipeline:W,all:e=>Promise.all(e),allValues:e=>W([F,J((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};Q.entries,Q.map,Q.filter,Q.reduce,Q.some,Q.every,Q.pipeline,Q.all,Q.allValues;var X=fetch;const{jsonTypeOf:Y,splitUrl:ee,safeResolveUrl:te}=c,re={},ne={},oe=(e,t)=>{const r=e in ne?ne[e]:e;if(r in re)return re[r][t]},ae={},ie={},se=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ee(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=oe(n,"baseToken"),a=oe(n,"anchorToken"),i=ee(t)[0];if(!i&&!ee(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=te(i,e[o]||""),[c,l]=ee(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(ie[i]=c);const u={},p=oe(n,"recursiveAnchorToken");let f;!0===e[p]&&(u[""]=`${c}#`,e[a]="",delete e[p]);const d=oe(n,"vocabularyToken");Y(e[d],"object")?(ne[c]=n,f=e[d],delete e[d]):(ne[c]=n,f={[n]:!0});const y={"":""};return ae[c]={id:c,schemaVersion:n,schema:ce(e,c,n,g.nil,y,u),anchors:y,dynamicAnchors:u,vocabulary:f,validated:!1},c},ce=(e,t,r,n,o,a)=>{if(Y(e,"object")){const i="string"==typeof e.$schema?ee(e.$schema)[0]:r,s=oe(i,"embeddedToken"),c=oe(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=te(t,e[s]);return e[s]=n,se(e,n,r),j.cons(e[s],e)}const l=oe(r,"anchorToken"),u=oe(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const p=oe(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==p?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const f=oe(r,"jrefToken");if("string"==typeof e[f])return j.cons(e[f],e);for(const i in e)e[i]=ce(e[i],t,r,g.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>ce(e,t,r,g.append(i,n),o,a))):e},le=e=>ae[ie[e]]||ae[e],ue=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:g.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),pe=async(e,t=ue)=>{const r=te(ye(t),e),[n,o]=ee(r);if(!(e=>e in ae||e in ie)(n)){const e=await X(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=B.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}se(await e.json(),n)}const a=le(n),i="/"!==o[0]?de(a,o):o,s=Object.freeze({...a,pointer:i,value:g.get(i,a.schema)});return fe(s)},fe=e=>j.isReference(e.value)?pe(j.href(e.value),e):e,de=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ye=e=>`${e.id}#${encodeURI(e.pointer)}`,he=e=>j.isReference(e.value)?j.value(e.value):e.value,ve=(e,t)=>{const r=le(t.id),n=Object.freeze({...t,pointer:g.append(e,t.pointer),value:he(t)[e],validated:r.validated});return fe(n)},me=t(((e,t)=>Q.pipeline([he,Q.map((async(r,n)=>e(await ve(n,t),n))),Q.all],t)));var be={setConfig:(e,t,r)=>{re[e]||(re[e]={}),re[e][t]=r},getConfig:oe,add:se,get:pe,markValidated:e=>{ae[e].validated=!0},uri:ye,value:he,getAnchorPointer:de,typeOf:(e,t)=>Y(he(e),t),has:(e,t)=>e in he(t),step:ve,keys:e=>Object.keys(he(e)),entries:e=>Q.pipeline([he,Object.keys,Q.map((async t=>[t,await ve(t,e)])),Q.all],e),map:me,length:e=>he(e).length};be.setConfig,be.getConfig,be.add,be.get,be.markValidated,be.uri,be.value,be.getAnchorPointer,be.typeOf,be.has,be.step,be.keys,be.entries,be.map,be.length;class we extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var ge=we;const{splitUrl:Oe}=c,Ee="FLAG",je="BASIC",$e="DETAILED",Se="VERBOSE";let Ae=$e,Ie=!0;const Te=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Ke(e,t)}},ke=t((({ast:e,schemaUri:t},r,n=Ee)=>{if(![Ee,je,$e,Se].includes(n))throw Error(`The '${n}' error format is not supported`);const a=[],i=o.subscribe("result",xe(n,a));return ze(t,r,e,{}),o.unsubscribe(i),a[0]})),xe=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===je&&(o.push(...t.errors),delete t.errors),(e===Se||e!==Ee&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Pe={},Ve=e=>Pe[e],Re=e=>e in Pe,Ue={},Ce={},Ke=async(e,t)=>{if(e=await Le(e),!Re(`${e.schemaVersion}#validate`)){const t=await be.get(e.schemaVersion);(be.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)=>{Pe[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Ie&&!e.validated){if(be.markValidated(e.id),!(e.schemaVersion in Ce)){const t=await be.get(e.schemaVersion),r=await Te(t);Ce[t.id]=ke(r)}const t=U.cons(e.schema,e.id),r=Ce[e.schemaVersion](t,Ae);if(!r.valid)throw new ge(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),Ve(`${e.schemaVersion}#validate`).compile(e,t)},Le=async e=>be.typeOf(e,"string")?Le(await be.get(be.value(e),e)):e,ze=(e,t,r,n)=>{const o=_e(e,r),a=Oe(e)[0];return Ve(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},_e=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var De={validate:async(e,t,r)=>{const n=await Te(e),o=(e,t)=>ke(n,U.cons(e),t);return void 0===t?o:o(t,r)},compile:Te,interpret:ke,setMetaOutputFormat:e=>{Ae=e},setShouldMetaValidate:e=>{Ie=e},FLAG:Ee,BASIC:je,DETAILED:$e,VERBOSE:Se,add:(e,t="",r="")=>{const n=be.add(e,t,r);delete Ce[n]},getKeyword:Ve,hasKeyword:Re,defineVocabulary:(e,t)=>{Ue[e]=t},compileSchema:Ke,interpretSchema:ze,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=_e(e,r);return Ve(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=_e(e,r);return Ve(a).collectEvaluatedItems(e,t,r,n,o)}};var Ne={compile:e=>be.value(e),interpret:()=>!0};var qe={compile:async(e,t)=>{const r=be.uri(e);if(!(r in t)){t[r]=!1;const n=be.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${be.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,be.uri(e),"boolean"==typeof n?n:await Q.pipeline([be.entries,Q.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),Q.filter((([t])=>De.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),Q.map((async([r,n])=>{const o=await De.getKeyword(r).compile(n,t,e);return[r,be.uri(n),o]})),Q.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=De.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:U.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:U.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&De.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&De.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Be={metaData:Ne,validate:qe},Fe={Core:De,Schema:be,Instance:U,Reference:j,Keywords:Be,InvalidSchemaError:ge},Ze=Fe.Core,Je=Fe.Schema,Me=Fe.Instance,Ge=Fe.Reference,He=Fe.Keywords,We=Fe.InvalidSchemaError;export{Ze as Core,Me as Instance,We as InvalidSchemaError,He as Keywords,Ge as Reference,Je as Schema,Fe as default}; | ||
var e=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)))}}};var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r,n=(function(e,r){var n;n={},("object"==typeof window&&window||t).PubSub=n,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},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)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(n),void 0!==e&&e.exports&&(r=e.exports=n),r.PubSub=n,e.exports=r=n}(r={exports:{}},r.exports),r.exports);n.PubSub;var o=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(s.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)?a(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+i(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,s=r.path,c=r.host;return 0===e.length?a=s:(s=s.substring(0,s.lastIndexOf("/")),a=i(s+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:a(e)}};function a(e){return e+("/"===e[e.length-1]?"":"/")}function i(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 s=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const c={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},l=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)]},u=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var f={jsonTypeOf:(e,t)=>c[t](e),splitUrl:l,safeResolveUrl:(e,t)=>{const r=o(e,t),n=l(e)[0];if(n&&"file"===u(r)&&"file"!==u(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const p=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(w)},d=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:d(e,O(t,o,n),r,b(o,n))}}if(Array.isArray(t)){const n=[...t];return n[g(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:O(t,e[0],n)},h=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||E(t)){const o=e.shift();h(e,O(t,o,n),r,b(o,n))}else{t[g(t,e[0])]=r}},y=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=O(t,n,r);return{...t,[n]:y(e,o,b(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 O(t,e[0],r)}},v=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=O(t,n,r);v(e,o,b(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:O(t,e[0],r)},b=e(((e,t)=>t+"/"+m(e))),m=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),w=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),g=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,O=(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(E(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[g(e,t)]},E=e=>null===e||"object"!=typeof e;var j={nil:"",append:b,get:(e,t)=>{const r=p(e),n=e=>r.reduce((([e,t],r)=>[O(e,r,t),b(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(t,r,n)=>{const o=p(t),a=e(((e,t)=>d(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(t,r,n)=>{const o=p(t),a=e(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=p(e),n=e=>y(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=p(e),n=e=>v(r,e,"");return void 0===t?n:n(t)}};j.nil,j.append,j.get,j.set,j.assign,j.unset,j.remove;const $=Symbol("$__value"),S=Symbol("$__href");var x={cons:(e,t)=>Object.freeze({[S]:e,[$]:t}),isReference:e=>e&&void 0!==e[S],href:e=>e[S],value:e=>e[$]};const{jsonTypeOf:A}=f,P=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),I=e=>x.isReference(e.value)?x.value(e.value):e.value,T=e(((e,t)=>A(I(e),t))),k=(e,t)=>Object.freeze({...t,pointer:j.append(e,t.pointer),value:I(t)[e]}),V=e(((e,t)=>I(t).map(((r,n,o,a)=>e(k(n,t),n,o,a))))),R=e(((e,t)=>I(t).map(((e,r,n,o)=>k(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),U=e(((e,t,r)=>I(r).reduce(((t,n,o)=>e(t,k(o,r),o)),t))),C=e(((e,t)=>I(t).every(((r,n,o,a)=>e(k(n,t),n,o,a))))),z=e(((e,t)=>I(t).some(((r,n,o,a)=>e(k(n,t),n,o,a)))));var K={nil:P,cons:(e,t="")=>Object.freeze({...P,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:I,has:(e,t)=>e in I(t),typeOf:T,step:k,entries:e=>Object.keys(I(e)).map((t=>[t,k(t,e)])),keys:e=>Object.keys(I(e)),map:V,filter:R,reduce:U,every:C,some:z,length:e=>I(e).length},L=/; *([!#$%&'*+.^_`|~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-]+$/,D=/\\([\u000b\u0020-\u00ff])/g,N=/([\\"])/g,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function F(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(N,"\\$1")+'"'}function Z(e){this.parameters=Object.create(null),this.type=e}var W={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+"="+F(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 Z(n.toLowerCase());if(-1!==r){var a,i,s;for(L.lastIndex=r;i=L.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(D,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},J=async e=>Object.entries(await e),M=e((async(e,t)=>(await t).map(e))),G=e((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),H=e((async(e,t,r={})=>G((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),Q=e((async(e,t)=>{const r=await M(e,t);return(await Promise.all(r)).some((e=>e))})),X=e((async(e,t)=>{const r=await M(e,t);return(await Promise.all(r)).every((e=>e))})),Y=e(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ee={entries:J,map:M,filter:H,reduce:G,some:Q,every:X,pipeline:Y,all:e=>Promise.all(e),allValues:e=>Y([J,G((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};ee.entries,ee.map,ee.filter,ee.reduce,ee.some,ee.every,ee.pipeline,ee.all,ee.allValues;var te=fetch;const{jsonTypeOf:re,splitUrl:ne,safeResolveUrl:oe}=f,ae={},ie={},se=(e,t)=>{const r=e in ie?ie[e]:e;if(r in ae)return ae[r][t]},ce={},le={},ue=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ne(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=se(n,"baseToken"),a=se(n,"anchorToken"),i=ne(t)[0];if(!i&&!ne(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=oe(i,e[o]||""),[c,l]=ne(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(le[i]=c);const u={},f=se(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=se(n,"vocabularyToken");re(e[d],"object")?(ie[c]=n,p=e[d],delete e[d]):(ie[c]=n,p={[n]:!0});const h={"":""};return ce[c]={id:c,schemaVersion:n,schema:fe(e,c,n,j.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:p,validated:!1},c},fe=(e,t,r,n,o,a)=>{if(re(e,"object")){const i="string"==typeof e.$schema?ne(e.$schema)[0]:r,s=se(i,"embeddedToken"),c=se(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=oe(t,e[s]);return e[s]=n,ue(e,n,r),x.cons(e[s],e)}const l=se(r,"anchorToken"),u=se(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=se(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=se(r,"jrefToken");if("string"==typeof e[p])return x.cons(e[p],e);for(const i in e)e[i]=fe(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>fe(e,t,r,j.append(i,n),o,a))):e},pe=e=>ce[le[e]]||ce[e],de=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),he=async(e,t=de)=>{const r=oe(be(t),e),[n,o]=ne(r);if(!(e=>e in ce||e in le)(n)){const e=await te(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=W.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}ue(await e.json(),n)}const a=pe(n),i="/"!==o[0]?ve(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return ye(s)},ye=e=>x.isReference(e.value)?he(x.href(e.value),e):e,ve=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},be=e=>`${e.id}#${encodeURI(e.pointer)}`,me=e=>x.isReference(e.value)?x.value(e.value):e.value,we=(e,t)=>{const r=pe(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:me(t)[e],validated:r.validated});return ye(n)},ge=e(((e,t)=>ee.pipeline([me,ee.map((async(r,n)=>e(await we(n,t),n))),ee.all],t)));var Oe={setConfig:(e,t,r)=>{ae[e]||(ae[e]={}),ae[e][t]=r},getConfig:se,add:ue,get:he,markValidated:e=>{ce[e].validated=!0},uri:be,value:me,getAnchorPointer:ve,typeOf:(e,t)=>re(me(e),t),has:(e,t)=>e in me(t),step:we,keys:e=>Object.keys(me(e)),entries:e=>ee.pipeline([me,Object.keys,ee.map((async t=>[t,await we(t,e)])),ee.all],e),map:ge,length:e=>me(e).length};Oe.setConfig,Oe.getConfig,Oe.add,Oe.get,Oe.markValidated,Oe.uri,Oe.value,Oe.getAnchorPointer,Oe.typeOf,Oe.has,Oe.step,Oe.keys,Oe.entries,Oe.map,Oe.length;class Ee extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var je=Ee;const{splitUrl:$e}=f,Se="FLAG",xe="BASIC",Ae="DETAILED",Pe="VERBOSE";let Ie=Ae,Te=!0;const ke=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await qe(e,t)}},Ve=e((({ast:e,schemaUri:t},r,o=Se)=>{if(![Se,xe,Ae,Pe].includes(o))throw Error(`The '${o}' error format is not supported`);const a=[],i=n.subscribe("result",Re(o,a));return De(t,r,e,{}),n.unsubscribe(i),a[0]})),Re=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===xe&&(o.push(...t.errors),delete t.errors),(e===Pe||e!==Se&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ue={},Ce=e=>Ue[e],ze=e=>e in Ue,Ke={},Le={},qe=async(e,t)=>{if(e=await _e(e),!ze(`${e.schemaVersion}#validate`)){const t=await Oe.get(e.schemaVersion);(Oe.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 Ke)Object.entries(Ke[e]).forEach((([e,r])=>{((e,t)=>{Ue[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Te&&!e.validated){if(Oe.markValidated(e.id),!(e.schemaVersion in Le)){const t=await Oe.get(e.schemaVersion),r=await ke(t);Le[t.id]=Ve(r)}const t=K.cons(e.schema,e.id),r=Le[e.schemaVersion](t,Ie);if(!r.valid)throw new je(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),Ce(`${e.schemaVersion}#validate`).compile(e,t)},_e=async e=>Oe.typeOf(e,"string")?_e(await Oe.get(Oe.value(e),e)):e,De=(e,t,r,n)=>{const o=Ne(e,r),a=$e(e)[0];return Ce(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Ne=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Be={validate:async(e,t,r)=>{const n=await ke(e),o=(e,t)=>Ve(n,K.cons(e),t);return void 0===t?o:o(t,r)},compile:ke,interpret:Ve,setMetaOutputFormat:e=>{Ie=e},setShouldMetaValidate:e=>{Te=e},FLAG:Se,BASIC:xe,DETAILED:Ae,VERBOSE:Pe,add:(e,t="",r="")=>{const n=Oe.add(e,t,r);delete Le[n]},getKeyword:Ce,hasKeyword:ze,defineVocabulary:(e,t)=>{Ke[e]=t},compileSchema:qe,interpretSchema:De,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Ne(e,r);return Ce(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Ne(e,r);return Ce(a).collectEvaluatedItems(e,t,r,n,o)}};var Fe={compile:e=>Oe.value(e),interpret:()=>!0};var Ze={compile:async(e,t)=>{const r=Oe.uri(e);if(!(r in t)){t[r]=!1;const n=Oe.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Oe.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Oe.uri(e),"boolean"==typeof n?n:await ee.pipeline([Oe.entries,ee.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ee.filter((([t])=>Be.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),ee.map((async([r,n])=>{const o=await Be.getKeyword(r).compile(n,t,e);return[r,Oe.uri(n),o]})),ee.all],e)]}return r},interpret:(e,t,r,o)=>{const[a,i,s]=r[e];n.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{n.publishSync("result.start");const s=Be.getKeyword(e).interpret(i,t,r,o);return n.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:K.uri(t),valid:s,ast:i}),n.publishSync("result.end"),s}));return n.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:K.uri(t),valid:c,ast:e}),n.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Be.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Be.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},We={metaData:Fe,validate:Ze},Je={Core:Be,Schema:Oe,Instance:K,Reference:x,Keywords:We,InvalidSchemaError:je},Me=Je.Core,Ge=Je.Schema,He=Je.Instance,Qe=Je.Reference,Xe=Je.Keywords,Ye=Je.InvalidSchemaError;export{Me as Core,He as Instance,Ye as InvalidSchemaError,Xe as Keywords,Qe as Reference,Ge as Schema,Je as default}; | ||
//# sourceMappingURL=json-schema-core-esm.min.js.map |
@@ -1,8 +0,4 @@ | ||
var JSC = (function (exports, urlResolveBrowser) { | ||
var JSC = (function (exports) { | ||
'use strict'; | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var urlResolveBrowser__default = /*#__PURE__*/_interopDefaultLegacy(urlResolveBrowser); | ||
var justCurryIt = curry; | ||
@@ -404,2 +400,213 @@ | ||
var urlResolveBrowser = urlResolve; | ||
/* | ||
The majority of the module is built by following RFC1808 | ||
url: https://tools.ietf.org/html/rfc1808 | ||
*/ | ||
// adds a slash at end if not present | ||
function _addSlash (url) { | ||
return url + (url[url.length-1] === '/' ? '' : '/'); | ||
} | ||
// resolve the ..'s (directory up) and such | ||
function _pathResolve (path) { | ||
let pathSplit = path.split('/'); | ||
// happens when path starts with / | ||
if (pathSplit[0] === '') { | ||
pathSplit = pathSplit.slice(1); | ||
} | ||
// let segmentCount = 0; // number of segments that have been passed | ||
let resultArray = []; | ||
pathSplit.forEach((current, index) => { | ||
// skip occurances of '.' | ||
if (current !== '.') { | ||
if (current === '..') { | ||
resultArray.pop(); // remove previous | ||
} else if (current !== '' || index === pathSplit.length - 1) { | ||
resultArray.push(current); | ||
} | ||
} | ||
}); | ||
return '/' + resultArray.join('/'); | ||
} | ||
// parses a base url string into an object containing host, path and query | ||
function _baseParse (base) { | ||
const resultObject = { | ||
host: '', | ||
path: '', | ||
query: '', | ||
protocol: '' | ||
}; | ||
let path = base; | ||
let protocolEndIndex = base.indexOf('//'); | ||
resultObject.protocol = path.substring(0, protocolEndIndex); | ||
protocolEndIndex += 2; // add two to pass double slash | ||
const pathIndex = base.indexOf('/', protocolEndIndex); | ||
const queryIndex = base.indexOf('?'); | ||
const hashIndex = base.indexOf('#'); | ||
if (hashIndex !== -1) { | ||
path = path.substring(0, hashIndex); // remove hash, not needed for base | ||
} | ||
if (queryIndex !== -1) { | ||
const query = path.substring(queryIndex); // remove query, save in return obj | ||
resultObject.query = query; | ||
path = path.substring(0, queryIndex); | ||
} | ||
if (pathIndex !== -1) { | ||
const host = path.substring(0, pathIndex); // separate host & path | ||
resultObject.host = host; | ||
path = path.substring(pathIndex); | ||
resultObject.path = path; | ||
} else { | ||
resultObject.host = path; // there was no path, therefore path is host | ||
} | ||
return resultObject; | ||
} | ||
// https://tools.ietf.org/html/rfc3986#section-3.1 | ||
const _scheme = '[a-z][a-z0-9+.-]*'; // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )] | ||
const _isAbsolute = new RegExp(`^(${_scheme}:)?//`, 'i'); | ||
// parses a relative url string into an object containing the href, | ||
// hash, query and whether it is a net path, absolute path or relative path | ||
function _relativeParse (relative) { | ||
const resultObject = { | ||
href: relative, // href is always what was passed through | ||
hash: '', | ||
query: '', | ||
netPath: false, | ||
absolutePath: false, | ||
relativePath: false | ||
}; | ||
// check for protocol | ||
// if protocol exists, is net path (absolute URL) | ||
if (_isAbsolute.test(relative)) { | ||
resultObject.netPath = true; | ||
// return, in this case the relative is the resolved url, no need to parse. | ||
return resultObject; | ||
} | ||
// if / is first, this is an absolute path, | ||
// I.E. it overwrites the base URL's path | ||
if (relative[0] === '/') { | ||
resultObject.absolutePath = true; | ||
// return resultObject | ||
} else if (relative !== '') { | ||
resultObject.relativePath = true; | ||
} | ||
let path = relative; | ||
const queryIndex = relative.indexOf('?'); | ||
const hashIndex = relative.indexOf('#'); | ||
if (hashIndex !== -1) { | ||
const hash = path.substring(hashIndex); | ||
resultObject.hash = hash; | ||
path = path.substring(0, hashIndex); | ||
} | ||
if (queryIndex !== -1) { | ||
const query = path.substring(queryIndex); | ||
resultObject.query = query; | ||
path = path.substring(0, queryIndex); | ||
} | ||
resultObject.path = path; // whatever is left is path | ||
return resultObject; | ||
} | ||
function _shouldAddSlash (url) { | ||
const protocolIndex = url.indexOf('//') + 2; | ||
const noPath = !(url.includes('/', protocolIndex)); | ||
const noQuery = !(url.includes('?', protocolIndex)); | ||
const noHash = !(url.includes('#', protocolIndex)); | ||
return (noPath && noQuery && noHash); | ||
} | ||
function _shouldAddProtocol (url) { | ||
return url.startsWith('//'); | ||
} | ||
/* | ||
* PRECONDITION: Base is a fully qualified URL. e.g. http://example.com/ | ||
* optional: path, query or hash | ||
* returns the resolved url | ||
*/ | ||
function urlResolve (base, relative) { | ||
base = base.trim(); | ||
relative = relative.trim(); | ||
// about is always absolute | ||
if (relative.startsWith('about:')) { | ||
return relative; | ||
} | ||
const baseObj = _baseParse(base); | ||
const relativeObj = _relativeParse(relative); | ||
if (!baseObj.protocol && !relativeObj.netPath) { | ||
throw new Error('Error, protocol is not specified'); | ||
} | ||
if (relativeObj.netPath) { // relative is full qualified URL | ||
if (_shouldAddProtocol(relativeObj.href)) { | ||
relativeObj.href = baseObj.protocol + relativeObj.href; | ||
} | ||
if (_shouldAddSlash(relativeObj.href)) { | ||
return _addSlash(relativeObj.href); | ||
} | ||
return relativeObj.href; | ||
} else if (relativeObj.absolutePath) { // relative is an absolute path | ||
const {path, query, hash} = relativeObj; | ||
return baseObj.host + _pathResolve(path) + query + hash; | ||
} else if (relativeObj.relativePath) { // relative is a relative path | ||
const {path, query, hash} = relativeObj; | ||
let basePath = baseObj.path; | ||
let resultString = baseObj.host; | ||
let resolvePath; | ||
if (path.length === 0) { | ||
resolvePath = basePath; | ||
} else { | ||
// remove last segment if no slash at end | ||
basePath = basePath.substring(0, basePath.lastIndexOf('/')); | ||
resolvePath = _pathResolve(basePath + '/' + path); | ||
} | ||
// if result is just the base host, add / | ||
if ((resolvePath === '') && (!query) && (!hash)) { | ||
resultString += '/'; | ||
} else { | ||
resultString += resolvePath + query + hash; | ||
} | ||
return resultString; | ||
} else { | ||
const {host, path, query} = baseObj; | ||
// when path and query aren't supplied add slash | ||
if ((!path) && (!query)) { | ||
return _addSlash(host); | ||
} | ||
return host + path + query + relativeObj.hash; | ||
} | ||
} | ||
const isObject = (value) => typeof value === "object" && !Array.isArray(value) && value !== null; | ||
@@ -432,3 +639,3 @@ const isType = { | ||
const safeResolveUrl$1 = (contextUrl, url) => { | ||
const resolvedUrl = urlResolveBrowser__default["default"](contextUrl, url); | ||
const resolvedUrl = urlResolveBrowser(contextUrl, url); | ||
const contextId = splitUrl$2(contextUrl)[0]; | ||
@@ -1545,3 +1752,3 @@ if (contextId && getScheme(resolvedUrl) === "file" && getScheme(contextId) !== "file") { | ||
})({}, urlResolveBrowser); | ||
})({}); | ||
//# sourceMappingURL=json-schema-core-iife.js.map |
@@ -1,2 +0,2 @@ | ||
var JSC=function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(t),o=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)))}}};var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var i,s=(function(e,t){var r,n;r="object"==typeof window&&window||a,n={},r.PubSub=n,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},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)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(n),void 0!==e&&e.exports&&(t=e.exports=n),t.PubSub=n,e.exports=t=n}(i={exports:{}},i.exports),i.exports);s.PubSub;const c={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},l=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)]},u=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var f={jsonTypeOf:(e,t)=>c[t](e),splitUrl:l,safeResolveUrl:(e,t)=>{const r=n.default(e,t),o=l(e)[0];if(o&&"file"===u(r)&&"file"!==u(o))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const p=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(w)},d=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:d(e,O(t,o,n),r,m(o,n))}}if(Array.isArray(t)){const n=[...t];return n[g(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:O(t,e[0],n)},y=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||j(t)){const o=e.shift();y(e,O(t,o,n),r,m(o,n))}else{t[g(t,e[0])]=r}},h=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=O(t,n,r);return{...t,[n]:h(e,o,m(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 O(t,e[0],r)}},v=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=O(t,n,r);v(e,o,m(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:O(t,e[0],r)},m=o(((e,t)=>t+"/"+b(e))),b=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),w=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),g=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,O=(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(j(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[g(e,t)]},j=e=>null===e||"object"!=typeof e;var E={nil:"",append:m,get:(e,t)=>{const r=p(e),n=e=>r.reduce((([e,t],r)=>[O(e,r,t),m(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const n=p(e),a=o(((e,t)=>d(n,e,t,"")));return void 0===t?a:a(t,r)},assign:(e,t,r)=>{const n=p(e),a=o(((e,t)=>y(n,e,t,"")));return void 0===t?a:a(t,r)},unset:(e,t)=>{const r=p(e),n=e=>h(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=p(e),n=e=>v(r,e,"");return void 0===t?n:n(t)}};E.nil,E.append,E.get,E.set,E.assign,E.unset,E.remove;const $=Symbol("$__value"),S=Symbol("$__href");var A={cons:(e,t)=>Object.freeze({[S]:e,[$]:t}),isReference:e=>e&&void 0!==e[S],href:e=>e[S],value:e=>e[$]};const{jsonTypeOf:I}=f,T=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),k=e=>A.isReference(e.value)?A.value(e.value):e.value,P=o(((e,t)=>I(k(e),t))),x=(e,t)=>Object.freeze({...t,pointer:E.append(e,t.pointer),value:k(t)[e]}),V=o(((e,t)=>k(t).map(((r,n,o,a)=>e(x(n,t),n,o,a))))),R=o(((e,t)=>k(t).map(((e,r,n,o)=>x(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),C=o(((e,t,r)=>k(r).reduce(((t,n,o)=>e(t,x(o,r),o)),t))),U=o(((e,t)=>k(t).every(((r,n,o,a)=>e(x(n,t),n,o,a))))),K=o(((e,t)=>k(t).some(((r,n,o,a)=>e(x(n,t),n,o,a)))));var L={nil:T,cons:(e,t="")=>Object.freeze({...T,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:k,has:(e,t)=>e in k(t),typeOf:P,step:x,entries:e=>Object.keys(k(e)).map((t=>[t,x(t,e)])),keys:e=>Object.keys(k(e)),map:V,filter:R,reduce:C,every:U,some:K,length:e=>k(e).length},z=/; *([!#$%&'*+.^_`|~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]+$/,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,N=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,q=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function F(e){var t=String(e);if(D.test(t))return t;if(t.length>0&&!_.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function Z(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||!q.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],!D.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+F(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(!q.test(n))throw new TypeError("invalid media type");var o=new Z(n.toLowerCase());if(-1!==r){var a,i,s;for(z.lastIndex=r;i=z.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(N,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},M=async e=>Object.entries(await e),G=o((async(e,t)=>(await t).map(e))),H=o((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),W=o((async(e,t,r={})=>H((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),Q=o((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).some((e=>e))})),X=o((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).every((e=>e))})),Y=o(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ee={entries:M,map:G,filter:W,reduce:H,some:Q,every:X,pipeline:Y,all:e=>Promise.all(e),allValues:e=>Y([M,H((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};ee.entries,ee.map,ee.filter,ee.reduce,ee.some,ee.every,ee.pipeline,ee.all,ee.allValues;var te=fetch;const{jsonTypeOf:re,splitUrl:ne,safeResolveUrl:oe}=f,ae={},ie={},se=(e,t)=>{const r=e in ie?ie[e]:e;if(r in ae)return ae[r][t]},ce={},le={},ue=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ne(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=se(n,"baseToken"),a=se(n,"anchorToken"),i=ne(t)[0];if(!i&&!ne(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=oe(i,e[o]||""),[c,l]=ne(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(le[i]=c);const u={},f=se(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=se(n,"vocabularyToken");re(e[d],"object")?(ie[c]=n,p=e[d],delete e[d]):(ie[c]=n,p={[n]:!0});const y={"":""};return ce[c]={id:c,schemaVersion:n,schema:fe(e,c,n,E.nil,y,u),anchors:y,dynamicAnchors:u,vocabulary:p,validated:!1},c},fe=(e,t,r,n,o,a)=>{if(re(e,"object")){const i="string"==typeof e.$schema?ne(e.$schema)[0]:r,s=se(i,"embeddedToken"),c=se(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=oe(t,e[s]);return e[s]=n,ue(e,n,r),A.cons(e[s],e)}const l=se(r,"anchorToken"),u=se(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=se(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=se(r,"jrefToken");if("string"==typeof e[p])return A.cons(e[p],e);for(const i in e)e[i]=fe(e[i],t,r,E.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>fe(e,t,r,E.append(i,n),o,a))):e},pe=e=>ce[le[e]]||ce[e],de=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:E.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),ye=async(e,t=de)=>{const r=oe(me(t),e),[n,o]=ne(r);if(!(e=>e in ce||e in le)(n)){const e=await te(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=J.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}ue(await e.json(),n)}const a=pe(n),i="/"!==o[0]?ve(a,o):o,s=Object.freeze({...a,pointer:i,value:E.get(i,a.schema)});return he(s)},he=e=>A.isReference(e.value)?ye(A.href(e.value),e):e,ve=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},me=e=>`${e.id}#${encodeURI(e.pointer)}`,be=e=>A.isReference(e.value)?A.value(e.value):e.value,we=(e,t)=>{const r=pe(t.id),n=Object.freeze({...t,pointer:E.append(e,t.pointer),value:be(t)[e],validated:r.validated});return he(n)},ge=o(((e,t)=>ee.pipeline([be,ee.map((async(r,n)=>e(await we(n,t),n))),ee.all],t)));var Oe={setConfig:(e,t,r)=>{ae[e]||(ae[e]={}),ae[e][t]=r},getConfig:se,add:ue,get:ye,markValidated:e=>{ce[e].validated=!0},uri:me,value:be,getAnchorPointer:ve,typeOf:(e,t)=>re(be(e),t),has:(e,t)=>e in be(t),step:we,keys:e=>Object.keys(be(e)),entries:e=>ee.pipeline([be,Object.keys,ee.map((async t=>[t,await we(t,e)])),ee.all],e),map:ge,length:e=>be(e).length};Oe.setConfig,Oe.getConfig,Oe.add,Oe.get,Oe.markValidated,Oe.uri,Oe.value,Oe.getAnchorPointer,Oe.typeOf,Oe.has,Oe.step,Oe.keys,Oe.entries,Oe.map,Oe.length;class je extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Ee=je;const{splitUrl:$e}=f,Se="FLAG",Ae="BASIC",Ie="DETAILED",Te="VERBOSE";let ke=Ie,Pe=!0;const xe=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await _e(e,t)}},Ve=o((({ast:e,schemaUri:t},r,n=Se)=>{if(![Se,Ae,Ie,Te].includes(n))throw Error(`The '${n}' error format is not supported`);const o=[],a=s.subscribe("result",Re(n,o));return Ne(t,r,e,{}),s.unsubscribe(a),o[0]})),Re=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Ae&&(o.push(...t.errors),delete t.errors),(e===Te||e!==Se&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ce={},Ue=e=>Ce[e],Ke=e=>e in Ce,Le={},ze={},_e=async(e,t)=>{if(e=await De(e),!Ke(`${e.schemaVersion}#validate`)){const t=await Oe.get(e.schemaVersion);(Oe.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 Le)Object.entries(Le[e]).forEach((([e,r])=>{((e,t)=>{Ce[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Pe&&!e.validated){if(Oe.markValidated(e.id),!(e.schemaVersion in ze)){const t=await Oe.get(e.schemaVersion),r=await xe(t);ze[t.id]=Ve(r)}const t=L.cons(e.schema,e.id),r=ze[e.schemaVersion](t,ke);if(!r.valid)throw new Ee(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),Ue(`${e.schemaVersion}#validate`).compile(e,t)},De=async e=>Oe.typeOf(e,"string")?De(await Oe.get(Oe.value(e),e)):e,Ne=(e,t,r,n)=>{const o=Be(e,r),a=$e(e)[0];return Ue(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Be=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var qe={validate:async(e,t,r)=>{const n=await xe(e),o=(e,t)=>Ve(n,L.cons(e),t);return void 0===t?o:o(t,r)},compile:xe,interpret:Ve,setMetaOutputFormat:e=>{ke=e},setShouldMetaValidate:e=>{Pe=e},FLAG:Se,BASIC:Ae,DETAILED:Ie,VERBOSE:Te,add:(e,t="",r="")=>{const n=Oe.add(e,t,r);delete ze[n]},getKeyword:Ue,hasKeyword:Ke,defineVocabulary:(e,t)=>{Le[e]=t},compileSchema:_e,interpretSchema:Ne,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Be(e,r);return Ue(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Be(e,r);return Ue(a).collectEvaluatedItems(e,t,r,n,o)}};var Fe={compile:e=>Oe.value(e),interpret:()=>!0};var Ze={compile:async(e,t)=>{const r=Oe.uri(e);if(!(r in t)){t[r]=!1;const n=Oe.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Oe.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Oe.uri(e),"boolean"==typeof n?n:await ee.pipeline([Oe.entries,ee.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ee.filter((([t])=>qe.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),ee.map((async([r,n])=>{const o=await qe.getKeyword(r).compile(n,t,e);return[r,Oe.uri(n),o]})),ee.all],e)]}return r},interpret:(e,t,r,n)=>{const[o,a,i]=r[e];s.publishSync("result.start");const c="boolean"==typeof i?i:i.every((([e,o,a])=>{s.publishSync("result.start");const i=qe.getKeyword(e).interpret(a,t,r,n);return s.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:L.uri(t),valid:i,ast:a}),s.publishSync("result.end"),i}));return s.publishSync("result",{keyword:o,absoluteKeywordLocation:a,instanceLocation:L.uri(t),valid:c,ast:e}),s.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&qe.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&qe.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Je={metaData:Fe,validate:Ze},Me={Core:qe,Schema:Oe,Instance:L,Reference:A,Keywords:Je,InvalidSchemaError:Ee},Ge=Me.Core,He=Me.Schema,We=Me.Instance,Qe=Me.Reference,Xe=Me.Keywords,Ye=Me.InvalidSchemaError;return e.Core=Ge,e.Instance=We,e.InvalidSchemaError=Ye,e.Keywords=Xe,e.Reference=Qe,e.Schema=He,e.default=Me,Object.defineProperty(e,"__esModule",{value:!0}),e}({},urlResolveBrowser); | ||
var JSC=function(e){"use strict";var t=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)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,o=(function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},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)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}(n={exports:{}},n.exports),n.exports);o.PubSub;var a=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(c.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)?i(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+s(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,i=r.path,c=r.host;return 0===e.length?a=i:(i=i.substring(0,i.lastIndexOf("/")),a=s(i+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:i(e)}};function i(e){return e+("/"===e[e.length-1]?"":"/")}function s(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 c=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const l={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},u=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)]},f=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var p={jsonTypeOf:(e,t)=>l[t](e),splitUrl:u,safeResolveUrl:(e,t)=>{const r=a(e,t),n=u(e)[0];if(n&&"file"===f(r)&&"file"!==f(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const d=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(g)},h=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:h(e,E(t,o,n),r,m(o,n))}}if(Array.isArray(t)){const n=[...t];return n[O(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:E(t,e[0],n)},y=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||j(t)){const o=e.shift();y(e,E(t,o,n),r,m(o,n))}else{t[O(t,e[0])]=r}},v=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=E(t,n,r);return{...t,[n]:v(e,o,m(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 E(t,e[0],r)}},b=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=E(t,n,r);b(e,o,m(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:E(t,e[0],r)},m=t(((e,t)=>t+"/"+w(e))),w=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),g=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),O=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,E=(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(j(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[O(e,t)]},j=e=>null===e||"object"!=typeof e;var $={nil:"",append:m,get:(e,t)=>{const r=d(e),n=e=>r.reduce((([e,t],r)=>[E(e,r,t),m(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=d(e),a=t(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=d(e),a=t(((e,t)=>y(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=d(e),n=e=>v(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=d(e),n=e=>b(r,e,"");return void 0===t?n:n(t)}};$.nil,$.append,$.get,$.set,$.assign,$.unset,$.remove;const S=Symbol("$__value"),P=Symbol("$__href");var A={cons:(e,t)=>Object.freeze({[P]:e,[S]:t}),isReference:e=>e&&void 0!==e[P],href:e=>e[P],value:e=>e[S]};const{jsonTypeOf:x}=p,I=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),T=e=>A.isReference(e.value)?A.value(e.value):e.value,k=t(((e,t)=>x(T(e),t))),V=(e,t)=>Object.freeze({...t,pointer:$.append(e,t.pointer),value:T(t)[e]}),R=t(((e,t)=>T(t).map(((r,n,o,a)=>e(V(n,t),n,o,a))))),C=t(((e,t)=>T(t).map(((e,r,n,o)=>V(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),U=t(((e,t,r)=>T(r).reduce(((t,n,o)=>e(t,V(o,r),o)),t))),z=t(((e,t)=>T(t).every(((r,n,o,a)=>e(V(n,t),n,o,a))))),K=t(((e,t)=>T(t).some(((r,n,o,a)=>e(V(n,t),n,o,a)))));var L={nil:I,cons:(e,t="")=>Object.freeze({...I,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:T,has:(e,t)=>e in T(t),typeOf:k,step:V,entries:e=>Object.keys(T(e)).map((t=>[t,V(t,e)])),keys:e=>Object.keys(T(e)),map:R,filter:C,reduce:U,every:z,some:K,length:e=>T(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]+$/,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,N=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,F=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function Z(e){var t=String(e);if(D.test(t))return t;if(t.length>0&&!_.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function J(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||!F.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],!D.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+Z(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(!F.test(n))throw new TypeError("invalid media type");var o=new J(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(N,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},W=async e=>Object.entries(await e),G=t((async(e,t)=>(await t).map(e))),H=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),Q=t((async(e,t,r={})=>H((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),X=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).some((e=>e))})),Y=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).every((e=>e))})),ee=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),te={entries:W,map:G,filter:Q,reduce:H,some:X,every:Y,pipeline:ee,all:e=>Promise.all(e),allValues:e=>ee([W,H((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};te.entries,te.map,te.filter,te.reduce,te.some,te.every,te.pipeline,te.all,te.allValues;var re=fetch;const{jsonTypeOf:ne,splitUrl:oe,safeResolveUrl:ae}=p,ie={},se={},ce=(e,t)=>{const r=e in se?se[e]:e;if(r in ie)return ie[r][t]},le={},ue={},fe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=oe(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=oe(t)[0];if(!i&&!oe(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ae(i,e[o]||""),[c,l]=oe(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(ue[i]=c);const u={},f=ce(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=ce(n,"vocabularyToken");ne(e[d],"object")?(se[c]=n,p=e[d],delete e[d]):(se[c]=n,p={[n]:!0});const h={"":""};return le[c]={id:c,schemaVersion:n,schema:pe(e,c,n,$.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:p,validated:!1},c},pe=(e,t,r,n,o,a)=>{if(ne(e,"object")){const i="string"==typeof e.$schema?oe(e.$schema)[0]:r,s=ce(i,"embeddedToken"),c=ce(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ae(t,e[s]);return e[s]=n,fe(e,n,r),A.cons(e[s],e)}const l=ce(r,"anchorToken"),u=ce(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=ce(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=ce(r,"jrefToken");if("string"==typeof e[p])return A.cons(e[p],e);for(const i in e)e[i]=pe(e[i],t,r,$.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>pe(e,t,r,$.append(i,n),o,a))):e},de=e=>le[ue[e]]||le[e],he=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:$.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),ye=async(e,t=he)=>{const r=ae(me(t),e),[n,o]=oe(r);if(!(e=>e in le||e in ue)(n)){const e=await re(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=M.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}fe(await e.json(),n)}const a=de(n),i="/"!==o[0]?be(a,o):o,s=Object.freeze({...a,pointer:i,value:$.get(i,a.schema)});return ve(s)},ve=e=>A.isReference(e.value)?ye(A.href(e.value),e):e,be=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},me=e=>`${e.id}#${encodeURI(e.pointer)}`,we=e=>A.isReference(e.value)?A.value(e.value):e.value,ge=(e,t)=>{const r=de(t.id),n=Object.freeze({...t,pointer:$.append(e,t.pointer),value:we(t)[e],validated:r.validated});return ve(n)},Oe=t(((e,t)=>te.pipeline([we,te.map((async(r,n)=>e(await ge(n,t),n))),te.all],t)));var Ee={setConfig:(e,t,r)=>{ie[e]||(ie[e]={}),ie[e][t]=r},getConfig:ce,add:fe,get:ye,markValidated:e=>{le[e].validated=!0},uri:me,value:we,getAnchorPointer:be,typeOf:(e,t)=>ne(we(e),t),has:(e,t)=>e in we(t),step:ge,keys:e=>Object.keys(we(e)),entries:e=>te.pipeline([we,Object.keys,te.map((async t=>[t,await ge(t,e)])),te.all],e),map:Oe,length:e=>we(e).length};Ee.setConfig,Ee.getConfig,Ee.add,Ee.get,Ee.markValidated,Ee.uri,Ee.value,Ee.getAnchorPointer,Ee.typeOf,Ee.has,Ee.step,Ee.keys,Ee.entries,Ee.map,Ee.length;class je extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var $e=je;const{splitUrl:Se}=p,Pe="FLAG",Ae="BASIC",xe="DETAILED",Ie="VERBOSE";let Te=xe,ke=!0;const Ve=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await _e(e,t)}},Re=t((({ast:e,schemaUri:t},r,n=Pe)=>{if(![Pe,Ae,xe,Ie].includes(n))throw Error(`The '${n}' error format is not supported`);const a=[],i=o.subscribe("result",Ce(n,a));return Ne(t,r,e,{}),o.unsubscribe(i),a[0]})),Ce=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Ae&&(o.push(...t.errors),delete t.errors),(e===Ie||e!==Pe&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ue={},ze=e=>Ue[e],Ke=e=>e in Ue,Le={},qe={},_e=async(e,t)=>{if(e=await De(e),!Ke(`${e.schemaVersion}#validate`)){const t=await Ee.get(e.schemaVersion);(Ee.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 Le)Object.entries(Le[e]).forEach((([e,r])=>{((e,t)=>{Ue[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(ke&&!e.validated){if(Ee.markValidated(e.id),!(e.schemaVersion in qe)){const t=await Ee.get(e.schemaVersion),r=await Ve(t);qe[t.id]=Re(r)}const t=L.cons(e.schema,e.id),r=qe[e.schemaVersion](t,Te);if(!r.valid)throw new $e(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),ze(`${e.schemaVersion}#validate`).compile(e,t)},De=async e=>Ee.typeOf(e,"string")?De(await Ee.get(Ee.value(e),e)):e,Ne=(e,t,r,n)=>{const o=Be(e,r),a=Se(e)[0];return ze(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Be=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Fe={validate:async(e,t,r)=>{const n=await Ve(e),o=(e,t)=>Re(n,L.cons(e),t);return void 0===t?o:o(t,r)},compile:Ve,interpret:Re,setMetaOutputFormat:e=>{Te=e},setShouldMetaValidate:e=>{ke=e},FLAG:Pe,BASIC:Ae,DETAILED:xe,VERBOSE:Ie,add:(e,t="",r="")=>{const n=Ee.add(e,t,r);delete qe[n]},getKeyword:ze,hasKeyword:Ke,defineVocabulary:(e,t)=>{Le[e]=t},compileSchema:_e,interpretSchema:Ne,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Be(e,r);return ze(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Be(e,r);return ze(a).collectEvaluatedItems(e,t,r,n,o)}};var Ze={compile:e=>Ee.value(e),interpret:()=>!0};var Je={compile:async(e,t)=>{const r=Ee.uri(e);if(!(r in t)){t[r]=!1;const n=Ee.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Ee.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Ee.uri(e),"boolean"==typeof n?n:await te.pipeline([Ee.entries,te.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),te.filter((([t])=>Fe.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),te.map((async([r,n])=>{const o=await Fe.getKeyword(r).compile(n,t,e);return[r,Ee.uri(n),o]})),te.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=Fe.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:L.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:L.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Fe.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Fe.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Me={metaData:Ze,validate:Je},We={Core:Fe,Schema:Ee,Instance:L,Reference:A,Keywords:Me,InvalidSchemaError:$e},Ge=We.Core,He=We.Schema,Qe=We.Instance,Xe=We.Reference,Ye=We.Keywords,et=We.InvalidSchemaError;return e.Core=Ge,e.Instance=Qe,e.InvalidSchemaError=et,e.Keywords=Ye,e.Reference=Xe,e.Schema=He,e.default=We,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
//# sourceMappingURL=json-schema-core-iife.min.js.map |
@@ -1,8 +0,4 @@ | ||
System.register('JSC', ['url-resolve-browser'], (function (exports) { | ||
System.register('JSC', [], (function (exports) { | ||
'use strict'; | ||
var urlResolveBrowser; | ||
return { | ||
setters: [function (module) { | ||
urlResolveBrowser = module["default"]; | ||
}], | ||
execute: (function () { | ||
@@ -406,2 +402,213 @@ | ||
var urlResolveBrowser = urlResolve; | ||
/* | ||
The majority of the module is built by following RFC1808 | ||
url: https://tools.ietf.org/html/rfc1808 | ||
*/ | ||
// adds a slash at end if not present | ||
function _addSlash (url) { | ||
return url + (url[url.length-1] === '/' ? '' : '/'); | ||
} | ||
// resolve the ..'s (directory up) and such | ||
function _pathResolve (path) { | ||
let pathSplit = path.split('/'); | ||
// happens when path starts with / | ||
if (pathSplit[0] === '') { | ||
pathSplit = pathSplit.slice(1); | ||
} | ||
// let segmentCount = 0; // number of segments that have been passed | ||
let resultArray = []; | ||
pathSplit.forEach((current, index) => { | ||
// skip occurances of '.' | ||
if (current !== '.') { | ||
if (current === '..') { | ||
resultArray.pop(); // remove previous | ||
} else if (current !== '' || index === pathSplit.length - 1) { | ||
resultArray.push(current); | ||
} | ||
} | ||
}); | ||
return '/' + resultArray.join('/'); | ||
} | ||
// parses a base url string into an object containing host, path and query | ||
function _baseParse (base) { | ||
const resultObject = { | ||
host: '', | ||
path: '', | ||
query: '', | ||
protocol: '' | ||
}; | ||
let path = base; | ||
let protocolEndIndex = base.indexOf('//'); | ||
resultObject.protocol = path.substring(0, protocolEndIndex); | ||
protocolEndIndex += 2; // add two to pass double slash | ||
const pathIndex = base.indexOf('/', protocolEndIndex); | ||
const queryIndex = base.indexOf('?'); | ||
const hashIndex = base.indexOf('#'); | ||
if (hashIndex !== -1) { | ||
path = path.substring(0, hashIndex); // remove hash, not needed for base | ||
} | ||
if (queryIndex !== -1) { | ||
const query = path.substring(queryIndex); // remove query, save in return obj | ||
resultObject.query = query; | ||
path = path.substring(0, queryIndex); | ||
} | ||
if (pathIndex !== -1) { | ||
const host = path.substring(0, pathIndex); // separate host & path | ||
resultObject.host = host; | ||
path = path.substring(pathIndex); | ||
resultObject.path = path; | ||
} else { | ||
resultObject.host = path; // there was no path, therefore path is host | ||
} | ||
return resultObject; | ||
} | ||
// https://tools.ietf.org/html/rfc3986#section-3.1 | ||
const _scheme = '[a-z][a-z0-9+.-]*'; // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )] | ||
const _isAbsolute = new RegExp(`^(${_scheme}:)?//`, 'i'); | ||
// parses a relative url string into an object containing the href, | ||
// hash, query and whether it is a net path, absolute path or relative path | ||
function _relativeParse (relative) { | ||
const resultObject = { | ||
href: relative, // href is always what was passed through | ||
hash: '', | ||
query: '', | ||
netPath: false, | ||
absolutePath: false, | ||
relativePath: false | ||
}; | ||
// check for protocol | ||
// if protocol exists, is net path (absolute URL) | ||
if (_isAbsolute.test(relative)) { | ||
resultObject.netPath = true; | ||
// return, in this case the relative is the resolved url, no need to parse. | ||
return resultObject; | ||
} | ||
// if / is first, this is an absolute path, | ||
// I.E. it overwrites the base URL's path | ||
if (relative[0] === '/') { | ||
resultObject.absolutePath = true; | ||
// return resultObject | ||
} else if (relative !== '') { | ||
resultObject.relativePath = true; | ||
} | ||
let path = relative; | ||
const queryIndex = relative.indexOf('?'); | ||
const hashIndex = relative.indexOf('#'); | ||
if (hashIndex !== -1) { | ||
const hash = path.substring(hashIndex); | ||
resultObject.hash = hash; | ||
path = path.substring(0, hashIndex); | ||
} | ||
if (queryIndex !== -1) { | ||
const query = path.substring(queryIndex); | ||
resultObject.query = query; | ||
path = path.substring(0, queryIndex); | ||
} | ||
resultObject.path = path; // whatever is left is path | ||
return resultObject; | ||
} | ||
function _shouldAddSlash (url) { | ||
const protocolIndex = url.indexOf('//') + 2; | ||
const noPath = !(url.includes('/', protocolIndex)); | ||
const noQuery = !(url.includes('?', protocolIndex)); | ||
const noHash = !(url.includes('#', protocolIndex)); | ||
return (noPath && noQuery && noHash); | ||
} | ||
function _shouldAddProtocol (url) { | ||
return url.startsWith('//'); | ||
} | ||
/* | ||
* PRECONDITION: Base is a fully qualified URL. e.g. http://example.com/ | ||
* optional: path, query or hash | ||
* returns the resolved url | ||
*/ | ||
function urlResolve (base, relative) { | ||
base = base.trim(); | ||
relative = relative.trim(); | ||
// about is always absolute | ||
if (relative.startsWith('about:')) { | ||
return relative; | ||
} | ||
const baseObj = _baseParse(base); | ||
const relativeObj = _relativeParse(relative); | ||
if (!baseObj.protocol && !relativeObj.netPath) { | ||
throw new Error('Error, protocol is not specified'); | ||
} | ||
if (relativeObj.netPath) { // relative is full qualified URL | ||
if (_shouldAddProtocol(relativeObj.href)) { | ||
relativeObj.href = baseObj.protocol + relativeObj.href; | ||
} | ||
if (_shouldAddSlash(relativeObj.href)) { | ||
return _addSlash(relativeObj.href); | ||
} | ||
return relativeObj.href; | ||
} else if (relativeObj.absolutePath) { // relative is an absolute path | ||
const {path, query, hash} = relativeObj; | ||
return baseObj.host + _pathResolve(path) + query + hash; | ||
} else if (relativeObj.relativePath) { // relative is a relative path | ||
const {path, query, hash} = relativeObj; | ||
let basePath = baseObj.path; | ||
let resultString = baseObj.host; | ||
let resolvePath; | ||
if (path.length === 0) { | ||
resolvePath = basePath; | ||
} else { | ||
// remove last segment if no slash at end | ||
basePath = basePath.substring(0, basePath.lastIndexOf('/')); | ||
resolvePath = _pathResolve(basePath + '/' + path); | ||
} | ||
// if result is just the base host, add / | ||
if ((resolvePath === '') && (!query) && (!hash)) { | ||
resultString += '/'; | ||
} else { | ||
resultString += resolvePath + query + hash; | ||
} | ||
return resultString; | ||
} else { | ||
const {host, path, query} = baseObj; | ||
// when path and query aren't supplied add slash | ||
if ((!path) && (!query)) { | ||
return _addSlash(host); | ||
} | ||
return host + path + query + relativeObj.hash; | ||
} | ||
} | ||
const isObject = (value) => typeof value === "object" && !Array.isArray(value) && value !== null; | ||
@@ -408,0 +615,0 @@ const isType = { |
@@ -1,2 +0,2 @@ | ||
System.register("JSC",["url-resolve-browser"],(function(e){"use strict";var t;return{setters:[function(e){t=e.default}],execute:function(){var r=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)))}}};var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var o,a=(function(e,t){var r,o;r="object"==typeof window&&window||n,o={},r.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function p(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function f(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!p(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return f(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return f(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},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)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}(o={exports:{}},o.exports),o.exports);a.PubSub;const i={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},s=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)]},c=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var l={jsonTypeOf:(e,t)=>i[t](e),splitUrl:s,safeResolveUrl:(e,r)=>{const n=t(e,r),o=s(e)[0];if(o&&"file"===c(n)&&"file"!==c(o))throw Error(`Can't access file '${n}' resource from network context '${e}'`);return n}};const u=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(m)},p=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:p(e,w(t,o,n),r,h(o,n))}}if(Array.isArray(t)){const n=[...t];return n[b(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:w(t,e[0],n)},f=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||g(t)){const o=e.shift();f(e,w(t,o,n),r,h(o,n))}else{t[b(t,e[0])]=r}},d=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=w(t,n,r);return{...t,[n]:d(e,o,h(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 w(t,e[0],r)}},y=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=w(t,n,r);y(e,o,h(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:w(t,e[0],r)},h=r(((e,t)=>t+"/"+v(e))),v=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),m=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),b=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,w=(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(g(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[b(e,t)]},g=e=>null===e||"object"!=typeof e;var O={nil:"",append:h,get:(e,t)=>{const r=u(e),n=e=>r.reduce((([e,t],r)=>[w(e,r,t),h(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,t,n)=>{const o=u(e),a=r(((e,t)=>p(o,e,t,"")));return void 0===t?a:a(t,n)},assign:(e,t,n)=>{const o=u(e),a=r(((e,t)=>f(o,e,t,"")));return void 0===t?a:a(t,n)},unset:(e,t)=>{const r=u(e),n=e=>d(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=u(e),n=e=>y(r,e,"");return void 0===t?n:n(t)}};O.nil,O.append,O.get,O.set,O.assign,O.unset,O.remove;const E=Symbol("$__value"),j=Symbol("$__href");var $={cons:(e,t)=>Object.freeze({[j]:e,[E]:t}),isReference:e=>e&&void 0!==e[j],href:e=>e[j],value:e=>e[E]};const{jsonTypeOf:S}=l,A=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),I=e=>$.isReference(e.value)?$.value(e.value):e.value,T=r(((e,t)=>S(I(e),t))),k=(e,t)=>Object.freeze({...t,pointer:O.append(e,t.pointer),value:I(t)[e]}),x=r(((e,t)=>I(t).map(((r,n,o,a)=>e(k(n,t),n,o,a))))),P=r(((e,t)=>I(t).map(((e,r,n,o)=>k(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),V=r(((e,t,r)=>I(r).reduce(((t,n,o)=>e(t,k(o,r),o)),t))),R=r(((e,t)=>I(t).every(((r,n,o,a)=>e(k(n,t),n,o,a))))),C=r(((e,t)=>I(t).some(((r,n,o,a)=>e(k(n,t),n,o,a)))));var U={nil:A,cons:(e,t="")=>Object.freeze({...A,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:I,has:(e,t)=>e in I(t),typeOf:T,step:k,entries:e=>Object.keys(I(e)).map((t=>[t,k(t,e)])),keys:e=>Object.keys(I(e)),map:x,filter:P,reduce:V,every:R,some:C,length:e=>I(e).length},K=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,L=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,z=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,_=/\\([\u000b\u0020-\u00ff])/g,D=/([\\"])/g,N=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function q(e){var t=String(e);if(z.test(t))return t;if(t.length>0&&!L.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(D,"\\$1")+'"'}function B(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||!N.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],!z.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+q(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(!N.test(n))throw new TypeError("invalid media type");var o=new B(n.toLowerCase());if(-1!==r){var a,i,s;for(K.lastIndex=r;i=K.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(_,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},Z=async e=>Object.entries(await e),J=r((async(e,t)=>(await t).map(e))),M=r((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),G=r((async(e,t,r={})=>M((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),H=r((async(e,t)=>{const r=await J(e,t);return(await Promise.all(r)).some((e=>e))})),W=r((async(e,t)=>{const r=await J(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:Z,map:J,filter:G,reduce:M,some:H,every:W,pipeline:Q,all:e=>Promise.all(e),allValues:e=>Q([Z,M((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};X.entries,X.map,X.filter,X.reduce,X.some,X.every,X.pipeline,X.all,X.allValues;var Y=fetch;const{jsonTypeOf:ee,splitUrl:te,safeResolveUrl:re}=l,ne={},oe={},ae=(e,t)=>{const r=e in oe?oe[e]:e;if(r in ne)return ne[r][t]},ie={},se={},ce=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=te(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ae(n,"baseToken"),a=ae(n,"anchorToken"),i=te(t)[0];if(!i&&!te(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=re(i,e[o]||""),[c,l]=te(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(se[i]=c);const u={},p=ae(n,"recursiveAnchorToken");let f;!0===e[p]&&(u[""]=`${c}#`,e[a]="",delete e[p]);const d=ae(n,"vocabularyToken");ee(e[d],"object")?(oe[c]=n,f=e[d],delete e[d]):(oe[c]=n,f={[n]:!0});const y={"":""};return ie[c]={id:c,schemaVersion:n,schema:le(e,c,n,O.nil,y,u),anchors:y,dynamicAnchors:u,vocabulary:f,validated:!1},c},le=(e,t,r,n,o,a)=>{if(ee(e,"object")){const i="string"==typeof e.$schema?te(e.$schema)[0]:r,s=ae(i,"embeddedToken"),c=ae(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=re(t,e[s]);return e[s]=n,ce(e,n,r),$.cons(e[s],e)}const l=ae(r,"anchorToken"),u=ae(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const p=ae(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==p?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const f=ae(r,"jrefToken");if("string"==typeof e[f])return $.cons(e[f],e);for(const i in e)e[i]=le(e[i],t,r,O.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>le(e,t,r,O.append(i,n),o,a))):e},ue=e=>ie[se[e]]||ie[e],pe=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:O.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),fe=async(e,t=pe)=>{const r=re(he(t),e),[n,o]=te(r);if(!(e=>e in ie||e in se)(n)){const e=await Y(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=F.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}ce(await e.json(),n)}const a=ue(n),i="/"!==o[0]?ye(a,o):o,s=Object.freeze({...a,pointer:i,value:O.get(i,a.schema)});return de(s)},de=e=>$.isReference(e.value)?fe($.href(e.value),e):e,ye=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},he=e=>`${e.id}#${encodeURI(e.pointer)}`,ve=e=>$.isReference(e.value)?$.value(e.value):e.value,me=(e,t)=>{const r=ue(t.id),n=Object.freeze({...t,pointer:O.append(e,t.pointer),value:ve(t)[e],validated:r.validated});return de(n)},be=r(((e,t)=>X.pipeline([ve,X.map((async(r,n)=>e(await me(n,t),n))),X.all],t)));var we={setConfig:(e,t,r)=>{ne[e]||(ne[e]={}),ne[e][t]=r},getConfig:ae,add:ce,get:fe,markValidated:e=>{ie[e].validated=!0},uri:he,value:ve,getAnchorPointer:ye,typeOf:(e,t)=>ee(ve(e),t),has:(e,t)=>e in ve(t),step:me,keys:e=>Object.keys(ve(e)),entries:e=>X.pipeline([ve,Object.keys,X.map((async t=>[t,await me(t,e)])),X.all],e),map:be,length:e=>ve(e).length};we.setConfig,we.getConfig,we.add,we.get,we.markValidated,we.uri,we.value,we.getAnchorPointer,we.typeOf,we.has,we.step,we.keys,we.entries,we.map,we.length;class ge extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Oe=ge;const{splitUrl:Ee}=l,je="FLAG",$e="BASIC",Se="DETAILED",Ae="VERBOSE";let Ie=Se,Te=!0;const ke=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Le(e,t)}},xe=r((({ast:e,schemaUri:t},r,n=je)=>{if(![je,$e,Se,Ae].includes(n))throw Error(`The '${n}' error format is not supported`);const o=[],i=a.subscribe("result",Pe(n,o));return _e(t,r,e,{}),a.unsubscribe(i),o[0]})),Pe=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===$e&&(o.push(...t.errors),delete t.errors),(e===Ae||e!==je&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ve={},Re=e=>Ve[e],Ce=e=>e in Ve,Ue={},Ke={},Le=async(e,t)=>{if(e=await ze(e),!Ce(`${e.schemaVersion}#validate`)){const t=await we.get(e.schemaVersion);(we.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)=>{Ve[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Te&&!e.validated){if(we.markValidated(e.id),!(e.schemaVersion in Ke)){const t=await we.get(e.schemaVersion),r=await ke(t);Ke[t.id]=xe(r)}const t=U.cons(e.schema,e.id),r=Ke[e.schemaVersion](t,Ie);if(!r.valid)throw new Oe(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),Re(`${e.schemaVersion}#validate`).compile(e,t)},ze=async e=>we.typeOf(e,"string")?ze(await we.get(we.value(e),e)):e,_e=(e,t,r,n)=>{const o=De(e,r),a=Ee(e)[0];return Re(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},De=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Ne={validate:async(e,t,r)=>{const n=await ke(e),o=(e,t)=>xe(n,U.cons(e),t);return void 0===t?o:o(t,r)},compile:ke,interpret:xe,setMetaOutputFormat:e=>{Ie=e},setShouldMetaValidate:e=>{Te=e},FLAG:je,BASIC:$e,DETAILED:Se,VERBOSE:Ae,add:(e,t="",r="")=>{const n=we.add(e,t,r);delete Ke[n]},getKeyword:Re,hasKeyword:Ce,defineVocabulary:(e,t)=>{Ue[e]=t},compileSchema:Le,interpretSchema:_e,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=De(e,r);return Re(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=De(e,r);return Re(a).collectEvaluatedItems(e,t,r,n,o)}};var qe={compile:e=>we.value(e),interpret:()=>!0};var Be={compile:async(e,t)=>{const r=we.uri(e);if(!(r in t)){t[r]=!1;const n=we.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${we.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,we.uri(e),"boolean"==typeof n?n:await X.pipeline([we.entries,X.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),X.filter((([t])=>Ne.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),X.map((async([r,n])=>{const o=await Ne.getKeyword(r).compile(n,t,e);return[r,we.uri(n),o]})),X.all],e)]}return r},interpret:(e,t,r,n)=>{const[o,i,s]=r[e];a.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,o,i])=>{a.publishSync("result.start");const s=Ne.getKeyword(e).interpret(i,t,r,n);return a.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:U.uri(t),valid:s,ast:i}),a.publishSync("result.end"),s}));return a.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:U.uri(t),valid:c,ast:e}),a.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Ne.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Ne.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Fe={metaData:qe,validate:Be},Ze=e("default",{Core:Ne,Schema:we,Instance:U,Reference:$,Keywords:Fe,InvalidSchemaError:Oe});e("Core",Ze.Core),e("Schema",Ze.Schema),e("Instance",Ze.Instance),e("Reference",Ze.Reference),e("Keywords",Ze.Keywords),e("InvalidSchemaError",Ze.InvalidSchemaError)}}})); | ||
System.register("JSC",[],(function(e){"use strict";return{execute:function(){var t=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)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,o=(function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},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)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}(n={exports:{}},n.exports),n.exports);o.PubSub;var a=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(c.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)?i(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+s(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,i=r.path,c=r.host;return 0===e.length?a=i:(i=i.substring(0,i.lastIndexOf("/")),a=s(i+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:i(e)}};function i(e){return e+("/"===e[e.length-1]?"":"/")}function s(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 c=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const l={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},u=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)]},f=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var p={jsonTypeOf:(e,t)=>l[t](e),splitUrl:u,safeResolveUrl:(e,t)=>{const r=a(e,t),n=u(e)[0];if(n&&"file"===f(r)&&"file"!==f(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const d=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(w)},h=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:h(e,E(t,o,n),r,m(o,n))}}if(Array.isArray(t)){const n=[...t];return n[O(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:E(t,e[0],n)},y=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||j(t)){const o=e.shift();y(e,E(t,o,n),r,m(o,n))}else{t[O(t,e[0])]=r}},v=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=E(t,n,r);return{...t,[n]:v(e,o,m(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 E(t,e[0],r)}},b=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=E(t,n,r);b(e,o,m(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:E(t,e[0],r)},m=t(((e,t)=>t+"/"+g(e))),g=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),w=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),O=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,E=(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(j(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[O(e,t)]},j=e=>null===e||"object"!=typeof e;var $={nil:"",append:m,get:(e,t)=>{const r=d(e),n=e=>r.reduce((([e,t],r)=>[E(e,r,t),m(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=d(e),a=t(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=d(e),a=t(((e,t)=>y(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=d(e),n=e=>v(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=d(e),n=e=>b(r,e,"");return void 0===t?n:n(t)}};$.nil,$.append,$.get,$.set,$.assign,$.unset,$.remove;const S=Symbol("$__value"),x=Symbol("$__href");var A={cons:(e,t)=>Object.freeze({[x]:e,[S]:t}),isReference:e=>e&&void 0!==e[x],href:e=>e[x],value:e=>e[S]};const{jsonTypeOf:P}=p,I=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),T=e=>A.isReference(e.value)?A.value(e.value):e.value,k=t(((e,t)=>P(T(e),t))),V=(e,t)=>Object.freeze({...t,pointer:$.append(e,t.pointer),value:T(t)[e]}),R=t(((e,t)=>T(t).map(((r,n,o,a)=>e(V(n,t),n,o,a))))),C=t(((e,t)=>T(t).map(((e,r,n,o)=>V(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),U=t(((e,t,r)=>T(r).reduce(((t,n,o)=>e(t,V(o,r),o)),t))),z=t(((e,t)=>T(t).every(((r,n,o,a)=>e(V(n,t),n,o,a))))),K=t(((e,t)=>T(t).some(((r,n,o,a)=>e(V(n,t),n,o,a)))));var L={nil:I,cons:(e,t="")=>Object.freeze({...I,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:T,has:(e,t)=>e in T(t),typeOf:k,step:V,entries:e=>Object.keys(T(e)).map((t=>[t,V(t,e)])),keys:e=>Object.keys(T(e)),map:R,filter:C,reduce:U,every:z,some:K,length:e=>T(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]+$/,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,N=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,F=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function Z(e){var t=String(e);if(D.test(t))return t;if(t.length>0&&!_.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function J(e){this.parameters=Object.create(null),this.type=e}var W={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!F.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],!D.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+Z(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(!F.test(n))throw new TypeError("invalid media type");var o=new J(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(N,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},M=async e=>Object.entries(await e),G=t((async(e,t)=>(await t).map(e))),H=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),Q=t((async(e,t,r={})=>H((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),X=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).some((e=>e))})),Y=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).every((e=>e))})),ee=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),te={entries:M,map:G,filter:Q,reduce:H,some:X,every:Y,pipeline:ee,all:e=>Promise.all(e),allValues:e=>ee([M,H((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};te.entries,te.map,te.filter,te.reduce,te.some,te.every,te.pipeline,te.all,te.allValues;var re=fetch;const{jsonTypeOf:ne,splitUrl:oe,safeResolveUrl:ae}=p,ie={},se={},ce=(e,t)=>{const r=e in se?se[e]:e;if(r in ie)return ie[r][t]},le={},ue={},fe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=oe(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=oe(t)[0];if(!i&&!oe(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ae(i,e[o]||""),[c,l]=oe(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(ue[i]=c);const u={},f=ce(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=ce(n,"vocabularyToken");ne(e[d],"object")?(se[c]=n,p=e[d],delete e[d]):(se[c]=n,p={[n]:!0});const h={"":""};return le[c]={id:c,schemaVersion:n,schema:pe(e,c,n,$.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:p,validated:!1},c},pe=(e,t,r,n,o,a)=>{if(ne(e,"object")){const i="string"==typeof e.$schema?oe(e.$schema)[0]:r,s=ce(i,"embeddedToken"),c=ce(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ae(t,e[s]);return e[s]=n,fe(e,n,r),A.cons(e[s],e)}const l=ce(r,"anchorToken"),u=ce(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=ce(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=ce(r,"jrefToken");if("string"==typeof e[p])return A.cons(e[p],e);for(const i in e)e[i]=pe(e[i],t,r,$.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>pe(e,t,r,$.append(i,n),o,a))):e},de=e=>le[ue[e]]||le[e],he=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:$.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),ye=async(e,t=he)=>{const r=ae(me(t),e),[n,o]=oe(r);if(!(e=>e in le||e in ue)(n)){const e=await re(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=W.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}fe(await e.json(),n)}const a=de(n),i="/"!==o[0]?be(a,o):o,s=Object.freeze({...a,pointer:i,value:$.get(i,a.schema)});return ve(s)},ve=e=>A.isReference(e.value)?ye(A.href(e.value),e):e,be=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},me=e=>`${e.id}#${encodeURI(e.pointer)}`,ge=e=>A.isReference(e.value)?A.value(e.value):e.value,we=(e,t)=>{const r=de(t.id),n=Object.freeze({...t,pointer:$.append(e,t.pointer),value:ge(t)[e],validated:r.validated});return ve(n)},Oe=t(((e,t)=>te.pipeline([ge,te.map((async(r,n)=>e(await we(n,t),n))),te.all],t)));var Ee={setConfig:(e,t,r)=>{ie[e]||(ie[e]={}),ie[e][t]=r},getConfig:ce,add:fe,get:ye,markValidated:e=>{le[e].validated=!0},uri:me,value:ge,getAnchorPointer:be,typeOf:(e,t)=>ne(ge(e),t),has:(e,t)=>e in ge(t),step:we,keys:e=>Object.keys(ge(e)),entries:e=>te.pipeline([ge,Object.keys,te.map((async t=>[t,await we(t,e)])),te.all],e),map:Oe,length:e=>ge(e).length};Ee.setConfig,Ee.getConfig,Ee.add,Ee.get,Ee.markValidated,Ee.uri,Ee.value,Ee.getAnchorPointer,Ee.typeOf,Ee.has,Ee.step,Ee.keys,Ee.entries,Ee.map,Ee.length;class je extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var $e=je;const{splitUrl:Se}=p,xe="FLAG",Ae="BASIC",Pe="DETAILED",Ie="VERBOSE";let Te=Pe,ke=!0;const Ve=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await _e(e,t)}},Re=t((({ast:e,schemaUri:t},r,n=xe)=>{if(![xe,Ae,Pe,Ie].includes(n))throw Error(`The '${n}' error format is not supported`);const a=[],i=o.subscribe("result",Ce(n,a));return Ne(t,r,e,{}),o.unsubscribe(i),a[0]})),Ce=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Ae&&(o.push(...t.errors),delete t.errors),(e===Ie||e!==xe&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ue={},ze=e=>Ue[e],Ke=e=>e in Ue,Le={},qe={},_e=async(e,t)=>{if(e=await De(e),!Ke(`${e.schemaVersion}#validate`)){const t=await Ee.get(e.schemaVersion);(Ee.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 Le)Object.entries(Le[e]).forEach((([e,r])=>{((e,t)=>{Ue[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(ke&&!e.validated){if(Ee.markValidated(e.id),!(e.schemaVersion in qe)){const t=await Ee.get(e.schemaVersion),r=await Ve(t);qe[t.id]=Re(r)}const t=L.cons(e.schema,e.id),r=qe[e.schemaVersion](t,Te);if(!r.valid)throw new $e(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),ze(`${e.schemaVersion}#validate`).compile(e,t)},De=async e=>Ee.typeOf(e,"string")?De(await Ee.get(Ee.value(e),e)):e,Ne=(e,t,r,n)=>{const o=Be(e,r),a=Se(e)[0];return ze(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Be=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Fe={validate:async(e,t,r)=>{const n=await Ve(e),o=(e,t)=>Re(n,L.cons(e),t);return void 0===t?o:o(t,r)},compile:Ve,interpret:Re,setMetaOutputFormat:e=>{Te=e},setShouldMetaValidate:e=>{ke=e},FLAG:xe,BASIC:Ae,DETAILED:Pe,VERBOSE:Ie,add:(e,t="",r="")=>{const n=Ee.add(e,t,r);delete qe[n]},getKeyword:ze,hasKeyword:Ke,defineVocabulary:(e,t)=>{Le[e]=t},compileSchema:_e,interpretSchema:Ne,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Be(e,r);return ze(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Be(e,r);return ze(a).collectEvaluatedItems(e,t,r,n,o)}};var Ze={compile:e=>Ee.value(e),interpret:()=>!0};var Je={compile:async(e,t)=>{const r=Ee.uri(e);if(!(r in t)){t[r]=!1;const n=Ee.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Ee.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Ee.uri(e),"boolean"==typeof n?n:await te.pipeline([Ee.entries,te.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),te.filter((([t])=>Fe.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),te.map((async([r,n])=>{const o=await Fe.getKeyword(r).compile(n,t,e);return[r,Ee.uri(n),o]})),te.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=Fe.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:L.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:L.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Fe.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Fe.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},We={metaData:Ze,validate:Je},Me=e("default",{Core:Fe,Schema:Ee,Instance:L,Reference:A,Keywords:We,InvalidSchemaError:$e});e("Core",Me.Core),e("Schema",Me.Schema),e("Instance",Me.Instance),e("Reference",Me.Reference),e("Keywords",Me.Keywords),e("InvalidSchemaError",Me.InvalidSchemaError)}}})); | ||
//# sourceMappingURL=json-schema-core-system.min.js.map |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('url-resolve-browser')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'url-resolve-browser'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSC = {}, global.urlResolveBrowser)); | ||
})(this, (function (exports, urlResolveBrowser) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSC = {})); | ||
})(this, (function (exports) { 'use strict'; | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var urlResolveBrowser__default = /*#__PURE__*/_interopDefaultLegacy(urlResolveBrowser); | ||
var justCurryIt = curry; | ||
@@ -407,2 +403,213 @@ | ||
var urlResolveBrowser = urlResolve; | ||
/* | ||
The majority of the module is built by following RFC1808 | ||
url: https://tools.ietf.org/html/rfc1808 | ||
*/ | ||
// adds a slash at end if not present | ||
function _addSlash (url) { | ||
return url + (url[url.length-1] === '/' ? '' : '/'); | ||
} | ||
// resolve the ..'s (directory up) and such | ||
function _pathResolve (path) { | ||
let pathSplit = path.split('/'); | ||
// happens when path starts with / | ||
if (pathSplit[0] === '') { | ||
pathSplit = pathSplit.slice(1); | ||
} | ||
// let segmentCount = 0; // number of segments that have been passed | ||
let resultArray = []; | ||
pathSplit.forEach((current, index) => { | ||
// skip occurances of '.' | ||
if (current !== '.') { | ||
if (current === '..') { | ||
resultArray.pop(); // remove previous | ||
} else if (current !== '' || index === pathSplit.length - 1) { | ||
resultArray.push(current); | ||
} | ||
} | ||
}); | ||
return '/' + resultArray.join('/'); | ||
} | ||
// parses a base url string into an object containing host, path and query | ||
function _baseParse (base) { | ||
const resultObject = { | ||
host: '', | ||
path: '', | ||
query: '', | ||
protocol: '' | ||
}; | ||
let path = base; | ||
let protocolEndIndex = base.indexOf('//'); | ||
resultObject.protocol = path.substring(0, protocolEndIndex); | ||
protocolEndIndex += 2; // add two to pass double slash | ||
const pathIndex = base.indexOf('/', protocolEndIndex); | ||
const queryIndex = base.indexOf('?'); | ||
const hashIndex = base.indexOf('#'); | ||
if (hashIndex !== -1) { | ||
path = path.substring(0, hashIndex); // remove hash, not needed for base | ||
} | ||
if (queryIndex !== -1) { | ||
const query = path.substring(queryIndex); // remove query, save in return obj | ||
resultObject.query = query; | ||
path = path.substring(0, queryIndex); | ||
} | ||
if (pathIndex !== -1) { | ||
const host = path.substring(0, pathIndex); // separate host & path | ||
resultObject.host = host; | ||
path = path.substring(pathIndex); | ||
resultObject.path = path; | ||
} else { | ||
resultObject.host = path; // there was no path, therefore path is host | ||
} | ||
return resultObject; | ||
} | ||
// https://tools.ietf.org/html/rfc3986#section-3.1 | ||
const _scheme = '[a-z][a-z0-9+.-]*'; // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )] | ||
const _isAbsolute = new RegExp(`^(${_scheme}:)?//`, 'i'); | ||
// parses a relative url string into an object containing the href, | ||
// hash, query and whether it is a net path, absolute path or relative path | ||
function _relativeParse (relative) { | ||
const resultObject = { | ||
href: relative, // href is always what was passed through | ||
hash: '', | ||
query: '', | ||
netPath: false, | ||
absolutePath: false, | ||
relativePath: false | ||
}; | ||
// check for protocol | ||
// if protocol exists, is net path (absolute URL) | ||
if (_isAbsolute.test(relative)) { | ||
resultObject.netPath = true; | ||
// return, in this case the relative is the resolved url, no need to parse. | ||
return resultObject; | ||
} | ||
// if / is first, this is an absolute path, | ||
// I.E. it overwrites the base URL's path | ||
if (relative[0] === '/') { | ||
resultObject.absolutePath = true; | ||
// return resultObject | ||
} else if (relative !== '') { | ||
resultObject.relativePath = true; | ||
} | ||
let path = relative; | ||
const queryIndex = relative.indexOf('?'); | ||
const hashIndex = relative.indexOf('#'); | ||
if (hashIndex !== -1) { | ||
const hash = path.substring(hashIndex); | ||
resultObject.hash = hash; | ||
path = path.substring(0, hashIndex); | ||
} | ||
if (queryIndex !== -1) { | ||
const query = path.substring(queryIndex); | ||
resultObject.query = query; | ||
path = path.substring(0, queryIndex); | ||
} | ||
resultObject.path = path; // whatever is left is path | ||
return resultObject; | ||
} | ||
function _shouldAddSlash (url) { | ||
const protocolIndex = url.indexOf('//') + 2; | ||
const noPath = !(url.includes('/', protocolIndex)); | ||
const noQuery = !(url.includes('?', protocolIndex)); | ||
const noHash = !(url.includes('#', protocolIndex)); | ||
return (noPath && noQuery && noHash); | ||
} | ||
function _shouldAddProtocol (url) { | ||
return url.startsWith('//'); | ||
} | ||
/* | ||
* PRECONDITION: Base is a fully qualified URL. e.g. http://example.com/ | ||
* optional: path, query or hash | ||
* returns the resolved url | ||
*/ | ||
function urlResolve (base, relative) { | ||
base = base.trim(); | ||
relative = relative.trim(); | ||
// about is always absolute | ||
if (relative.startsWith('about:')) { | ||
return relative; | ||
} | ||
const baseObj = _baseParse(base); | ||
const relativeObj = _relativeParse(relative); | ||
if (!baseObj.protocol && !relativeObj.netPath) { | ||
throw new Error('Error, protocol is not specified'); | ||
} | ||
if (relativeObj.netPath) { // relative is full qualified URL | ||
if (_shouldAddProtocol(relativeObj.href)) { | ||
relativeObj.href = baseObj.protocol + relativeObj.href; | ||
} | ||
if (_shouldAddSlash(relativeObj.href)) { | ||
return _addSlash(relativeObj.href); | ||
} | ||
return relativeObj.href; | ||
} else if (relativeObj.absolutePath) { // relative is an absolute path | ||
const {path, query, hash} = relativeObj; | ||
return baseObj.host + _pathResolve(path) + query + hash; | ||
} else if (relativeObj.relativePath) { // relative is a relative path | ||
const {path, query, hash} = relativeObj; | ||
let basePath = baseObj.path; | ||
let resultString = baseObj.host; | ||
let resolvePath; | ||
if (path.length === 0) { | ||
resolvePath = basePath; | ||
} else { | ||
// remove last segment if no slash at end | ||
basePath = basePath.substring(0, basePath.lastIndexOf('/')); | ||
resolvePath = _pathResolve(basePath + '/' + path); | ||
} | ||
// if result is just the base host, add / | ||
if ((resolvePath === '') && (!query) && (!hash)) { | ||
resultString += '/'; | ||
} else { | ||
resultString += resolvePath + query + hash; | ||
} | ||
return resultString; | ||
} else { | ||
const {host, path, query} = baseObj; | ||
// when path and query aren't supplied add slash | ||
if ((!path) && (!query)) { | ||
return _addSlash(host); | ||
} | ||
return host + path + query + relativeObj.hash; | ||
} | ||
} | ||
const isObject = (value) => typeof value === "object" && !Array.isArray(value) && value !== null; | ||
@@ -435,3 +642,3 @@ const isType = { | ||
const safeResolveUrl$1 = (contextUrl, url) => { | ||
const resolvedUrl = urlResolveBrowser__default["default"](contextUrl, url); | ||
const resolvedUrl = urlResolveBrowser(contextUrl, url); | ||
const contextId = splitUrl$2(contextUrl)[0]; | ||
@@ -438,0 +645,0 @@ if (contextId && getScheme(resolvedUrl) === "file" && getScheme(contextId) !== "file") { |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("url-resolve-browser")):"function"==typeof define&&define.amd?define(["exports","url-resolve-browser"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JSC={},e.urlResolveBrowser)}(this,(function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(t),o=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)))}}};var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var i=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){var r,n;r="object"==typeof window&&window||a,n={},r.PubSub=n,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},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)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(n),void 0!==e&&e.exports&&(t=e.exports=n),t.PubSub=n,e.exports=t=n}));i.PubSub;const s={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},c=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)]},l=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var u={jsonTypeOf:(e,t)=>s[t](e),splitUrl:c,safeResolveUrl:(e,t)=>{const r=n.default(e,t),o=c(e)[0];if(o&&"file"===l(r)&&"file"!==l(o))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const f=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(b)},p=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:p(e,g(t,o,n),r,v(o,n))}}if(Array.isArray(t)){const n=[...t];return n[w(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:g(t,e[0],n)},d=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||O(t)){const o=e.shift();d(e,g(t,o,n),r,v(o,n))}else{t[w(t,e[0])]=r}},y=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=g(t,n,r);return{...t,[n]:y(e,o,v(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 g(t,e[0],r)}},h=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=g(t,n,r);h(e,o,v(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:g(t,e[0],r)},v=o(((e,t)=>t+"/"+m(e))),m=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),b=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),w=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,g=(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(O(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[w(e,t)]},O=e=>null===e||"object"!=typeof e;var j={nil:"",append:v,get:(e,t)=>{const r=f(e),n=e=>r.reduce((([e,t],r)=>[g(e,r,t),v(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const n=f(e),a=o(((e,t)=>p(n,e,t,"")));return void 0===t?a:a(t,r)},assign:(e,t,r)=>{const n=f(e),a=o(((e,t)=>d(n,e,t,"")));return void 0===t?a:a(t,r)},unset:(e,t)=>{const r=f(e),n=e=>y(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=f(e),n=e=>h(r,e,"");return void 0===t?n:n(t)}};j.nil,j.append,j.get,j.set,j.assign,j.unset,j.remove;const E=Symbol("$__value"),$=Symbol("$__href");var S={cons:(e,t)=>Object.freeze({[$]:e,[E]:t}),isReference:e=>e&&void 0!==e[$],href:e=>e[$],value:e=>e[E]};const{jsonTypeOf:A}=u,T=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),I=e=>S.isReference(e.value)?S.value(e.value):e.value,x=o(((e,t)=>A(I(e),t))),k=(e,t)=>Object.freeze({...t,pointer:j.append(e,t.pointer),value:I(t)[e]}),P=o(((e,t)=>I(t).map(((r,n,o,a)=>e(k(n,t),n,o,a))))),V=o(((e,t)=>I(t).map(((e,r,n,o)=>k(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),R=o(((e,t,r)=>I(r).reduce(((t,n,o)=>e(t,k(o,r),o)),t))),C=o(((e,t)=>I(t).every(((r,n,o,a)=>e(k(n,t),n,o,a))))),U=o(((e,t)=>I(t).some(((r,n,o,a)=>e(k(n,t),n,o,a)))));var K={nil:T,cons:(e,t="")=>Object.freeze({...T,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:I,has:(e,t)=>e in I(t),typeOf:x,step:k,entries:e=>Object.keys(I(e)).map((t=>[t,k(t,e)])),keys:e=>Object.keys(I(e)),map:P,filter:V,reduce:R,every:C,some:U,length:e=>I(e).length},L=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,z=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,_=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,D=/\\([\u000b\u0020-\u00ff])/g,N=/([\\"])/g,q=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function B(e){var t=String(e);if(_.test(t))return t;if(t.length>0&&!z.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(N,"\\$1")+'"'}function F(e){this.parameters=Object.create(null),this.type=e}var Z={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!q.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+"="+B(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(!q.test(n))throw new TypeError("invalid media type");var o=new F(n.toLowerCase());if(-1!==r){var a,i,s;for(L.lastIndex=r;i=L.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(D,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},J=async e=>Object.entries(await e),M=o((async(e,t)=>(await t).map(e))),G=o((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),H=o((async(e,t,r={})=>G((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),W=o((async(e,t)=>{const r=await M(e,t);return(await Promise.all(r)).some((e=>e))})),Q=o((async(e,t)=>{const r=await M(e,t);return(await Promise.all(r)).every((e=>e))})),X=o(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),Y={entries:J,map:M,filter:H,reduce:G,some:W,every:Q,pipeline:X,all:e=>Promise.all(e),allValues:e=>X([J,G((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};Y.entries,Y.map,Y.filter,Y.reduce,Y.some,Y.every,Y.pipeline,Y.all,Y.allValues;var ee=fetch;const{jsonTypeOf:te,splitUrl:re,safeResolveUrl:ne}=u,oe={},ae={},ie=(e,t)=>{const r=e in ae?ae[e]:e;if(r in oe)return oe[r][t]},se={},ce={},le=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=re(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ie(n,"baseToken"),a=ie(n,"anchorToken"),i=re(t)[0];if(!i&&!re(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ne(i,e[o]||""),[c,l]=re(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(ce[i]=c);const u={},f=ie(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=ie(n,"vocabularyToken");te(e[d],"object")?(ae[c]=n,p=e[d],delete e[d]):(ae[c]=n,p={[n]:!0});const y={"":""};return se[c]={id:c,schemaVersion:n,schema:ue(e,c,n,j.nil,y,u),anchors:y,dynamicAnchors:u,vocabulary:p,validated:!1},c},ue=(e,t,r,n,o,a)=>{if(te(e,"object")){const i="string"==typeof e.$schema?re(e.$schema)[0]:r,s=ie(i,"embeddedToken"),c=ie(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ne(t,e[s]);return e[s]=n,le(e,n,r),S.cons(e[s],e)}const l=ie(r,"anchorToken"),u=ie(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=ie(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=ie(r,"jrefToken");if("string"==typeof e[p])return S.cons(e[p],e);for(const i in e)e[i]=ue(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>ue(e,t,r,j.append(i,n),o,a))):e},fe=e=>se[ce[e]]||se[e],pe=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),de=async(e,t=pe)=>{const r=ne(ve(t),e),[n,o]=re(r);if(!(e=>e in se||e in ce)(n)){const e=await ee(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=Z.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}le(await e.json(),n)}const a=fe(n),i="/"!==o[0]?he(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return ye(s)},ye=e=>S.isReference(e.value)?de(S.href(e.value),e):e,he=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ve=e=>`${e.id}#${encodeURI(e.pointer)}`,me=e=>S.isReference(e.value)?S.value(e.value):e.value,be=(e,t)=>{const r=fe(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:me(t)[e],validated:r.validated});return ye(n)},we=o(((e,t)=>Y.pipeline([me,Y.map((async(r,n)=>e(await be(n,t),n))),Y.all],t)));var ge={setConfig:(e,t,r)=>{oe[e]||(oe[e]={}),oe[e][t]=r},getConfig:ie,add:le,get:de,markValidated:e=>{se[e].validated=!0},uri:ve,value:me,getAnchorPointer:he,typeOf:(e,t)=>te(me(e),t),has:(e,t)=>e in me(t),step:be,keys:e=>Object.keys(me(e)),entries:e=>Y.pipeline([me,Object.keys,Y.map((async t=>[t,await be(t,e)])),Y.all],e),map:we,length:e=>me(e).length};ge.setConfig,ge.getConfig,ge.add,ge.get,ge.markValidated,ge.uri,ge.value,ge.getAnchorPointer,ge.typeOf,ge.has,ge.step,ge.keys,ge.entries,ge.map,ge.length;class Oe extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var je=Oe;const{splitUrl:Ee}=u,$e="FLAG",Se="BASIC",Ae="DETAILED",Te="VERBOSE";let Ie=Ae,xe=!0;const ke=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await ze(e,t)}},Pe=o((({ast:e,schemaUri:t},r,n=$e)=>{if(![$e,Se,Ae,Te].includes(n))throw Error(`The '${n}' error format is not supported`);const o=[],a=i.subscribe("result",Ve(n,o));return De(t,r,e,{}),i.unsubscribe(a),o[0]})),Ve=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Se&&(o.push(...t.errors),delete t.errors),(e===Te||e!==$e&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Re={},Ce=e=>Re[e],Ue=e=>e in Re,Ke={},Le={},ze=async(e,t)=>{if(e=await _e(e),!Ue(`${e.schemaVersion}#validate`)){const t=await ge.get(e.schemaVersion);(ge.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 Ke)Object.entries(Ke[e]).forEach((([e,r])=>{((e,t)=>{Re[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(xe&&!e.validated){if(ge.markValidated(e.id),!(e.schemaVersion in Le)){const t=await ge.get(e.schemaVersion),r=await ke(t);Le[t.id]=Pe(r)}const t=K.cons(e.schema,e.id),r=Le[e.schemaVersion](t,Ie);if(!r.valid)throw new je(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),Ce(`${e.schemaVersion}#validate`).compile(e,t)},_e=async e=>ge.typeOf(e,"string")?_e(await ge.get(ge.value(e),e)):e,De=(e,t,r,n)=>{const o=Ne(e,r),a=Ee(e)[0];return Ce(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Ne=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var qe={validate:async(e,t,r)=>{const n=await ke(e),o=(e,t)=>Pe(n,K.cons(e),t);return void 0===t?o:o(t,r)},compile:ke,interpret:Pe,setMetaOutputFormat:e=>{Ie=e},setShouldMetaValidate:e=>{xe=e},FLAG:$e,BASIC:Se,DETAILED:Ae,VERBOSE:Te,add:(e,t="",r="")=>{const n=ge.add(e,t,r);delete Le[n]},getKeyword:Ce,hasKeyword:Ue,defineVocabulary:(e,t)=>{Ke[e]=t},compileSchema:ze,interpretSchema:De,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Ne(e,r);return Ce(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Ne(e,r);return Ce(a).collectEvaluatedItems(e,t,r,n,o)}};var Be={compile:e=>ge.value(e),interpret:()=>!0};var Fe={compile:async(e,t)=>{const r=ge.uri(e);if(!(r in t)){t[r]=!1;const n=ge.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${ge.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,ge.uri(e),"boolean"==typeof n?n:await Y.pipeline([ge.entries,Y.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),Y.filter((([t])=>qe.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),Y.map((async([r,n])=>{const o=await qe.getKeyword(r).compile(n,t,e);return[r,ge.uri(n),o]})),Y.all],e)]}return r},interpret:(e,t,r,n)=>{const[o,a,s]=r[e];i.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,o,a])=>{i.publishSync("result.start");const s=qe.getKeyword(e).interpret(a,t,r,n);return i.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:K.uri(t),valid:s,ast:a}),i.publishSync("result.end"),s}));return i.publishSync("result",{keyword:o,absoluteKeywordLocation:a,instanceLocation:K.uri(t),valid:c,ast:e}),i.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&qe.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&qe.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Ze={metaData:Be,validate:Fe},Je={Core:qe,Schema:ge,Instance:K,Reference:S,Keywords:Ze,InvalidSchemaError:je},Me=Je.Core,Ge=Je.Schema,He=Je.Instance,We=Je.Reference,Qe=Je.Keywords,Xe=Je.InvalidSchemaError;e.Core=Me,e.Instance=He,e.InvalidSchemaError=Xe,e.Keywords=Qe,e.Reference=We,e.Schema=Ge,e.default=Je,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JSC={})}(this,(function(e){"use strict";var t=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)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},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)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}));n.PubSub;var o=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(s.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)?a(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+i(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,s=r.path,c=r.host;return 0===e.length?a=s:(s=s.substring(0,s.lastIndexOf("/")),a=i(s+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:a(e)}};function a(e){return e+("/"===e[e.length-1]?"":"/")}function i(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 s=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const c={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},l=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)]},u=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var f={jsonTypeOf:(e,t)=>c[t](e),splitUrl:l,safeResolveUrl:(e,t)=>{const r=o(e,t),n=l(e)[0];if(n&&"file"===u(r)&&"file"!==u(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const p=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(g)},d=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:d(e,O(t,o,n),r,v(o,n))}}if(Array.isArray(t)){const n=[...t];return n[w(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:O(t,e[0],n)},h=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||E(t)){const o=e.shift();h(e,O(t,o,n),r,v(o,n))}else{t[w(t,e[0])]=r}},y=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=O(t,n,r);return{...t,[n]:y(e,o,v(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 O(t,e[0],r)}},b=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=O(t,n,r);b(e,o,v(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:O(t,e[0],r)},v=t(((e,t)=>t+"/"+m(e))),m=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),g=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),w=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,O=(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(E(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[w(e,t)]},E=e=>null===e||"object"!=typeof e;var j={nil:"",append:v,get:(e,t)=>{const r=p(e),n=e=>r.reduce((([e,t],r)=>[O(e,r,t),v(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=p(e),a=t(((e,t)=>d(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=p(e),a=t(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=p(e),n=e=>y(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=p(e),n=e=>b(r,e,"");return void 0===t?n:n(t)}};j.nil,j.append,j.get,j.set,j.assign,j.unset,j.remove;const $=Symbol("$__value"),S=Symbol("$__href");var x={cons:(e,t)=>Object.freeze({[S]:e,[$]:t}),isReference:e=>e&&void 0!==e[S],href:e=>e[S],value:e=>e[$]};const{jsonTypeOf:P}=f,A=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),T=e=>x.isReference(e.value)?x.value(e.value):e.value,I=t(((e,t)=>P(T(e),t))),k=(e,t)=>Object.freeze({...t,pointer:j.append(e,t.pointer),value:T(t)[e]}),V=t(((e,t)=>T(t).map(((r,n,o,a)=>e(k(n,t),n,o,a))))),R=t(((e,t)=>T(t).map(((e,r,n,o)=>k(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),C=t(((e,t,r)=>T(r).reduce(((t,n,o)=>e(t,k(o,r),o)),t))),U=t(((e,t)=>T(t).every(((r,n,o,a)=>e(k(n,t),n,o,a))))),z=t(((e,t)=>T(t).some(((r,n,o,a)=>e(k(n,t),n,o,a)))));var K={nil:A,cons:(e,t="")=>Object.freeze({...A,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:T,has:(e,t)=>e in T(t),typeOf:I,step:k,entries:e=>Object.keys(T(e)).map((t=>[t,k(t,e)])),keys:e=>Object.keys(T(e)),map:V,filter:R,reduce:C,every:U,some:z,length:e=>T(e).length},L=/; *([!#$%&'*+.^_`|~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-]+$/,D=/\\([\u000b\u0020-\u00ff])/g,N=/([\\"])/g,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function F(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(N,"\\$1")+'"'}function Z(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||!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+"="+F(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 Z(n.toLowerCase());if(-1!==r){var a,i,s;for(L.lastIndex=r;i=L.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(D,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},M=async e=>Object.entries(await e),W=t((async(e,t)=>(await t).map(e))),G=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),H=t((async(e,t,r={})=>G((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),Q=t((async(e,t)=>{const r=await W(e,t);return(await Promise.all(r)).some((e=>e))})),X=t((async(e,t)=>{const r=await W(e,t);return(await Promise.all(r)).every((e=>e))})),Y=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ee={entries:M,map:W,filter:H,reduce:G,some:Q,every:X,pipeline:Y,all:e=>Promise.all(e),allValues:e=>Y([M,G((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};ee.entries,ee.map,ee.filter,ee.reduce,ee.some,ee.every,ee.pipeline,ee.all,ee.allValues;var te=fetch;const{jsonTypeOf:re,splitUrl:ne,safeResolveUrl:oe}=f,ae={},ie={},se=(e,t)=>{const r=e in ie?ie[e]:e;if(r in ae)return ae[r][t]},ce={},le={},ue=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ne(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=se(n,"baseToken"),a=se(n,"anchorToken"),i=ne(t)[0];if(!i&&!ne(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=oe(i,e[o]||""),[c,l]=ne(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(le[i]=c);const u={},f=se(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=se(n,"vocabularyToken");re(e[d],"object")?(ie[c]=n,p=e[d],delete e[d]):(ie[c]=n,p={[n]:!0});const h={"":""};return ce[c]={id:c,schemaVersion:n,schema:fe(e,c,n,j.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:p,validated:!1},c},fe=(e,t,r,n,o,a)=>{if(re(e,"object")){const i="string"==typeof e.$schema?ne(e.$schema)[0]:r,s=se(i,"embeddedToken"),c=se(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=oe(t,e[s]);return e[s]=n,ue(e,n,r),x.cons(e[s],e)}const l=se(r,"anchorToken"),u=se(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=se(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=se(r,"jrefToken");if("string"==typeof e[p])return x.cons(e[p],e);for(const i in e)e[i]=fe(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>fe(e,t,r,j.append(i,n),o,a))):e},pe=e=>ce[le[e]]||ce[e],de=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),he=async(e,t=de)=>{const r=oe(ve(t),e),[n,o]=ne(r);if(!(e=>e in ce||e in le)(n)){const e=await te(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=J.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}ue(await e.json(),n)}const a=pe(n),i="/"!==o[0]?be(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return ye(s)},ye=e=>x.isReference(e.value)?he(x.href(e.value),e):e,be=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ve=e=>`${e.id}#${encodeURI(e.pointer)}`,me=e=>x.isReference(e.value)?x.value(e.value):e.value,ge=(e,t)=>{const r=pe(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:me(t)[e],validated:r.validated});return ye(n)},we=t(((e,t)=>ee.pipeline([me,ee.map((async(r,n)=>e(await ge(n,t),n))),ee.all],t)));var Oe={setConfig:(e,t,r)=>{ae[e]||(ae[e]={}),ae[e][t]=r},getConfig:se,add:ue,get:he,markValidated:e=>{ce[e].validated=!0},uri:ve,value:me,getAnchorPointer:be,typeOf:(e,t)=>re(me(e),t),has:(e,t)=>e in me(t),step:ge,keys:e=>Object.keys(me(e)),entries:e=>ee.pipeline([me,Object.keys,ee.map((async t=>[t,await ge(t,e)])),ee.all],e),map:we,length:e=>me(e).length};Oe.setConfig,Oe.getConfig,Oe.add,Oe.get,Oe.markValidated,Oe.uri,Oe.value,Oe.getAnchorPointer,Oe.typeOf,Oe.has,Oe.step,Oe.keys,Oe.entries,Oe.map,Oe.length;class Ee extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var je=Ee;const{splitUrl:$e}=f,Se="FLAG",xe="BASIC",Pe="DETAILED",Ae="VERBOSE";let Te=Pe,Ie=!0;const ke=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await qe(e,t)}},Ve=t((({ast:e,schemaUri:t},r,o=Se)=>{if(![Se,xe,Pe,Ae].includes(o))throw Error(`The '${o}' error format is not supported`);const a=[],i=n.subscribe("result",Re(o,a));return De(t,r,e,{}),n.unsubscribe(i),a[0]})),Re=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===xe&&(o.push(...t.errors),delete t.errors),(e===Ae||e!==Se&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ce={},Ue=e=>Ce[e],ze=e=>e in Ce,Ke={},Le={},qe=async(e,t)=>{if(e=await _e(e),!ze(`${e.schemaVersion}#validate`)){const t=await Oe.get(e.schemaVersion);(Oe.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 Ke)Object.entries(Ke[e]).forEach((([e,r])=>{((e,t)=>{Ce[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Ie&&!e.validated){if(Oe.markValidated(e.id),!(e.schemaVersion in Le)){const t=await Oe.get(e.schemaVersion),r=await ke(t);Le[t.id]=Ve(r)}const t=K.cons(e.schema,e.id),r=Le[e.schemaVersion](t,Te);if(!r.valid)throw new je(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),Ue(`${e.schemaVersion}#validate`).compile(e,t)},_e=async e=>Oe.typeOf(e,"string")?_e(await Oe.get(Oe.value(e),e)):e,De=(e,t,r,n)=>{const o=Ne(e,r),a=$e(e)[0];return Ue(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Ne=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Be={validate:async(e,t,r)=>{const n=await ke(e),o=(e,t)=>Ve(n,K.cons(e),t);return void 0===t?o:o(t,r)},compile:ke,interpret:Ve,setMetaOutputFormat:e=>{Te=e},setShouldMetaValidate:e=>{Ie=e},FLAG:Se,BASIC:xe,DETAILED:Pe,VERBOSE:Ae,add:(e,t="",r="")=>{const n=Oe.add(e,t,r);delete Le[n]},getKeyword:Ue,hasKeyword:ze,defineVocabulary:(e,t)=>{Ke[e]=t},compileSchema:qe,interpretSchema:De,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Ne(e,r);return Ue(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Ne(e,r);return Ue(a).collectEvaluatedItems(e,t,r,n,o)}};var Fe={compile:e=>Oe.value(e),interpret:()=>!0};var Ze={compile:async(e,t)=>{const r=Oe.uri(e);if(!(r in t)){t[r]=!1;const n=Oe.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Oe.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Oe.uri(e),"boolean"==typeof n?n:await ee.pipeline([Oe.entries,ee.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ee.filter((([t])=>Be.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),ee.map((async([r,n])=>{const o=await Be.getKeyword(r).compile(n,t,e);return[r,Oe.uri(n),o]})),ee.all],e)]}return r},interpret:(e,t,r,o)=>{const[a,i,s]=r[e];n.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{n.publishSync("result.start");const s=Be.getKeyword(e).interpret(i,t,r,o);return n.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:K.uri(t),valid:s,ast:i}),n.publishSync("result.end"),s}));return n.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:K.uri(t),valid:c,ast:e}),n.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Be.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Be.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Je={metaData:Fe,validate:Ze},Me={Core:Be,Schema:Oe,Instance:K,Reference:x,Keywords:Je,InvalidSchemaError:je},We=Me.Core,Ge=Me.Schema,He=Me.Instance,Qe=Me.Reference,Xe=Me.Keywords,Ye=Me.InvalidSchemaError;e.Core=We,e.Instance=He,e.InvalidSchemaError=Ye,e.Keywords=Xe,e.Reference=Qe,e.Schema=Ge,e.default=Me,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=json-schema-core-umd.min.js.map |
{ | ||
"name": "@hyperjump/json-schema-core", | ||
"version": "0.23.1", | ||
"version": "0.23.2", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1673102
9980
2