@blockcerts/blockcerts-verifier 1.72.4 → 1.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +8 -0
  2. package/bundle-stats.html +1 -1
  3. package/codecov +0 -0
  4. package/codecov.SHA256SUM +1 -0
  5. package/codecov.SHA256SUM.sig +16 -0
  6. package/coverage/lcov.info +475 -472
  7. package/dist/{DataIntegrityProof-x-pKdBCc-B_YUlE0Z.js → DataIntegrityProof-D8TnXEkl-CGiIg0kn.js} +2 -2
  8. package/dist/{EcdsaSd2023-CU35O_1w-CISk0lEt.js → EcdsaSd2023-D2eJBmaY-mHNjbn8h.js} +11 -15
  9. package/dist/EcdsaSecp256k1Signature2019-BRdQnZ0o-D_QN8KrS.js +1 -0
  10. package/dist/{Ed25519Signature2020-B6yblwC5-BRlzT2Yc.js → Ed25519Signature2020-D2tdrIA4-PSi5TCQH.js} +5 -5
  11. package/dist/{EddsaRdfc2022-Csk9U_qt-B798omlR.js → EddsaRdfc2022-CpZAUc7W-BJP0532C.js} +3 -3
  12. package/dist/MerkleProof2017-DW_9FhLr-C0dPtifx.js +1 -0
  13. package/dist/MerkleProof2019-DJbo7uW--CHlhsnHk.js +5 -0
  14. package/dist/Suite-BmP2Qu19-D1ucdMDB.js +1 -0
  15. package/dist/_polyfill-node.path-hKwMKLNw-B7aPtphV.js +1 -0
  16. package/dist/checkBitStringStatusList-BUPuVWy_-CYedocxJ.js +13 -0
  17. package/dist/checkCredentialSchemaConformity-CJdGwNcY-CaSak-bD.js +1 -0
  18. package/dist/{controlVerificationMethod-Cuyek_Vk-C_Uq2iA5.js → controlVerificationMethod-C71lJp3H-n-AbzkO8.js} +1 -1
  19. package/dist/{downloadPDF-UAsY-nU_.js → downloadPDF-BU6CfP-N.js} +2 -2
  20. package/dist/{ensureNotRevoked-CNUfpW4F-BheL-ZKZ.js → ensureNotRevoked-BWp1jPEo-DSQMtjrj.js} +1 -1
  21. package/dist/ensureValidIssuingKey-BYAR3LEF-76kiqVKA.js +1 -0
  22. package/dist/{index-DNlz8u7B-CYTlxhyY.js → index-BCu3PGuw-Dh4-8Ruv.js} +1 -1
  23. package/dist/index-CB7VaVsF-G_Mj6xql.js +30 -0
  24. package/dist/index-Jn9Q6fuB-uChPhl1c.js +56 -0
  25. package/dist/{index.es-CnYWLNZV.js → index.es-C2GPR7m7.js} +1 -1
  26. package/dist/jsonld-DqC1oHcn-ruRlORc0.js +88 -0
  27. package/dist/main.js +85 -85
  28. package/dist/purify.es-C6IIzwyE.js +2 -0
  29. package/dist/{retrieveVerificationMethodPublicKey-DcEGtx_h-D1zuvtQB.js → retrieveVerificationMethodPublicKey-Dai7em0K-BqIH8qzD.js} +1 -1
  30. package/dist/verifyIssuerProfile-zkczSLpC-CTHpISfH.js +1 -0
  31. package/package.json +9 -9
  32. package/dist/EcdsaSecp256k1Signature2019-DiXIv8yq-B2kEN_Qo.js +0 -1
  33. package/dist/MerkleProof2017-BIJKwMk5-CLYAJK4G.js +0 -1
  34. package/dist/MerkleProof2019-CeAt2OGM-DOuISx_E.js +0 -5
  35. package/dist/Suite-CBLHluYK-Dmvbh142.js +0 -33
  36. package/dist/checkCredentialSchemaConformity-CECtM4WI-C1vg05zb.js +0 -1
  37. package/dist/checkRevocationStatusList2021-B7NFlV-5-C3Zng1tA.js +0 -13
  38. package/dist/ensureValidIssuingKey-DN2kpCwj-DY8BTObG.js +0 -1
  39. package/dist/index-DFOHyoZq-BCuOIg2Z.js +0 -29
  40. package/dist/jsonld-signatures-BtZPa7MV-DTekMXP5.js +0 -56
  41. package/dist/pako.esm-BGRKTPxS-Bodm4Eha.js +0 -2
  42. package/dist/purify.es-Om653OSQ.js +0 -2
  43. package/dist/sha2-JcCWfgvE-By1_saxP.js +0 -2
  44. package/dist/verifyIssuerProfile-DQji41Fc-l31-7imR.js +0 -1
  45. /package/dist/{HashlinkVerifier-Bi7nn19S-DMjUYzMR.js → HashlinkVerifier-BcdAFe02-DMjUYzMR.js} +0 -0
  46. /package/dist/{index-6G1g4ypj-Dgus2xdV.js → index-KzSDgEl9-Dgus2xdV.js} +0 -0
  47. /package/dist/{index-D7PA_QcD-CyttRwCk.js → index-OtXtCWrq-CyttRwCk.js} +0 -0
  48. /package/dist/{webcrypto.es-aoUxIxUm-gGk5JRJH.js → webcrypto.es-9hytEjC6-gGk5JRJH.js} +0 -0
