UNPKG

mashlib

Version:
3 lines • 119 kB
(self.webpackChunkMashlib=self.webpackChunkMashlib||[]).push([[841],{2341(e){"use strict";e.exports=function e(t){if("number"==typeof t&&isNaN(t))throw new Error("NaN is not allowed");if("number"==typeof t&&!isFinite(t))throw new Error("Infinity is not allowed");if(null===t||"object"!=typeof t)return JSON.stringify(t);if(t.toJSON instanceof Function)return e(t.toJSON());if(Array.isArray(t)){return`[${t.reduce((t,n,o)=>`${t}${0===o?"":","}${e(void 0===n||"symbol"==typeof n?null:n)}`,"")}]`}return`{${Object.keys(t).sort().reduce((n,o)=>{if(void 0===t[o]||"symbol"==typeof t[o])return n;return`${n}${0===n.length?"":","}${e(o)}:${e(t[o])}`},"")}}`}},7034(e,t,n){"use strict";const{isArray:o,isObject:i,isString:r}=n(7382),{asArray:a}=n(9263),{prependBase:s}=n(470),l=n(2207),c=n(7532);function d(e){throw new l("Invalid JSON-LD syntax; @context must be an object.","jsonld.SyntaxError",{code:"invalid local context",context:e})}function u({context:e,base:t}){if(!e)return;const n=e["@context"];if(r(n))e["@context"]=s(t,n);else if(o(n))for(let e=0;e<n.length;++e){const o=n[e];r(o)?n[e]=s(t,o):i(o)&&u({context:{"@context":o},base:t})}else if(i(n))for(const e in n)u({context:n[e],base:t})}e.exports=class{constructor({sharedCache:e}){this.perOpCache=new Map,this.sharedCache=e}async resolve({activeCtx:e,context:t,documentLoader:n,base:s,cycles:l=new Set}){t&&i(t)&&t["@context"]&&(t=t["@context"]),t=a(t);const u=[];for(const a of t){if(r(a)){let t=this._get(a);t||(t=await this._resolveRemoteContext({activeCtx:e,url:a,documentLoader:n,base:s,cycles:l})),o(t)?u.push(...t):u.push(t);continue}if(null===a){u.push(new c({document:null}));continue}i(a)||d(t);const p=JSON.stringify(a);let h=this._get(p);h||(h=new c({document:a}),this._cacheResolvedContext({key:p,resolved:h,tag:"static"})),u.push(h)}return u}_get(e){let t=this.perOpCache.get(e);if(!t){const n=this.sharedCache.get(e);n&&(t=n.get("static"),t&&this.perOpCache.set(e,t))}return t}_cacheResolvedContext({key:e,resolved:t,tag:n}){if(this.perOpCache.set(e,t),void 0!==n){let o=this.sharedCache.get(e);o||(o=new Map,this.sharedCache.set(e,o)),o.set(n,t)}return t}async _resolveRemoteContext({activeCtx:e,url:t,documentLoader:n,base:o,cycles:i}){t=s(o,t);const{context:r,remoteDoc:a}=await this._fetchContext({activeCtx:e,url:t,documentLoader:n,cycles:i});u({context:r,base:o=a.documentUrl||t});const l=await this.resolve({activeCtx:e,context:r,documentLoader:n,base:o,cycles:i});return this._cacheResolvedContext({key:t,resolved:l,tag:a.tag}),l}async _fetchContext({activeCtx:e,url:t,documentLoader:n,cycles:a}){if(a.size>10)throw new l("Maximum number of @context URLs exceeded.","jsonld.ContextUrlError",{code:"json-ld-1.0"===e.processingMode?"loading remote context failed":"context overflow",max:10});if(a.has(t))throw new l("Cyclical @context URLs detected.","jsonld.ContextUrlError",{code:"json-ld-1.0"===e.processingMode?"recursive context inclusion":"context overflow",url:t});let s,c;a.add(t);try{c=await n(t),s=c.document||null,r(s)&&(s=JSON.parse(s))}catch(e){throw new l(`Dereferencing a URL did not result in a valid JSON-LD object. Possible causes are an inaccessible URL perhaps due to a same-origin policy (ensure the server uses CORS if you are using client-side JavaScript), too many redirects, a non-JSON response, or more than one HTTP Link Header was provided for a remote context. URL: "${t}".`,"jsonld.InvalidUrl",{code:"loading remote context failed",url:t,cause:e})}if(!i(s))throw new l(`Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object. URL: "${t}".`,"jsonld.InvalidUrl",{code:"invalid remote context",url:t});return s="@context"in s?{"@context":s["@context"]}:{"@context":{}},c.contextUrl&&(o(s["@context"])||(s["@context"]=[s["@context"]]),s["@context"].push(c.contextUrl)),{context:s,remoteDoc:c}}}},2207(e){"use strict";e.exports=class extends Error{constructor(e="An unspecified JSON-LD error occurred.",t="jsonld.Error",n={}){super(e),this.name=t,this.message=e,this.details=n}}},5445(e){"use strict";e.exports=e=>{class t{toString(){return"[object JsonLdProcessor]"}}return Object.defineProperty(t,"prototype",{writable:!1,enumerable:!1}),Object.defineProperty(t.prototype,"constructor",{writable:!0,enumerable:!1,configurable:!0,value:t}),t.compact=function(t,n){return arguments.length<2?Promise.reject(new TypeError("Could not compact, too few arguments.")):e.compact(t,n)},t.expand=function(t){return arguments.length<1?Promise.reject(new TypeError("Could not expand, too few arguments.")):e.expand(t)},t.flatten=function(t){return arguments.length<1?Promise.reject(new TypeError("Could not flatten, too few arguments.")):e.flatten(t)},t}},8229(e,t,n){"use strict";e.exports=n(989).NQuads},3743(e){"use strict";e.exports=class{constructor(){this._requests={}}wrapLoader(e){const t=this;return t._loader=e,function(){return t.add.apply(t,arguments)}}async add(e){let t=this._requests[e];if(t)return Promise.resolve(t);t=this._requests[e]=this._loader(e);try{return await t}finally{delete this._requests[e]}}}},7532(e,t,n){"use strict";const o=n(1235);e.exports=class{constructor({document:e}){this.document=e,this.cache=new o({max:10})}getProcessed(e){return this.cache.get(e)}setProcessed(e,t){this.cache.set(e,t)}}},1058(e,t,n){"use strict";const o=n(2207),{isArray:i,isObject:r,isString:a,isUndefined:s}=n(7382),{isList:l,isValue:c,isGraph:d,isSimpleGraph:u,isSubjectReference:p}=n(3978),{expandIri:h,getContextValue:f,isKeyword:v,process:g,processingMode:y}=n(1972),{removeBase:m,prependBase:x}=n(470),{REGEX_KEYWORD:b,addValue:w,asArray:I,compareShortestLeast:j}=n(9263),S={};function O(e,t,n){if("@nest"!==h(e,t,{vocab:!0},n))throw new o("JSON-LD compact error; nested property must have an @nest value resolving to @nest.","jsonld.SyntaxError",{code:"invalid @nest value"})}e.exports=S,S.compact=async({activeCtx:e,activeProperty:t=null,element:n,options:h={}})=>{if(i(n)){let o=[];for(let i=0;i<n.length;++i){const r=await S.compact({activeCtx:e,activeProperty:t,element:n[i],options:h});null!==r&&o.push(r)}if(h.compactArrays&&1===o.length){0===(f(e,t,"@container")||[]).length&&(o=o[0])}return o}const m=f(e,t,"@context");if(s(m)||(e=await g({activeCtx:e,localCtx:m,propagate:!0,overrideProtected:!0,options:h})),r(n)){if(h.link&&"@id"in n&&h.link.hasOwnProperty(n["@id"])){const e=h.link[n["@id"]];for(let t=0;t<e.length;++t)if(e[t].expanded===n)return e[t].compacted}if(c(n)||p(n)){const o=S.compactValue({activeCtx:e,activeProperty:t,value:n,options:h});return h.link&&p(n)&&(h.link.hasOwnProperty(n["@id"])||(h.link[n["@id"]]=[]),h.link[n["@id"]].push({expanded:n,compacted:o})),o}if(l(n)){if((f(e,t,"@container")||[]).includes("@list"))return S.compact({activeCtx:e,activeProperty:t,element:n["@list"],options:h})}const m="@reverse"===t,x={},b=e;c(n)||p(n)||(e=e.revertToPreviousContext());const j=f(b,t,"@context");s(j)||(e=await g({activeCtx:e,localCtx:j,propagate:!0,overrideProtected:!0,options:h})),h.link&&"@id"in n&&(h.link.hasOwnProperty(n["@id"])||(h.link[n["@id"]]=[]),h.link[n["@id"]].push({expanded:n,compacted:x}));let D=n["@type"]||[];D.length>1&&(D=Array.from(D).sort());const E=e;for(const t of D){const n=S.compactIri({activeCtx:E,iri:t,relativeTo:{vocab:!0}}),o=f(b,n,"@context");s(o)||(e=await g({activeCtx:e,localCtx:o,options:h,propagate:!1}))}const N=Object.keys(n).sort();for(const s of N){const p=n[s];if("@id"===s){let t=I(p).map(t=>S.compactIri({activeCtx:e,iri:t,relativeTo:{vocab:!1},base:h.base}));1===t.length&&(t=t[0]);x[S.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]=t;continue}if("@type"===s){let t=I(p).map(e=>S.compactIri({activeCtx:b,iri:e,relativeTo:{vocab:!0}}));1===t.length&&(t=t[0]);const n=S.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}}),o=(f(e,n,"@container")||[]).includes("@set")&&y(e,1.1)||i(t)&&0===p.length;w(x,n,t,{propertyIsArray:o});continue}if("@reverse"===s){const t=await S.compact({activeCtx:e,activeProperty:"@reverse",element:p,options:h});for(const n in t)if(e.mappings.has(n)&&e.mappings.get(n).reverse){const o=t[n],i=(f(e,n,"@container")||[]).includes("@set")||!h.compactArrays;w(x,n,o,{propertyIsArray:i}),delete t[n]}if(Object.keys(t).length>0){const n=S.compactIri({activeCtx:e,iri:s,relativeTo:{vocab:!0}});w(x,n,t)}continue}if("@preserve"===s){const n=await S.compact({activeCtx:e,activeProperty:t,element:p,options:h});i(n)&&0===n.length||w(x,s,n);continue}if("@index"===s){if((f(e,t,"@container")||[]).includes("@index"))continue;const n=S.compactIri({activeCtx:e,iri:s,relativeTo:{vocab:!0}});w(x,n,p);continue}if("@graph"!==s&&"@list"!==s&&"@included"!==s&&v(s)){const t=S.compactIri({activeCtx:e,iri:s,relativeTo:{vocab:!0}});w(x,t,p);continue}if(!i(p))throw new o("JSON-LD expansion error; expanded value must be an array.","jsonld.SyntaxError");if(0===p.length){const t=S.compactIri({activeCtx:e,iri:s,value:p,relativeTo:{vocab:!0},reverse:m}),n=e.mappings.has(t)?e.mappings.get(t)["@nest"]:null;let o=x;n&&(O(e,n,h),r(x[n])||(x[n]={}),o=x[n]),w(o,t,p,{propertyIsArray:!0})}for(const t of p){const n=S.compactIri({activeCtx:e,iri:s,value:t,relativeTo:{vocab:!0},reverse:m}),o=e.mappings.has(n)?e.mappings.get(n)["@nest"]:null;let p=x;o&&(O(e,o,h),r(x[o])||(x[o]={}),p=x[o]);const v=f(e,n,"@container")||[],g=d(t),y=l(t);let b;y?b=t["@list"]:g&&(b=t["@graph"]);let j=await S.compact({activeCtx:e,activeProperty:n,element:y||g?b:t,options:h});if(y){if(i(j)||(j=[j]),v.includes("@list")){w(p,n,j,{valueIsArray:!0,allowDuplicate:!0});continue}j={[S.compactIri({activeCtx:e,iri:"@list",relativeTo:{vocab:!0}})]:j},"@index"in t&&(j[S.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=t["@index"])}if(g)if(v.includes("@graph")&&(v.includes("@id")||v.includes("@index")&&u(t))){let o;p.hasOwnProperty(n)?o=p[n]:p[n]=o={};const i=(v.includes("@id")?t["@id"]:t["@index"])||S.compactIri({activeCtx:e,iri:"@none",relativeTo:{vocab:!0}});w(o,i,j,{propertyIsArray:!h.compactArrays||v.includes("@set")})}else v.includes("@graph")&&u(t)?(i(j)&&j.length>1&&(j={"@included":j}),w(p,n,j,{propertyIsArray:!h.compactArrays||v.includes("@set")})):(i(j)&&1===j.length&&h.compactArrays&&(j=j[0]),j={[S.compactIri({activeCtx:e,iri:"@graph",relativeTo:{vocab:!0}})]:j},"@id"in t&&(j[S.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]=t["@id"]),"@index"in t&&(j[S.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=t["@index"]),w(p,n,j,{propertyIsArray:!h.compactArrays||v.includes("@set")}));else if(v.includes("@language")||v.includes("@index")||v.includes("@id")||v.includes("@type")){let o,i;if(p.hasOwnProperty(n)?o=p[n]:p[n]=o={},v.includes("@language"))c(j)&&(j=j["@value"]),i=t["@language"];else if(v.includes("@index")){const o=f(e,n,"@index")||"@index",r=S.compactIri({activeCtx:e,iri:o,relativeTo:{vocab:!0}});if("@index"===o)i=t["@index"],delete j[r];else{let e;if([i,...e]=I(j[o]||[]),a(i))switch(e.length){case 0:delete j[o];break;case 1:j[o]=e[0];break;default:j[o]=e}else i=null}}else if(v.includes("@id")){const t=S.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}});i=j[t],delete j[t]}else if(v.includes("@type")){const o=S.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}});let r;switch([i,...r]=I(j[o]||[]),r.length){case 0:delete j[o];break;case 1:j[o]=r[0];break;default:j[o]=r}1===Object.keys(j).length&&"@id"in t&&(j=await S.compact({activeCtx:e,activeProperty:n,element:{"@id":t["@id"]},options:h}))}i||(i=S.compactIri({activeCtx:e,iri:"@none",relativeTo:{vocab:!0}})),w(o,i,j,{propertyIsArray:v.includes("@set")})}else{const e=!h.compactArrays||v.includes("@set")||v.includes("@list")||i(j)&&0===j.length||"@list"===s||"@graph"===s;w(p,n,j,{propertyIsArray:e})}}}return x}return n},S.compactIri=({activeCtx:e,iri:t,value:n=null,relativeTo:i={vocab:!1},reverse:a=!1,base:s=null})=>{if(null===t)return t;e.isPropertyTermScoped&&e.previousContext&&(e=e.previousContext);const u=e.getInverse();if(v(t)&&t in u&&"@none"in u[t]&&"@type"in u[t]["@none"]&&"@none"in u[t]["@none"]["@type"])return u[t]["@none"]["@type"]["@none"];if(i.vocab&&t in u){const o=e["@language"]||"@none",i=[];r(n)&&"@index"in n&&!("@graph"in n)&&i.push("@index","@index@set"),r(n)&&"@preserve"in n&&(n=n["@preserve"][0]),d(n)?("@index"in n&&i.push("@graph@index","@graph@index@set","@index","@index@set"),"@id"in n&&i.push("@graph@id","@graph@id@set"),i.push("@graph","@graph@set","@set"),"@index"in n||i.push("@graph@index","@graph@index@set","@index","@index@set"),"@id"in n||i.push("@graph@id","@graph@id@set")):r(n)&&!c(n)&&i.push("@id","@id@set","@type","@set@type");let s="@language",u="@null";if(a)s="@type",u="@reverse",i.push("@set");else if(l(n)){"@index"in n||i.push("@list");const e=n["@list"];if(0===e.length)s="@any",u="@none";else{let t=0===e.length?o:null,n=null;for(let o=0;o<e.length;++o){const i=e[o];let r="@none",a="@none";if(c(i))if("@direction"in i){r=`${(i["@language"]||"").toLowerCase()}_${i["@direction"]}`}else"@language"in i?r=i["@language"].toLowerCase():"@type"in i?a=i["@type"]:r="@null";else a="@id";if(null===t?t=r:r!==t&&c(i)&&(t="@none"),null===n?n=a:a!==n&&(n="@none"),"@none"===t&&"@none"===n)break}t=t||"@none",n=n||"@none","@none"!==n?(s="@type",u=n):u=t}}else{if(c(n))if("@language"in n&&!("@index"in n)){i.push("@language","@language@set"),u=n["@language"];const e=n["@direction"];e&&(u=`${u}_${e}`)}else"@direction"in n&&!("@index"in n)?u=`_${n["@direction"]}`:"@type"in n&&(s="@type",u=n["@type"]);else s="@type",u="@id";i.push("@set")}i.push("@none"),r(n)&&!("@index"in n)&&i.push("@index","@index@set"),c(n)&&1===Object.keys(n).length&&i.push("@language","@language@set");const p=function(e,t,n,o,i,a){null===a&&(a="@null");const s=[];if(("@id"===a||"@reverse"===a)&&r(n)&&"@id"in n){"@reverse"===a&&s.push("@reverse");const t=S.compactIri({activeCtx:e,iri:n["@id"],relativeTo:{vocab:!0}});e.mappings.has(t)&&e.mappings.get(t)&&e.mappings.get(t)["@id"]===n["@id"]?s.push.apply(s,["@vocab","@id"]):s.push.apply(s,["@id","@vocab"])}else{s.push(a);const e=s.find(e=>e.includes("_"));e&&s.push(e.replace(/^[^_]+_/,"_"))}s.push("@none");const l=e.inverse[t];for(const e of o){if(!(e in l))continue;const t=l[e][i];for(const e of s)if(e in t)return t[e]}return null}(e,t,n,i,s,u);if(null!==p)return p}if(i.vocab&&"@vocab"in e){const n=e["@vocab"];if(0===t.indexOf(n)&&t!==n){const o=t.substr(n.length);if(!e.mappings.has(o))return o}}let p=null;const h=[];let f=e.fastCurieMap;const g=t.length-1;for(let e=0;e<g&&t[e]in f;++e)f=f[t[e]],""in f&&h.push(f[""][0]);for(let o=h.length-1;o>=0;--o){const i=h[o],r=i.terms;for(const o of r){const r=o+":"+t.substr(i.iri.length);e.mappings.get(o)._prefix&&(!e.mappings.has(r)||null===n&&e.mappings.get(r)["@id"]===t)&&(null===p||j(r,p)<0)&&(p=r)}}if(null!==p)return p;for(const[n,i]of e.mappings)if(i&&i._prefix&&t.startsWith(n+":"))throw new o(`Absolute IRI "${t}" confused with prefix "${n}".`,"jsonld.SyntaxError",{code:"IRI confused with prefix",context:e});if(!i.vocab){if("@base"in e){if(e["@base"]){const n=m(x(s,e["@base"]),t);return b.test(n)?`./${n}`:n}return t}return m(s,t)}return t},S.compactValue=({activeCtx:e,activeProperty:t,value:n,options:o})=>{if(c(n)){const o=f(e,t,"@type"),i=f(e,t,"@language"),r=f(e,t,"@direction"),s=f(e,t,"@container")||[],l="@index"in n&&!s.includes("@index");if(!l&&"@none"!==o){if(n["@type"]===o)return n["@value"];if("@language"in n&&n["@language"]===i&&"@direction"in n&&n["@direction"]===r)return n["@value"];if("@language"in n&&n["@language"]===i)return n["@value"];if("@direction"in n&&n["@direction"]===r)return n["@value"]}const c=Object.keys(n).length,d=1===c||2===c&&"@index"in n&&!l,u="@language"in e,p=a(n["@value"]),h=e.mappings.has(t)&&null===e.mappings.get(t)["@language"];if(d&&"@none"!==o&&(!u||!p||h))return n["@value"];const v={};return l&&(v[S.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=n["@index"]),"@type"in n?v[S.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}})]=S.compactIri({activeCtx:e,iri:n["@type"],relativeTo:{vocab:!0}}):"@language"in n&&(v[S.compactIri({activeCtx:e,iri:"@language",relativeTo:{vocab:!0}})]=n["@language"]),"@direction"in n&&(v[S.compactIri({activeCtx:e,iri:"@direction",relativeTo:{vocab:!0}})]=n["@direction"]),v[S.compactIri({activeCtx:e,iri:"@value",relativeTo:{vocab:!0}})]=n["@value"],v}const i=h(e,t,{vocab:!0},o),r=f(e,t,"@type"),s=S.compactIri({activeCtx:e,iri:n["@id"],relativeTo:{vocab:"@vocab"===r},base:o.base});return"@id"===r||"@vocab"===r||"@graph"===i?s:{[S.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]:s}}},9378(e){"use strict";const t="http://www.w3.org/1999/02/22-rdf-syntax-ns#",n="http://www.w3.org/2001/XMLSchema#";e.exports={LINK_HEADER_REL:"http://www.w3.org/ns/json-ld#context",LINK_HEADER_CONTEXT:"http://www.w3.org/ns/json-ld#context",RDF:t,RDF_LIST:t+"List",RDF_FIRST:t+"first",RDF_REST:t+"rest",RDF_NIL:t+"nil",RDF_TYPE:t+"type",RDF_PLAIN_LITERAL:t+"PlainLiteral",RDF_XML_LITERAL:t+"XMLLiteral",RDF_JSON_LITERAL:t+"JSON",RDF_OBJECT:t+"object",RDF_LANGSTRING:t+"langString",XSD:n,XSD_BOOLEAN:n+"boolean",XSD_DOUBLE:n+"double",XSD_INTEGER:n+"integer",XSD_STRING:n+"string"}},1972(e,t,n){"use strict";const o=n(9263),i=n(2207),{isArray:r,isObject:a,isString:s,isUndefined:l}=n(7382),{isAbsolute:c,isRelative:d,prependBase:u}=n(470),{handleEvent:p}=n(2246),{REGEX_BCP47:h,REGEX_KEYWORD:f,asArray:v,compareShortestLeast:g}=n(9263),y=new Map,m={};function x(e,t,n,o,i,r){if(null===t||!s(t)||m.isKeyword(t))return t;if(t.match(f))return null;if(o&&o.hasOwnProperty(t)&&!0!==i.get(t)&&m.createTermDefinition({activeCtx:e,localCtx:o,term:t,defined:i,options:r}),(n=n||{}).vocab){const n=e.mappings.get(t);if(null===n)return null;if(a(n)&&"@id"in n)return n["@id"]}const l=t.indexOf(":");if(l>0){const n=t.substr(0,l),a=t.substr(l+1);if("_"===n||0===a.indexOf("//"))return t;o&&o.hasOwnProperty(n)&&m.createTermDefinition({activeCtx:e,localCtx:o,term:n,defined:i,options:r});const s=e.mappings.get(n);if(s&&s._prefix)return s["@id"]+a;if(c(t))return t}if(n.vocab&&"@vocab"in e){t=e["@vocab"]+t}else if(n.base){let n,o;"@base"in e?e["@base"]?(o=u(r.base,e["@base"]),n=u(o,t)):(o=e["@base"],n=t):(o=r.base,n=u(r.base,t)),t=n}return t}function b(e,t){if(!e||"object"!=typeof e||!t||"object"!=typeof t)return e===t;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!b(e[n],t[n]))return!1;return!0}const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(const n in e){let o=e[n],i=t[n];if("@container"===n&&Array.isArray(o)&&Array.isArray(i)&&(o=o.slice().sort(),i=i.slice().sort()),!b(o,i))return!1}return!0}e.exports=m,m.process=async({activeCtx:e,localCtx:t,options:n,propagate:o=!0,overrideProtected:l=!1,cycles:f=new Set})=>{a(t)&&"@context"in t&&r(t["@context"])&&(t=t["@context"]);if(0===v(t).length)return e;const g=[],y=[({event:e,next:t})=>{g.push(e),t()}];n.eventHandler&&y.push(n.eventHandler);const b=n;n={...n,eventHandler:y};const w=await n.contextResolver.resolve({activeCtx:e,context:t,documentLoader:n.documentLoader,base:n.base});a(w[0].document)&&"boolean"==typeof w[0].document["@propagate"]&&(o=w[0].document["@propagate"]);let I=e;o||I.previousContext||(I=I.clone(),I.previousContext=e);for(const o of w){let{document:r}=o;if(e=I,null===r){if(!l&&0!==Object.keys(e.protected).length)throw new i("Tried to nullify a context with protected terms outside of a term definition.","jsonld.SyntaxError",{code:"invalid context nullification"});I=e=m.getInitialContext(n).clone();continue}const v=o.getProcessed(e);if(v){if(b.eventHandler)for(const e of v.events)p({event:e,options:b});I=e=v.context;continue}if(a(r)&&"@context"in r&&(r=r["@context"]),!a(r))throw new i("Invalid JSON-LD syntax; @context must be an object.","jsonld.SyntaxError",{code:"invalid local context",context:r});I=I.clone();const y=new Map;if("@version"in r){if(1.1!==r["@version"])throw new i("Unsupported JSON-LD version: "+r["@version"],"jsonld.UnsupportedVersion",{code:"invalid @version value",context:r});if(e.processingMode&&"json-ld-1.0"===e.processingMode)throw new i("@version: "+r["@version"]+" not compatible with "+e.processingMode,"jsonld.ProcessingModeConflict",{code:"processing mode conflict",context:r});I.processingMode="json-ld-1.1",I["@version"]=r["@version"],y.set("@version",!0)}if(I.processingMode=I.processingMode||e.processingMode,"@base"in r){let e=r["@base"];if(null===e||c(e));else{if(!d(e))throw new i('Invalid JSON-LD syntax; the value of "@base" in a @context must be an absolute IRI, a relative IRI, or null.',"jsonld.SyntaxError",{code:"invalid base IRI",context:r});e=u(I["@base"],e)}I["@base"]=e,y.set("@base",!0)}if("@vocab"in r){const e=r["@vocab"];if(null===e)delete I["@vocab"];else{if(!s(e))throw new i('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:r});if(!c(e)&&m.processingMode(I,1))throw new i('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be an absolute IRI.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:r});{const t=x(I,e,{vocab:!0,base:!0},void 0,void 0,n);c(t)||n.eventHandler&&p({event:{type:["JsonLdEvent"],code:"relative @vocab reference",level:"warning",message:"Relative @vocab reference found.",details:{vocab:t}},options:n}),I["@vocab"]=t}}y.set("@vocab",!0)}if("@language"in r){const e=r["@language"];if(null===e)delete I["@language"];else{if(!s(e))throw new i('Invalid JSON-LD syntax; the value of "@language" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid default language",context:r});e.match(h)||n.eventHandler&&p({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:n}),I["@language"]=e.toLowerCase()}y.set("@language",!0)}if("@direction"in r){const t=r["@direction"];if("json-ld-1.0"===e.processingMode)throw new i("Invalid JSON-LD syntax; @direction not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context member",context:r});if(null===t)delete I["@direction"];else{if("ltr"!==t&&"rtl"!==t)throw new i('Invalid JSON-LD syntax; the value of "@direction" in a @context must be null, "ltr", or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",context:r});I["@direction"]=t}y.set("@direction",!0)}if("@propagate"in r){const n=r["@propagate"];if("json-ld-1.0"===e.processingMode)throw new i("Invalid JSON-LD syntax; @propagate not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context entry",context:r});if("boolean"!=typeof n)throw new i("Invalid JSON-LD syntax; @propagate value must be a boolean.","jsonld.SyntaxError",{code:"invalid @propagate value",context:t});y.set("@propagate",!0)}if("@import"in r){const o=r["@import"];if("json-ld-1.0"===e.processingMode)throw new i("Invalid JSON-LD syntax; @import not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context entry",context:r});if(!s(o))throw new i("Invalid JSON-LD syntax; @import must be a string.","jsonld.SyntaxError",{code:"invalid @import value",context:t});const a=await n.contextResolver.resolve({activeCtx:e,context:o,documentLoader:n.documentLoader,base:n.base});if(1!==a.length)throw new i("Invalid JSON-LD syntax; @import must reference a single context.","jsonld.SyntaxError",{code:"invalid remote context",context:t});const l=a[0].getProcessed(e);if(l)r=l;else{const n=a[0].document;if("@import"in n)throw new i("Invalid JSON-LD syntax: imported context must not include @import.","jsonld.SyntaxError",{code:"invalid context entry",context:t});for(const e in n)r.hasOwnProperty(e)||(r[e]=n[e]);a[0].setProcessed(e,r)}y.set("@import",!0)}y.set("@protected",r["@protected"]||!1);for(const e in r)if(m.createTermDefinition({activeCtx:I,localCtx:r,term:e,defined:y,options:n,overrideProtected:l}),a(r[e])&&"@context"in r[e]){const t=r[e]["@context"];let o=!0;if(s(t)){const e=u(n.base,t);f.has(e)?o=!1:f.add(e)}if(o)try{await m.process({activeCtx:I.clone(),localCtx:r[e]["@context"],overrideProtected:!0,options:n,cycles:f})}catch(t){throw new i("Invalid JSON-LD syntax; invalid scoped context.","jsonld.SyntaxError",{code:"invalid scoped context",context:r[e]["@context"],term:e})}}o.setProcessed(e,{context:I,events:g})}return I},m.createTermDefinition=({activeCtx:e,localCtx:t,term:n,defined:o,options:l,overrideProtected:d=!1})=>{if(o.has(n)){if(o.get(n))return;throw new i("Cyclical context definition detected.","jsonld.CyclicalContext",{code:"cyclic IRI mapping",context:t,term:n})}let u;if(o.set(n,!1),t.hasOwnProperty(n)&&(u=t[n]),"@type"===n&&a(u)&&"@set"===(u["@container"]||"@set")&&m.processingMode(e,1.1)){const e=["@container","@id","@protected"],o=Object.keys(u);if(0===o.length||o.some(t=>!e.includes(t)))throw new i("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:t,term:n})}else{if(m.isKeyword(n))throw new i("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:t,term:n});if(n.match(f))return void(l.eventHandler&&p({event:{type:["JsonLdEvent"],code:"reserved term",level:"warning",message:'Terms beginning with "@" are reserved for future use and dropped.',details:{term:n}},options:l}));if(""===n)throw new i("Invalid JSON-LD syntax; a term cannot be an empty string.","jsonld.SyntaxError",{code:"invalid term definition",context:t})}const h=e.mappings.get(n);e.mappings.has(n)&&e.mappings.delete(n);let v=!1;if((s(u)||null===u)&&(v=!0,u={"@id":u}),!a(u))throw new i("Invalid JSON-LD syntax; @context term values must be strings or objects.","jsonld.SyntaxError",{code:"invalid term definition",context:t});const g={};e.mappings.set(n,g),g.reverse=!1;const y=["@container","@id","@language","@reverse","@type"];m.processingMode(e,1.1)&&y.push("@context","@direction","@index","@nest","@prefix","@protected");for(const e in u)if(!y.includes(e))throw new i("Invalid JSON-LD syntax; a term definition must not contain "+e,"jsonld.SyntaxError",{code:"invalid term definition",context:t});const w=n.indexOf(":");if(g._termHasColon=w>0,"@reverse"in u){if("@id"in u)throw new i("Invalid JSON-LD syntax; a @reverse term definition must not contain @id.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});if("@nest"in u)throw new i("Invalid JSON-LD syntax; a @reverse term definition must not contain @nest.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});const r=u["@reverse"];if(!s(r))throw new i("Invalid JSON-LD syntax; a @context @reverse value must be a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});if(r.match(f))return l.eventHandler&&p({event:{type:["JsonLdEvent"],code:"reserved @reverse value",level:"warning",message:'@reverse values beginning with "@" are reserved for future use and dropped.',details:{reverse:r}},options:l}),void(h?e.mappings.set(n,h):e.mappings.delete(n));const a=x(e,r,{vocab:!0,base:!1},t,o,l);if(!c(a))throw new i("Invalid JSON-LD syntax; a @context @reverse value must be an absolute IRI or a blank node identifier.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});g["@id"]=a,g.reverse=!0}else if("@id"in u){let r=u["@id"];if(r&&!s(r))throw new i("Invalid JSON-LD syntax; a @context @id value must be an array of strings or a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});if(null===r)g["@id"]=null;else{if(!m.isKeyword(r)&&r.match(f))return l.eventHandler&&p({event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:'@id values beginning with "@" are reserved for future use and dropped.',details:{id:r}},options:l}),void(h?e.mappings.set(n,h):e.mappings.delete(n));if(r!==n){if(r=x(e,r,{vocab:!0,base:!1},t,o,l),!c(r)&&!m.isKeyword(r))throw new i("Invalid JSON-LD syntax; a @context @id value must be an absolute IRI, a blank node identifier, or a keyword.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});if(n.match(/(?::[^:])|\//)){if(x(e,n,{vocab:!0,base:!1},t,new Map(o).set(n,!0),l)!==r)throw new i("Invalid JSON-LD syntax; term in form of IRI must expand to definition.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t})}g["@id"]=r,g._prefix=v&&!g._termHasColon&&null!==r.match(/[:\/\?#\[\]@]$/)}}}if(!("@id"in g))if(g._termHasColon){const i=n.substr(0,w);if(t.hasOwnProperty(i)&&m.createTermDefinition({activeCtx:e,localCtx:t,term:i,defined:o,options:l}),e.mappings.has(i)){const t=n.substr(w+1);g["@id"]=e.mappings.get(i)["@id"]+t}else g["@id"]=n}else if("@type"===n)g["@id"]=n;else{if(!("@vocab"in e))throw new i("Invalid JSON-LD syntax; @context terms must define an @id.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t,term:n});g["@id"]=e["@vocab"]+n}if((!0===u["@protected"]||!0===o.get("@protected")&&!1!==u["@protected"])&&(e.protected[n]=!0,g.protected=!0),o.set(n,!0),"@type"in u){let n=u["@type"];if(!s(n))throw new i("Invalid JSON-LD syntax; an @context @type value must be a string.","jsonld.SyntaxError",{code:"invalid type mapping",context:t});if("@json"===n||"@none"===n){if(m.processingMode(e,1))throw new i(`Invalid JSON-LD syntax; an @context @type value must not be "${n}" in JSON-LD 1.0 mode.`,"jsonld.SyntaxError",{code:"invalid type mapping",context:t})}else if("@id"!==n&&"@vocab"!==n){if(n=x(e,n,{vocab:!0,base:!1},t,o,l),!c(n))throw new i("Invalid JSON-LD syntax; an @context @type value must be an absolute IRI.","jsonld.SyntaxError",{code:"invalid type mapping",context:t});if(0===n.indexOf("_:"))throw new i("Invalid JSON-LD syntax; an @context @type value must be an IRI, not a blank node identifier.","jsonld.SyntaxError",{code:"invalid type mapping",context:t})}g["@type"]=n}if("@container"in u){const n=s(u["@container"])?[u["@container"]]:u["@container"]||[],o=["@list","@set","@index","@language"];let a=!0;const l=n.includes("@set");if(m.processingMode(e,1.1)){if(o.push("@graph","@id","@type"),n.includes("@list")){if(1!==n.length)throw new i("Invalid JSON-LD syntax; @context @container with @list must have no other values","jsonld.SyntaxError",{code:"invalid container mapping",context:t})}else if(n.includes("@graph")){if(n.some(e=>"@graph"!==e&&"@id"!==e&&"@index"!==e&&"@set"!==e))throw new i("Invalid JSON-LD syntax; @context @container with @graph must have no other values other than @id, @index, and @set","jsonld.SyntaxError",{code:"invalid container mapping",context:t})}else a&=n.length<=(l?2:1);if(n.includes("@type")&&(g["@type"]=g["@type"]||"@id",!["@id","@vocab"].includes(g["@type"])))throw new i("Invalid JSON-LD syntax; container: @type requires @type to be @id or @vocab.","jsonld.SyntaxError",{code:"invalid type mapping",context:t})}else a&=!r(u["@container"]),a&=n.length<=1;if(a&=n.every(e=>o.includes(e)),a&=!(l&&n.includes("@list")),!a)throw new i("Invalid JSON-LD syntax; @context @container value must be one of the following: "+o.join(", "),"jsonld.SyntaxError",{code:"invalid container mapping",context:t});if(g.reverse&&!n.every(e=>["@index","@set"].includes(e)))throw new i("Invalid JSON-LD syntax; @context @container value for a @reverse type definition must be @index or @set.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});g["@container"]=n}if("@index"in u){if(!("@container"in u)||!g["@container"].includes("@index"))throw new i(`Invalid JSON-LD syntax; @index without @index in @container: "${u["@index"]}" on term "${n}".`,"jsonld.SyntaxError",{code:"invalid term definition",context:t});if(!s(u["@index"])||0===u["@index"].indexOf("@"))throw new i(`Invalid JSON-LD syntax; @index must expand to an IRI: "${u["@index"]}" on term "${n}".`,"jsonld.SyntaxError",{code:"invalid term definition",context:t});g["@index"]=u["@index"]}if("@context"in u&&(g["@context"]=u["@context"]),"@language"in u&&!("@type"in u)){let e=u["@language"];if(null!==e&&!s(e))throw new i("Invalid JSON-LD syntax; @context @language value must be a string or null.","jsonld.SyntaxError",{code:"invalid language mapping",context:t});null!==e&&(e=e.toLowerCase()),g["@language"]=e}if("@prefix"in u){if(n.match(/:|\//))throw new i("Invalid JSON-LD syntax; @context @prefix used on a compact IRI term","jsonld.SyntaxError",{code:"invalid term definition",context:t});if(m.isKeyword(g["@id"]))throw new i("Invalid JSON-LD syntax; keywords may not be used as prefixes","jsonld.SyntaxError",{code:"invalid term definition",context:t});if("boolean"!=typeof u["@prefix"])throw new i("Invalid JSON-LD syntax; @context value for @prefix must be boolean","jsonld.SyntaxError",{code:"invalid @prefix value",context:t});g._prefix=!0===u["@prefix"]}if("@direction"in u){const e=u["@direction"];if(null!==e&&"ltr"!==e&&"rtl"!==e)throw new i('Invalid JSON-LD syntax; @direction value must be null, "ltr", or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",context:t});g["@direction"]=e}if("@nest"in u){const e=u["@nest"];if(!s(e)||"@nest"!==e&&0===e.indexOf("@"))throw new i("Invalid JSON-LD syntax; @context @nest value must be a string which is not a keyword other than @nest.","jsonld.SyntaxError",{code:"invalid @nest value",context:t});g["@nest"]=e} // disallow aliasing @context and @preserve const I=g["@id"];if("@context"===I||"@preserve"===I)throw new i("Invalid JSON-LD syntax; @context and @preserve cannot be aliased.","jsonld.SyntaxError",{code:"invalid keyword alias",context:t});if(h&&h.protected&&!d&&(e.protected[n]=!0,g.protected=!0,!b(h,g)))throw new i("Invalid JSON-LD syntax; tried to redefine a protected term.","jsonld.SyntaxError",{code:"protected term redefinition",context:t,term:n})},m.expandIri=(e,t,n,o)=>x(e,t,n,void 0,void 0,o),m.getInitialContext=e=>{const t=JSON.stringify({processingMode:e.processingMode}),n=y.get(t);if(n)return n;const i={processingMode:e.processingMode,mappings:new Map,inverse:null,getInverse:function(){const e=this;if(e.inverse)return e.inverse;const t=e.inverse={},n=e.fastCurieMap={},o={},i=(e["@language"]||"@none").toLowerCase(),s=e["@direction"],l=e.mappings,c=[...l.keys()].sort(g);for(const e of c){const r=l.get(e);if(null===r)continue;let c=r["@container"]||"@none";if(c=[].concat(c).sort().join(""),null===r["@id"])continue;const d=v(r["@id"]);for(const l of d){let d=t[l];const u=m.isKeyword(l);if(d)u||r._termHasColon||o[l].push(e);else if(t[l]=d={},!u&&!r._termHasColon){o[l]=[e];const t={iri:l,terms:o[l]};l[0]in n?n[l[0]].push(t):n[l[0]]=[t]}if(d[c]||(d[c]={"@language":{},"@type":{},"@any":{}}),d=d[c],a(e,d["@any"],"@none"),r.reverse)a(e,d["@type"],"@reverse");else if("@none"===r["@type"])a(e,d["@any"],"@none"),a(e,d["@language"],"@none"),a(e,d["@type"],"@none");else if("@type"in r)a(e,d["@type"],r["@type"]);else if("@language"in r&&"@direction"in r){const t=r["@language"],n=r["@direction"];a(e,d["@language"],t&&n?`${t}_${n}`.toLowerCase():t?t.toLowerCase():n?`_${n}`:"@null")}else"@language"in r?a(e,d["@language"],(r["@language"]||"@null").toLowerCase()):"@direction"in r?r["@direction"]?a(e,d["@language"],`_${r["@direction"]}`):a(e,d["@language"],"@none"):s?(a(e,d["@language"],`_${s}`),a(e,d["@language"],"@none"),a(e,d["@type"],"@none")):(a(e,d["@language"],i),a(e,d["@language"],"@none"),a(e,d["@type"],"@none"))}}for(const e in n)r(n,e,1);return t},clone:function(){const e={};e.mappings=o.clone(this.mappings),e.clone=this.clone,e.inverse=null,e.getInverse=this.getInverse,e.protected=o.clone(this.protected),this.previousContext&&(e.previousContext=this.previousContext.clone());e.revertToPreviousContext=this.revertToPreviousContext,"@base"in this&&(e["@base"]=this["@base"]);"@language"in this&&(e["@language"]=this["@language"]);"@vocab"in this&&(e["@vocab"]=this["@vocab"]);return e},revertToPreviousContext:function(){if(!this.previousContext)return this;return this.previousContext.clone()},protected:{}};return 1e4===y.size&&y.clear(),y.set(t,i),i;function r(e,t,n){const o=e[t],i=e[t]={};let a,s;for(const e of o)a=e.iri,s=n>=a.length?"":a[n],s in i?i[s].push(e):i[s]=[e];for(const e in i)""!==e&&r(i,e,n+1)}function a(e,t,n){t.hasOwnProperty(n)||(t[n]=e)}},m.getContextValue=(e,t,n)=>{if(null===t){if("@context"===n)return;return null}if(e.mappings.has(t)){const o=e.mappings.get(t);if(l(n))return o;if(o.hasOwnProperty(n))return o[n]}return"@language"===n&&n in e||"@direction"===n&&n in e?e[n]:"@context"!==n?null:void 0},m.processingMode=(e,t)=>t.toString()>="1.1"?!e.processingMode||e.processingMode>="json-ld-"+t.toString():"json-ld-1.0"===e.processingMode,m.isKeyword=e=>{if(!s(e)||"@"!==e[0])return!1;switch(e){case"@base":case"@container":case"@context":case"@default":case"@direction":case"@embed":case"@explicit":case"@graph":case"@id":case"@included":case"@index":case"@json":case"@language":case"@list":case"@nest":case"@none":case"@omitDefault":case"@prefix":case"@preserve":case"@protected":case"@requireAll":case"@reverse":case"@set":case"@type":case"@value":case"@version":case"@vocab":return!0}return!1}},6957(e,t,n){"use strict";const{parseLinkHeader:o,buildHeaders:i}=n(9263),{LINK_HEADER_CONTEXT:r}=n(9378),a=n(2207),s=n(3743),{prependBase:l}=n(470),c=/(^|(\r\n))link:/i;e.exports=({secure:e,headers:t={},xhr:n}={headers:{}})=>{t=i(t);return(new s).wrapLoader(async function i(s){if(0!==s.indexOf("http:")&&0!==s.indexOf("https:"))throw new a('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:s});if(e&&0!==s.indexOf("https"))throw new a('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:s});let d;try{d=await function(e,t,n){e=e||XMLHttpRequest;const o=new e;return new Promise((e,i)=>{o.onload=()=>e(o),o.onerror=e=>i(e),o.open("GET",t,!0);for(const e in n)o.setRequestHeader(e,n[e]);o.send()})}(n,s,t)}catch(e){throw new a("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:s,cause:e})}if(d.status>=400)throw new a("URL could not be dereferenced: "+d.statusText,"jsonld.LoadDocumentError",{code:"loading document failed",url:s,httpStatusCode:d.status});let u={contextUrl:null,documentUrl:s,document:d.response},p=null;const h=d.getResponseHeader("Content-Type");let f;c.test(d.getAllResponseHeaders())&&(f=d.getResponseHeader("Link"));if(f&&"application/ld+json"!==h){const e=o(f),t=e[r];if(Array.isArray(t))throw new a("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:s});t&&(u.contextUrl=t.target),p=e.alternate,p&&"application/ld+json"==p.type&&!(h||"").match(/^application\/(\w*\+)?json$/)&&(u=await i(l(s,p.target)))}return u})}},2246(e,t,n){"use strict";const o=n(2207),{isArray:i}=n(7382),{asArray:r}=n(9263),a={};function s({event:e,handlers:t}){let n=!0;for(let r=0;n&&r<t.length;++r){n=!1;const a=t[r];if(i(a))n=s({event:e,handlers:a});else if("function"==typeof a)a({event:e,next:()=>{n=!0}});else{if("object"!=typeof a)throw new o("Invalid event handler.","jsonld.InvalidEventHandler",{event:e});e.code in a?a[e.code]({event:e,next:()=>{n=!0}}):n=!0}}return n}e.exports=a,a.defaultEventHandler=null,a.setupEventHandler=({options:e={}})=>{const t=[].concat(e.safe?a.safeEventHandler:[],e.eventHandler?r(e.eventHandler):[],a.defaultEventHandler?a.defaultEventHandler:[]);return 0===t.length?null:t},a.handleEvent=({event:e,options:t})=>{s({event:e,handlers:t.eventHandler})};const l=new Set(["empty object","free-floating scalar","invalid @language value","invalid property","null @id value","null @value value","object with only @id","object with only @language","object with only @list","object with only @value","relative @id reference","relative @type reference","relative @vocab reference","reserved @id value","reserved @reverse value","reserved term","blank node predicate","relative graph reference","relative object reference","relative predicate reference","relative subject reference","rdfDirection not set"]);a.safeEventHandler=function({event:e,next:t}){if("warning"===e.level&&l.has(e.code))throw new o("Safe mode validation error.","jsonld.ValidationError",{event:e});t()},a.logEventHandler=function({event:e,next:t}){t()},a.logWarningEventHandler=function({event:e,next:t}){e.level,t()},a.unhandledEventHandler=function({event:e}){throw new o("No handler for event.","jsonld.UnhandledEvent",{event:e})},a.setDefaultEventHandler=function({eventHandler:e}={}){a.defaultEventHandler=e?r(e):null}},4019(e,t,n){"use strict";const o=n(2207),{isArray:i,isObject:r,isEmptyObject:a,isString:s,isUndefined:l}=n(7382),{isList:c,isValue:d,isGraph:u,isSubject:p}=n(3978),{expandIri:h,getContextValue:f,isKeyword:v,process:g,processingMode:y}=n(1972),{isAbsolute:m}=n(470),{REGEX_BCP47:x,REGEX_KEYWORD:b,addValue:w,asArray:I,getValues:j,validateTypeValue:S}=n(9263),{handleEvent:O}=n(2246),D={};function E({value:e,count:t,options:n}){if(0===t||"@value"in e||"@list"in e||1===t&&"@id"in e){if(n.eventHandler){let o,i;0===t?(o="empty object",i="Dropping empty object."):"@value"in e?(o="object with only @value",i="Dropping object with only @value."):"@list"in e?(o="object with only @list",i="Dropping object with only @list."):1===t&&"@id"in e&&(o="object with only @id",i="Dropping object with only @id."),O({event:{type:["JsonLdEvent"],code:o,level:"warning",message:i,details:{value:e}},options:n})}return null}return e}async function N({activeCtx:e,activeProperty:t,expandedActiveProperty:n,element:u,expandedParent:b,options:j={},insideList:C,typeKey:A,typeScopedContext:R}){const T=Object.keys(u).sort(),_=[];let P;const J=u[A]&&"@json"===h(e,i(u[A])?u[A][0]:u[A],{vocab:!0},{...j,typeExpansion:!0});for(const N of T){let C,A=u[N];if("@context"===N)continue;const T=h(e,N,{vocab:!0},j);if(null===T||!m(T)&&!v(T)){j.eventHandler&&O({event:{type:["JsonLdEvent"],code:"invalid property",level:"warning",message:"Dropping property that did not expand into an absolute IRI or keyword.",details:{property:N,expandedProperty:T}},options:j});continue}if(v(T)){if("@reverse"===n)throw new o("Invalid JSON-LD syntax; a keyword cannot be used as a @reverse property.","jsonld.SyntaxError",{code:"invalid reverse property map",value:A});if(T in b&&"@included"!==T&&"@type"!==T)throw new o("Invalid JSON-LD syntax; colliding keywords detected.","jsonld.SyntaxError",{code:"colliding keywords",keyword:T})}if("@id"===T){if(!s(A)){if(!j.isFrame)throw new o('Invalid JSON-LD syntax; "@id" value must a string.',"jsonld.SyntaxError",{code:"invalid @id value",value:A});if(r(A)){if(!a(A))throw new o('Invalid JSON-LD syntax; "@id" value an empty object or array of strings, if framing',"jsonld.SyntaxError",{code:"invalid @id value",value:A})}else{if(!i(A))throw new o('Invalid JSON-LD syntax; "@id" value an empty object or array of strings, if framing',"jsonld.SyntaxError",{code:"invalid @id value",value:A});if(!A.every(e=>s(e)))throw new o('Invalid JSON-LD syntax; "@id" value an empty object or array of strings, if framing',"jsonld.SyntaxError",{code:"invalid @id value",value:A})}}w(b,"@id",I(A).map(t=>{if(s(t)){const n=h(e,t,{base:!0},j);return j.eventHandler&&(null===n?O(null===t?{event:{type:["JsonLdEvent"],code:"null @id value",level:"warning",message:"Null @id found.",details:{id:t}},options:j}:{event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:"Reserved @id found.",details:{id:t}},options:j}):m(n)||O({event:{type:["JsonLdEvent"],code:"relative @id reference",level:"warning",message:"Relative @id reference found.",details:{id:t,expandedId:n}},options:j})),n}return t}),{propertyIsArray:j.isFrame});continue}if("@type"===T){r(A)&&(A=Object.fromEntries(Object.entries(A).map(([e,t])=>[h(R,e,{vocab:!0}),I(t).map(e=>h(R,e,{base:!0,vocab:!0},{...j,typeExpansion:!0}))]))),S(A,j.isFrame),w(b,"@type",I(A).map(e=>{if(s(e)){const t=h(R,e,{base:!0,vocab:!0},{...j,typeExpansion:!0});return"@json"===t||m(t)||j.eventHandler&&O({event:{type:["JsonLdEvent"],code:"relative @type reference",level:"warning",message:"Relative @type reference found.",details:{type:e}},options:j}),t}return e}),{propertyIsArray:!!j.isFrame});continue}if("@included"===T&&y(e,1.1)){const n=I(await D.expand({activeCtx:e,activeProperty:t,element:A,options:j}));if(!n.every(e=>p(e)))throw new o("Invalid JSON-LD syntax; values of @included must expand to node objects.","jsonld.SyntaxError",{code:"invalid @included value",value:A});w(b,"@included",n,{propertyIsArray:!0});continue}if("@graph"===T&&!r(A)&&!i(A))throw new o('Invalid JSON-LD syntax; "@graph" value must not be an object or an array.',"jsonld.SyntaxError",{code:"invalid @graph value",value:A});if("@value"===T){P=A,J&&y(e,1.1)?b["@value"]=A:w(b,"@value",A,{propertyIsArray:j.isFrame});continue}if("@language"===T){if(null===A)continue;if(!s(A)&&!j.isFrame)throw new o('Invalid JSON-LD syntax; "@language" value must be a string.',"jsonld.SyntaxError",{code:"invalid language-tagged string",value:A});A=I(A).map(e=>s(e)?e.toLowerCase():e);for(const e of A)s(e)&&!e.match(x)&&j.eventHandler&&O({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:j});w(b,"@language",A,{propertyIsArray:j.isFrame});continue}if("@direction"===T){if(!s(A)&&!j.isFrame)throw new o('Invalid JSON-LD syntax; "@direction" value must be a string.',"jsonld.SyntaxError",{code:"invalid base direction",value:A});A=I(A);for(const e of A)if(s(e)&&"ltr"!==e&&"rtl"!==e)throw new o('Invalid JSON-LD syntax; "@direction" must be "ltr" or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",value:A});w(b,"@direction",A,{propertyIsArray:j.isFrame});continue}if("@index"===T){if(!s(A))throw new o('Invalid JSON-LD syntax; "@index" value must be a string.',"jsonld.SyntaxError",{code:"invalid @index value",value:A});w(b,"@index",A);continue}if("@reverse"===T){if(!r(A))throw new o('Invalid JSON-LD syntax; "@reverse" value must be an object.',"jsonld.SyntaxError",{code:"invalid @reverse value",value:A});if(C=await D.expand({activeCtx:e,activeProperty:"@reverse",element:A,options:j}),"@reverse"in C)for(const e in C["@reverse"])w(b,e,C["@reverse"][e],{propertyIsArray:!0});let t=b["@reverse"]||null;for(const e in C){if("@reverse"===e)continue;null===t&&(t=b["@reverse"]={}),w(t,e,[],{propertyIsArray:!0});const n=C[e];for(let i=0;i<n.length;++i){const r=n[i];if(d(r)||c(r))throw new o('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:C});w(t,e,r,{propertyIsArray:!0})}}continue}if("@nest"===T){_.push(N);continue}let M=e;const F=f(e,N,"@context");l(F)||(M=await g({activeCtx:e,localCtx:F,propagate:!0,overrideProtected:!0,options:j}));const H=f(e,N,"@container")||[];if(H.includes("@language")&&r(A)){C=k(M,A,f(M,N,"@direction"),j)}else if(H.includes("@index")&&r(A)){const t=H.includes("@graph"),n=f(M,N,"@index")||"@index",o="@index"!==n&&h(e,n,{vocab:!0},j);C=await L({activeCtx:M,options:j,activeProperty:N,value:A,asGraph:t,indexKey:n,propertyIndex:o})}else if(H.includes("@id")&&r(A)){const e=H.includes("@graph");C=await L({activeCtx:M,options:j,activeProperty:N,value:A,asGraph:e,indexKey:"@id"})}else if(H.includes("@type")&&r(A))C=await L({activeCtx:M.revertToPreviousContext(),options:j,activeProperty:N,value:A,asGraph:!1,indexKey:"@type"});else{const o="@list"===T;if(o||"@set"===T){let e=t;o&&"@graph"===n&&(e=null),C=await D.expand({activeCtx:M,activeProperty:e,element:A,options:j,insideList:o})}else C="@json"===f(e,N,"@type")?{"@type":"@json","@value":A}:await D.expand({activeCtx:M,activeProperty:N,element:A,options:j,insideList:!1})}if(null!==C||"@value"===T){if("@list"!==T&&!c(C)&&H.includes("@list")&&(C={"@list":I(C)}),H.includes("@graph")&&!H.some(e=>"@id"===e||"@index"===e)){if(C=I(C),j.isFrame||(C=C.filter(e=>null!==E({value:e,count:Object.keys(e).length,options:j}))),0===C.length)continue;C=C.map(e=>({"@graph":I(e)}))}if(M.mappings.has(N)&&M.mappings.get(N).reverse){const e=b["@reverse"]=b["@reverse"]||{};C=I(C);for(let t=0;t<C.length;++t){const n=C[t];if(d(n)||c(n))throw new o('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:C});w(e,T,n,{propertyIsArray:!0})}continue}w(b,T,C,{propertyIsArray:!0})}}if("@value"in b)if("@json"===b["@type"]&&y(e,1.1));else if((r(P)||i(P))&&!j.isFrame)throw new o('Invalid JSON-LD syntax; "@value" value must not be an object or an array.',"jsonld.SyntaxError",{code:"invalid value object value",value:P});for(const a of _){const s=i(u[a])?u[a]:[u[a]];for(const i of s){if(!r(i)||Object.keys(i).some(t=>"@value"===h(e,t,{vocab:!0},j)))throw new o("Invalid JSON-LD syntax; nested value must be a node object.","jsonld.SyntaxError",{code:"invalid @nest value",value:i});await N({activeCtx:e,activeProperty:t,expandedActiveProperty:n,element:i,expandedParent:b,options:j,insideList:C,typeScopedContext:R,typeKey:A})}}}function C({activeCtx:e,activeProperty:t,value:n,options:o}){if(null==n)return null;const i=h(e,t,{vocab:!0},o);if("@id"===i)return h(e,n,{base:!0},o);if("@type"===i)return h(e,n,{vocab:!0,base:!0},{...o,typeExpansion:!0});const r=f(e,t,"@type");if(("@id"===r||"@graph"===i)&&s(n)){const i=h(e,n,{base:!0},o);return null===i&&n.match(b)&&o.eventHandler&&O({event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:"Reserved @id found.",details:{id:t}},options:o}),{"@id":i}}if("@vocab"===r&&s(n))return{"@id":h(e,n,{vocab:!0,base:!0},o)};if(v(i))return n;const a={};if(r&&!["@id","@vocab","@none"].includes(r))a["@type"]=r;else if(s(n)){const n=f(e,t,"@language");null!==n&&(a["@language"]=n);const o=f(e,t,"@direction");null!==o&&(a["@direction"]=o)}return["boolean","number","string"].includes(typeof n)||(n=n.toString()),a["@value"]=n,a}function k(e,t,n,r){const a=[],l=Object.keys(t).sort();for(const c of l){const l=h(e,c,{vocab:!0},r);let d=t[c];i(d)||(d=[d]);for(const e of d){if(