@@ -1,33 +0,0 @@
1
- import{h as e}from"./main.js";var t,n,o={};function r(){return n?t:(n=1,t=class e{constructor(e,t=new Map,n=0){this.prefix=e,this._existing=t,this.counter=n}clone(){const{prefix:t,_existing:n,counter:o}=this;return new e(t,new Map(n),o)}getId(e){const t=e&&this._existing.get(e);if(t)return t;const n=this.prefix+this.counter;return this.counter++,e&&this._existing.set(e,n),n}hasId(e){return this._existing.has(e)}getOldIds(){return[...this._existing.keys()]}})}var i,a,s,l,c,d,u,p,f,h,v,g,y,m,x,b,w,I,j,S,D,N,O,E,C,k,L,A,R,T,_,J,P,M,F,H,B,q,U,$,V,z,G,Q,W,X,K,Z,Y,ee,te,ne,oe,re,ie,ae,se,le,ce,de,ue,pe,fe,he,ve,ge,ye,me,xe={};
2
- /*!
3
- * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
4
- */function be(){if(i)return xe;i=1,xe.setImmediate=setImmediate,xe.crypto=globalThis.crypto;const e=[];for(let t=0;t<=255;++t)e.push(t.toString(16).padStart(2,"0"));return xe.bufferToHex=function(t){let n="";const o=new Uint8Array(t);for(let t=0;t<o.length;++t)n+=e[o[t]];return n},xe}
5
- /*!
6
- * Copyright (c) 2016-2023 Digital Bazaar, Inc. All rights reserved.
7
- */function we(){if(s)return a;s=1;const{bufferToHex:e,crypto:t}=be(),n=new Map([["sha256","SHA-256"],["SHA256","SHA-256"],["SHA-256","SHA-256"],["sha384","SHA-384"],["SHA384","SHA-384"],["SHA-384","SHA-384"],["sha512","SHA-512"],["SHA512","SHA-512"],["SHA-512","SHA-512"]]);return a=class{constructor(e){if(!t||!t.subtle)throw new Error("crypto.subtle not found.");if(!n.has(e))throw new Error(`Unsupported algorithm "${e}".`);this.algorithm=n.get(e),this._content=""}update(e){this._content+=e}async digest(){const n=(new TextEncoder).encode(this._content),o=await t.subtle.digest(this.algorithm,n);return e(o)}}}
8
- /*!
9
- * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
10
- */function Ie(){return c?l:(c=1,l=class{constructor(e){this.current=e.sort(),this.done=!1,this.dir=new Map;for(let t=0;t<e.length;++t)this.dir.set(e[t],!0)}hasNext(){return!this.done}next(){const{current:e,dir:t}=this,n=e.slice();let o=null,r=0;const i=e.length;for(let n=0;n<i;++n){const a=e[n],s=t.get(a);(null===o||a>o)&&(s&&n>0&&a>e[n-1]||!s&&n<i-1&&a>e[n+1])&&(o=a,r=n)}if(null===o)this.done=!0;else{const n=t.get(o)?r-1:r+1;e[r]=e[n],e[n]=o;for(const n of e)n>o&&t.set(n,!t.get(n))}return n}})}
11
- /*!
12
- * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
13
- */function je(){if(u)return d;u=1;const e="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",t="http://www.w3.org/2001/XMLSchema#string",n="NamedNode",o="BlankNode",r="Literal",i={};function a(e,t){return e.subject.termType===t.subject.termType&&e.object.termType===t.object.termType&&(e.subject.value===t.subject.value&&e.predicate.value===t.predicate.value&&e.object.value===t.object.value&&(e.object.termType!==r||e.object.datatype.termType===t.object.datatype.termType&&e.object.language===t.object.language&&e.object.datatype.value===t.object.datatype.value))}(()=>{const e="A-Za-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�_",t=e+"0-9-·̀-ͯ‿-⁀",n="_:((?:["+e+"0-9])(?:(?:["+t+".])*(?:["+t+"]))?)",o='(?:<((?:[^\0- <>"{}|^`\\\\]|\\\\u[0-9A-Fa-f]{4}|\\\\U[0-9A-Fa-f]{8})*)>)',r="[ \\t]+",a="[ \\t]*",s="(?:"+o+"|"+n+")"+r,l=o+r,c="(?:"+o+"|"+n+"|"+('(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"(?:'+("(?:\\^\\^"+o+")")+"|(?:@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)))?)")+")"+a,d="(?:\\.|(?:(?:"+o+"|"+n+")"+a+"\\.))";i.eoln=/(?:\r\n)|(?:\n)|(?:\r)/g,i.empty=new RegExp("^"+a+"$"),i.quad=new RegExp("^"+a+s+l+c+d+a+"$")})(),d=class c{static parse(s){const l=[],c={},d=s.split(i.eoln);let u=0;for(const s of d){if(u++,i.empty.test(s))continue;const d=s.match(i.quad);if(null===d)throw new Error("N-Quads parse error on line "+u+".");const f={subject:null,predicate:null,object:null,graph:null};if(void 0!==d[1]?f.subject={termType:n,value:y(d[1])}:f.subject={termType:o,value:d[2]},f.predicate={termType:n,value:y(d[3])},void 0!==d[4]?f.object={termType:n,value:y(d[4])}:void 0!==d[5]?f.object={termType:o,value:d[5]}:(f.object={termType:r,value:void 0,datatype:{termType:n}},void 0!==d[7]?f.object.datatype.value=y(d[7]):void 0!==d[8]?(f.object.datatype.value=e,f.object.language=d[8]):f.object.datatype.value=t,f.object.value=p(d[6])),void 0!==d[9]?f.graph={termType:n,value:y(d[9])}:void 0!==d[10]?f.graph={termType:o,value:d[10]}:f.graph={termType:"DefaultGraph",value:""},f.graph.value in c){let e=!0;const t=c[f.graph.value];for(const n of t)if(a(n,f)){e=!1;break}e&&(t.push(f),l.push(f))}else c[f.graph.value]=[f],l.push(f)}return l}static serialize(e){const t=[];for(const n of e)t.push(c.serializeQuad(n));return t.sort().join("")}static serializeQuadComponents(r,i,a,c){let d="";return r.termType===n?d+=`<${v(r.value)}>`:d+=`_:${r.value}`,i.termType===n?d+=` <${v(i.value)}> `:d+=` _:${i.value} `,a.termType===n?d+=`<${v(a.value)}>`:a.termType===o?d+=`_:${a.value}`:(d+=`"${function(e){if(!s.test(e))return e;return e.replace(s,function(e){return l[e.codePointAt(0)]})}(a.value)}"`,a.datatype.value===e?a.language&&(d+=`@${a.language}`):a.datatype.value!==t&&(d+=`^^<${v(a.datatype.value)}>`)),c.termType===n?d+=` <${v(c.value)}>`:c.termType===o&&(d+=` _:${c.value}`),d+=" .\n",d}static serializeQuad(e){return c.serializeQuadComponents(e.subject,e.predicate,e.object,e.graph)}};const s=/[\u0000-\u001F\u007F"\\]/g,l=[];for(let e=0;e<=127;++e)s.test(String.fromCharCode(e))&&(l[e]="\\u"+e.toString(16).toUpperCase().padStart(4,"0"),s.lastIndex=0);l["\b".codePointAt(0)]="\\b",l["\t".codePointAt(0)]="\\t",l["\n".codePointAt(0)]="\\n",l["\f".codePointAt(0)]="\\f",l["\r".codePointAt(0)]="\\r",l['"'.codePointAt(0)]='\\"',l["\\".codePointAt(0)]="\\\\";const c=/(?:\\([btnfr"'\\]))|(?:\\u([0-9A-Fa-f]{4}))|(?:\\U([0-9A-Fa-f]{8}))/g;function p(e){return c.test(e)?e.replace(c,function(e,t,n,o){if(t)switch(t){case"b":return"\b";case"t":return"\t";case"n":return"\n";case"f":return"\f";case"r":return"\r";case'"':return'"';case"'":return"'";case"\\":return"\\"}return n?String.fromCharCode(parseInt(n,16)):o?String.fromCodePoint(parseInt(o,16)):void 0}):e}const f=/[\u0000-\u0020<>"{}|^`\\]/g,h=[];for(let e=0;e<=127;++e)f.test(String.fromCharCode(e))&&(h[e]="\\u"+e.toString(16).toUpperCase().padStart(4,"0"),f.lastIndex=0);function v(e){return f.test(e)?e.replace(f,function(e){return h[e.codePointAt(0)]}):e}const g=/(?:\\u([0-9A-Fa-f]{4}))|(?:\\U([0-9A-Fa-f]{8}))/g;function y(e){return g.test(e)?e.replace(g,function(e,t,n){return t?String.fromCharCode(parseInt(t,16)):n?String.fromCodePoint(parseInt(n,16)):void 0}):e}return d}
14
- /*!
15
- * Copyright (c) 2016-2023 Digital Bazaar, Inc. All rights reserved.
16
- */function Se(){return g||(g=1,function(e){const t=function(){if(f)return p;f=1;const e=r(),t=we(),n=Ie(),o=je(),{setImmediate:i}=be();function a(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}return p=class{constructor({createMessageDigest:n=null,messageDigestAlgorithm:o="sha256",canonicalIdMap:r=new Map,maxWorkFactor:i=1,maxDeepIterations:a=-1,signal:s=null}={}){this.name="RDFC-1.0",this.blankNodeInfo=new Map,this.canonicalIssuer=new e("c14n",r),this.createMessageDigest=n||(()=>new t(o)),this.maxWorkFactor=i,this.maxDeepIterations=a,this.remainingDeepIterations=0,this.signal=s,this.quads=null}async main(t){this.quads=t;for(const e of t)this._addBlankNodeQuadInfo({quad:e,component:e.subject}),this._addBlankNodeQuadInfo({quad:e,component:e.object}),this._addBlankNodeQuadInfo({quad:e,component:e.graph});const n=new Map,r=[...this.blankNodeInfo.keys()];let i=0;for(const e of r)++i%100==0&&await this._yield(),await this._hashAndTrackBlankNode({id:e,hashToBlankNodes:n});const s=[...n.keys()].sort(),l=[];for(const e of s){const t=n.get(e);if(t.length>1){l.push(t);continue}const o=t[0];this.canonicalIssuer.getId(o)}if(this.maxDeepIterations<0)if(0===this.maxWorkFactor)this.maxDeepIterations=0;else if(this.maxWorkFactor===1/0)this.maxDeepIterations=1/0;else{const e=l.reduce((e,t)=>e+t.length,0);this.maxDeepIterations=e**this.maxWorkFactor}this.maxDeepIterations>Number.MAX_SAFE_INTEGER&&(this.maxDeepIterations=1/0),this.remainingDeepIterations=this.maxDeepIterations;for(const t of l){const n=[];for(const o of t){if(this.canonicalIssuer.hasId(o))continue;const t=new e("b");t.getId(o);const r=await this.hashNDegreeQuads(o,t);n.push(r)}n.sort(a);for(const e of n){const t=e.issuer.getOldIds();for(const e of t)this.canonicalIssuer.getId(e)}}const c=[];for(const e of this.quads){const t=o.serializeQuadComponents(this._componentWithCanonicalId(e.subject),e.predicate,this._componentWithCanonicalId(e.object),this._componentWithCanonicalId(e.graph));c.push(t)}return c.sort(),c.join("")}async hashFirstDegreeQuads(e){const t=[],n=this.blankNodeInfo.get(e),r=n.quads;for(const n of r)t.push(o.serializeQuadComponents(this.modifyFirstDegreeComponent(e,n.subject,"subject"),n.predicate,this.modifyFirstDegreeComponent(e,n.object,"object"),this.modifyFirstDegreeComponent(e,n.graph,"graph")));t.sort();const i=this.createMessageDigest();for(const e of t)i.update(e);return n.hash=await i.digest(),n.hash}async hashRelatedBlankNode(e,t,n,o){const r=this.createMessageDigest();let i;return r.update(o),"g"!==o&&r.update(this.getRelatedPredicate(t)),i=this.canonicalIssuer.hasId(e)?"_:"+this.canonicalIssuer.getId(e):n.hasId(e)?"_:"+n.getId(e):this.blankNodeInfo.get(e).hash,r.update(i),r.digest()}async hashNDegreeQuads(e,t){if(0===this.remainingDeepIterations)throw new Error(`Maximum deep iterations exceeded (${this.maxDeepIterations}).`);this.remainingDeepIterations--;const o=this.createMessageDigest(),r=await this.createHashToRelated(e,t),i=[...r.keys()].sort();for(const e of i){o.update(e);let i,a="";const s=new n(r.get(e));let l=0;for(;s.hasNext();){const e=s.next();if(++l%3==0){if(this.signal&&this.signal.aborted)throw new Error(`Abort signal received: "${this.signal.reason}".`);await this._yield()}let n=t.clone(),o="";const r=[];let c=!1;for(const t of e)if(this.canonicalIssuer.hasId(t)?o+="_:"+this.canonicalIssuer.getId(t):(n.hasId(t)||r.push(t),o+="_:"+n.getId(t)),0!==a.length&&o>a){c=!0;break}if(!c){for(const e of r){const t=await this.hashNDegreeQuads(e,n);if(o+="_:"+n.getId(e),o+=`<${t.hash}>`,n=t.issuer,0!==a.length&&o>a){c=!0;break}}c||(0===a.length||o<a)&&(a=o,i=n)}}o.update(a),t=i}return{hash:await o.digest(),issuer:t}}modifyFirstDegreeComponent(e,t){return"BlankNode"!==t.termType?t:{termType:"BlankNode",value:t.value===e?"a":"z"}}getRelatedPredicate(e){return`<${e.predicate.value}>`}async createHashToRelated(e,t){const n=new Map,o=this.blankNodeInfo.get(e).quads;let r=0;for(const i of o)++r%100==0&&await this._yield(),await Promise.all([this._addRelatedBlankNodeHash({quad:i,component:i.subject,position:"s",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:i,component:i.object,position:"o",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:i,component:i.graph,position:"g",id:e,issuer:t,hashToRelated:n})]);return n}async _hashAndTrackBlankNode({id:e,hashToBlankNodes:t}){const n=await this.hashFirstDegreeQuads(e),o=t.get(n);o?o.push(e):t.set(n,[e])}_addBlankNodeQuadInfo({quad:e,component:t}){if("BlankNode"!==t.termType)return;const n=t.value,o=this.blankNodeInfo.get(n);o?o.quads.add(e):this.blankNodeInfo.set(n,{quads:new Set([e]),hash:null})}async _addRelatedBlankNodeHash({quad:e,component:t,position:n,id:o,issuer:r,hashToRelated:i}){if("BlankNode"!==t.termType||t.value===o)return;const a=t.value,s=await this.hashRelatedBlankNode(a,e,r,n),l=i.get(s);l?l.push(a):i.set(s,[a])}_componentWithCanonicalId(e){return"BlankNode"!==e.termType||e.value.startsWith(this.canonicalIssuer.prefix)?e:{termType:"BlankNode",value:this.canonicalIssuer.getId(e.value)}}async _yield(){return new Promise(e=>i(e))}}}
17
- /*!
18
- * Copyright (c) 2016-2023 Digital Bazaar, Inc. All rights reserved.
19
- */(),n=function(){if(v)return h;v=1;const e=r(),t=we(),n=Ie(),o=je();function i(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}return h=class{constructor({createMessageDigest:n=null,messageDigestAlgorithm:o="sha256",canonicalIdMap:r=new Map,maxWorkFactor:i=1,maxDeepIterations:a=-1,timeout:s=0}={}){this.name="RDFC-1.0",this.blankNodeInfo=new Map,this.canonicalIssuer=new e("c14n",r),this.createMessageDigest=n||(()=>new t(o)),this.maxWorkFactor=i,this.maxDeepIterations=a,this.remainingDeepIterations=0,this.timeout=s,s>0&&(this.startTime=Date.now()),this.quads=null}main(t){this.quads=t;for(const e of t)this._addBlankNodeQuadInfo({quad:e,component:e.subject}),this._addBlankNodeQuadInfo({quad:e,component:e.object}),this._addBlankNodeQuadInfo({quad:e,component:e.graph});const n=new Map,r=[...this.blankNodeInfo.keys()];for(const e of r)this._hashAndTrackBlankNode({id:e,hashToBlankNodes:n});const a=[...n.keys()].sort(),s=[];for(const e of a){const t=n.get(e);if(t.length>1){s.push(t);continue}const o=t[0];this.canonicalIssuer.getId(o)}if(this.maxDeepIterations<0)if(0===this.maxWorkFactor)this.maxDeepIterations=0;else if(this.maxWorkFactor===1/0)this.maxDeepIterations=1/0;else{const e=s.reduce((e,t)=>e+t.length,0);this.maxDeepIterations=e**this.maxWorkFactor}this.maxDeepIterations>Number.MAX_SAFE_INTEGER&&(this.maxDeepIterations=1/0),this.remainingDeepIterations=this.maxDeepIterations;for(const t of s){const n=[];for(const o of t){if(this.canonicalIssuer.hasId(o))continue;const t=new e("b");t.getId(o);const r=this.hashNDegreeQuads(o,t);n.push(r)}n.sort(i);for(const e of n){const t=e.issuer.getOldIds();for(const e of t)this.canonicalIssuer.getId(e)}}const l=[];for(const e of this.quads){const t=o.serializeQuadComponents(this._componentWithCanonicalId(e.subject),e.predicate,this._componentWithCanonicalId(e.object),this._componentWithCanonicalId(e.graph));l.push(t)}return l.sort(),l.join("")}hashFirstDegreeQuads(e){const t=[],n=this.blankNodeInfo.get(e),r=n.quads;for(const n of r)t.push(o.serializeQuadComponents(this.modifyFirstDegreeComponent(e,n.subject,"subject"),n.predicate,this.modifyFirstDegreeComponent(e,n.object,"object"),this.modifyFirstDegreeComponent(e,n.graph,"graph")));t.sort();const i=this.createMessageDigest();for(const e of t)i.update(e);return n.hash=i.digest(),n.hash}hashRelatedBlankNode(e,t,n,o){const r=this.createMessageDigest();let i;return r.update(o),"g"!==o&&r.update(this.getRelatedPredicate(t)),i=this.canonicalIssuer.hasId(e)?"_:"+this.canonicalIssuer.getId(e):n.hasId(e)?"_:"+n.getId(e):this.blankNodeInfo.get(e).hash,r.update(i),r.digest()}hashNDegreeQuads(e,t){if(0===this.remainingDeepIterations)throw new Error(`Maximum deep iterations exceeded (${this.maxDeepIterations}).`);this.remainingDeepIterations--;const o=this.createMessageDigest(),r=this.createHashToRelated(e,t),i=[...r.keys()].sort();for(const e of i){o.update(e);let i,a="";const s=new n(r.get(e));let l=0;for(;s.hasNext();){const e=s.next();if(++l%3==0&&this.timeout>0&&Date.now()-this.startTime>this.timeout)throw new Error("Canonize timeout.");let n=t.clone(),o="";const r=[];let c=!1;for(const t of e)if(this.canonicalIssuer.hasId(t)?o+="_:"+this.canonicalIssuer.getId(t):(n.hasId(t)||r.push(t),o+="_:"+n.getId(t)),0!==a.length&&o>a){c=!0;break}if(!c){for(const e of r){const t=this.hashNDegreeQuads(e,n);if(o+="_:"+n.getId(e),o+=`<${t.hash}>`,n=t.issuer,0!==a.length&&o>a){c=!0;break}}c||(0===a.length||o<a)&&(a=o,i=n)}}o.update(a),t=i}return{hash:o.digest(),issuer:t}}modifyFirstDegreeComponent(e,t){return"BlankNode"!==t.termType?t:{termType:"BlankNode",value:t.value===e?"a":"z"}}getRelatedPredicate(e){return`<${e.predicate.value}>`}createHashToRelated(e,t){const n=new Map,o=this.blankNodeInfo.get(e).quads;for(const r of o)this._addRelatedBlankNodeHash({quad:r,component:r.subject,position:"s",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:r,component:r.object,position:"o",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:r,component:r.graph,position:"g",id:e,issuer:t,hashToRelated:n});return n}_hashAndTrackBlankNode({id:e,hashToBlankNodes:t}){const n=this.hashFirstDegreeQuads(e),o=t.get(n);o?o.push(e):t.set(n,[e])}_addBlankNodeQuadInfo({quad:e,component:t}){if("BlankNode"!==t.termType)return;const n=t.value,o=this.blankNodeInfo.get(n);o?o.quads.add(e):this.blankNodeInfo.set(n,{quads:new Set([e]),hash:null})}_addRelatedBlankNodeHash({quad:e,component:t,position:n,id:o,issuer:r,hashToRelated:i}){if("BlankNode"!==t.termType||t.value===o)return;const a=t.value,s=this.hashRelatedBlankNode(a,e,r,n),l=i.get(s);l?l.push(a):i.set(s,[a])}_componentWithCanonicalId(e){return"BlankNode"!==e.termType||e.value.startsWith(this.canonicalIssuer.prefix)?e:{termType:"BlankNode",value:this.canonicalIssuer.getId(e.value)}}}}();function o(t,n){if(n.inputFormat){if("application/n-quads"===n.inputFormat){if("string"!=typeof t)throw new Error("N-Quads input must be a string.");return e.NQuads.parse(t)}throw new Error(`Unknown canonicalization input format: "${n.inputFormat}".`)}return t}function i(e){if(e.format&&"application/n-quads"!==e.format)throw new Error(`Unknown canonicalization output format: "${e.format}".`)}function a(){globalThis.RDF_CANONIZE_TRACE_URDNA2015&&console.trace("[rdf-canonize] URDNA2015 is deprecated, use RDFC-1.0")}e.NQuads=je(),e.IdentifierIssuer=r(),e.canonize=async function(e,n={}){const r=o(e,n);if(i(n),!("algorithm"in n))throw new Error("No RDF Dataset Canonicalization algorithm specified.");if("RDFC-1.0"===n.algorithm)return new t(n).main(r);if("URDNA2015"===n.algorithm&&!n.rejectURDNA2015)return a(),new t(n).main(r);throw new Error("Invalid RDF Dataset Canonicalization algorithm: "+n.algorithm)},e._canonizeSync=function(e,t={}){const r=o(e,t);if(i(t),!("algorithm"in t))throw new Error("No RDF Dataset Canonicalization algorithm specified.");if("RDFC-1.0"===t.algorithm)return new n(t).main(r);if("URDNA2015"===t.algorithm&&!t.rejectURDNA2015)return a(),new n(t).main(r);throw new Error("Invalid RDF Dataset Canonicalization algorithm: "+t.algorithm)}}(o)),o}function De(){return m?y:(m=1,y=Se())}function Ne(){if(b)return x;b=1;const e={};return x=e,e.isArray=Array.isArray,e.isBoolean=e=>"boolean"==typeof e||"[object Boolean]"===Object.prototype.toString.call(e),e.isDouble=t=>e.isNumber(t)&&(-1!==String(t).indexOf(".")||Math.abs(t)>=1e21),e.isEmptyObject=t=>e.isObject(t)&&0===Object.keys(t).length,e.isNumber=e=>"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e),e.isNumeric=e=>!isNaN(parseFloat(e))&&isFinite(e),e.isObject=e=>"[object Object]"===Object.prototype.toString.call(e),e.isString=e=>"string"==typeof e||"[object String]"===Object.prototype.toString.call(e),e.isUndefined=e=>void 0===e,x}function Oe(){if(I)return w;I=1;const e=Ne(),t={};return w=t,t.isSubject=t=>{if(e.isObject(t)&&!("@value"in t||"@set"in t||"@list"in t)){return Object.keys(t).length>1||!("@id"in t)}return!1},t.isSubjectReference=t=>e.isObject(t)&&1===Object.keys(t).length&&"@id"in t,t.isValue=t=>e.isObject(t)&&"@value"in t,t.isList=t=>e.isObject(t)&&"@list"in t,t.isGraph=t=>e.isObject(t)&&"@graph"in t&&1===Object.keys(t).filter(e=>"@id"!==e&&"@index"!==e).length,t.isSimpleGraph=e=>t.isGraph(e)&&!("@id"in e),t.isBlankNode=t=>{if(e.isObject(t)){if("@id"in t){const n=t["@id"];return!e.isString(n)||0===n.indexOf("_:")}return 0===Object.keys(t).length||!("@value"in t||"@set"in t||"@list"in t)}return!1},w}function Ee(){return S?j:(S=1,j=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}})}function Ce(){if(N)return D;N=1;const e=Oe(),t=Ne(),n=De().IdentifierIssuer,o=Ee(),r=/(?:<[^>]*?>|"[^"]*?"|[^,])+/g,i=/\s*<([^>]*?)>\s*(?:;\s*(.*))?/,a=/(.*?)=(?:(?:"([^"]*?)")|([^"]*?))\s*(?:(?:;\s*)|$)/g,s={accept:"application/ld+json, application/json"},l={};function c(n,o){if(t.isArray(o))for(let e=0;e<o.length;++e)o[e]=c(n,o[e]);else if(e.isList(o))o["@list"]=c(n,o["@list"]);else if(t.isObject(o)){e.isBlankNode(o)&&(o["@id"]=n.getId(o["@id"]));const t=Object.keys(o).sort();for(let e=0;e<t.length;++e){const r=t[e];"@id"!==r&&(o[r]=c(n,o[r]))}}return o}return D=l,l.IdentifierIssuer=n,l.REGEX_BCP47=/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/,l.REGEX_KEYWORD=/^@[a-zA-Z]+$/,l.clone=function(e){if(e&&"object"==typeof e){let n;if(t.isArray(e)){n=[];for(let t=0;t<e.length;++t)n[t]=l.clone(e[t])}else if(e instanceof Map){n=new Map;for(const[t,o]of e)n.set(t,l.clone(o))}else if(e instanceof Set){n=new Set;for(const t of e)n.add(l.clone(t))}else if(t.isObject(e)){n={};for(const t in e)n[t]=l.clone(e[t])}else n=e.toString();return n}return e},l.asArray=function(e){return Array.isArray(e)?e:[e]},l.buildHeaders=(e={})=>{if(Object.keys(e).some(e=>"accept"===e.toLowerCase()))throw new RangeError('Accept header may not be specified; only "'+s.accept+'" is supported.');return Object.assign({Accept:s.accept},e)},l.parseLinkHeader=e=>{const t={},n=e.match(r);for(let e=0;e<n.length;++e){let o=n[e].match(i);if(!o)continue;const r={target:o[1]},s=o[2];for(;o=a.exec(s);)r[o[1]]=void 0===o[2]?o[3]:o[2];const l=r.rel||"";Array.isArray(t[l])?t[l].push(r):t.hasOwnProperty(l)?t[l]=[t[l],r]:t[l]=r}return t},l.validateTypeValue=(e,n)=>{if(!(t.isString(e)||t.isArray(e)&&e.every(e=>t.isString(e)))){if(n&&t.isObject(e))switch(Object.keys(e).length){case 0:return;case 1:if("@default"in e&&l.asArray(e["@default"]).every(e=>t.isString(e)))return}throw new o('Invalid JSON-LD syntax; "@type" value must a string, an array of strings, an empty object, or a default object.',"jsonld.SyntaxError",{code:"invalid type value",value:e})}},l.hasProperty=(e,n)=>{if(e.hasOwnProperty(n)){const o=e[n];return!t.isArray(o)||o.length>0}return!1},l.hasValue=(n,o,r)=>{if(l.hasProperty(n,o)){let i=n[o];const a=e.isList(i);if(t.isArray(i)||a){a&&(i=i["@list"]);for(let e=0;e<i.length;++e)if(l.compareValues(r,i[e]))return!0}else if(!t.isArray(r))return l.compareValues(r,i)}return!1},l.addValue=(e,n,o,r)=>{if("propertyIsArray"in(r=r||{})||(r.propertyIsArray=!1),"valueIsArray"in r||(r.valueIsArray=!1),"allowDuplicate"in r||(r.allowDuplicate=!0),"prependValue"in r||(r.prependValue=!1),r.valueIsArray)e[n]=o;else if(t.isArray(o)){0===o.length&&r.propertyIsArray&&!e.hasOwnProperty(n)&&(e[n]=[]),r.prependValue&&(o=o.concat(e[n]),e[n]=[]);for(let t=0;t<o.length;++t)l.addValue(e,n,o[t],r)}else if(e.hasOwnProperty(n)){const i=!r.allowDuplicate&&l.hasValue(e,n,o);t.isArray(e[n])||i&&!r.propertyIsArray||(e[n]=[e[n]]),i||(r.prependValue?e[n].unshift(o):e[n].push(o))}else e[n]=r.propertyIsArray?[o]:o},l.getValues=(e,t)=>[].concat(e[t]||[]),l.removeProperty=(e,t)=>{delete e[t]},l.removeValue=(e,t,n,o)=>{"propertyIsArray"in(o=o||{})||(o.propertyIsArray=!1);const r=l.getValues(e,t).filter(e=>!l.compareValues(e,n));0===r.length?l.removeProperty(e,t):1!==r.length||o.propertyIsArray?e[t]=r:e[t]=r[0]},l.relabelBlankNodes=(e,t)=>c((t=t||{}).issuer||new n("_:b"),e),l.compareValues=(n,o)=>n===o||(!(!e.isValue(n)||!e.isValue(o)||n["@value"]!==o["@value"]||n["@type"]!==o["@type"]||n["@language"]!==o["@language"]||n["@index"]!==o["@index"])||!!(t.isObject(n)&&"@id"in n&&t.isObject(o)&&"@id"in o)&&n["@id"]===o["@id"]),l.compareShortestLeast=(e,t)=>e.length<t.length?-1:t.length<e.length?1:e===t?0:e<t?-1:1,D}function ke(){if(E)return O;E=1;const e="http://www.w3.org/1999/02/22-rdf-syntax-ns#",t="http://www.w3.org/2001/XMLSchema#";return O={LINK_HEADER_REL:"http://www.w3.org/ns/json-ld#context",LINK_HEADER_CONTEXT:"http://www.w3.org/ns/json-ld#context",RDF:e,RDF_LIST:e+"List",RDF_FIRST:e+"first",RDF_REST:e+"rest",RDF_NIL:e+"nil",RDF_TYPE:e+"type",RDF_PLAIN_LITERAL:e+"PlainLiteral",RDF_XML_LITERAL:e+"XMLLiteral",RDF_JSON_LITERAL:e+"JSON",RDF_OBJECT:e+"object",RDF_LANGSTRING:e+"langString",XSD:t,XSD_BOOLEAN:t+"boolean",XSD_DOUBLE:t+"double",XSD_INTEGER:t+"integer",XSD_STRING:t+"string"}}function Le(){return k||(k=1,C=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]}}}),C}function Ae(){if(A)return L;A=1;const e=Ne(),t={};L=t,t.parsers={simple:{keys:["href","scheme","authority","path","query","fragment"],regex:/^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/},full:{keys:["href","protocol","scheme","authority","auth","user","password","hostname","port","path","directory","file","query","fragment"],regex:/^(([a-zA-Z][a-zA-Z0-9+-.]*):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?(?:(((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/}},t.parse=(e,n)=>{const o={},r=t.parsers[n||"full"],i=r.regex.exec(e);let a=r.keys.length;for(;a--;)o[r.keys[a]]=void 0===i[a]?null:i[a];return("https"===o.scheme&&"443"===o.port||"http"===o.scheme&&"80"===o.port)&&(o.href=o.href.replace(":"+o.port,""),o.authority=o.authority.replace(":"+o.port,""),o.port=null),o.normalizedPath=t.removeDotSegments(o.path),o},t.prependBase=(n,o)=>{if(null===n)return o;if(t.isAbsolute(o))return o;n&&!e.isString(n)||(n=t.parse(n||""));const r=t.parse(o),i={protocol:n.protocol||""};if(null!==r.authority)i.authority=r.authority,i.path=r.path,i.query=r.query;else if(i.authority=n.authority,""===r.path)i.path=n.path,null!==r.query?i.query=r.query:i.query=n.query;else{if(0===r.path.indexOf("/"))i.path=r.path;else{let e=n.path;e=e.substr(0,e.lastIndexOf("/")+1),(e.length>0||n.authority)&&"/"!==e.substr(-1)&&(e+="/"),e+=r.path,i.path=e}i.query=r.query}""!==r.path&&(i.path=t.removeDotSegments(i.path));let a=i.protocol;return null!==i.authority&&(a+="//"+i.authority),a+=i.path,null!==i.query&&(a+="?"+i.query),null!==r.fragment&&(a+="#"+r.fragment),""===a&&(a="./"),a},t.removeBase=(n,o)=>{if(null===n)return o;n&&!e.isString(n)||(n=t.parse(n||""));let r="";if(""!==n.href?r+=(n.protocol||"")+"//"+(n.authority||""):o.indexOf("//")&&(r+="//"),0!==o.indexOf(r))return o;const i=t.parse(o.substr(r.length)),a=n.normalizedPath.split("/"),s=i.normalizedPath.split("/"),l=i.fragment||i.query?0:1;for(;a.length>0&&s.length>l&&a[0]===s[0];)a.shift(),s.shift();let c="";if(a.length>0){a.pop();for(let e=0;e<a.length;++e)c+="../"}return c+=s.join("/"),null!==i.query&&(c+="?"+i.query),null!==i.fragment&&(c+="#"+i.fragment),""===c&&(c="./"),c},t.removeDotSegments=e=>{if(0===e.length)return"";const t=e.split("/"),n=[];for(;t.length>0;){const e=t.shift(),o=0===t.length;"."!==e?".."!==e?n.push(e):(n.pop(),o&&n.push("")):o&&n.push("")}return"/"===e[0]&&n.length>0&&""!==n[0]&&n.unshift(""),1===n.length&&""===n[0]?"/":n.join("/")};const n=/^([A-Za-z][A-Za-z0-9+-.]*|_):[^\s]*$/;return t.isAbsolute=t=>e.isString(t)&&n.test(t),t.isRelative=t=>e.isString(t),L}function Re(){if(T)return R;T=1;const{parseLinkHeader:e,buildHeaders:t}=Ce(),{LINK_HEADER_CONTEXT:n}=ke(),o=Ee(),r=Le(),{prependBase:i}=Ae(),a=/(^|(\r\n))link:/i;return R=({secure:s,headers:l={},xhr:c}={headers:{}})=>{l=t(l);return(new r).wrapLoader(async function t(r){if(0!==r.indexOf("http:")&&0!==r.indexOf("https:"))throw new o('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:r});if(s&&0!==r.indexOf("https"))throw new o('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:r});let d;try{d=await function(e,t,n){e=e||XMLHttpRequest;const o=new e;return new Promise((e,r)=>{o.onload=()=>e(o),o.onerror=e=>r(e),o.open("GET",t,!0);for(const e in n)o.setRequestHeader(e,n[e]);o.send()})}(c,r,l)}catch(e){throw new o("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:r,cause:e})}if(d.status>=400)throw new o("URL could not be dereferenced: "+d.statusText,"jsonld.LoadDocumentError",{code:"loading document failed",url:r,httpStatusCode:d.status});let u={contextUrl:null,documentUrl:r,document:d.response},p=null;const f=d.getResponseHeader("Content-Type");let h;a.test(d.getAllResponseHeaders())&&(h=d.getResponseHeader("Link"));if(h&&"application/ld+json"!==f){const a=e(h),s=a[n];if(Array.isArray(s))throw new o("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:r});s&&(u.contextUrl=s.target),p=a.alternate,p&&"application/ld+json"==p.type&&!(f||"").match(/^application\/(\w*\+)?json$/)&&(u=await t(i(r,p.target)))}return u})},R}function Te(){if(H)return F;function e(t){var n=this;if(n instanceof e||(n=new e),n.tail=null,n.head=null,n.length=0,t&&"function"==typeof t.forEach)t.forEach(function(e){n.push(e)});else if(arguments.length>0)for(var o=0,r=arguments.length;o<r;o++)n.push(arguments[o]);return n}function t(e,t,n){var o=t===e.head?new r(n,null,t,e):new r(n,t,t.next,e);return null===o.next&&(e.tail=o),null===o.prev&&(e.head=o),e.length++,o}function n(e,t){e.tail=new r(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function o(e,t){e.head=new r(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function r(e,t,n,o){if(!(this instanceof r))return new r(e,t,n,o);this.list=o,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,n?(n.prev=this,this.next=n):this.next=null}H=1,F=e,e.Node=r,e.create=e,e.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,n=e.prev;return t&&(t.prev=n),n&&(n.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=n),e.list.length--,e.next=null,e.prev=null,e.list=null,t},e.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},e.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},e.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)n(this,arguments[e]);return this.length},e.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)o(this,arguments[e]);return this.length},e.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},e.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},e.prototype.forEach=function(e,t){t=t||this;for(var n=this.head,o=0;null!==n;o++)e.call(t,n.value,o,this),n=n.next},e.prototype.forEachReverse=function(e,t){t=t||this;for(var n=this.tail,o=this.length-1;null!==n;o--)e.call(t,n.value,o,this),n=n.prev},e.prototype.get=function(e){for(var t=0,n=this.head;null!==n&&t<e;t++)n=n.next;if(t===e&&null!==n)return n.value},e.prototype.getReverse=function(e){for(var t=0,n=this.tail;null!==n&&t<e;t++)n=n.prev;if(t===e&&null!==n)return n.value},e.prototype.map=function(t,n){n=n||this;for(var o=new e,r=this.head;null!==r;)o.push(t.call(n,r.value,this)),r=r.next;return o},e.prototype.mapReverse=function(t,n){n=n||this;for(var o=new e,r=this.tail;null!==r;)o.push(t.call(n,r.value,this)),r=r.prev;return o},e.prototype.reduce=function(e,t){var n,o=this.head;if(arguments.length>1)n=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");o=this.head.next,n=this.head.value}for(var r=0;null!==o;r++)n=e(n,o.value,r),o=o.next;return n},e.prototype.reduceReverse=function(e,t){var n,o=this.tail;if(arguments.length>1)n=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");o=this.tail.prev,n=this.tail.value}for(var r=this.length-1;null!==o;r--)n=e(n,o.value,r),o=o.prev;return n},e.prototype.toArray=function(){for(var e=new Array(this.length),t=0,n=this.head;null!==n;t++)e[t]=n.value,n=n.next;return e},e.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,n=this.tail;null!==n;t++)e[t]=n.value,n=n.prev;return e},e.prototype.slice=function(t,n){(n=n||this.length)<0&&(n+=this.length),(t=t||0)<0&&(t+=this.length);var o=new e;if(n<t||n<0)return o;t<0&&(t=0),n>this.length&&(n=this.length);for(var r=0,i=this.head;null!==i&&r<t;r++)i=i.next;for(;null!==i&&r<n;r++,i=i.next)o.push(i.value);return o},e.prototype.sliceReverse=function(t,n){(n=n||this.length)<0&&(n+=this.length),(t=t||0)<0&&(t+=this.length);var o=new e;if(n<t||n<0)return o;t<0&&(t=0),n>this.length&&(n=this.length);for(var r=this.length,i=this.tail;null!==i&&r>n;r--)i=i.prev;for(;null!==i&&r>t;r--,i=i.prev)o.push(i.value);return o},e.prototype.splice=function(e,n,...o){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var r=0,i=this.head;null!==i&&r<e;r++)i=i.next;var a=[];for(r=0;i&&r<n;r++)a.push(i.value),i=this.removeNode(i);null===i&&(i=this.tail),i!==this.head&&i!==this.tail&&(i=i.prev);for(r=0;r<o.length;r++)i=t(this,i,o[r]);return a},e.prototype.reverse=function(){for(var e=this.head,t=this.tail,n=e;null!==n;n=n.prev){var o=n.prev;n.prev=n.next,n.next=o}return this.head=t,this.tail=e,this};try{(M?P:(M=1,P=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}))(e)}catch(e){}return F}function _e(){if(q)return B;q=1;const e=Te(),t=Symbol("max"),n=Symbol("length"),o=Symbol("lengthCalculator"),r=Symbol("allowStale"),i=Symbol("maxAge"),a=Symbol("dispose"),s=Symbol("noDisposeOnSet"),l=Symbol("lruList"),c=Symbol("cache"),d=Symbol("updateAgeOnGet"),u=()=>1;const p=(e,t,n)=>{const o=e[c].get(t);if(o){const t=o.value;if(f(e,t)){if(v(e,o),!e[r])return}else n&&(e[d]&&(o.value.now=Date.now()),e[l].unshiftNode(o));return t.value}},f=(e,t)=>{if(!t||!t.maxAge&&!e[i])return!1;const n=Date.now()-t.now;return t.maxAge?n>t.maxAge:e[i]&&n>e[i]},h=e=>{if(e[n]>e[t])for(let o=e[l].tail;e[n]>e[t]&&null!==o;){const t=o.prev;v(e,o),o=t}},v=(e,t)=>{if(t){const o=t.value;e[a]&&e[a](o.key,o.value),e[n]-=o.length,e[c].delete(o.key),e[l].removeNode(t)}};class g{constructor(e,t,n,o,r){this.key=e,this.value=t,this.length=n,this.now=o,this.maxAge=r||0}}const y=(e,t,n,o)=>{let i=n.value;f(e,i)&&(v(e,n),e[r]||(i=void 0)),i&&t.call(o,i.value,i.key,e)};return B=class{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[t]=e.max||1/0;const n=e.length||u;if(this[o]="function"!=typeof n?u:n,this[r]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[i]=e.maxAge||0,this[a]=e.dispose,this[s]=e.noDisposeOnSet||!1,this[d]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[t]=e||1/0,h(this)}get max(){return this[t]}set allowStale(e){this[r]=!!e}get allowStale(){return this[r]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[i]=e,h(this)}get maxAge(){return this[i]}set lengthCalculator(e){"function"!=typeof e&&(e=u),e!==this[o]&&(this[o]=e,this[n]=0,this[l].forEach(e=>{e.length=this[o](e.value,e.key),this[n]+=e.length})),h(this)}get lengthCalculator(){return this[o]}get length(){return this[n]}get itemCount(){return this[l].length}rforEach(e,t){t=t||this;for(let n=this[l].tail;null!==n;){const o=n.prev;y(this,e,n,t),n=o}}forEach(e,t){t=t||this;for(let n=this[l].head;null!==n;){const o=n.next;y(this,e,n,t),n=o}}keys(){return this[l].toArray().map(e=>e.key)}values(){return this[l].toArray().map(e=>e.value)}reset(){this[a]&&this[l]&&this[l].length&&this[l].forEach(e=>this[a](e.key,e.value)),this[c]=new Map,this[l]=new e,this[n]=0}dump(){return this[l].map(e=>!f(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[l]}set(e,r,d){if((d=d||this[i])&&"number"!=typeof d)throw new TypeError("maxAge must be a number");const u=d?Date.now():0,p=this[o](r,e);if(this[c].has(e)){if(p>this[t])return v(this,this[c].get(e)),!1;const o=this[c].get(e).value;return this[a]&&(this[s]||this[a](e,o.value)),o.now=u,o.maxAge=d,o.value=r,this[n]+=p-o.length,o.length=p,this.get(e),h(this),!0}const f=new g(e,r,p,u,d);return f.length>this[t]?(this[a]&&this[a](e,r),!1):(this[n]+=f.length,this[l].unshift(f),this[c].set(e,this[l].head),h(this),!0)}has(e){if(!this[c].has(e))return!1;const t=this[c].get(e).value;return!f(this,t)}get(e){return p(this,e,!0)}peek(e){return p(this,e,!1)}pop(){const e=this[l].tail;return e?(v(this,e),e.value):null}del(e){v(this,this[c].get(e))}load(e){this.reset();const t=Date.now();for(let n=e.length-1;n>=0;n--){const o=e[n],r=o.e||0;if(0===r)this.set(o.k,o.v);else{const e=r-t;e>0&&this.set(o.k,o.v,e)}}}prune(){this[c].forEach((e,t)=>p(this,t,!1))}}}function Je(){if(z)return V;z=1;const{isArray:e,isObject:t,isString:n}=Ne(),{asArray:o}=Ce(),{prependBase:r}=Ae(),i=Ee(),a=function(){if($)return U;$=1;const e=_e();return U=class{constructor({document:t}){this.document=t,this.cache=new e({max:10})}getProcessed(e){return this.cache.get(e)}setProcessed(e,t){this.cache.set(e,t)}}}();function s(e){throw new i("Invalid JSON-LD syntax; @context must be an object.","jsonld.SyntaxError",{code:"invalid local context",context:e})}function l({context:o,base:i}){if(!o)return;const a=o["@context"];if(n(a))o["@context"]=r(i,a);else if(e(a))for(let e=0;e<a.length;++e){const o=a[e];n(o)?a[e]=r(i,o):t(o)&&l({context:{"@context":o},base:i})}else if(t(a))for(const e in a)l({context:a[e],base:i})}return V=class{constructor({sharedCache:e}){this.perOpCache=new Map,this.sharedCache=e}async resolve({activeCtx:r,context:i,documentLoader:l,base:c,cycles:d=new Set}){i&&t(i)&&i["@context"]&&(i=i["@context"]),i=o(i);const u=[];for(const o of i){if(n(o)){let t=this._get(o);t||(t=await this._resolveRemoteContext({activeCtx:r,url:o,documentLoader:l,base:c,cycles:d})),e(t)?u.push(...t):u.push(t);continue}if(null===o){u.push(new a({document:null}));continue}t(o)||s(i);const p=JSON.stringify(o);let f=this._get(p);f||(f=new a({document:o}),this._cacheResolvedContext({key:p,resolved:f,tag:"static"})),u.push(f)}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=r(o,t);const{context:a,remoteDoc:s}=await this._fetchContext({activeCtx:e,url:t,documentLoader:n,cycles:i});l({context:a,base:o=s.documentUrl||t});const c=await this.resolve({activeCtx:e,context:a,documentLoader:n,base:o,cycles:i});return this._cacheResolvedContext({key:t,resolved:c,tag:s.tag}),c}async _fetchContext({activeCtx:o,url:r,documentLoader:a,cycles:s}){if(s.size>10)throw new i("Maximum number of @context URLs exceeded.","jsonld.ContextUrlError",{code:"json-ld-1.0"===o.processingMode?"loading remote context failed":"context overflow",max:10});if(s.has(r))throw new i("Cyclical @context URLs detected.","jsonld.ContextUrlError",{code:"json-ld-1.0"===o.processingMode?"recursive context inclusion":"context overflow",url:r});let l,c;s.add(r);try{c=await a(r),l=c.document||null,n(l)&&(l=JSON.parse(l))}catch(e){throw new i(`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: "${r}".`,"jsonld.InvalidUrl",{code:"loading remote context failed",url:r,cause:e})}if(!t(l))throw new i(`Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object. URL: "${r}".`,"jsonld.InvalidUrl",{code:"invalid remote context",url:r});return l="@context"in l?{"@context":l["@context"]}:{"@context":{}},c.contextUrl&&(e(l["@context"])||(l["@context"]=[l["@context"]]),l["@context"].push(c.contextUrl)),{context:l,remoteDoc:c}}},V}function Pe(){return Q?G:(Q=1,G=De().NQuads)}function Me(){if(X)return W;X=1;const e=Ee(),{isArray:t}=Ne(),{asArray:n}=Ce(),o={};function r({event:n,handlers:o}){let i=!0;for(let a=0;i&&a<o.length;++a){i=!1;const s=o[a];if(t(s))i=r({event:n,handlers:s});else if("function"==typeof s)s({event:n,next:()=>{i=!0}});else{if("object"!=typeof s)throw new e("Invalid event handler.","jsonld.InvalidEventHandler",{event:n});n.code in s?s[n.code]({event:n,next:()=>{i=!0}}):i=!0}}return i}W=o,o.defaultEventHandler=null,o.setupEventHandler=({options:e={}})=>{const t=[].concat(e.safe?o.safeEventHandler:[],e.eventHandler?n(e.eventHandler):[],o.defaultEventHandler?o.defaultEventHandler:[]);return 0===t.length?null:t},o.handleEvent=({event:e,options:t})=>{r({event:e,handlers:t.eventHandler})};const i=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"]);return o.safeEventHandler=function({event:t,next:n}){if("warning"===t.level&&i.has(t.code))throw new e("Safe mode validation error.","jsonld.ValidationError",{event:t});n()},o.logEventHandler=function({event:e,next:t}){console.log(`EVENT: ${e.message}`,{event:e}),t()},o.logWarningEventHandler=function({event:e,next:t}){"warning"===e.level&&console.warn(`WARNING: ${e.message}`,{event:e}),t()},o.unhandledEventHandler=function({event:t}){throw new e("No handler for event.","jsonld.UnhandledEvent",{event:t})},o.setDefaultEventHandler=function({eventHandler:e}={}){o.defaultEventHandler=e?n(e):null},W}function Fe(){if(Z)return K;Z=1;const e=Ce(),t=Ee(),{isArray:n,isObject:o,isString:r,isUndefined:i}=Ne(),{isAbsolute:a,isRelative:s,prependBase:l}=Ae(),{handleEvent:c}=Me(),{REGEX_BCP47:d,REGEX_KEYWORD:u,asArray:p,compareShortestLeast:f}=Ce(),h=new Map,v={};function g(e,t,n,i,s,c){if(null===t||!r(t)||v.isKeyword(t))return t;if(t.match(u))return null;if(i&&i.hasOwnProperty(t)&&!0!==s.get(t)&&v.createTermDefinition({activeCtx:e,localCtx:i,term:t,defined:s,options:c}),(n=n||{}).vocab){const n=e.mappings.get(t);if(null===n)return null;if(o(n)&&"@id"in n)return n["@id"]}const d=t.indexOf(":");if(d>0){const n=t.substr(0,d),o=t.substr(d+1);if("_"===n||0===o.indexOf("//"))return t;i&&i.hasOwnProperty(n)&&v.createTermDefinition({activeCtx:e,localCtx:i,term:n,defined:s,options:c});const r=e.mappings.get(n);if(r&&r._prefix)return r["@id"]+o;if(a(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=l(c.base,e["@base"]),n=l(o,t)):(o=e["@base"],n=t):(o=c.base,n=l(c.base,t)),t=n}return t}function y(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(!y(e[n],t[n]))return!1;return!0}const o=Object.keys(e),r=Object.keys(t);if(o.length!==r.length)return!1;for(const n in e){let o=e[n],r=t[n];if("@container"===n&&Array.isArray(o)&&Array.isArray(r)&&(o=o.slice().sort(),r=r.slice().sort()),!y(o,r))return!1}return!0}return K=v,v.process=async({activeCtx:e,localCtx:i,options:u,propagate:f=!0,overrideProtected:h=!1,cycles:y=new Set})=>{o(i)&&"@context"in i&&n(i["@context"])&&(i=i["@context"]);if(0===p(i).length)return e;const m=[],x=[({event:e,next:t})=>{m.push(e),t()}];u.eventHandler&&x.push(u.eventHandler);const b=u;u={...u,eventHandler:x};const w=await u.contextResolver.resolve({activeCtx:e,context:i,documentLoader:u.documentLoader,base:u.base});o(w[0].document)&&"boolean"==typeof w[0].document["@propagate"]&&(f=w[0].document["@propagate"]);let I=e;f||I.previousContext||(I=I.clone(),I.previousContext=e);for(const n of w){let{document:p}=n;if(e=I,null===p){if(!h&&0!==Object.keys(e.protected).length)throw new t("Tried to nullify a context with protected terms outside of a term definition.","jsonld.SyntaxError",{code:"invalid context nullification"});I=e=v.getInitialContext(u).clone();continue}const f=n.getProcessed(e);if(f){if(b.eventHandler)for(const e of f.events)c({event:e,options:b});I=e=f.context;continue}if(o(p)&&"@context"in p&&(p=p["@context"]),!o(p))throw new t("Invalid JSON-LD syntax; @context must be an object.","jsonld.SyntaxError",{code:"invalid local context",context:p});I=I.clone();const x=new Map;if("@version"in p){if(1.1!==p["@version"])throw new t("Unsupported JSON-LD version: "+p["@version"],"jsonld.UnsupportedVersion",{code:"invalid @version value",context:p});if(e.processingMode&&"json-ld-1.0"===e.processingMode)throw new t("@version: "+p["@version"]+" not compatible with "+e.processingMode,"jsonld.ProcessingModeConflict",{code:"processing mode conflict",context:p});I.processingMode="json-ld-1.1",I["@version"]=p["@version"],x.set("@version",!0)}if(I.processingMode=I.processingMode||e.processingMode,"@base"in p){let e=p["@base"];if(null===e||a(e));else{if(!s(e))throw new t('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:p});e=l(I["@base"],e)}I["@base"]=e,x.set("@base",!0)}if("@vocab"in p){const e=p["@vocab"];if(null===e)delete I["@vocab"];else{if(!r(e))throw new t('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:p});if(!a(e)&&v.processingMode(I,1))throw new t('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be an absolute IRI.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:p});{const t=g(I,e,{vocab:!0,base:!0},void 0,void 0,u);a(t)||u.eventHandler&&c({event:{type:["JsonLdEvent"],code:"relative @vocab reference",level:"warning",message:"Relative @vocab reference found.",details:{vocab:t}},options:u}),I["@vocab"]=t}}x.set("@vocab",!0)}if("@language"in p){const e=p["@language"];if(null===e)delete I["@language"];else{if(!r(e))throw new t('Invalid JSON-LD syntax; the value of "@language" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid default language",context:p});e.match(d)||u.eventHandler&&c({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:u}),I["@language"]=e.toLowerCase()}x.set("@language",!0)}if("@direction"in p){const n=p["@direction"];if("json-ld-1.0"===e.processingMode)throw new t("Invalid JSON-LD syntax; @direction not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context member",context:p});if(null===n)delete I["@direction"];else{if("ltr"!==n&&"rtl"!==n)throw new t('Invalid JSON-LD syntax; the value of "@direction" in a @context must be null, "ltr", or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",context:p});I["@direction"]=n}x.set("@direction",!0)}if("@propagate"in p){const n=p["@propagate"];if("json-ld-1.0"===e.processingMode)throw new t("Invalid JSON-LD syntax; @propagate not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context entry",context:p});if("boolean"!=typeof n)throw new t("Invalid JSON-LD syntax; @propagate value must be a boolean.","jsonld.SyntaxError",{code:"invalid @propagate value",context:i});x.set("@propagate",!0)}if("@import"in p){const n=p["@import"];if("json-ld-1.0"===e.processingMode)throw new t("Invalid JSON-LD syntax; @import not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context entry",context:p});if(!r(n))throw new t("Invalid JSON-LD syntax; @import must be a string.","jsonld.SyntaxError",{code:"invalid @import value",context:i});const o=await u.contextResolver.resolve({activeCtx:e,context:n,documentLoader:u.documentLoader,base:u.base});if(1!==o.length)throw new t("Invalid JSON-LD syntax; @import must reference a single context.","jsonld.SyntaxError",{code:"invalid remote context",context:i});const a=o[0].getProcessed(e);if(a)p=a;else{const n=o[0].document;if("@import"in n)throw new t("Invalid JSON-LD syntax: imported context must not include @import.","jsonld.SyntaxError",{code:"invalid context entry",context:i});for(const e in n)p.hasOwnProperty(e)||(p[e]=n[e]);o[0].setProcessed(e,p)}x.set("@import",!0)}x.set("@protected",p["@protected"]||!1);for(const e in p)if(v.createTermDefinition({activeCtx:I,localCtx:p,term:e,defined:x,options:u,overrideProtected:h}),o(p[e])&&"@context"in p[e]){const n=p[e]["@context"];let o=!0;if(r(n)){const e=l(u.base,n);y.has(e)?o=!1:y.add(e)}if(o)try{await v.process({activeCtx:I.clone(),localCtx:p[e]["@context"],overrideProtected:!0,options:u,cycles:y})}catch(n){throw new t("Invalid JSON-LD syntax; invalid scoped context.","jsonld.SyntaxError",{code:"invalid scoped context",context:p[e]["@context"],term:e})}}n.setProcessed(e,{context:I,events:m})}return I},v.createTermDefinition=({activeCtx:e,localCtx:i,term:s,defined:l,options:d,overrideProtected:p=!1})=>{if(l.has(s)){if(l.get(s))return;throw new t("Cyclical context definition detected.","jsonld.CyclicalContext",{code:"cyclic IRI mapping",context:i,term:s})}let f;if(l.set(s,!1),i.hasOwnProperty(s)&&(f=i[s]),"@type"===s&&o(f)&&"@set"===(f["@container"]||"@set")&&v.processingMode(e,1.1)){const e=["@container","@id","@protected"],n=Object.keys(f);if(0===n.length||n.some(t=>!e.includes(t)))throw new t("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:i,term:s})}else{if(v.isKeyword(s))throw new t("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:i,term:s});if(s.match(u))return void(d.eventHandler&&c({event:{type:["JsonLdEvent"],code:"reserved term",level:"warning",message:'Terms beginning with "@" are reserved for future use and dropped.',details:{term:s}},options:d}));if(""===s)throw new t("Invalid JSON-LD syntax; a term cannot be an empty string.","jsonld.SyntaxError",{code:"invalid term definition",context:i})}const h=e.mappings.get(s);e.mappings.has(s)&&e.mappings.delete(s);let m=!1;if((r(f)||null===f)&&(m=!0,f={"@id":f}),!o(f))throw new t("Invalid JSON-LD syntax; @context term values must be strings or objects.","jsonld.SyntaxError",{code:"invalid term definition",context:i});const x={};e.mappings.set(s,x),x.reverse=!1;const b=["@container","@id","@language","@reverse","@type"];v.processingMode(e,1.1)&&b.push("@context","@direction","@index","@nest","@prefix","@protected");for(const e in f)if(!b.includes(e))throw new t("Invalid JSON-LD syntax; a term definition must not contain "+e,"jsonld.SyntaxError",{code:"invalid term definition",context:i});const w=s.indexOf(":");if(x._termHasColon=w>0,"@reverse"in f){if("@id"in f)throw new t("Invalid JSON-LD syntax; a @reverse term definition must not contain @id.","jsonld.SyntaxError",{code:"invalid reverse property",context:i});if("@nest"in f)throw new t("Invalid JSON-LD syntax; a @reverse term definition must not contain @nest.","jsonld.SyntaxError",{code:"invalid reverse property",context:i});const n=f["@reverse"];if(!r(n))throw new t("Invalid JSON-LD syntax; a @context @reverse value must be a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:i});if(n.match(u))return d.eventHandler&&c({event:{type:["JsonLdEvent"],code:"reserved @reverse value",level:"warning",message:'@reverse values beginning with "@" are reserved for future use and dropped.',details:{reverse:n}},options:d}),void(h?e.mappings.set(s,h):e.mappings.delete(s));const o=g(e,n,{vocab:!0,base:!1},i,l,d);if(!a(o))throw new t("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:i});x["@id"]=o,x.reverse=!0}else if("@id"in f){let n=f["@id"];if(n&&!r(n))throw new t("Invalid JSON-LD syntax; a @context @id value must be an array of strings or a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:i});if(null===n)x["@id"]=null;else{if(!v.isKeyword(n)&&n.match(u))return d.eventHandler&&c({event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:'@id values beginning with "@" are reserved for future use and dropped.',details:{id:n}},options:d}),void(h?e.mappings.set(s,h):e.mappings.delete(s));if(n!==s){if(n=g(e,n,{vocab:!0,base:!1},i,l,d),!a(n)&&!v.isKeyword(n))throw new t("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:i});if(s.match(/(?::[^:])|\//)){if(g(e,s,{vocab:!0,base:!1},i,new Map(l).set(s,!0),d)!==n)throw new t("Invalid JSON-LD syntax; term in form of IRI must expand to definition.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:i})}x["@id"]=n,x._prefix=m&&!x._termHasColon&&null!==n.match(/[:\/\?#\[\]@]$/)}}}if(!("@id"in x))if(x._termHasColon){const t=s.substr(0,w);if(i.hasOwnProperty(t)&&v.createTermDefinition({activeCtx:e,localCtx:i,term:t,defined:l,options:d}),e.mappings.has(t)){const n=s.substr(w+1);x["@id"]=e.mappings.get(t)["@id"]+n}else x["@id"]=s}else if("@type"===s)x["@id"]=s;else{if(!("@vocab"in e))throw new t("Invalid JSON-LD syntax; @context terms must define an @id.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:i,term:s});x["@id"]=e["@vocab"]+s}if((!0===f["@protected"]||!0===l.get("@protected")&&!1!==f["@protected"])&&(e.protected[s]=!0,x.protected=!0),l.set(s,!0),"@type"in f){let n=f["@type"];if(!r(n))throw new t("Invalid JSON-LD syntax; an @context @type value must be a string.","jsonld.SyntaxError",{code:"invalid type mapping",context:i});if("@json"===n||"@none"===n){if(v.processingMode(e,1))throw new t(`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:i})}else if("@id"!==n&&"@vocab"!==n){if(n=g(e,n,{vocab:!0,base:!1},i,l,d),!a(n))throw new t("Invalid JSON-LD syntax; an @context @type value must be an absolute IRI.","jsonld.SyntaxError",{code:"invalid type mapping",context:i});if(0===n.indexOf("_:"))throw new t("Invalid JSON-LD syntax; an @context @type value must be an IRI, not a blank node identifier.","jsonld.SyntaxError",{code:"invalid type mapping",context:i})}x["@type"]=n}if("@container"in f){const o=r(f["@container"])?[f["@container"]]:f["@container"]||[],a=["@list","@set","@index","@language"];let s=!0;const l=o.includes("@set");if(v.processingMode(e,1.1)){if(a.push("@graph","@id","@type"),o.includes("@list")){if(1!==o.length)throw new t("Invalid JSON-LD syntax; @context @container with @list must have no other values","jsonld.SyntaxError",{code:"invalid container mapping",context:i})}else if(o.includes("@graph")){if(o.some(e=>"@graph"!==e&&"@id"!==e&&"@index"!==e&&"@set"!==e))throw new t("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:i})}else s&=o.length<=(l?2:1);if(o.includes("@type")&&(x["@type"]=x["@type"]||"@id",!["@id","@vocab"].includes(x["@type"])))throw new t("Invalid JSON-LD syntax; container: @type requires @type to be @id or @vocab.","jsonld.SyntaxError",{code:"invalid type mapping",context:i})}else s&=!n(f["@container"]),s&=o.length<=1;if(s&=o.every(e=>a.includes(e)),s&=!(l&&o.includes("@list")),!s)throw new t("Invalid JSON-LD syntax; @context @container value must be one of the following: "+a.join(", "),"jsonld.SyntaxError",{code:"invalid container mapping",context:i});if(x.reverse&&!o.every(e=>["@index","@set"].includes(e)))throw new t("Invalid JSON-LD syntax; @context @container value for a @reverse type definition must be @index or @set.","jsonld.SyntaxError",{code:"invalid reverse property",context:i});x["@container"]=o}if("@index"in f){if(!("@container"in f)||!x["@container"].includes("@index"))throw new t(`Invalid JSON-LD syntax; @index without @index in @container: "${f["@index"]}" on term "${s}".`,"jsonld.SyntaxError",{code:"invalid term definition",context:i});if(!r(f["@index"])||0===f["@index"].indexOf("@"))throw new t(`Invalid JSON-LD syntax; @index must expand to an IRI: "${f["@index"]}" on term "${s}".`,"jsonld.SyntaxError",{code:"invalid term definition",context:i});x["@index"]=f["@index"]}if("@context"in f&&(x["@context"]=f["@context"]),"@language"in f&&!("@type"in f)){let e=f["@language"];if(null!==e&&!r(e))throw new t("Invalid JSON-LD syntax; @context @language value must be a string or null.","jsonld.SyntaxError",{code:"invalid language mapping",context:i});null!==e&&(e=e.toLowerCase()),x["@language"]=e}if("@prefix"in f){if(s.match(/:|\//))throw new t("Invalid JSON-LD syntax; @context @prefix used on a compact IRI term","jsonld.SyntaxError",{code:"invalid term definition",context:i});if(v.isKeyword(x["@id"]))throw new t("Invalid JSON-LD syntax; keywords may not be used as prefixes","jsonld.SyntaxError",{code:"invalid term definition",context:i});if("boolean"!=typeof f["@prefix"])throw new t("Invalid JSON-LD syntax; @context value for @prefix must be boolean","jsonld.SyntaxError",{code:"invalid @prefix value",context:i});x._prefix=!0===f["@prefix"]}if("@direction"in f){const e=f["@direction"];if(null!==e&&"ltr"!==e&&"rtl"!==e)throw new t('Invalid JSON-LD syntax; @direction value must be null, "ltr", or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",context:i});x["@direction"]=e}if("@nest"in f){const e=f["@nest"];if(!r(e)||"@nest"!==e&&0===e.indexOf("@"))throw new t("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:i});x["@nest"]=e}
20
- // disallow aliasing @context and @preserve
21
- const I=x["@id"];if("@context"===I||"@preserve"===I)throw new t("Invalid JSON-LD syntax; @context and @preserve cannot be aliased.","jsonld.SyntaxError",{code:"invalid keyword alias",context:i});if(h&&h.protected&&!p&&(e.protected[s]=!0,x.protected=!0,!y(h,x)))throw new t("Invalid JSON-LD syntax; tried to redefine a protected term.","jsonld.SyntaxError",{code:"protected term redefinition",context:i,term:s})},v.expandIri=(e,t,n,o)=>g(e,t,n,void 0,void 0,o),v.getInitialContext=t=>{const n=JSON.stringify({processingMode:t.processingMode}),o=h.get(n);if(o)return o;const r={processingMode:t.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={},r=(e["@language"]||"@none").toLowerCase(),s=e["@direction"],l=e.mappings,c=[...l.keys()].sort(f);for(const e of c){const i=l.get(e);if(null===i)continue;let c=i["@container"]||"@none";if(c=[].concat(c).sort().join(""),null===i["@id"])continue;const d=p(i["@id"]);for(const l of d){let d=t[l];const u=v.isKeyword(l);if(d)u||i._termHasColon||o[l].push(e);else if(t[l]=d={},!u&&!i._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"),i.reverse)a(e,d["@type"],"@reverse");else if("@none"===i["@type"])a(e,d["@any"],"@none"),a(e,d["@language"],"@none"),a(e,d["@type"],"@none");else if("@type"in i)a(e,d["@type"],i["@type"]);else if("@language"in i&&"@direction"in i){const t=i["@language"],n=i["@direction"];a(e,d["@language"],t&&n?`${t}_${n}`.toLowerCase():t?t.toLowerCase():n?`_${n}`:"@null")}else"@language"in i?a(e,d["@language"],(i["@language"]||"@null").toLowerCase()):"@direction"in i?i["@direction"]?a(e,d["@language"],`_${i["@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"],r),a(e,d["@language"],"@none"),a(e,d["@type"],"@none"))}}for(const e in n)i(n,e,1);return t},clone:function(){const t={};t.mappings=e.clone(this.mappings),t.clone=this.clone,t.inverse=null,t.getInverse=this.getInverse,t.protected=e.clone(this.protected),this.previousContext&&(t.previousContext=this.previousContext.clone());t.revertToPreviousContext=this.revertToPreviousContext,"@base"in this&&(t["@base"]=this["@base"]);"@language"in this&&(t["@language"]=this["@language"]);"@vocab"in this&&(t["@vocab"]=this["@vocab"]);return t},revertToPreviousContext:function(){if(!this.previousContext)return this;return this.previousContext.clone()},protected:{}};return 1e4===h.size&&h.clear(),h.set(n,r),r;function i(e,t,n){const o=e[t],r=e[t]={};let a,s;for(const e of o)a=e.iri,s=n>=a.length?"":a[n],s in r?r[s].push(e):r[s]=[e];for(const e in r)""!==e&&i(r,e,n+1)}function a(e,t,n){t.hasOwnProperty(n)||(t[n]=e)}},v.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(i(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},v.processingMode=(e,t)=>t.toString()>="1.1"?!e.processingMode||e.processingMode>="json-ld-"+t.toString():"json-ld-1.0"===e.processingMode,v.isKeyword=e=>{if(!r(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},K}function He(){if(ee)return Y;ee=1;const e=Ee(),{isArray:t,isObject:n,isEmptyObject:o,isString:r,isUndefined:i}=Ne(),{isList:a,isValue:s,isGraph:l,isSubject:c}=Oe(),{expandIri:d,getContextValue:u,isKeyword:p,process:f,processingMode:h}=Fe(),{isAbsolute:v}=Ae(),{REGEX_BCP47:g,REGEX_KEYWORD:y,addValue:m,asArray:x,getValues:b,validateTypeValue:w}=Ce(),{handleEvent:I}=Me(),j={};function S({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,r;0===t?(o="empty object",r="Dropping empty object."):"@value"in e?(o="object with only @value",r="Dropping object with only @value."):"@list"in e?(o="object with only @list",r="Dropping object with only @list."):1===t&&"@id"in e&&(o="object with only @id",r="Dropping object with only @id."),I({event:{type:["JsonLdEvent"],code:o,level:"warning",message:r,details:{value:e}},options:n})}return null}return e}async function D({activeCtx:l,activeProperty:y,expandedActiveProperty:b,element:N,expandedParent:C,options:k={},insideList:L,typeKey:A,typeScopedContext:R}){const T=Object.keys(N).sort(),_=[];let J;const P=N[A]&&"@json"===d(l,t(N[A])?N[A][0]:N[A],{vocab:!0},{...k,typeExpansion:!0});for(const D of T){let L,A=N[D];if("@context"===D)continue;const T=d(l,D,{vocab:!0},k);if(null===T||!v(T)&&!p(T)){k.eventHandler&&I({event:{type:["JsonLdEvent"],code:"invalid property",level:"warning",message:"Dropping property that did not expand into an absolute IRI or keyword.",details:{property:D,expandedProperty:T}},options:k});continue}if(p(T)){if("@reverse"===b)throw new e("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 C&&"@included"!==T&&"@type"!==T)throw new e("Invalid JSON-LD syntax; colliding keywords detected.","jsonld.SyntaxError",{code:"colliding keywords",keyword:T})}if("@id"===T){if(!r(A)){if(!k.isFrame)throw new e('Invalid JSON-LD syntax; "@id" value must a string.',"jsonld.SyntaxError",{code:"invalid @id value",value:A});if(n(A)){if(!o(A))throw new e('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(!t(A))throw new e('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=>r(e)))throw new e('Invalid JSON-LD syntax; "@id" value an empty object or array of strings, if framing',"jsonld.SyntaxError",{code:"invalid @id value",value:A})}}m(C,"@id",x(A).map(e=>{if(r(e)){const t=d(l,e,{base:!0},k);return k.eventHandler&&(null===t?I(null===e?{event:{type:["JsonLdEvent"],code:"null @id value",level:"warning",message:"Null @id found.",details:{id:e}},options:k}:{event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:"Reserved @id found.",details:{id:e}},options:k}):v(t)||I({event:{type:["JsonLdEvent"],code:"relative @id reference",level:"warning",message:"Relative @id reference found.",details:{id:e,expandedId:t}},options:k})),t}return e}),{propertyIsArray:k.isFrame});continue}if("@type"===T){n(A)&&(A=Object.fromEntries(Object.entries(A).map(([e,t])=>[d(R,e,{vocab:!0}),x(t).map(e=>d(R,e,{base:!0,vocab:!0},{...k,typeExpansion:!0}))]))),w(A,k.isFrame),m(C,"@type",x(A).map(e=>{if(r(e)){const t=d(R,e,{base:!0,vocab:!0},{...k,typeExpansion:!0});return"@json"===t||v(t)||k.eventHandler&&I({event:{type:["JsonLdEvent"],code:"relative @type reference",level:"warning",message:"Relative @type reference found.",details:{type:e}},options:k}),t}return e}),{propertyIsArray:!!k.isFrame});continue}if("@included"===T&&h(l,1.1)){const t=x(await j.expand({activeCtx:l,activeProperty:y,element:A,options:k}));if(!t.every(e=>c(e)))throw new e("Invalid JSON-LD syntax; values of @included must expand to node objects.","jsonld.SyntaxError",{code:"invalid @included value",value:A});m(C,"@included",t,{propertyIsArray:!0});continue}if("@graph"===T&&!n(A)&&!t(A))throw new e('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){J=A,P&&h(l,1.1)?C["@value"]=A:m(C,"@value",A,{propertyIsArray:k.isFrame});continue}if("@language"===T){if(null===A)continue;if(!r(A)&&!k.isFrame)throw new e('Invalid JSON-LD syntax; "@language" value must be a string.',"jsonld.SyntaxError",{code:"invalid language-tagged string",value:A});A=x(A).map(e=>r(e)?e.toLowerCase():e);for(const e of A)r(e)&&!e.match(g)&&k.eventHandler&&I({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:k});m(C,"@language",A,{propertyIsArray:k.isFrame});continue}if("@direction"===T){if(!r(A)&&!k.isFrame)throw new e('Invalid JSON-LD syntax; "@direction" value must be a string.',"jsonld.SyntaxError",{code:"invalid base direction",value:A});A=x(A);for(const t of A)if(r(t)&&"ltr"!==t&&"rtl"!==t)throw new e('Invalid JSON-LD syntax; "@direction" must be "ltr" or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",value:A});m(C,"@direction",A,{propertyIsArray:k.isFrame});continue}if("@index"===T){if(!r(A))throw new e('Invalid JSON-LD syntax; "@index" value must be a string.',"jsonld.SyntaxError",{code:"invalid @index value",value:A});m(C,"@index",A);continue}if("@reverse"===T){if(!n(A))throw new e('Invalid JSON-LD syntax; "@reverse" value must be an object.',"jsonld.SyntaxError",{code:"invalid @reverse value",value:A});if(L=await j.expand({activeCtx:l,activeProperty:"@reverse",element:A,options:k}),"@reverse"in L)for(const e in L["@reverse"])m(C,e,L["@reverse"][e],{propertyIsArray:!0});let t=C["@reverse"]||null;for(const n in L){if("@reverse"===n)continue;null===t&&(t=C["@reverse"]={}),m(t,n,[],{propertyIsArray:!0});const o=L[n];for(let r=0;r<o.length;++r){const i=o[r];if(s(i)||a(i))throw new e('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:L});m(t,n,i,{propertyIsArray:!0})}}continue}if("@nest"===T){_.push(D);continue}let M=l;const F=u(l,D,"@context");i(F)||(M=await f({activeCtx:l,localCtx:F,propagate:!0,overrideProtected:!0,options:k}));const H=u(l,D,"@container")||[];if(H.includes("@language")&&n(A)){L=O(M,A,u(M,D,"@direction"),k)}else if(H.includes("@index")&&n(A)){const e=H.includes("@graph"),t=u(M,D,"@index")||"@index",n="@index"!==t&&d(l,t,{vocab:!0},k);L=await E({activeCtx:M,options:k,activeProperty:D,value:A,asGraph:e,indexKey:t,propertyIndex:n})}else if(H.includes("@id")&&n(A)){const e=H.includes("@graph");L=await E({activeCtx:M,options:k,activeProperty:D,value:A,asGraph:e,indexKey:"@id"})}else if(H.includes("@type")&&n(A))L=await E({activeCtx:M.revertToPreviousContext(),options:k,activeProperty:D,value:A,asGraph:!1,indexKey:"@type"});else{const e="@list"===T;if(e||"@set"===T){let t=y;e&&"@graph"===b&&(t=null),L=await j.expand({activeCtx:M,activeProperty:t,element:A,options:k,insideList:e})}else L="@json"===u(l,D,"@type")?{"@type":"@json","@value":A}:await j.expand({activeCtx:M,activeProperty:D,element:A,options:k,insideList:!1})}if(null!==L||"@value"===T){if("@list"!==T&&!a(L)&&H.includes("@list")&&(L={"@list":x(L)}),H.includes("@graph")&&!H.some(e=>"@id"===e||"@index"===e)){if(L=x(L),k.isFrame||(L=L.filter(e=>null!==S({value:e,count:Object.keys(e).length,options:k}))),0===L.length)continue;L=L.map(e=>({"@graph":x(e)}))}if(M.mappings.has(D)&&M.mappings.get(D).reverse){const t=C["@reverse"]=C["@reverse"]||{};L=x(L);for(let n=0;n<L.length;++n){const o=L[n];if(s(o)||a(o))throw new e('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:L});m(t,T,o,{propertyIsArray:!0})}continue}m(C,T,L,{propertyIsArray:!0})}}if("@value"in C)if("@json"===C["@type"]&&h(l,1.1));else if((n(J)||t(J))&&!k.isFrame)throw new e('Invalid JSON-LD syntax; "@value" value must not be an object or an array.',"jsonld.SyntaxError",{code:"invalid value object value",value:J});for(const o of _){const r=t(N[o])?N[o]:[N[o]];for(const t of r){if(!n(t)||Object.keys(t).some(e=>"@value"===d(l,e,{vocab:!0},k)))throw new e("Invalid JSON-LD syntax; nested value must be a node object.","jsonld.SyntaxError",{code:"invalid @nest value",value:t});await D({activeCtx:l,activeProperty:y,expandedActiveProperty:b,element:t,expandedParent:C,options:k,insideList:L,typeScopedContext:R,typeKey:A})}}}function N({activeCtx:e,activeProperty:t,value:n,options:o}){if(null==n)return null;const i=d(e,t,{vocab:!0},o);if("@id"===i)return d(e,n,{base:!0},o);if("@type"===i)return d(e,n,{vocab:!0,base:!0},{...o,typeExpansion:!0});const a=u(e,t,"@type");if(("@id"===a||"@graph"===i)&&r(n)){const r=d(e,n,{base:!0},o);return null===r&&n.match(y)&&o.eventHandler&&I({event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:"Reserved @id found.",details:{id:t}},options:o}),{"@id":r}}if("@vocab"===a&&r(n))return{"@id":d(e,n,{vocab:!0,base:!0},o)};if(p(i))return n;const s={};if(a&&!["@id","@vocab","@none"].includes(a))s["@type"]=a;else if(r(n)){const n=u(e,t,"@language");null!==n&&(s["@language"]=n);const o=u(e,t,"@direction");null!==o&&(s["@direction"]=o)}return["boolean","number","string"].includes(typeof n)||(n=n.toString()),s["@value"]=n,s}function O(n,o,i,a){const s=[],l=Object.keys(o).sort();for(const c of l){const l=d(n,c,{vocab:!0},a);let u=o[c];t(u)||(u=[u]);for(const t of u){if(null===t)continue;if(!r(t))throw new e("Invalid JSON-LD syntax; language map values must be strings.","jsonld.SyntaxError",{code:"invalid language map value",languageMap:o});const n={"@value":t};"@none"!==l&&(c.match(g)||a.eventHandler&&I({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:c}},options:a}),n["@language"]=c.toLowerCase()),i&&(n["@direction"]=i),s.push(n)}}return s}async function E({activeCtx:n,options:o,activeProperty:r,value:a,asGraph:c,indexKey:p,propertyIndex:h}){const v=[],g=Object.keys(a).sort(),y="@type"===p;for(let x of g){if(y){const e=u(n,x,"@context");i(e)||(n=await f({activeCtx:n,localCtx:e,propagate:!1,options:o}))}let g,b=a[x];t(b)||(b=[b]),b=await j.expand({activeCtx:n,activeProperty:r,element:b,options:o,insideList:!1,insideIndex:!0}),g=h?"@none"===x?"@none":N({activeCtx:n,activeProperty:p,value:x,options:o}):d(n,x,{vocab:!0},o),"@id"===p?x=d(n,x,{base:!0},o):y&&(x=g);for(let t of b){if(c&&!l(t)&&(t={"@graph":[t]}),"@type"===p)"@none"===g||(t["@type"]?t["@type"]=[x].concat(t["@type"]):t["@type"]=[x]);else{if(s(t)&&!["@language","@type","@index"].includes(p))throw new e(`Invalid JSON-LD syntax; Attempt to add illegal key to value object: "${p}".`,"jsonld.SyntaxError",{code:"invalid value object",value:t});h?"@none"!==g&&m(t,h,g,{propertyIsArray:!0,prependValue:!0}):"@none"===g||p in t||(t[p]=x)}v.push(t)}}return v}return Y=j,j.expand=async({activeCtx:a,activeProperty:s=null,element:l,options:c={},insideList:p=!1,insideIndex:g=!1,typeScopedContext:y=null})=>{if(null==l)return null;if("@default"===s&&(c=Object.assign({},c,{isFrame:!1})),!t(l)&&!n(l))return p||null!==s&&"@graph"!==d(a,s,{vocab:!0},c)?N({activeCtx:a,activeProperty:s,value:l,options:c}):(c.eventHandler&&I({event:{type:["JsonLdEvent"],code:"free-floating scalar",level:"warning",message:"Dropping free-floating scalar not in a list.",details:{value:l}},options:c}),null);if(t(l)){let e=[];const n=u(a,s,"@container")||[];p=p||n.includes("@list");for(let n=0;n<l.length;++n){let o=await j.expand({activeCtx:a,activeProperty:s,element:l[n],options:c,insideIndex:g,typeScopedContext:y});p&&t(o)&&(o={"@list":o}),null!==o&&(t(o)?e=e.concat(o):e.push(o))}return e}const m=d(a,s,{vocab:!0},c),w=u(a,s,"@context");y=y||(a.previousContext?a:null);let O=Object.keys(l).sort(),E=!g;if(E&&y&&O.length<=2&&!O.includes("@context"))for(const e of O){const t=d(y,e,{vocab:!0},c);if("@value"===t){E=!1,a=y;break}if("@id"===t&&1===O.length){E=!1;break}}E&&(a=a.revertToPreviousContext()),i(w)||(a=await f({activeCtx:a,localCtx:w,propagate:!0,overrideProtected:!0,options:c})),"@context"in l&&(a=await f({activeCtx:a,localCtx:l["@context"],options:c})),y=a;let C=null;for(const e of O){if("@type"===d(a,e,{vocab:!0},c)){C=C||e;const t=l[e],n=Array.isArray(t)?t.length>1?t.slice().sort():t:[t];for(const e of n){const t=u(y,e,"@context");i(t)||(a=await f({activeCtx:a,localCtx:t,options:c,propagate:!1}))}}}let k={};await D({activeCtx:a,activeProperty:s,expandedActiveProperty:m,element:l,expandedParent:k,options:c,insideList:p,typeKey:C,typeScopedContext:y}),O=Object.keys(k);let L=O.length;if("@value"in k){if("@type"in k&&("@language"in k||"@direction"in k))throw new e('Invalid JSON-LD syntax; an element containing "@value" may not contain both "@type" and either "@language" or "@direction".',"jsonld.SyntaxError",{code:"invalid value object",element:k});let t=L-1;if("@type"in k&&(t-=1),"@index"in k&&(t-=1),"@language"in k&&(t-=1),"@direction"in k&&(t-=1),0!==t)throw new e('Invalid JSON-LD syntax; an element containing "@value" may only have an "@index" property and either "@type" or either or both "@language" or "@direction".',"jsonld.SyntaxError",{code:"invalid value object",element:k});const n=null===k["@value"]?[]:x(k["@value"]),i=b(k,"@type");if(h(a,1.1)&&i.includes("@json")&&1===i.length);else if(0===n.length)c.eventHandler&&I({event:{type:["JsonLdEvent"],code:"null @value value",level:"warning",message:"Dropping null @value value.",details:{value:k}},options:c}),k=null;else{if(!n.every(e=>r(e)||o(e))&&"@language"in k)throw new e("Invalid JSON-LD syntax; only strings may be language-tagged.","jsonld.SyntaxError",{code:"invalid language-tagged value",element:k});if(!i.every(e=>v(e)&&!(r(e)&&0===e.indexOf("_:"))||o(e)))throw new e('Invalid JSON-LD syntax; an element containing "@value" and "@type" must have an absolute IRI for the value of "@type".',"jsonld.SyntaxError",{code:"invalid typed value",element:k})}}else if("@type"in k&&!t(k["@type"]))k["@type"]=[k["@type"]];else if("@set"in k||"@list"in k){if(L>1&&(2!==L||!("@index"in k)))throw new e('Invalid JSON-LD syntax; if an element has the property "@set" or "@list", then it can have at most one other property that is "@index".',"jsonld.SyntaxError",{code:"invalid set or list object",element:k});"@set"in k&&(k=k["@set"],O=Object.keys(k),L=O.length)}else 1===L&&"@language"in k&&(c.eventHandler&&I({event:{type:["JsonLdEvent"],code:"object with only @language",level:"warning",message:"Dropping object with only @language.",details:{value:k}},options:c}),k=null);return!n(k)||c.keepFreeFloatingNodes||p||null!==s&&"@graph"!==m&&!(u(a,s,"@container")||[]).includes("@graph")||(k=S({value:k,count:L,options:c})),k},Y}function Be(){if(ne)return te;ne=1;const{isKeyword:e}=Fe(),t=Oe(),n=Ne(),o=Ce(),r=Ee(),i={};return te=i,i.createMergedNodeMap=(e,t)=>{const n=(t=t||{}).issuer||new o.IdentifierIssuer("_:b"),r={"@default":{}};return i.createNodeMap(e,r,"@default",n),i.mergeNodeMaps(r)},i.createNodeMap=(a,s,l,c,d,u)=>{if(n.isArray(a)){for(const e of a)i.createNodeMap(e,s,l,c,void 0,u);return}if(!n.isObject(a))return void(u&&u.push(a));if(t.isValue(a)){if("@type"in a){let e=a["@type"];0===e.indexOf("_:")&&(a["@type"]=e=c.getId(e))}return void(u&&u.push(a))}if(u&&t.isList(a)){const e=[];return i.createNodeMap(a["@list"],s,l,c,d,e),void u.push({"@list":e})}if("@type"in a){const e=a["@type"];for(const t of e)0===t.indexOf("_:")&&c.getId(t)}n.isUndefined(d)&&(d=t.isBlankNode(a)?c.getId(a["@id"]):a["@id"]),u&&u.push({"@id":d});const p=s[l],f=p[d]=p[d]||{};f["@id"]=d;const h=Object.keys(a).sort();for(let n of h){if("@id"===n)continue;if("@reverse"===n){const e={"@id":d},n=a["@reverse"];for(const r in n){const a=n[r];for(const n of a){let a=n["@id"];t.isBlankNode(n)&&(a=c.getId(a)),i.createNodeMap(n,s,l,c,a),o.addValue(p[a],r,e,{propertyIsArray:!0,allowDuplicate:!1})}}continue}if("@graph"===n){d in s||(s[d]={}),i.createNodeMap(a[n],s,d,c);continue}if("@included"===n){i.createNodeMap(a[n],s,l,c);continue}if("@type"!==n&&e(n)){if("@index"===n&&n in f&&(a[n]!==f[n]||a[n]["@id"]!==f[n]["@id"]))throw new r("Invalid JSON-LD syntax; conflicting @index property detected.","jsonld.SyntaxError",{code:"conflicting indexes",subject:f});f[n]=a[n];continue}const u=a[n];if(0===n.indexOf("_:")&&(n=c.getId(n)),0!==u.length)for(let e of u)if("@type"===n&&(e=0===e.indexOf("_:")?c.getId(e):e),t.isSubject(e)||t.isSubjectReference(e)){if("@id"in e&&!e["@id"])continue;const r=t.isBlankNode(e)?c.getId(e["@id"]):e["@id"];o.addValue(f,n,{"@id":r},{propertyIsArray:!0,allowDuplicate:!1}),i.createNodeMap(e,s,l,c,r)}else if(t.isValue(e))o.addValue(f,n,e,{propertyIsArray:!0,allowDuplicate:!1});else if(t.isList(e)){const t=[];i.createNodeMap(e["@list"],s,l,c,d,t),e={"@list":t},o.addValue(f,n,e,{propertyIsArray:!0,allowDuplicate:!1})}else i.createNodeMap(e,s,l,c,d),o.addValue(f,n,e,{propertyIsArray:!0,allowDuplicate:!1});else o.addValue(f,n,[],{propertyIsArray:!0})}},i.mergeNodeMapGraphs=t=>{const n={};for(const r of Object.keys(t).sort())for(const i of Object.keys(t[r]).sort()){const a=t[r][i];i in n||(n[i]={"@id":i});const s=n[i];for(const t of Object.keys(a).sort())if(e(t)&&"@type"!==t)s[t]=o.clone(a[t]);else for(const e of a[t])o.addValue(s,t,o.clone(e),{propertyIsArray:!0,allowDuplicate:!1})}return n},i.mergeNodeMaps=e=>{const n=e["@default"],o=Object.keys(e).sort();for(const r of o){if("@default"===r)continue;const o=e[r];let i=n[r];i?"@graph"in i||(i["@graph"]=[]):n[r]=i={"@id":r,"@graph":[]};const a=i["@graph"];for(const e of Object.keys(o).sort()){const n=o[e];t.isSubjectReference(n)||a.push(n)}}return n},te}function qe(){if(de)return ce;de=1;const{createNodeMap:e}=Be(),{isKeyword:t}=Fe(),n=Oe(),o=le?se:(le=1,se=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");return null===t||"object"!=typeof t?JSON.stringify(t):t.toJSON instanceof Function?e(t.toJSON()):Array.isArray(t)?`[${t.reduce((t,n,o)=>`${t}${0===o?"":","}${e(void 0===n||"symbol"==typeof n?null:n)}`,"")}]`:`{${Object.keys(t).sort().reduce((n,o)=>void 0===t[o]||"symbol"==typeof t[o]?n:`${n}${0===n.length?"":","}${e(o)}:${e(t[o])}`,"")}}`}),r=Ee(),i=Ne(),a=Ce(),{handleEvent:s}=Me(),{RDF_FIRST:l,RDF_REST:c,RDF_NIL:d,RDF_TYPE:u,RDF_JSON_LITERAL:p,RDF_LANGSTRING:f,XSD_BOOLEAN:h,XSD_DOUBLE:v,XSD_INTEGER:g,XSD_STRING:y}=ke(),{isAbsolute:m}=Ae(),x={};function b(e,n,o,r,i){const a=Object.keys(n).sort();for(const l of a){const a=n[l],c=Object.keys(a).sort();for(let n of c){const c=a[n];if("@type"===n)n=u;else if(t(n))continue;for(const t of c){const a=I(l);if(!m(l)){i.eventHandler&&s({event:{type:["JsonLdEvent"],code:"relative subject reference",level:"warning",message:"Relative subject reference found.",details:{subject:l}},options:i});continue}const c=I(n);if(!m(n)){i.eventHandler&&s({event:{type:["JsonLdEvent"],code:"relative predicate reference",level:"warning",message:"Relative predicate reference found.",details:{predicate:n}},options:i});continue}if("BlankNode"===c.termType&&!i.produceGeneralizedRdf){i.eventHandler&&s({event:{type:["JsonLdEvent"],code:"blank node predicate",level:"warning",message:"Dropping blank node predicate.",details:{property:r.getOldIds().find(e=>r.getId(e)===n)}},options:i});continue}const d=w(t,r,e,o,i.rdfDirection,i);d&&e.push({subject:a,predicate:c,object:d,graph:o})}}}}function w(e,t,a,u,x,b){let j;if(n.isValue(e)){j={termType:"Literal",value:void 0,datatype:{termType:"NamedNode"}};let t=e["@value"];const n=e["@type"]||null;if("@json"===n)j.value=o(t),j.datatype.value=p;else if(i.isBoolean(t))j.value=t.toString(),j.datatype.value=n||h;else if(i.isDouble(t)||n===v)i.isDouble(t)||(t=parseFloat(t)),j.value=t.toExponential(15).replace(/(\d)0*e\+?/,"$1E"),j.datatype.value=n||v;else if(i.isNumber(t))j.value=t.toFixed(0),j.datatype.value=n||g;else if("@direction"in e&&"i18n-datatype"===x){const n=`https://www.w3.org/ns/i18n#${(e["@language"]||"").toLowerCase()}_${e["@direction"]}`;j.datatype.value=n,j.value=t}else{if("@direction"in e&&"compound-literal"===x)throw new r("Unsupported rdfDirection value.","jsonld.InvalidRdfDirection",{value:x});if("@direction"in e&&x)throw new r("Unknown rdfDirection value.","jsonld.InvalidRdfDirection",{value:x});"@language"in e?("@direction"in e&&!x&&b.eventHandler&&s({event:{type:["JsonLdEvent"],code:"rdfDirection not set",level:"warning",message:"rdfDirection not set for @direction.",details:{object:j.value}},options:b}),j.value=t,j.datatype.value=n||f,j.language=e["@language"]):("@direction"in e&&!x&&b.eventHandler&&s({event:{type:["JsonLdEvent"],code:"rdfDirection not set",level:"warning",message:"rdfDirection not set for @direction.",details:{object:j.value}},options:b}),j.value=t,j.datatype.value=n||y)}}else if(n.isList(e)){const n=function(e,t,n,o,r,i){const a={termType:"NamedNode",value:l},s={termType:"NamedNode",value:c},u={termType:"NamedNode",value:d},p=e.pop(),f=p?{termType:"BlankNode",value:t.getId().slice(2)}:u;let h=f;for(const l of e){const e=w(l,t,n,o,r,i),c={termType:"BlankNode",value:t.getId().slice(2)};n.push({subject:h,predicate:a,object:e,graph:o}),n.push({subject:h,predicate:s,object:c,graph:o}),h=c}if(p){const e=w(p,t,n,o,r,i);n.push({subject:h,predicate:a,object:e,graph:o}),n.push({subject:h,predicate:s,object:u,graph:o})}return f}(e["@list"],t,a,u,x,b);j={termType:n.termType,value:n.value}}else{j=I(i.isObject(e)?e["@id"]:e)}return"NamedNode"!==j.termType||m(j.value)?j:(b.eventHandler&&s({event:{type:["JsonLdEvent"],code:"relative object reference",level:"warning",message:"Relative object reference found.",details:{object:j.value}},options:b}),null)}function I(e){return e.startsWith("_:")?{termType:"BlankNode",value:e.slice(2)}:{termType:"NamedNode",value:e}}return ce=x,x.toRDF=(t,n)=>{const o=new a.IdentifierIssuer("_:b"),r={"@default":{}};e(t,r,"@default",o);const i=[],l=Object.keys(r).sort();for(const e of l){let t;if("@default"===e)t={termType:"DefaultGraph",value:""};else{if(!m(e)){n.eventHandler&&s({event:{type:["JsonLdEvent"],code:"relative graph reference",level:"warning",message:"Relative graph reference found.",details:{graph:e}},options:n});continue}t=I(e)}b(i,r[e],t,o,n)}return i},ce}function Ue(){if(pe)return ue;pe=1;const{isKeyword:e}=Fe(),t=Oe(),n=Ne(),o=Ce(),r=Ae(),i=Ee(),{createNodeMap:a,mergeNodeMapGraphs:s}=Be(),l={};function c(e){const t={};for(const n in e)void 0!==e[n]&&(t["@"+n]=[e[n]]);return[t]}function d(e,t,n){for(let o=n.length-1;o>=0;--o){const r=n[o];if(r.graph===t&&r.subject["@id"]===e["@id"])return!0}return!1}function u(e,t,n){const o="@"+n;let r=o in e?e[o][0]:t[n];if("embed"===n)if(!0===r)r="@once";else if(!1===r)r="@never";else if("@always"!==r&&"@never"!==r&&"@link"!==r&&"@first"!==r&&"@last"!==r&&"@once"!==r)throw new i("Invalid JSON-LD syntax; invalid value of @embed.","jsonld.SyntaxError",{code:"invalid @embed value",frame:e});return r}function p(e){if(!n.isArray(e)||1!==e.length||!n.isObject(e[0]))throw new i("Invalid JSON-LD syntax; a JSON-LD frame must be a single object.","jsonld.SyntaxError",{frame:e});if("@id"in e[0])for(const t of o.asArray(e[0]["@id"]))if(!n.isObject(t)&&!r.isAbsolute(t)||n.isString(t)&&0===t.indexOf("_:"))throw new i("Invalid JSON-LD syntax; invalid @id in frame.","jsonld.SyntaxError",{code:"invalid frame",frame:e});if("@type"in e[0])for(const t of o.asArray(e[0]["@type"]))if(!n.isObject(t)&&!r.isAbsolute(t)&&"@json"!==t||n.isString(t)&&0===t.indexOf("_:"))throw new i("Invalid JSON-LD syntax; invalid @type in frame.","jsonld.SyntaxError",{code:"invalid frame",frame:e})}function f(r,i,a,s){let l=!0,c=!1;for(const d in a){let u=!1;const f=o.getValues(i,d),h=0===o.getValues(a,d).length;if("@id"===d){if(n.isEmptyObject(a["@id"][0]||{})?u=!0:a["@id"].length>=0&&(u=a["@id"].includes(f[0])),!s.requireAll)return u}else if("@type"===d){if(l=!1,h){if(f.length>0)return!1;u=!0}else if(1===a["@type"].length&&n.isEmptyObject(a["@type"][0]))u=f.length>0;else for(const e of a["@type"])u=!(!n.isObject(e)||!("@default"in e))||(u||f.some(t=>t===e));if(!s.requireAll)return u}else{if(e(d))continue;{const e=o.getValues(a,d)[0];let i=!1;if(e&&(p([e]),i="@default"in e),l=!1,0===f.length&&i)continue;if(f.length>0&&h)return!1;if(void 0===e){if(f.length>0)return!1;u=!0}else if(t.isList(e)){const n=e["@list"][0];if(t.isList(f[0])){const e=f[0]["@list"];t.isValue(n)?u=e.some(e=>m(n,e)):(t.isSubject(n)||t.isSubjectReference(n))&&(u=e.some(e=>y(r,n,e,s)))}}else u=t.isValue(e)?f.some(t=>m(e,t)):t.isSubjectReference(e)?f.some(t=>y(r,e,t,s)):!!n.isObject(e)&&f.length>0}}if(!u&&s.requireAll)return!1;c=c||u}return l||c}function h(e,t){const r=e.uniqueEmbeds[e.graph],i=r[t],a=i.parent,s=i.property,l={"@id":t};if(n.isArray(a)){for(let e=0;e<a.length;++e)if(o.compareValues(a[e],l)){a[e]=l;break}}else{const e=n.isArray(a[s]);o.removeValue(a,s,l,{propertyIsArray:e}),o.addValue(a,s,l,{propertyIsArray:e})}const c=e=>{const t=Object.keys(r);for(const o of t)o in r&&n.isObject(r[o].parent)&&r[o].parent["@id"]===e&&(delete r[o],c(o))};c(t)}
22
- /**
23
- * Removes the @preserve keywords from expanded result of framing.
24
- *
25
- * @param input the framed, framed output.
26
- * @param options the framing options used.
27
- *
28
- * @return the resulting output.
29
- */function v(e,o){if(n.isArray(e))return e.map(e=>v(e,o));if(n.isObject(e)){
30
- // remove @preserve
31
- if("@preserve"in e)return e["@preserve"][0];if(t.isValue(e))return e;if(t.isList(e))return e["@list"]=v(e["@list"],o),e;if("@id"in e){const t=e["@id"];if(o.link.hasOwnProperty(t)){const n=o.link[t].indexOf(e);if(-1!==n)return o.link[t][n];o.link[t].push(e)}else o.link[t]=[e]}for(const t in e)"@id"===t&&o.bnodesToClear.includes(e[t])?delete e["@id"]:e[t]=v(e[t],o)}return e}function g(e,t,r){n.isObject(e)?o.addValue(e,t,r,{propertyIsArray:!0}):e.push(r)}function y(e,t,n,o){if(!("@id"in n))return!1;const r=e.subjects[n["@id"]];return r&&f(e,r,t,o)}function m(e,t){const o=t["@value"],r=t["@type"],i=t["@language"],a=e["@value"]?n.isArray(e["@value"])?e["@value"]:[e["@value"]]:[],s=e["@type"]?n.isArray(e["@type"])?e["@type"]:[e["@type"]]:[],l=e["@language"]?n.isArray(e["@language"])?e["@language"]:[e["@language"]]:[];return 0===a.length&&0===s.length&&0===l.length||!(!a.includes(o)&&!n.isEmptyObject(a[0]))&&(!!(!r&&0===s.length||s.includes(r)||r&&n.isEmptyObject(s[0]))&&!!(!i&&0===l.length||l.includes(i)||i&&n.isEmptyObject(l[0])))}return ue=l,l.frameMergedOrDefault=(e,t,n)=>{const r={options:n,embedded:!1,graph:"@default",graphMap:{"@default":{}},subjectStack:[],link:{},bnodeMap:{}},i=new o.IdentifierIssuer("_:b");a(e,r.graphMap,"@default",i),n.merged&&(r.graphMap["@merged"]=s(r.graphMap),r.graph="@merged"),r.subjects=r.graphMap[r.graph];const c=[];return l.frame(r,Object.keys(r.subjects).sort(),t,c),n.pruneBlankNodeIdentifiers&&(n.bnodesToClear=Object.keys(r.bnodeMap).filter(e=>1===r.bnodeMap[e].length)),
32
- // remove @preserve from results
33
- n.link={},v(c,n)},l.frame=(r,a,s,v,y=null)=>{p(s),s=s[0];const x=r.options,b={embed:u(s,x,"embed"),explicit:u(s,x,"explicit"),requireAll:u(s,x,"requireAll")};r.link.hasOwnProperty(r.graph)||(r.link[r.graph]={});const w=r.link[r.graph],I=function(e,t,n,o){const r={};for(const i of t){const t=e.graphMap[e.graph][i];f(e,t,n,o)&&(r[i]=t)}return r}(r,a,s,b),j=Object.keys(I).sort();for(const p of j){const f=I[p];if(null===y?r.uniqueEmbeds={[r.graph]:{}}:r.uniqueEmbeds[r.graph]=r.uniqueEmbeds[r.graph]||{},"@link"===b.embed&&p in w){g(v,y,w[p]);continue}const j={"@id":p};if(0===p.indexOf("_:")&&o.addValue(r.bnodeMap,p,j,{propertyIsArray:!0}),w[p]=j,("@first"===b.embed||"@last"===b.embed)&&r.is11)throw new i("Invalid JSON-LD syntax; invalid value of @embed.","jsonld.SyntaxError",{code:"invalid @embed value",frame:s});if(r.embedded||!r.uniqueEmbeds[r.graph].hasOwnProperty(p))if(!r.embedded||"@never"!==b.embed&&!d(f,r.graph,r.subjectStack))if(!r.embedded||"@first"!=b.embed&&"@once"!=b.embed||!r.uniqueEmbeds[r.graph].hasOwnProperty(p)){if("@last"===b.embed&&p in r.uniqueEmbeds[r.graph]&&h(r,p),r.uniqueEmbeds[r.graph][p]={parent:v,property:y},r.subjectStack.push({subject:f,graph:r.graph}),p in r.graphMap){let e=!1,t=null;"@graph"in s?(t=s["@graph"][0],e=!("@merged"===p||"@default"===p),n.isObject(t)||(t={})):(e="@merged"!==r.graph,t={}),e&&l.frame({...r,graph:p,embedded:!1},Object.keys(r.graphMap[p]).sort(),[t],j,"@graph")}"@included"in s&&l.frame({...r,embedded:!1},a,s["@included"],j,"@included");for(const n of Object.keys(f).sort())if(e(n)){if(j[n]=o.clone(f[n]),"@type"===n)for(const e of f["@type"])0===e.indexOf("_:")&&o.addValue(r.bnodeMap,e,j,{propertyIsArray:!0})}else if(!b.explicit||n in s)for(const e of f[n]){const i=n in s?s[n]:c(b);if(t.isList(e)){const i=s[n]&&s[n][0]&&s[n][0]["@list"]?s[n][0]["@list"]:c(b),a={"@list":[]};g(j,n,a);const d=e["@list"];for(const e of d)t.isSubjectReference(e)?l.frame({...r,embedded:!0},[e["@id"]],i,a,"@list"):g(a,"@list",o.clone(e))}else t.isSubjectReference(e)?l.frame({...r,embedded:!0},[e["@id"]],i,j,n):m(i[0],e)&&g(j,n,o.clone(e))}for(const t of Object.keys(s).sort()){if("@type"===t){if(!n.isObject(s[t][0])||!("@default"in s[t][0]))continue}else if(e(t))continue;const r=s[t][0]||{};if(!u(r,x,"omitDefault")&&!(t in j)){let e="@null";"@default"in r&&(e=o.clone(r["@default"])),n.isArray(e)||(e=[e]),j[t]=[{"@preserve":e}]}}for(const e of Object.keys(s["@reverse"]||{}).sort()){const t=s["@reverse"][e];for(const n of Object.keys(r.subjects)){o.getValues(r.subjects[n],e).some(e=>e["@id"]===p)&&(j["@reverse"]=j["@reverse"]||{},o.addValue(j["@reverse"],e,[],{propertyIsArray:!0}),l.frame({...r,embedded:!0},[n],t,j["@reverse"][e],y))}}g(v,y,j),r.subjectStack.pop()}else g(v,y,j);else g(v,y,j)}},l.cleanupNull=(e,t)=>{if(n.isArray(e)){return e.map(e=>l.cleanupNull(e,t)).filter(e=>e)}if("@null"===e)return null;if(n.isObject(e)){if("@id"in e){const n=e["@id"];if(t.link.hasOwnProperty(n)){const o=t.link[n].indexOf(e);if(-1!==o)return t.link[n][o];t.link[n].push(e)}else t.link[n]=[e]}for(const n in e)e[n]=l.cleanupNull(e[n],t)}return e},ue}function $e(){if(he)return fe;he=1;const e=Ee(),{isArray:t,isObject:n,isString:o,isUndefined:r}=Ne(),{isList:i,isValue:a,isGraph:s,isSimpleGraph:l,isSubjectReference:c}=Oe(),{expandIri:d,getContextValue:u,isKeyword:p,process:f,processingMode:h}=Fe(),{removeBase:v,prependBase:g}=Ae(),{REGEX_KEYWORD:y,addValue:m,asArray:x,compareShortestLeast:b}=Ce(),w={};function I(t,n,o){if("@nest"!==d(t,n,{vocab:!0},o))throw new e("JSON-LD compact error; nested property must have an @nest value resolving to @nest.","jsonld.SyntaxError",{code:"invalid @nest value"})}return fe=w,w.compact=async({activeCtx:d,activeProperty:v=null,element:g,options:y={}})=>{if(t(g)){let e=[];for(let t=0;t<g.length;++t){const n=await w.compact({activeCtx:d,activeProperty:v,element:g[t],options:y});null!==n&&e.push(n)}if(y.compactArrays&&1===e.length){0===(u(d,v,"@container")||[]).length&&(e=e[0])}return e}const b=u(d,v,"@context");if(r(b)||(d=await f({activeCtx:d,localCtx:b,propagate:!0,overrideProtected:!0,options:y})),n(g)){if(y.link&&"@id"in g&&y.link.hasOwnProperty(g["@id"])){const e=y.link[g["@id"]];for(let t=0;t<e.length;++t)if(e[t].expanded===g)return e[t].compacted}if(a(g)||c(g)){const e=w.compactValue({activeCtx:d,activeProperty:v,value:g,options:y});return y.link&&c(g)&&(y.link.hasOwnProperty(g["@id"])||(y.link[g["@id"]]=[]),y.link[g["@id"]].push({expanded:g,compacted:e})),e}if(i(g)){if((u(d,v,"@container")||[]).includes("@list"))return w.compact({activeCtx:d,activeProperty:v,element:g["@list"],options:y})}const b="@reverse"===v,j={},S=d;a(g)||c(g)||(d=d.revertToPreviousContext());const D=u(S,v,"@context");r(D)||(d=await f({activeCtx:d,localCtx:D,propagate:!0,overrideProtected:!0,options:y})),y.link&&"@id"in g&&(y.link.hasOwnProperty(g["@id"])||(y.link[g["@id"]]=[]),y.link[g["@id"]].push({expanded:g,compacted:j}));let N=g["@type"]||[];N.length>1&&(N=Array.from(N).sort());const O=d;for(const e of N){const t=w.compactIri({activeCtx:O,iri:e,relativeTo:{vocab:!0}}),n=u(S,t,"@context");r(n)||(d=await f({activeCtx:d,localCtx:n,options:y,propagate:!1}))}const E=Object.keys(g).sort();for(const r of E){const c=g[r];if("@id"===r){let e=x(c).map(e=>w.compactIri({activeCtx:d,iri:e,relativeTo:{vocab:!1},base:y.base}));1===e.length&&(e=e[0]);j[w.compactIri({activeCtx:d,iri:"@id",relativeTo:{vocab:!0}})]=e;continue}if("@type"===r){let e=x(c).map(e=>w.compactIri({activeCtx:S,iri:e,relativeTo:{vocab:!0}}));1===e.length&&(e=e[0]);const n=w.compactIri({activeCtx:d,iri:"@type",relativeTo:{vocab:!0}}),o=(u(d,n,"@container")||[]).includes("@set")&&h(d,1.1)||t(e)&&0===c.length;m(j,n,e,{propertyIsArray:o});continue}if("@reverse"===r){const e=await w.compact({activeCtx:d,activeProperty:"@reverse",element:c,options:y});for(const t in e)if(d.mappings.has(t)&&d.mappings.get(t).reverse){const n=e[t],o=(u(d,t,"@container")||[]).includes("@set")||!y.compactArrays;m(j,t,n,{propertyIsArray:o}),delete e[t]}if(Object.keys(e).length>0){const t=w.compactIri({activeCtx:d,iri:r,relativeTo:{vocab:!0}});m(j,t,e)}continue}if("@preserve"===r){const e=await w.compact({activeCtx:d,activeProperty:v,element:c,options:y});t(e)&&0===e.length||m(j,r,e);continue}if("@index"===r){if((u(d,v,"@container")||[]).includes("@index"))continue;const e=w.compactIri({activeCtx:d,iri:r,relativeTo:{vocab:!0}});m(j,e,c);continue}if("@graph"!==r&&"@list"!==r&&"@included"!==r&&p(r)){const e=w.compactIri({activeCtx:d,iri:r,relativeTo:{vocab:!0}});m(j,e,c);continue}if(!t(c))throw new e("JSON-LD expansion error; expanded value must be an array.","jsonld.SyntaxError");if(0===c.length){const e=w.compactIri({activeCtx:d,iri:r,value:c,relativeTo:{vocab:!0},reverse:b}),t=d.mappings.has(e)?d.mappings.get(e)["@nest"]:null;let o=j;t&&(I(d,t,y),n(j[t])||(j[t]={}),o=j[t]),m(o,e,c,{propertyIsArray:!0})}for(const e of c){const c=w.compactIri({activeCtx:d,iri:r,value:e,relativeTo:{vocab:!0},reverse:b}),p=d.mappings.has(c)?d.mappings.get(c)["@nest"]:null;let f=j;p&&(I(d,p,y),n(j[p])||(j[p]={}),f=j[p]);const h=u(d,c,"@container")||[],v=s(e),g=i(e);let S;g?S=e["@list"]:v&&(S=e["@graph"]);let D=await w.compact({activeCtx:d,activeProperty:c,element:g||v?S:e,options:y});if(g){if(t(D)||(D=[D]),h.includes("@list")){m(f,c,D,{valueIsArray:!0,allowDuplicate:!0});continue}D={[w.compactIri({activeCtx:d,iri:"@list",relativeTo:{vocab:!0}})]:D},"@index"in e&&(D[w.compactIri({activeCtx:d,iri:"@index",relativeTo:{vocab:!0}})]=e["@index"])}if(v)if(h.includes("@graph")&&(h.includes("@id")||h.includes("@index")&&l(e))){let t;f.hasOwnProperty(c)?t=f[c]:f[c]=t={};const n=(h.includes("@id")?e["@id"]:e["@index"])||w.compactIri({activeCtx:d,iri:"@none",relativeTo:{vocab:!0}});m(t,n,D,{propertyIsArray:!y.compactArrays||h.includes("@set")})}else h.includes("@graph")&&l(e)?(t(D)&&D.length>1&&(D={"@included":D}),m(f,c,D,{propertyIsArray:!y.compactArrays||h.includes("@set")})):(t(D)&&1===D.length&&y.compactArrays&&(D=D[0]),D={[w.compactIri({activeCtx:d,iri:"@graph",relativeTo:{vocab:!0}})]:D},"@id"in e&&(D[w.compactIri({activeCtx:d,iri:"@id",relativeTo:{vocab:!0}})]=e["@id"]),"@index"in e&&(D[w.compactIri({activeCtx:d,iri:"@index",relativeTo:{vocab:!0}})]=e["@index"]),m(f,c,D,{propertyIsArray:!y.compactArrays||h.includes("@set")}));else if(h.includes("@language")||h.includes("@index")||h.includes("@id")||h.includes("@type")){let t,n;if(f.hasOwnProperty(c)?t=f[c]:f[c]=t={},h.includes("@language"))a(D)&&(D=D["@value"]),n=e["@language"];else if(h.includes("@index")){const t=u(d,c,"@index")||"@index",r=w.compactIri({activeCtx:d,iri:t,relativeTo:{vocab:!0}});if("@index"===t)n=e["@index"],delete D[r];else{let e;if([n,...e]=x(D[t]||[]),o(n))switch(e.length){case 0:delete D[t];break;case 1:D[t]=e[0];break;default:D[t]=e}else n=null}}else if(h.includes("@id")){const e=w.compactIri({activeCtx:d,iri:"@id",relativeTo:{vocab:!0}});n=D[e],delete D[e]}else if(h.includes("@type")){const t=w.compactIri({activeCtx:d,iri:"@type",relativeTo:{vocab:!0}});let o;switch([n,...o]=x(D[t]||[]),o.length){case 0:delete D[t];break;case 1:D[t]=o[0];break;default:D[t]=o}1===Object.keys(D).length&&"@id"in e&&(D=await w.compact({activeCtx:d,activeProperty:c,element:{"@id":e["@id"]},options:y}))}n||(n=w.compactIri({activeCtx:d,iri:"@none",relativeTo:{vocab:!0}})),m(t,n,D,{propertyIsArray:h.includes("@set")})}else{const e=!y.compactArrays||h.includes("@set")||h.includes("@list")||t(D)&&0===D.length||"@list"===r||"@graph"===r;m(f,c,D,{propertyIsArray:e})}}}return j}return g},w.compactIri=({activeCtx:t,iri:o,value:r=null,relativeTo:l={vocab:!1},reverse:c=!1,base:d=null})=>{if(null===o)return o;t.isPropertyTermScoped&&t.previousContext&&(t=t.previousContext);const u=t.getInverse();if(p(o)&&o in u&&"@none"in u[o]&&"@type"in u[o]["@none"]&&"@none"in u[o]["@none"]["@type"])return u[o]["@none"]["@type"]["@none"];if(l.vocab&&o in u){const e=t["@language"]||"@none",l=[];n(r)&&"@index"in r&&!("@graph"in r)&&l.push("@index","@index@set"),n(r)&&"@preserve"in r&&(r=r["@preserve"][0]),s(r)?("@index"in r&&l.push("@graph@index","@graph@index@set","@index","@index@set"),"@id"in r&&l.push("@graph@id","@graph@id@set"),l.push("@graph","@graph@set","@set"),"@index"in r||l.push("@graph@index","@graph@index@set","@index","@index@set"),"@id"in r||l.push("@graph@id","@graph@id@set")):n(r)&&!a(r)&&l.push("@id","@id@set","@type","@set@type");let d="@language",u="@null";if(c)d="@type",u="@reverse",l.push("@set");else if(i(r)){"@index"in r||l.push("@list");const t=r["@list"];if(0===t.length)d="@any",u="@none";else{let n=0===t.length?e:null,o=null;for(let e=0;e<t.length;++e){const r=t[e];let i="@none",s="@none";if(a(r))if("@direction"in r){i=`${(r["@language"]||"").toLowerCase()}_${r["@direction"]}`}else"@language"in r?i=r["@language"].toLowerCase():"@type"in r?s=r["@type"]:i="@null";else s="@id";if(null===n?n=i:i!==n&&a(r)&&(n="@none"),null===o?o=s:s!==o&&(o="@none"),"@none"===n&&"@none"===o)break}n=n||"@none",o=o||"@none","@none"!==o?(d="@type",u=o):u=n}}else{if(a(r))if("@language"in r&&!("@index"in r)){l.push("@language","@language@set"),u=r["@language"];const e=r["@direction"];e&&(u=`${u}_${e}`)}else"@direction"in r&&!("@index"in r)?u=`_${r["@direction"]}`:"@type"in r&&(d="@type",u=r["@type"]);else d="@type",u="@id";l.push("@set")}l.push("@none"),n(r)&&!("@index"in r)&&l.push("@index","@index@set"),a(r)&&1===Object.keys(r).length&&l.push("@language","@language@set");const p=function(e,t,o,r,i,a){null===a&&(a="@null");const s=[];if(("@id"===a||"@reverse"===a)&&n(o)&&"@id"in o){"@reverse"===a&&s.push("@reverse");const t=w.compactIri({activeCtx:e,iri:o["@id"],relativeTo:{vocab:!0}});e.mappings.has(t)&&e.mappings.get(t)&&e.mappings.get(t)["@id"]===o["@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 r){if(!(e in l))continue;const t=l[e][i];for(const e of s)if(e in t)return t[e]}return null}(t,o,r,l,d,u);if(null!==p)return p}if(l.vocab&&"@vocab"in t){const e=t["@vocab"];if(0===o.indexOf(e)&&o!==e){const n=o.substr(e.length);if(!t.mappings.has(n))return n}}let f=null;const h=[];let m=t.fastCurieMap;const x=o.length-1;for(let e=0;e<x&&o[e]in m;++e)m=m[o[e]],""in m&&h.push(m[""][0]);for(let e=h.length-1;e>=0;--e){const n=h[e],i=n.terms;for(const e of i){const i=e+":"+o.substr(n.iri.length);t.mappings.get(e)._prefix&&(!t.mappings.has(i)||null===r&&t.mappings.get(i)["@id"]===o)&&(null===f||b(i,f)<0)&&(f=i)}}if(null!==f)return f;for(const[n,r]of t.mappings)if(r&&r._prefix&&o.startsWith(n+":"))throw new e(`Absolute IRI "${o}" confused with prefix "${n}".`,"jsonld.SyntaxError",{code:"IRI confused with prefix",context:t});if(!l.vocab){if("@base"in t){if(t["@base"]){const e=v(g(d,t["@base"]),o);return y.test(e)?`./${e}`:e}return o}return v(d,o)}return o},w.compactValue=({activeCtx:e,activeProperty:t,value:n,options:r})=>{if(a(n)){const r=u(e,t,"@type"),i=u(e,t,"@language"),a=u(e,t,"@direction"),s=u(e,t,"@container")||[],l="@index"in n&&!s.includes("@index");if(!l&&"@none"!==r){if(n["@type"]===r)return n["@value"];if("@language"in n&&n["@language"]===i&&"@direction"in n&&n["@direction"]===a)return n["@value"];if("@language"in n&&n["@language"]===i)return n["@value"];if("@direction"in n&&n["@direction"]===a)return n["@value"]}const c=Object.keys(n).length,d=1===c||2===c&&"@index"in n&&!l,p="@language"in e,f=o(n["@value"]),h=e.mappings.has(t)&&null===e.mappings.get(t)["@language"];if(d&&"@none"!==r&&(!p||!f||h))return n["@value"];const v={};return l&&(v[w.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=n["@index"]),"@type"in n?v[w.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}})]=w.compactIri({activeCtx:e,iri:n["@type"],relativeTo:{vocab:!0}}):"@language"in n&&(v[w.compactIri({activeCtx:e,iri:"@language",relativeTo:{vocab:!0}})]=n["@language"]),"@direction"in n&&(v[w.compactIri({activeCtx:e,iri:"@direction",relativeTo:{vocab:!0}})]=n["@direction"]),v[w.compactIri({activeCtx:e,iri:"@value",relativeTo:{vocab:!0}})]=n["@value"],v}const i=d(e,t,{vocab:!0},r),s=u(e,t,"@type"),l=w.compactIri({activeCtx:e,iri:n["@id"],relativeTo:{vocab:"@vocab"===s},base:r.base});return"@id"===s||"@vocab"===s||"@graph"===i?l:{[w.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]:l}},fe}function Ve(){if(me)return ye;me=1;const e=De(),t=function(){if(J)return _;J=1;const e=Re(),t={};return _=t,t.setupDocumentLoaders=function(t){"undefined"!=typeof XMLHttpRequest&&(t.documentLoaders.xhr=e,t.useDocumentLoader("xhr"))},t.setupGlobals=function(e){void 0===globalThis.JsonLdProcessor&&Object.defineProperty(globalThis,"JsonLdProcessor",{writable:!0,enumerable:!1,configurable:!0,value:e.JsonLdProcessor})},_}(),n=Ce(),o=Je(),r=n.IdentifierIssuer,i=Ee(),a=_e(),s=Pe(),{expand:l}=He(),{flatten:c}=function(){if(re)return oe;re=1;const{isSubjectReference:e}=Oe(),{createMergedNodeMap:t}=Be(),n={};return oe=n,n.flatten=n=>{const o=t(n),r=[],i=Object.keys(o).sort();for(let t=0;t<i.length;++t){const n=o[i[t]];e(n)||r.push(n)}return r},oe}(),{fromRDF:d}=function(){if(ae)return ie;ae=1;const e=Ee(),t=Oe(),n=Ne(),{REGEX_BCP47:o,addValue:r}=Ce(),{handleEvent:i}=Me(),{RDF_LIST:a,RDF_FIRST:s,RDF_REST:l,RDF_NIL:c,RDF_TYPE:d,RDF_JSON_LITERAL:u,XSD_BOOLEAN:p,XSD_DOUBLE:f,XSD_INTEGER:h,XSD_STRING:v}=ke(),g={};function y(t,r,a,s){const l=m(t);if(l)return{"@id":l};const c={"@value":t.value};if(t.language)t.language.match(o)||s.eventHandler&&i({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:t.language}},options:s}),c["@language"]=t.language;else{let l=t.datatype.value;if(l||(l=v),l===u){l="@json";try{c["@value"]=JSON.parse(c["@value"])}catch(t){throw new e("JSON literal could not be parsed.","jsonld.InvalidJsonLiteral",{code:"invalid JSON literal",value:c["@value"],cause:t})}}if(r)if(l===p)"true"===c["@value"]||"1"===c["@value"]?c["@value"]=!0:"false"===c["@value"]||"0"===c["@value"]?c["@value"]=!1:c["@type"]=l;else if(l===h)if(n.isNumeric(c["@value"])){const e=parseInt(c["@value"],10);e.toFixed(0)===c["@value"]&&(c["@value"]=e)}else c["@type"]=l;else l===f&&n.isNumeric(c["@value"])?c["@value"]=parseFloat(c["@value"]):c["@type"]=l;else if("i18n-datatype"===a&&l.startsWith("https://www.w3.org/ns/i18n#")){const[,e,t]=l.split(/[#_]/);e.length>0&&(c["@language"]=e,e.match(o)||s.eventHandler&&i({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:s})),c["@direction"]=t}else l!==v&&(c["@type"]=l)}return c}function m(e){return"NamedNode"===e.termType?e.value:"BlankNode"===e.termType?"_:"+e.value:null}return ie=g,g.fromRDF=async(o,i)=>{const{useRdfType:u=!1,useNativeTypes:p=!1,rdfDirection:f=null}=i,h={},v={"@default":h},g={};if(f){if("compound-literal"===f)throw new e("Unsupported rdfDirection value.","jsonld.InvalidRdfDirection",{value:f});if("i18n-datatype"!==f)throw new e("Unknown rdfDirection value.","jsonld.InvalidRdfDirection",{value:f})}for(const e of o){const t="DefaultGraph"===e.graph.termType?"@default":e.graph.value;t in v||(v[t]={}),"@default"===t||t in h||(h[t]={"@id":t});const n=v[t],o=m(e.subject),a=e.predicate.value,s=e.object;o in n||(n[o]={"@id":o});const l=n[o],x=m(s),b=!!x;if(b&&!(x in n)&&(n[x]={"@id":x}),a===d&&!u&&b){r(l,"@type",x,{propertyIsArray:!0});continue}const w=y(s,p,f,i);if(r(l,a,w,{propertyIsArray:!0}),b)if(x===c){const e=n[x];"usages"in e||(e.usages=[]),e.usages.push({node:l,property:a,value:w})}else g[x]=!(x in g)&&{node:l,property:a,value:w}}for(const e in v){const o=v[e];if(!(c in o))continue;const r=o[c];if(r.usages){for(let e of r.usages){let r=e.node,i=e.property,c=e.value;const d=[],u=[];let p=Object.keys(r).length;for(;i===l&&n.isObject(g[r["@id"]])&&n.isArray(r[s])&&1===r[s].length&&n.isArray(r[l])&&1===r[l].length&&(3===p||4===p&&n.isArray(r["@type"])&&1===r["@type"].length&&r["@type"][0]===a)&&(d.push(r[s][0]),u.push(r["@id"]),e=g[r["@id"]],r=e.node,i=e.property,c=e.value,p=Object.keys(r).length,t.isBlankNode(r)););delete c["@id"],c["@list"]=d.reverse();for(const e of u)delete o[e]}delete r.usages}}const x=[],b=Object.keys(h).sort();for(const e of b){const n=h[e];if(e in v){const o=n["@graph"]=[],r=v[e],i=Object.keys(r).sort();for(const e of i){const n=r[e];t.isSubjectReference(n)||o.push(n)}}t.isSubjectReference(n)||x.push(n)}return x},ie}(),{toRDF:u}=qe(),{frameMergedOrDefault:p,cleanupNull:f}=Ue(),{isArray:h,isObject:v,isString:g}=Ne(),{isSubjectReference:y}=Oe(),{expandIri:m,getInitialContext:x,process:b,processingMode:w}=Fe(),{compact:I,compactIri:j}=$e(),{createNodeMap:S,createMergedNodeMap:D,mergeNodeMaps:N}=Be(),{logEventHandler:O,logWarningEventHandler:E,safeEventHandler:C,setDefaultEventHandler:k,setupEventHandler:L,strictEventHandler:A,unhandledEventHandler:R}=Me(),T=function(T){const _={},J=new a({max:100});function P(e,{documentLoader:t=T.documentLoader,...n}){if(e&&"compactionMap"in e)throw new i('"compactionMap" not supported.',"jsonld.OptionsError");if(e&&"expansionMap"in e)throw new i('"expansionMap" not supported.',"jsonld.OptionsError");return Object.assign({},{documentLoader:t},n,e,{eventHandler:L({options:e})})}return T.compact=async function(e,t,a){if(arguments.length<2)throw new TypeError("Could not compact, too few arguments.");if(null===t)throw new i("The compaction context must not be null.","jsonld.CompactError",{code:"invalid local context"});if(null===e)return null;let s;(a=P(a,{base:g(e)?e:"",compactArrays:!0,compactToRelative:!0,graph:!1,skipExpansion:!1,link:!1,issuer:new r("_:b"),contextResolver:new o({sharedCache:J})})).link&&(a.skipExpansion=!0),a.compactToRelative||delete a.base,s=a.skipExpansion?e:await T.expand(e,a);const l=await T.processContext(x(a),t,a);let c=await I({activeCtx:l,element:s,options:a});a.compactArrays&&!a.graph&&h(c)?1===c.length?c=c[0]:0===c.length&&(c={}):a.graph&&v(c)&&(c=[c]),v(t)&&"@context"in t&&(t=t["@context"]),t=n.clone(t),h(t)||(t=[t]);const d=t;t=[];for(let e=0;e<d.length;++e)(!v(d[e])||Object.keys(d[e]).length>0)&&t.push(d[e]);const u=t.length>0;if(1===t.length&&(t=t[0]),h(c)){const e=j({activeCtx:l,iri:"@graph",relativeTo:{vocab:!0}}),n=c;c={},u&&(c["@context"]=t),c[e]=n}else if(v(c)&&u){const e=c;c={"@context":t};for(const t in e)c[t]=e[t]}return c},T.expand=async function(e,t){if(arguments.length<1)throw new TypeError("Could not expand, too few arguments.");const r={},i=[];if("expandContext"in(t=P(t,{keepFreeFloatingNodes:!1,contextResolver:new o({sharedCache:J})}))){const e=n.clone(t.expandContext);v(e)&&"@context"in e?r.expandContext=e:r.expandContext={"@context":e},i.push(r.expandContext)}let a;if(g(e)){const n=await T.get(e,t);a=n.documentUrl,r.input=n.document,n.contextUrl&&(r.remoteContext={"@context":n.contextUrl},i.push(r.remoteContext))}else r.input=n.clone(e);"base"in t||(t.base=a||"");let s=x(t);for(const e of i)s=await b({activeCtx:s,localCtx:e,options:t});let c=await l({activeCtx:s,element:r.input,options:t});return v(c)&&"@graph"in c&&1===Object.keys(c).length?c=c["@graph"]:null===c&&(c=[]),h(c)||(c=[c]),c},T.flatten=async function(e,t,n){if(arguments.length<1)return new TypeError("Could not flatten, too few arguments.");t="function"==typeof t?null:t||null,n=P(n,{base:g(e)?e:"",contextResolver:new o({sharedCache:J})});const r=await T.expand(e,n),i=c(r);if(null===t)return i;n.graph=!0,n.skipExpansion=!0;return await T.compact(i,t,n)},T.frame=async function(e,t,n){if(arguments.length<2)throw new TypeError("Could not frame, too few arguments.");if(n=P(n,{base:g(e)?e:"",embed:"@once",explicit:!1,requireAll:!1,omitDefault:!1,bnodesToClear:[],contextResolver:new o({sharedCache:J})}),g(t)){const e=await T.get(t,n);if(t=e.document,e.contextUrl){let n=t["@context"];n?h(n)?n.push(e.contextUrl):n=[n,e.contextUrl]:n=e.contextUrl,t["@context"]=n}}const r=t&&t["@context"]||{},i=await T.processContext(x(n),r,n);n.hasOwnProperty("omitGraph")||(n.omitGraph=w(i,1.1)),n.hasOwnProperty("pruneBlankNodeIdentifiers")||(n.pruneBlankNodeIdentifiers=w(i,1.1));const a=await T.expand(e,n),s={...n};s.isFrame=!0,s.keepFreeFloatingNodes=!0;const l=await T.expand(t,s),c=Object.keys(t).map(e=>m(i,e,{vocab:!0}));s.merged=!c.includes("@graph"),s.is11=w(i,1.1);const d=p(a,l,s);s.graph=!n.omitGraph,s.skipExpansion=!0,s.link={},s.framing=!0;let u=await T.compact(d,r,s);return s.link={},u=f(u,s),u},T.link=async function(e,t,n){const o={};return t&&(o["@context"]=t),o["@embed"]="@link",T.frame(e,o,n)},T.normalize=T.canonize=async function(t,n){if(arguments.length<1)throw new TypeError("Could not canonize, too few arguments.");n=P(n,{skipExpansion:!1,safe:!0,contextResolver:new o({sharedCache:J})});const r=Object.assign({},{algorithm:"RDFC-1.0"},n.canonizeOptions||null);if("inputFormat"in n){if("application/n-quads"!==n.inputFormat)throw new i("Unknown canonicalization input format.","jsonld.CanonizeError");const o=s.parse(t);return e.canonize(o,r)}const a={...n};delete a.format,delete a.canonizeOptions,a.produceGeneralizedRdf=!1;const l=await T.toRDF(t,a);return e.canonize(l,r)},T.fromRDF=async function(e,t){if(arguments.length<1)throw new TypeError("Could not convert from RDF, too few arguments.");t=P(t,{format:g(e)?"application/n-quads":void 0});const{format:n}=t;let{rdfParser:o}=t;if(n){if(o=o||_[n],!o)throw new i("Unknown input format.","jsonld.UnknownFormat",{format:n})}else o=()=>e;const r=await o(e);return d(r,t)},T.toRDF=async function(e,t){if(arguments.length<1)throw new TypeError("Could not convert to RDF, too few arguments.");let n;n=(t=P(t,{skipExpansion:!1,contextResolver:new o({sharedCache:J})})).skipExpansion?e:await T.expand(e,t);const r=u(n,t);if(t.format){if("application/n-quads"===t.format)return s.serialize(r);throw new i("Unknown output format.","jsonld.UnknownFormat",{format:t.format})}return r},T.createNodeMap=async function(e,t){if(arguments.length<1)throw new TypeError("Could not create node map, too few arguments.");t=P(t,{base:g(e)?e:"",contextResolver:new o({sharedCache:J})});const n=await T.expand(e,t);return D(n,t)},T.merge=async function(e,t,i){if(arguments.length<1)throw new TypeError("Could not merge, too few arguments.");if(!h(e))throw new TypeError('Could not merge, "docs" must be an array.');t="function"==typeof t?null:t||null,i=P(i,{contextResolver:new o({sharedCache:J})});const a=await Promise.all(e.map(e=>{const t={...i};return T.expand(e,t)}));let s=!0;"mergeNodes"in i&&(s=i.mergeNodes);const l=i.issuer||new r("_:b"),c={"@default":{}};for(let e=0;e<a.length;++e){const t=n.relabelBlankNodes(a[e],{issuer:new r("_:b"+e+"-")}),o=s||0===e?c:{"@default":{}};if(S(t,o,"@default",l),o!==c)for(const e in o){const t=o[e];if(!(e in c)){c[e]=t;continue}const n=c[e];for(const e in t)e in n||(n[e]=t[e])}}const d=N(c),u=[],p=Object.keys(d).sort();for(let e=0;e<p.length;++e){const t=d[p[e]];y(t)||u.push(t)}if(null===t)return u;i.graph=!0,i.skipExpansion=!0;return await T.compact(u,t,i)},Object.defineProperty(T,"documentLoader",{get:()=>T._documentLoader,set:e=>T._documentLoader=e}),T.documentLoader=async e=>{throw new i("Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.","jsonld.LoadDocumentError",{code:"loading document failed",url:e})},T.get=async function(e,t){let n;n="function"==typeof t.documentLoader?t.documentLoader:T.documentLoader;const o=await n(e);try{if(!o.document)throw new i("No remote document found at the given URL.","jsonld.NullRemoteDocument");g(o.document)&&(o.document=JSON.parse(o.document))}catch(e){throw new i("Could not retrieve a JSON-LD document from the URL.","jsonld.LoadDocumentError",{code:"loading document failed",cause:e,remoteDoc:o})}return o},T.processContext=async function(e,t,r){return r=P(r,{base:"",contextResolver:new o({sharedCache:J})}),null===t?x(r):(t=n.clone(t),v(t)&&"@context"in t||(t={"@context":t}),b({activeCtx:e,localCtx:t,options:r}))},T.getContextValue=Fe().getContextValue,T.documentLoaders={},T.useDocumentLoader=function(e){if(!(e in T.documentLoaders))throw new i('Unknown document loader type: "'+e+'"',"jsonld.UnknownDocumentLoader",{type:e});T.documentLoader=T.documentLoaders[e].apply(T,Array.prototype.slice.call(arguments,1))},T.registerRDFParser=function(e,t){_[e]=t},T.unregisterRDFParser=function(e){delete _[e]},T.registerRDFParser("application/n-quads",s.parse),T.url=Ae(),T.logEventHandler=O,T.logWarningEventHandler=E,T.safeEventHandler=C,T.setDefaultEventHandler=k,T.strictEventHandler=A,T.unhandledEventHandler=R,T.util=n,Object.assign(T,n),T.promises=T,T.RequestQueue=Le(),T.JsonLdProcessor=(ge||(ge=1,ve=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}),ve)(T),t.setupGlobals(T),t.setupDocumentLoaders(T),T},P=function(){return T(function(){return P()})};return T(P),ye=P}var ze=e(Ve());class Ge{constructor(e){}}export{Ge as S,Ve as a,ze as j,De as r};
@@ -1 +0,0 @@
1
- import{r}from"./index-DNlz8u7B-CYTlxhyY.js";import{A as o,V as a,z as e,g as t}from"./main.js";var s=r();async function c(r,c){Array.isArray(c)||(c=[c]),Array.isArray(r)||(r=[r]);for(const i of c){const c=await o({url:i.id});let n;try{n=JSON.parse(c)}catch(r){throw console.error(r),new Error(`Specified schema at url: ${i.id} could not be parsed`)}const f=s.validator(n);for(const o of r){if(!f(o))throw new a(e.checkCredentialSchemaConformity,t("errors","checkCredentialSchemaConformity"))}}}export{c as default};
@@ -1,13 +0,0 @@
1
- import{V as t,z as e,d as n,C as i,A as o,D as s,F as r,u as a,t as c}from"./main.js";import{g as u,u as d}from"./pako.esm-BGRKTPxS-Bodm4Eha.js";
2
- /*!
3
- * Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.
4
- */function h(t,e){if("number"!=typeof t)throw new TypeError(`"${e}" must be number.`)}function f(t,e){if(!(Number.isInteger(t)&&t>0))throw new TypeError(`"${e}" must be a positive integer.`)}function g(t,e){if("boolean"!=typeof t)throw new TypeError(`"${e}" must be a boolean.`)}function l(t,e){if(!(t instanceof Uint8Array))throw new TypeError(`"${e}" must be a Uint8Array.`)}
5
- /*!
6
- * Copyright (c) 2020-2023 Digital Bazaar, Inc. All rights reserved.
7
- */class w{constructor({length:t,buffer:e,leftToRightIndexing:n,littleEndianBits:i}={}){if(t&&e)throw new Error('Only one of "length" or "buffer" must be given.');if(void 0!==t?f(t,"length"):l(e,"buffer"),void 0!==i){if(void 0!==n)throw new Error('Using both "littleEndianBits" and "leftToRightIndexing" is not allowed.');g(i,"littleEndianBits"),n=i}void 0===n?n=!0:g(n,"leftToRightIndexing"),t?(this.bits=new Uint8Array(Math.ceil(t/8)),this.length=t):(this.bits=new Uint8Array(e.buffer),this.length=8*e.length),this.leftToRightIndexing=n}set(t,e){h(t,"position"),g(e,"on");const{length:n,leftToRightIndexing:i}=this,{index:o,bit:s}=b(t,n,i);e?this.bits[o]|=s:this.bits[o]&=255^s}get(t){h(t,"position");const{length:e,leftToRightIndexing:n}=this,{index:i,bit:o}=b(t,e,n);return!!(this.bits[i]&o)}async encodeBits(){return a(u(this.bits))}static async decodeBits({encoded:t}){return function(t,e){if("string"!=typeof t)throw new TypeError(`"${e}" must be a string.`)}(t,"encoded"),d(c(t))}async compressBits(){return u(this.bits)}static async uncompressBits({compressed:t}){return l(t,"compressed"),d(t)}}function b(t,e,n){if(function(t,e){if(!(Number.isInteger(t)&&t>=0))throw new TypeError(`"${e}" must be a non-negative integer.`)}(t,"position"),f(e,"length"),g(n,"leftToRightIndexing"),t>=e)throw new Error(`Position "${t}" is out of range "0-${e-1}".`);const i=t%8;return{index:Math.floor(t/8),bit:1<<(n?7-i:i)}}
8
- /*!
9
- * Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved.
10
- */class y{constructor({length:t,buffer:e}={}){this.bitstring=new w({length:t,buffer:e}),this.length=this.bitstring.length}setRevoked(t,e){if("boolean"!=typeof e)throw new TypeError('"revoked" must be a boolean.');return this.bitstring.set(t,e)}isRevoked(t){return this.bitstring.get(t)}async encode(){return this.bitstring.encodeBits()}static async decode({encodedList:t}){const e=await w.decodeBits({encoded:t});return new y({buffer:e})}}
11
- /*!
12
- * Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved.
13
- */async function v({encodedList:t}){return y.decode({encodedList:t})}async function p(i){const s=await o({url:i}).catch(o=>{throw console.error(o),new t(e.checkRevokedStatus,`${n.i18n.getText("revocation","noRevocationStatusList2021Found")} ${i}.`)});if(s)try{return JSON.parse(s)}catch(o){throw console.error(o),new t(e.checkRevokedStatus,`${n.i18n.getText("revocation","noRevocationStatusList2021Found")} ${i}.`)}return s}async function R(i){const o=new s(i);await o.init();if((await o.verify()).status===r.FAILURE)throw new t(e.checkRevokedStatus,n.i18n.getText("revocation","revocationListAuthenticityFailure"))}async function m(o){Array.isArray(o)||(o=[o]);for(const s of o){const o=parseInt(s.statusListIndex,10),r=await p(s.statusListCredential);if(!r)throw new t(e.checkRevokedStatus,`${n.i18n.getText("revocation","noRevocationStatusList2021Found")} ${s.statusListCredential}.`);await R(r);const{encodedList:a}=r.credentialSubject;if((await v({encodedList:a})).isRevoked(o)){const o="revocation"===s.statusPurpose?i.REVOKED:i.SUSPENDED;throw new t(e.checkRevokedStatus,n.certificates.generateRevocationReason("",o))}}}export{m as default};
@@ -1 +0,0 @@
1
- import{q as e,V as s,g as r}from"./main.js";function i(i,n,o){let t="";const d=function(e,s){let r=null;for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&i.toLowerCase()===s.toLowerCase()&&(r=i);return e[r]}(i,n),a=e(o);if(d?(d.created&&a<=d.created&&(t="invalidIssuingAddressCreationTime"),d.revoked&&a>=d.revoked&&(t="invalidIssuingAddressRevoked"),d.expires&&a>=d.expires&&(t="invalidIssuingAddressExpired")):t="invalidIssuingAddressUnknown",t)throw new s("checkAuthenticity",r("errors",t))}export{i as e};
@@ -1,29 +0,0 @@
1
- import{t as e,f as t,v as r}from"./main.js";import{a as n,r as i,b as o,c as s,h as c,d as u,i as a,e as f,f as l,g as d,s as y}from"./sha2-JcCWfgvE-By1_saxP.js";
2
- /*!
3
- * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
4
- */
5
- const h="ECDSA",p=!0,w="https://w3id.org/security/suites/ecdsa-2019/v1",b="https://w3id.org/security/multikey/v1",g="z",m=new Uint8Array([231,1]),E=new Uint8Array([128,36]),v=new Uint8Array([129,36]),B=new Uint8Array([130,36]),x=new Uint8Array([129,38]),k=new Uint8Array([134,38]),K=new Uint8Array([135,38]),R=new Uint8Array([136,38]),O="P-256",A="P-384",U="P-521",S="K-256",I="SHA-256",q="SHA-384",C="SHA-512",M=globalThis.crypto,N=globalThis.CryptoKey??M.CryptoKey;function j({curve:e}){if(e===O||e===S)return I;if(e===A)return q;if(e===U)return C;throw new TypeError(`Unsupported curve "${e}".`)}
6
- /*!
7
- * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
8
- */function T({publicMultikey:e}){if(e[0]===E[0]&&e[1]===E[1])return O;if(e[0]===v[0]&&e[1]===v[1])return A;if(e[0]===B[0]&&e[1]===B[1])return U;if(e[0]===m[0]&&e[1]===m[1])return S;throw new TypeError("Unsupported public multikey header.")}function F({secretMultikey:e}){if(e[0]===k[0]&&e[1]===k[1])return O;if(e[0]===K[0]&&e[1]===K[1])return A;if(e[0]===R[0]&&e[1]===R[1])return U;if(e[0]===x[0]&&e[1]===x[1])return S;throw new TypeError("Unsupported secret multikey header.")}function P({curve:e}){if(e===O||e===S)return 32;if(e===A)return 48;if(e===U)return 66;throw new TypeError(`Unsupported curve "${e}".`)}
9
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
10
- const H=BigInt(0),Z=BigInt(1);function V(e,t=""){if("boolean"!=typeof e){throw new Error((t&&`"${t}" `)+"expected boolean, got type="+typeof e)}return e}function D(e){if("bigint"==typeof e){if(!G(e))throw new Error("positive bigint expected, got "+e)}else d(e);return e}function L(e){const t=D(e).toString(16);return 1&t.length?"0"+t:t}function _(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?H:BigInt("0x"+e)}function $(e){return _(o(e))}function Y(e){return _(o(function(e){return Uint8Array.from(e)}(s(e)).reverse()))}function z(e,t){d(t),e=D(e);const r=c(e.toString(16).padStart(2*t,"0"));if(r.length!==t)throw new Error("number too large");return r}function X(e,t){return z(e,t).reverse()}const G=e=>"bigint"==typeof e&&H<=e;function W(e,t,r,n){if(!function(e,t,r){return G(e)&&G(t)&&G(r)&&t<=e&&e<r}(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}const J=e=>(Z<<BigInt(e))-Z;function Q(e,t={},r={}){if(!e||"object"!=typeof e)throw new Error("expected valid options object");const n=(t,r)=>Object.entries(t).forEach(([t,n])=>function(t,r,n){const i=e[t];if(n&&void 0===i)return;const o=typeof i;if(o!==r||null===i)throw new Error(`param "${t}" is invalid: expected ${r}, got ${o}`)}(t,n,r));n(t,!1),n(r,!0)}function ee(e){const t=new WeakMap;return(r,...n)=>{const i=t.get(r);if(void 0!==i)return i;const o=e(r,...n);return t.set(r,o),o}}
11
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const te=BigInt(0),re=BigInt(1),ne=BigInt(2),ie=BigInt(3),oe=BigInt(4),se=BigInt(5),ce=BigInt(7),ue=BigInt(8),ae=BigInt(9),fe=BigInt(16);function le(e,t){const r=e%t;return r>=te?r:t+r}function de(e,t,r){let n=e;for(;t-- >te;)n*=n,n%=r;return n}function ye(e,t){if(e===te)throw new Error("invert: expected non-zero number");if(t<=te)throw new Error("invert: expected positive modulus, got "+t);let r=le(e,t),n=t,i=te,o=re;for(;r!==te;){const e=n%r,t=i-o*(n/r);n=r,r=e,i=o,o=t}if(n!==re)throw new Error("invert: does not exist");return le(i,t)}function he(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function pe(e,t){const r=(e.ORDER+re)/oe,n=e.pow(t,r);return he(e,n,t),n}function we(e,t){const r=(e.ORDER-se)/ue,n=e.mul(t,ne),i=e.pow(n,r),o=e.mul(t,i),s=e.mul(e.mul(o,ne),i),c=e.mul(o,e.sub(s,e.ONE));return he(e,c,t),c}function be(e){if(e<ie)throw new Error("sqrt is not defined for small field");let t=e-re,r=0;for(;t%ne===te;)t/=ne,r++;let n=ne;const i=xe(e);for(;1===ve(i,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===r)return pe;let o=i.pow(n,t);const s=(t+re)/ne;return function(e,n){if(e.is0(n))return n;if(1!==ve(e,n))throw new Error("Cannot find square root");let i=r,c=e.mul(e.ONE,o),u=e.pow(n,t),a=e.pow(n,s);for(;!e.eql(u,e.ONE);){if(e.is0(u))return e.ZERO;let t=1,r=e.sqr(u);for(;!e.eql(r,e.ONE);)if(t++,r=e.sqr(r),t===i)throw new Error("Cannot find square root");const n=re<<BigInt(i-t-1),o=e.pow(c,n);i=t,c=e.sqr(o),u=e.mul(u,c),a=e.mul(a,o)}return a}}function ge(e){return e%oe===ie?pe:e%ue===se?we:e%fe===ae?function(e){const t=xe(e),r=be(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+ce)/fe;return(e,t)=>{let r=e.pow(t,s),c=e.mul(r,n);const u=e.mul(r,i),a=e.mul(r,o),f=e.eql(e.sqr(c),t),l=e.eql(e.sqr(u),t);r=e.cmov(r,c,f),c=e.cmov(a,u,l);const d=e.eql(e.sqr(c),t),y=e.cmov(r,c,d);return he(e,y,t),y}}(e):be(e)}const me=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ee(e,t,r=!1){const n=new Array(t.length).fill(r?e.ZERO:void 0),i=t.reduce((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r)),e.ONE),o=e.inv(i);return t.reduceRight((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r)),o),n}function ve(e,t){const r=(e.ORDER-re)/ne,n=e.pow(t,r),i=e.eql(n,e.ONE),o=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!i&&!o&&!s)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}class Be{ORDER;BITS;BYTES;isLE;ZERO=te;ONE=re;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=te)throw new Error("invalid field: expected ORDER > 0, got "+e);let r;this.isLE=!1,null!=t&&"object"==typeof t&&("number"==typeof t.BITS&&(r=t.BITS),"function"==typeof t.sqrt&&(this.sqrt=t.sqrt),"boolean"==typeof t.isLE&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=t.allowedLengths?.slice()),"boolean"==typeof t.modFromBytes&&(this._mod=t.modFromBytes));const{nBitLength:n,nByteLength:i}=function(e,t){void 0!==t&&d(t);const r=void 0!==t?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}(e,r);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=n,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return le(e,this.ORDER)}isValid(e){if("bigint"!=typeof e)throw new Error("invalid field element: expected bigint, got "+typeof e);return te<=e&&e<this.ORDER}is0(e){return e===te}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&re)===re}neg(e){return le(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return le(e*e,this.ORDER)}add(e,t){return le(e+t,this.ORDER)}sub(e,t){return le(e-t,this.ORDER)}mul(e,t){return le(e*t,this.ORDER)}pow(e,t){return function(e,t,r){if(r<te)throw new Error("invalid exponent, negatives unsupported");if(r===te)return e.ONE;if(r===re)return t;let n=e.ONE,i=t;for(;r>te;)r&re&&(n=e.mul(n,i)),i=e.sqr(i),r>>=re;return n}(this,e,t)}div(e,t){return le(e*ye(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return ye(e,this.ORDER)}sqrt(e){return this._sqrt||(this._sqrt=ge(this.ORDER)),this._sqrt(this,e)}toBytes(e){return this.isLE?X(e,this.BYTES):z(e,this.BYTES)}fromBytes(e,t=!1){s(e);const{_lengths:r,BYTES:n,isLE:i,ORDER:o,_mod:c}=this;if(r){if(!r.includes(e.length)||e.length>n)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);const t=new Uint8Array(n);t.set(e,i?0:t.length-e.length),e=t}if(e.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let u=i?Y(e):$(e);if(c&&(u=le(u,o)),!t&&!this.isValid(u))throw new Error("invalid field element: outside of range 0..ORDER");return u}invertBatch(e){return Ee(this,e)}cmov(e,t,r){return r?t:e}}function xe(e,t={}){return new Be(e,t)}function ke(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function Ke(e){const t=ke(e);return t+Math.ceil(t/2)}
12
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
13
- const Re=BigInt(0),Oe=BigInt(1);function Ae(e,t){const r=t.negate();return e?r:t}function Ue(e,t){const r=Ee(e.Fp,t.map(e=>e.Z));return t.map((t,n)=>e.fromAffine(t.toAffine(r[n])))}function Se(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Ie(e,t){Se(e,t);const r=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:J(e),maxNumber:r,shiftBy:BigInt(e)}}function qe(e,t,r){const{windowSize:n,mask:i,maxNumber:o,shiftBy:s}=r;let c=Number(e&i),u=e>>s;c>n&&(c-=o,u+=Oe);const a=t*n;return{nextN:u,offset:a+Math.abs(c)-1,isZero:0===c,isNeg:c<0,isNegF:t%2!=0,offsetF:a}}const Ce=new WeakMap,Me=new WeakMap;function Ne(e){return Me.get(e)||1}function je(e){if(e!==Re)throw new Error("invalid wNAF")}class Te{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let n=e;for(;t>Re;)t&Oe&&(r=r.add(n)),n=n.double(),t>>=Oe;return r}precomputeWindow(e,t){const{windows:r,windowSize:n}=Ie(t,this.bits),i=[];let o=e,s=o;for(let e=0;e<r;e++){s=o,i.push(s);for(let e=1;e<n;e++)s=s.add(o),i.push(s);o=s.double()}return i}wNAF(e,t,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let n=this.ZERO,i=this.BASE;const o=Ie(e,this.bits);for(let e=0;e<o.windows;e++){const{nextN:s,offset:c,isZero:u,isNeg:a,isNegF:f,offsetF:l}=qe(r,e,o);r=s,u?i=i.add(Ae(f,t[l])):n=n.add(Ae(a,t[c]))}return je(r),{p:n,f:i}}wNAFUnsafe(e,t,r,n=this.ZERO){const i=Ie(e,this.bits);for(let e=0;e<i.windows&&r!==Re;e++){const{nextN:o,offset:s,isZero:c,isNeg:u}=qe(r,e,i);if(r=o,!c){const e=t[s];n=n.add(u?e.negate():e)}}return je(r),n}getPrecomputes(e,t,r){let n=Ce.get(t);return n||(n=this.precomputeWindow(t,e),1!==e&&("function"==typeof r&&(n=r(n)),Ce.set(t,n))),n}cached(e,t,r){const n=Ne(e);return this.wNAF(n,this.getPrecomputes(n,e,r),t)}unsafe(e,t,r,n){const i=Ne(e);return 1===i?this._unsafeLadder(e,t,n):this.wNAFUnsafe(i,this.getPrecomputes(i,e,r),t,n)}createCache(e,t){Se(t,this.bits),Me.set(e,t),Ce.delete(e)}hasCache(e){return 1!==Ne(e)}}function Fe(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(e){Q(e,me.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",BYTES:"number",BITS:"number"}))}(t),t}return xe(e,{isLE:r})}class Pe{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(n(e),s(t,void 0,"key"),this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(t.length>r?e.create().update(t).digest():t);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),f(i)}update(e){return l(this),this.iHash.update(e),this}digestInto(e){l(this),s(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});const{oHash:t,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return e.finished=n,e.destroyed=i,e.blockLen=o,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const He=(e,t,r)=>new Pe(e,t).update(r).digest();He.create=(e,t)=>new Pe(e,t);
14
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
15
- const Ze=(e,t)=>(e+(e>=0?t:-t)/Xe)/t;function Ve(e,t,r){const[[n,i],[o,s]]=t,c=Ze(s*e,r),u=Ze(-i*e,r);let a=e-c*n-u*o,f=-c*i-u*s;const l=a<Ye,d=f<Ye;l&&(a=-a),d&&(f=-f);const y=J(Math.ceil(function(e){let t;for(t=0;e>H;e>>=Z,t+=1);return t}(r)/2))+ze;if(a<Ye||a>=y||f<Ye||f>=y)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:l,k1:a,k2neg:d,k2:f}}function De(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Le(e,t){const r={};for(let n of Object.keys(t))r[n]=void 0===e[n]?t[n]:e[n];return V(r.lowS,"lowS"),V(r.prehash,"prehash"),void 0!==r.format&&De(r.format),r}class _e extends Error{constructor(e=""){super(e)}}const $e={Err:_e,_tlv:{encode:(e,t)=>{const{Err:r}=$e;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(1&t.length)throw new r("tlv.encode: unpadded data");const n=t.length/2,i=L(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");const o=n>127?L(i.length/2|128):"";return L(e)+o+i+t},decode(e,t){const{Err:r}=$e;let n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");const i=t[n++];let o=0;if(!!(128&i)){const e=127&i;if(!e)throw new r("tlv.decode(long): indefinite length not supported");if(e>4)throw new r("tlv.decode(long): byte length is too big");const s=t.subarray(n,n+e);if(s.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===s[0])throw new r("tlv.decode(long): zero leftmost byte");for(const e of s)o=o<<8|e;if(n+=e,o<128)throw new r("tlv.decode(long): not minimal encoding")}else o=i;const s=t.subarray(n,n+o);if(s.length!==o)throw new r("tlv.decode: wrong value length");return{v:s,l:t.subarray(n+o)}}},_int:{encode(e){const{Err:t}=$e;if(e<Ye)throw new t("integer: negative integers are not allowed");let r=L(e);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){const{Err:t}=$e;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return $(e)}},toSig(e){const{Err:t,_int:r,_tlv:n}=$e,i=s(e,void 0,"signature"),{v:o,l:c}=n.decode(48,i);if(c.length)throw new t("invalid signature: left bytes after parsing");const{v:u,l:a}=n.decode(2,o),{v:f,l:l}=n.decode(2,a);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(u),s:r.decode(f)}},hexFromSig(e){const{_tlv:t,_int:r}=$e,n=t.encode(2,r.encode(e.r))+t.encode(2,r.encode(e.s));return t.encode(48,n)}},Ye=BigInt(0),ze=BigInt(1),Xe=BigInt(2),Ge=BigInt(3),We=BigInt(4);function Je(e,t={}){const r=function(e,t,r={},n){if(void 0===n&&(n="edwards"===e),!t||"object"!=typeof t)throw new Error(`expected valid ${e} CURVE object`);for(const e of["p","n","h"]){const r=t[e];if(!("bigint"==typeof r&&r>Re))throw new Error(`CURVE.${e} must be positive bigint`)}const i=Fe(t.p,r.Fp,n),o=Fe(t.n,r.Fn,n),s=["Gx","Gy","a","b"];for(const e of s)if(!i.isValid(t[e]))throw new Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:i,Fn:o}}("weierstrass",e,t),{Fp:n,Fn:i}=r;let a=r.CURVE;const{h:f,n:l}=a;Q(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});const{endo:d}=t;if(d&&(!n.is0(a.a)||"bigint"!=typeof d.beta||!Array.isArray(d.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const y=et(n,i);function h(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const p=t.toBytes||function(e,t,r){const{x:i,y:o}=t.toAffine(),s=n.toBytes(i);if(V(r,"isCompressed"),r){h();const e=!n.isOdd(o);return u(Qe(e),s)}return u(Uint8Array.of(4),s,n.toBytes(o))},w=t.fromBytes||function(e){s(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:r}=y,i=e.length,o=e[0],c=e.subarray(1);if(i!==t||2!==o&&3!==o){if(i===r&&4===o){const e=n.BYTES,t=n.fromBytes(c.subarray(0,e)),r=n.fromBytes(c.subarray(e,2*e));if(!g(t,r))throw new Error("bad point: is not on curve");return{x:t,y:r}}throw new Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${r}`)}{const e=n.fromBytes(c);if(!n.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=b(e);let r;try{r=n.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}h();return!(1&~o)!==n.isOdd(r)&&(r=n.neg(r)),{x:e,y:r}}};function b(e){const t=n.sqr(e),r=n.mul(t,e);return n.add(n.add(r,n.mul(e,a.a)),a.b)}function g(e,t){const r=n.sqr(t),i=b(e);return n.eql(r,i)}if(!g(a.Gx,a.Gy))throw new Error("bad curve params: generator point");const m=n.mul(n.pow(a.a,Ge),We),E=n.mul(n.sqr(a.b),BigInt(27));if(n.is0(n.add(m,E)))throw new Error("bad curve params: a or b");function v(e,t,r=!1){if(!n.isValid(t)||r&&n.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function B(e){if(!(e instanceof O))throw new Error("Weierstrass Point expected")}function x(e){if(!d||!d.basises)throw new Error("no endo");return Ve(e,d.basises,i.ORDER)}const k=ee((e,t)=>{const{X:r,Y:i,Z:o}=e;if(n.eql(o,n.ONE))return{x:r,y:i};const s=e.is0();null==t&&(t=s?n.ONE:n.inv(o));const c=n.mul(r,t),u=n.mul(i,t),a=n.mul(o,t);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(a,n.ONE))throw new Error("invZ was invalid");return{x:c,y:u}}),K=ee(e=>{if(e.is0()){if(t.allowInfinityPoint&&!n.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:r,y:i}=e.toAffine();if(!n.isValid(r)||!n.isValid(i))throw new Error("bad point: x or y not field elements");if(!g(r,i))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function R(e,t,r,i,o){return r=new O(n.mul(r.X,e),r.Y,r.Z),t=Ae(i,t),r=Ae(o,r),t.add(r)}class O{static BASE=new O(a.Gx,a.Gy,n.ONE);static ZERO=new O(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=i;X;Y;Z;constructor(e,t,r){this.X=v("x",e),this.Y=v("y",t,!0),this.Z=v("z",r),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof O)throw new Error("projective point not allowed");return n.is0(t)&&n.is0(r)?O.ZERO:new O(t,r,n.ONE)}static fromBytes(e){const t=O.fromAffine(w(s(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return O.fromBytes(c(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return U.createCache(this,e),t||this.multiply(Ge),this}assertValidity(){K(this)}hasEvenY(){const{y:e}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(e)}equals(e){B(e);const{X:t,Y:r,Z:i}=this,{X:o,Y:s,Z:c}=e,u=n.eql(n.mul(t,c),n.mul(o,i)),a=n.eql(n.mul(r,c),n.mul(s,i));return u&&a}negate(){return new O(this.X,n.neg(this.Y),this.Z)}double(){const{a:e,b:t}=a,r=n.mul(t,Ge),{X:i,Y:o,Z:s}=this;let c=n.ZERO,u=n.ZERO,f=n.ZERO,l=n.mul(i,i),d=n.mul(o,o),y=n.mul(s,s),h=n.mul(i,o);return h=n.add(h,h),f=n.mul(i,s),f=n.add(f,f),c=n.mul(e,f),u=n.mul(r,y),u=n.add(c,u),c=n.sub(d,u),u=n.add(d,u),u=n.mul(c,u),c=n.mul(h,c),f=n.mul(r,f),y=n.mul(e,y),h=n.sub(l,y),h=n.mul(e,h),h=n.add(h,f),f=n.add(l,l),l=n.add(f,l),l=n.add(l,y),l=n.mul(l,h),u=n.add(u,l),y=n.mul(o,s),y=n.add(y,y),l=n.mul(y,h),c=n.sub(c,l),f=n.mul(y,d),f=n.add(f,f),f=n.add(f,f),new O(c,u,f)}add(e){B(e);const{X:t,Y:r,Z:i}=this,{X:o,Y:s,Z:c}=e;let u=n.ZERO,f=n.ZERO,l=n.ZERO;const d=a.a,y=n.mul(a.b,Ge);let h=n.mul(t,o),p=n.mul(r,s),w=n.mul(i,c),b=n.add(t,r),g=n.add(o,s);b=n.mul(b,g),g=n.add(h,p),b=n.sub(b,g),g=n.add(t,i);let m=n.add(o,c);return g=n.mul(g,m),m=n.add(h,w),g=n.sub(g,m),m=n.add(r,i),u=n.add(s,c),m=n.mul(m,u),u=n.add(p,w),m=n.sub(m,u),l=n.mul(d,g),u=n.mul(y,w),l=n.add(u,l),u=n.sub(p,l),l=n.add(p,l),f=n.mul(u,l),p=n.add(h,h),p=n.add(p,h),w=n.mul(d,w),g=n.mul(y,g),p=n.add(p,w),w=n.sub(h,w),w=n.mul(d,w),g=n.add(g,w),h=n.mul(p,g),f=n.add(f,h),h=n.mul(m,g),u=n.mul(b,u),u=n.sub(u,h),h=n.mul(b,p),l=n.mul(m,l),l=n.add(l,h),new O(u,f,l)}subtract(e){return this.add(e.negate())}is0(){return this.equals(O.ZERO)}multiply(e){const{endo:r}=t;if(!i.isValidNot0(e))throw new Error("invalid scalar: out of range");let n,o;const s=e=>U.cached(this,e,e=>Ue(O,e));if(r){const{k1neg:t,k1:i,k2neg:c,k2:u}=x(e),{p:a,f:f}=s(i),{p:l,f:d}=s(u);o=f.add(d),n=R(r.beta,a,l,t,c)}else{const{p:t,f:r}=s(e);n=t,o=r}return Ue(O,[n,o])[0]}multiplyUnsafe(e){const{endo:r}=t,n=this;if(!i.isValid(e))throw new Error("invalid scalar: out of range");if(e===Ye||n.is0())return O.ZERO;if(e===ze)return n;if(U.hasCache(this))return this.multiply(e);if(r){const{k1neg:t,k1:i,k2neg:o,k2:s}=x(e),{p1:c,p2:u}=function(e,t,r,n){let i=t,o=e.ZERO,s=e.ZERO;for(;r>Re||n>Re;)r&Oe&&(o=o.add(i)),n&Oe&&(s=s.add(i)),i=i.double(),r>>=Oe,n>>=Oe;return{p1:o,p2:s}}(O,n,i,s);return R(r.beta,c,u,t,o)}return U.unsafe(n,e)}toAffine(e){return k(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return f===ze||(e?e(O,this):U.unsafe(this,l).is0())}clearCofactor(){const{clearCofactor:e}=t;return f===ze?this:e?e(O,this):this.multiplyUnsafe(f)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}toBytes(e=!0){return V(e,"isCompressed"),this.assertValidity(),p(O,this,e)}toHex(e=!0){return o(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const A=i.BITS,U=new Te(O,t.endo?Math.ceil(A/2):A);return O.BASE.precompute(8),O}function Qe(e){return Uint8Array.of(e?2:3)}function et(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function tt(e,t={}){const{Fn:r}=e,n=t.randomBytes||i,o=Object.assign(et(e.Fp,r),{seed:Ke(r.ORDER)});function c(e=n(o.seed)){return function(e,t,r=!1){s(e);const n=e.length,i=ke(t),o=Ke(t);if(n<16||n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);const c=le(r?Y(e):$(e),t-re)+re;return r?X(c,i):z(c,i)}(s(e,o.seed,"seed"),r.ORDER)}function u(t,n=!0){return e.BASE.multiply(r.fromBytes(t)).toBytes(n)}function f(e){const{secretKey:t,publicKey:n,publicKeyUncompressed:i}=o;if(!a(e))return;if("_lengths"in r&&r._lengths||t===n)return;const c=s(e,void 0,"key").length;return c===n||c===i}const l={isValidSecretKey:function(e){try{const t=r.fromBytes(e);return r.isValidNot0(t)}catch(e){return!1}},isValidPublicKey:function(t,r){const{publicKey:n,publicKeyUncompressed:i}=o;try{const o=t.length;return(!0!==r||o===n)&&((!1!==r||o===i)&&!!e.fromBytes(t))}catch(e){return!1}},randomSecretKey:c},d=function(e,t){return function(r){const n=e(r);return{secretKey:n,publicKey:t(n)}}}(c,u);return Object.freeze({getPublicKey:u,getSharedSecret:function(t,n,i=!0){if(!0===f(t))throw new Error("first arg must be private key");if(!1===f(n))throw new Error("second arg must be public key");const o=r.fromBytes(t);return e.fromBytes(n).multiply(o).toBytes(i)},keygen:d,Point:e,utils:l,lengths:o})}function rt(e,t,r={}){n(t),Q(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const f=(r=Object.assign({},r)).randomBytes||i,l=r.hmac||((e,r)=>He(t,e,r)),{Fp:y,Fn:h}=e,{ORDER:p,BITS:w}=h,{keygen:b,getPublicKey:g,getSharedSecret:m,utils:E,lengths:v}=tt(e,r),B={prehash:!0,lowS:"boolean"!=typeof r.lowS||r.lowS,format:"compact",extraEntropy:!1},x=p*Xe<y.ORDER;function k(e){return e>p>>ze}function K(e,t){if(!h.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function R(){if(x)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function O(e,t){De(t);const r=v.signature;return s(e,"compact"===t?r:"recovered"===t?r+1:void 0)}class A{r;s;recovery;constructor(e,t,r){if(this.r=K("r",e),this.s=K("s",t),null!=r){if(R(),![0,1,2,3].includes(r))throw new Error("invalid recovery id");this.recovery=r}Object.freeze(this)}static fromBytes(e,t=B.format){let r;if(O(e,t),"der"===t){const{r:t,s:r}=$e.toSig(s(e));return new A(t,r)}"recovered"===t&&(r=e[0],t="compact",e=e.subarray(1));const n=v.signature/2,i=e.subarray(0,n),o=e.subarray(n,2*n);return new A(h.fromBytes(i),h.fromBytes(o),r)}static fromHex(e,t){return this.fromBytes(c(e),t)}assertRecovery(){const{recovery:e}=this;if(null==e)throw new Error("invalid recovery id: must be present");return e}addRecoveryBit(e){return new A(this.r,this.s,e)}recoverPublicKey(t){const{r:r,s:n}=this,i=this.assertRecovery(),o=2===i||3===i?r+p:r;if(!y.isValid(o))throw new Error("invalid recovery id: sig.r+curve.n != R.x");const c=y.toBytes(o),a=e.fromBytes(u(Qe(!(1&i)),c)),f=h.inv(o),l=S(s(t,void 0,"msgHash")),d=h.create(-l*f),w=h.create(n*f),b=e.BASE.multiplyUnsafe(d).add(a.multiplyUnsafe(w));if(b.is0())throw new Error("invalid recovery: point at infinify");return b.assertValidity(),b}hasHighS(){return k(this.s)}toBytes(e=B.format){if(De(e),"der"===e)return c($e.hexFromSig(this));const{r:t,s:r}=this,n=h.toBytes(t),i=h.toBytes(r);return"recovered"===e?(R(),u(Uint8Array.of(this.assertRecovery()),n,i)):u(n,i)}toHex(e){return o(this.toBytes(e))}}const U=r.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=$(e),r=8*e.length-w;return r>0?t>>BigInt(r):t},S=r.bits2int_modN||function(e){return h.create(U(e))},I=J(w);function q(e){return W("num < 2^"+w,e,Ye,I),h.toBytes(e)}function C(e,r){return s(e,void 0,"message"),r?s(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:b,getPublicKey:g,getSharedSecret:m,utils:E,lengths:v,Point:e,sign:function(r,n,i={}){const{seed:o,k2sig:c}=function(t,r,n){const{lowS:i,prehash:o,extraEntropy:c}=Le(n,B);t=C(t,o);const a=S(t),l=h.fromBytes(r);if(!h.isValidNot0(l))throw new Error("invalid private key");const d=[q(l),q(a)];if(null!=c&&!1!==c){const e=!0===c?f(v.secretKey):c;d.push(s(e,void 0,"extraEntropy"))}const y=u(...d),p=a;return{seed:y,k2sig:function(t){const r=U(t);if(!h.isValidNot0(r))return;const n=h.inv(r),o=e.BASE.multiply(r).toAffine(),s=h.create(o.x);if(s===Ye)return;const c=h.create(n*h.create(p+s*l));if(c===Ye)return;let u=(o.x===s?0:2)|Number(o.y&ze),a=c;return i&&k(c)&&(a=h.neg(c),u^=1),new A(s,a,x?void 0:u)}}}(r,n,i);return function(e,t,r){if(d(e,"hashLen"),d(t,"qByteLen"),"function"!=typeof r)throw new Error("hmacFn must be a function");const n=e=>new Uint8Array(e),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1);let c=n(e),a=n(e),f=0;const l=()=>{c.fill(1),a.fill(0),f=0},y=(...e)=>r(a,u(c,...e)),h=(e=i)=>{a=y(o,e),c=y(),0!==e.length&&(a=y(s,e),c=y())},p=()=>{if(f++>=1e3)throw new Error("drbg: tried max amount of iterations");let e=0;const r=[];for(;e<t;){c=y();const t=c.slice();r.push(t),e+=c.length}return u(...r)};return(e,t)=>{let r;for(l(),h(e);!(r=t(p()));)h();return l(),r}}(t.outputLen,h.BYTES,l)(o,c).toBytes(i.format)},verify:function(t,r,n,i={}){const{lowS:o,prehash:c,format:u}=Le(i,B);if(n=s(n,void 0,"publicKey"),r=C(r,c),!a(t)){throw new Error("verify expects Uint8Array signature"+(t instanceof A?", use sig.toBytes()":""))}O(t,u);try{const i=A.fromBytes(t,u),s=e.fromBytes(n);if(o&&i.hasHighS())return!1;const{r:c,s:a}=i,f=S(r),l=h.inv(a),d=h.create(f*l),y=h.create(c*l),p=e.BASE.multiplyUnsafe(d).add(s.multiplyUnsafe(y));if(p.is0())return!1;return h.create(p.x)===c}catch(e){return!1}},recoverPublicKey:function(e,t,r={}){const{prehash:n}=Le(r,B);return t=C(t,n),A.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:A,hash:t})}
16
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const nt={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},it={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},ot=BigInt(2);const st=xe(nt.p,{sqrt:function(e){const t=nt.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),c=BigInt(44),u=BigInt(88),a=e*e*e%t,f=a*a*e%t,l=de(f,r,t)*f%t,d=de(l,r,t)*f%t,y=de(d,ot,t)*a%t,h=de(y,i,t)*y%t,p=de(h,o,t)*h%t,w=de(p,c,t)*p%t,b=de(w,u,t)*w%t,g=de(b,c,t)*p%t,m=de(g,r,t)*f%t,E=de(m,s,t)*h%t,v=de(E,n,t)*a%t,B=de(v,ot,t);if(!st.eql(st.sqr(B),e))throw new Error("Cannot find square root");return B}}),ct=rt(Je(nt,{Fp:st,endo:it}),y);class ut{constructor(e){this.ec={...ct},null!=e.priv&&(this.priv=e.priv),null!=e.pub&&(this.pub=e.pub)}static hexToBytes(e){if("string"!=typeof e)throw new Error("hex string expected");if(e.length%2)throw new Error("hex string must have even length");const t=e.length/2,r=new Uint8Array(t);for(let n=0;n<t;n++)r[n]=parseInt(e.substr(2*n,2),16);return r}static bytesToHex(e){return Array.from(e||[]).map(e=>e.toString(16).padStart(2,"0")).join("")}static keyFromPublic(e,t="hex"){const r="hex"===t?ut.hexToBytes(e):e;return new ut({pub:r})}getPublic(e=!0,t="hex"){this.pub||(this.pub=this.ec.getPublicKey(this.priv,!1));let r=this.pub;const n=this.ec.Point.fromHex(ut.bytesToHex(r)).toHex(e);return r=ut.hexToBytes(n),"hex"===t?ut.bytesToHex(r):r}}
17
- /*!
18
- * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
19
- */const at=new Map([[O,{secret:new Uint8Array([48,103,2,1,0,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,4,77,48,75,2,1,1,4,32]),public:new Uint8Array([161,36,3,34,0])}],[A,{secret:new Uint8Array([48,129,132,2,1,0,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,4,109,48,107,2,1,1,4,48]),public:new Uint8Array([161,52,3,50,0])}],[U,{secret:new Uint8Array([48,129,170,2,1,0,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,35,4,129,146,48,129,143,2,1,1,4,66]),public:new Uint8Array([161,70,3,68,0])}],[S,{secret:new Uint8Array([48,129,132,2,1,0,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10,4,109,48,107,2,1,1,4,32]),public:new Uint8Array([161,68,3,66,0])}]]),ft=new Map([[O,new Uint8Array([48,57,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,3,34,0])],[A,new Uint8Array([48,70,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,50,0])],[U,new Uint8Array([48,88,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,35,3,68,0])],[S,new Uint8Array([48,86,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10,3,66,0])]]);function lt(e){return Uint8Array.from(ut.keyFromPublic(e,"bytes").getPublic(!1,"array"))}async function dt({id:e,controller:r,secretKeyMultibase:n,publicKeyMultibase:i,keyAgreement:o=!1}){if(!i)throw new TypeError('The "publicKeyMultibase" property is required.');const s={id:e,controller:r};if(!i||"string"!=typeof i||i[0]!==g)throw new TypeError('"publicKeyMultibase" must be a multibase, base58-encoded string.');const c=t(i.slice(1)),u={name:o?"ECDH":h,namedCurve:T({publicMultikey:c})},a=function({publicMultikey:e}){const t=T({publicMultikey:e});let r=e.subarray(2);t===S&&(r=lt(r));return function({curve:e,publicKey:t}){const r=ft.get(e),n=new Uint8Array(r.length+t.length);let i=0;return n.set(r,i),i+=r.length,n.set(t,i),n}
20
- /*!
21
- * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
22
- */({curve:t,publicKey:r})}({publicMultikey:c}),f=o?[]:["verify"];if(u.namedCurve===S){const{Crypto:e}=await import("./webcrypto.es-aoUxIxUm-gGk5JRJH.js"),t=new e;s.publicKey=await t.subtle.importKey("spki",a,u,p,f)}else s.publicKey=await M.subtle.importKey("spki",a,u,p,f);if(n){if("string"!=typeof n||n[0]!==g)throw new TypeError('"secretKeyMultibase" must be a multibase, base58-encoded string.');const e=t(n.slice(1));!function({secretMultikey:e,publicMultikey:t}){const r=T({publicMultikey:t}),n=F({secretMultikey:e});if(r!==n)throw new Error(`Public key curve ('${r}') does not match secret key curve ('${n}').`)}({secretMultikey:e,publicMultikey:c});const r=function({secretMultikey:e,publicMultikey:t}){const r=F({secretMultikey:e}),n=e.subarray(2),i=t.subarray(2);return function({curve:e,secretKey:t,publicKey:r}){const n=at.get(e);if(!n)throw new Error(`Unsupported curve "${e}".`);e===S&&(r=lt(r));const i=new Uint8Array(n.secret.length+t.length+n.public.length+r.length);let o=0;return i.set(n.secret,o),o+=n.secret.length,i.set(t,o),o+=t.length,i.set(n.public,o),o+=n.public.length,i.set(r,o),i}({curve:r,secretKey:n,publicKey:i})}({secretMultikey:e,publicMultikey:c}),i=o?["deriveBits"]:["sign"];if(u.namedCurve===S){const{Crypto:e}=await import("./webcrypto.es-aoUxIxUm-gGk5JRJH.js"),t=new e;s.secretKey=await t.subtle.importKey("pkcs8",r,u,p,i)}else s.secretKey=await M.subtle.importKey("pkcs8",r,u,p,i)}return s}function yt({jwk:t}={}){if("EC"!==t?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:r}=t,n=P({curve:r}),i=e(t.x),o=e(t.y),s=new Uint8Array(n+1),c=o[o.length-1]%2==0;return s[0]=c?2:3,s.set(i,s.length-i.length),s}function ht({jwk:t}={}){if("EC"!==t?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:n}=t,i=P({curve:n}),o=e(t.x),s=e(t.y),c=new Uint8Array(2+(i+1));!function({curve:e,buffer:t}){if(e===O)t[0]=E[0],t[1]=E[1];else if(e===A)t[0]=v[0],t[1]=v[1];else if(e===U)t[0]=B[0],t[1]=B[1];else{if(e!==S)throw new TypeError(`Unsupported curve "${e}".`);t[0]=m[0],t[1]=m[1]}}({curve:n,buffer:c});const u=s[s.length-1]%2==0;c[2]=u?2:3,c.set(o,c.length-o.length);return g+r(c)}function pt({jwk:t}={}){if("EC"!==t?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:n}=t,i=P({curve:n}),o=e(t.d),s=new Uint8Array(2+i);!function({curve:e,buffer:t}){if(e===O)t[0]=k[0],t[1]=k[1];else if(e===A)t[0]=K[0],t[1]=K[1];else if(e===U)t[0]=R[0],t[1]=R[1];else{if(e!==S)throw new TypeError(`Unsupported curve "${e}".`);t[0]=x[0],t[1]=x[1]}}({curve:t.crv,buffer:s}),s.set(o,s.length-o.length);return g+r(s)}const wt=new Set(["EcdsaSecp256r1VerificationKey2019","EcdsaSecp384r1VerificationKey2019","EcdsaSecp521r1VerificationKey2019","EcdsaSecp256k1VerificationKey2019"]);async function bt({keyPair:e}){if(!wt.has(e.type))throw new TypeError(`Unsupported key type "${e.type}".`);if(e["@context"]||(e["@context"]=w),!function({document:e,contextUrl:t}){const r=e["@context"];return r===t||Array.isArray(r)&&r.includes(t)}
23
- /*!
24
- * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
25
- */({document:e,contextUrl:w}))throw new TypeError(`Context not supported "${e["@context"]}".`);return{"@context":b,id:e.id,type:"Multikey",controller:e.controller,publicKeyMultibase:e.publicKeyMultibase,secretKeyMultibase:e.secretKeyMultibase}}async function gt(e,t={}){"boolean"==typeof t&&(t={keyAgreement:t});const{keyAgreement:r}=t;let n={...e};if("Multikey"!==n.type){if(n.publicKeyJwk)return async function({jwk:e,secretKey:t=!1}={}){const r={"@context":b,type:"Multikey",publicKeyMultibase:ht({jwk:e})};t&&e.d&&(r.secretKeyMultibase=pt({jwk:e}));const n=!e.key_ops||e.key_ops.includes("deriveBits");return gt(r,n)}({jwk:n.publicKeyJwk,secretKey:!1});if(n.type)return n=await bt({keyPair:n}),Et({keyPair:n,keyAgreement:r})}return n.type||(n.type="Multikey"),n["@context"]||(n["@context"]=b),n.controller&&!n.id&&(n.id=`${e.controller}#${e.publicKeyMultibase}`),function(e){if(!e||"object"!=typeof e)throw new TypeError('"key" must be an object.');if("Multikey"!==e.type)throw new TypeError('"key" must be a Multikey with type "Multikey".');if(!(e["@context"]===b||Array.isArray(e["@context"])&&e["@context"].includes(b)))throw new TypeError(`"key" must be a Multikey with context "${b}".`)}(n),Et({keyPair:n,keyAgreement:r})}async function mt({keyPair:e,secretKey:t=!1}={}){e?.publicKey instanceof N||(e=await dt(e));const r=t&&!!e.secretKey?e.secretKey:e.publicKey;let n;if(e.publicKey.algorithm.namedCurve===S){const{Crypto:e}=await import("./webcrypto.es-aoUxIxUm-gGk5JRJH.js"),t=new e;n=await t.subtle.exportKey("jwk",r)}else n=await M.subtle.exportKey("jwk",r);return n}async function Et({keyPair:t,keyAgreement:r=!1}){t?.publicKey instanceof N||t.publicKey?.algorithm.namedCurve===S||(t=await dt(t));const n=async({publicKey:r=!0,secretKey:n=!1,includeContext:i=!0,raw:o=!1}={})=>{if(o){const i=await mt({keyPair:t,secretKey:n}),o={};return r&&(o.publicKey=yt({jwk:i})),n&&(o.secretKey=function({jwk:t}={}){if("EC"!==t?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:r}=t,n=P({curve:r}),i=e(t.d),o=new Uint8Array(n);return o.set(i,o.length-i.length),o}({jwk:i})),o}return async function({keyPair:e,secretKey:t,publicKey:r,includeContext:n}={}){if(!r&&!t)throw new TypeError('Export requires specifying either "publicKey" or "secretKey".');const i=t&&!!e.secretKey,o=i?e.secretKey:e.publicKey;let s;if(o.algorithm.namedCurve===S){const{Crypto:e}=await import("./webcrypto.es-aoUxIxUm-gGk5JRJH.js"),t=new e;s=await t.subtle.exportKey("jwk",o)}else s=await M.subtle.exportKey("jwk",o);const c={};return n&&(c["@context"]=b),c.id=e.id,c.type="Multikey",c.controller=e.controller,r&&(c.publicKeyMultibase=ht({jwk:s})),i&&(c.secretKeyMultibase=pt({jwk:s})),c}({keyPair:t,publicKey:r,secretKey:n,includeContext:i})},{publicKeyMultibase:i,secretKeyMultibase:o}=await n({publicKey:!0,secretKey:!0,includeContext:!0});return t={...t,publicKeyMultibase:i,secretKeyMultibase:o,keyAgreement:r,export:n,signer(){const{id:e,secretKey:r}=t;
26
- /*!
27
- * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
28
- */
29
- return function({id:e,secretKey:t}){if(!t)throw new Error('"secretKey" is required for signing.');const{namedCurve:r}=t.algorithm,n={name:h,hash:{name:j({curve:r})}};return{algorithm:r,id:e,async sign({data:e}={}){if(r===S){const{Crypto:r}=await import("./webcrypto.es-aoUxIxUm-gGk5JRJH.js"),i=new r;return new Uint8Array(await i.subtle.sign(n,t,e))}return new Uint8Array(await M.subtle.sign(n,t,e))}}}({id:e,secretKey:r})},verifier(){const{id:e,publicKey:r}=t;return function({id:e,publicKey:t}){if(!t)throw new Error('"publicKey" is required for verifying.');const{namedCurve:r}=t.algorithm,n={name:h,hash:{name:j({curve:r})}};return{algorithm:r,id:e,async verify({data:e,signature:i}={}){if(r===S){const{Crypto:r}=await import("./webcrypto.es-aoUxIxUm-gGk5JRJH.js");return(new r).subtle.verify(n,t,i,e)}return M.subtle.verify(n,t,i,e)}}}({id:e,publicKey:r})},async deriveSecret({publicKey:e,remotePublicKey:r}={}){if(r&&e)throw new Error('Only one of "remotePublicKey" and "publicKey" must be given.');if(!t.keyAgreement){const e=Error('"keyAgreement" is not supported by this keypair.');throw e.name="NotSupportedError",e}return async function({localKeyPair:e,remoteKeyPair:t}){if(!e.secretKey){const e=Error('"secretKey" required to derive secret.');throw e.name="NotSupportedError",e}e=await dt({...e,keyAgreement:!0}),t=await dt({...t,keyAgreement:!0});const{namedCurve:r}=e.secretKey.algorithm,n=P({curve:r});if(r===S){const{Crypto:i}=await import("./webcrypto.es-aoUxIxUm-gGk5JRJH.js"),o=new i,s=await o.subtle.deriveBits({name:"ECDH",namedCurve:r,public:t.publicKey},e.secretKey,8*n);return new Uint8Array(s,0,n)}const i=await M.subtle.deriveBits({name:"ECDH",namedCurve:r,public:t.publicKey},e.secretKey,8*n);return new Uint8Array(i,0,n)}({localKeyPair:this,remoteKeyPair:r||e})}}}export{yt as a,gt as f,mt as t};