solid-logic 3.1.1-da65b2c → 3.1.1-e3eba68
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.
- package/README.md +2 -108
- package/eslint.config.js +29 -0
- package/jest.config.js +10 -0
- package/lib/acl/aclLogic.d.ts +5 -0
- package/{dist → lib}/acl/aclLogic.d.ts.map +1 -1
- package/lib/acl/aclLogic.js +168 -0
- package/lib/acl/aclLogic.js.map +1 -0
- package/{dist → lib}/authSession/authSession.js +1 -1
- package/{dist → lib}/authSession/authSession.js.map +1 -1
- package/{dist → lib}/authn/SolidAuthnLogic.d.ts +3 -3
- package/{dist → lib}/authn/SolidAuthnLogic.d.ts.map +1 -1
- package/lib/authn/SolidAuthnLogic.js +193 -0
- package/lib/authn/SolidAuthnLogic.js.map +1 -0
- package/{dist → lib}/authn/authUtil.d.ts +1 -1
- package/{dist → lib}/authn/authUtil.js +12 -12
- package/lib/authn/authUtil.js.map +1 -0
- package/{dist → lib}/chat/chatLogic.d.ts +1 -1
- package/lib/chat/chatLogic.js +272 -0
- package/lib/chat/chatLogic.js.map +1 -0
- package/{dist → lib}/inbox/inboxLogic.d.ts +1 -1
- package/{dist → lib}/inbox/inboxLogic.d.ts.map +1 -1
- package/lib/inbox/inboxLogic.js +139 -0
- package/lib/inbox/inboxLogic.js.map +1 -0
- package/{dist → lib}/index.d.ts +1 -1
- package/{dist → lib}/index.d.ts.map +1 -1
- package/{dist → lib}/index.js +4 -4
- package/{dist → lib}/index.js.map +1 -1
- package/lib/issuer/issuerLogic.js +52 -0
- package/lib/issuer/issuerLogic.js.map +1 -0
- package/{dist → lib}/logic/CustomError.d.ts.map +1 -1
- package/lib/logic/CustomError.js +89 -0
- package/lib/logic/CustomError.js.map +1 -0
- package/lib/logic/solidLogic.d.ts +6 -0
- package/{dist → lib}/logic/solidLogic.d.ts.map +1 -1
- package/{dist → lib}/logic/solidLogic.js +33 -32
- package/lib/logic/solidLogic.js.map +1 -0
- package/lib/logic/solidLogicSingleton.js +94 -0
- package/lib/logic/solidLogicSingleton.js.map +1 -0
- package/{dist → lib}/profile/profileLogic.d.ts +1 -1
- package/lib/profile/profileLogic.js +259 -0
- package/lib/profile/profileLogic.js.map +1 -0
- package/lib/typeIndex/typeIndexLogic.js +399 -0
- package/lib/typeIndex/typeIndexLogic.js.map +1 -0
- package/{dist → lib}/types.d.ts +2 -2
- package/{dist → lib}/util/containerLogic.d.ts +1 -1
- package/{dist → lib}/util/containerLogic.d.ts.map +1 -1
- package/lib/util/containerLogic.js +102 -0
- package/lib/util/containerLogic.js.map +1 -0
- package/lib/util/debug.d.ts.map +1 -0
- package/lib/util/debug.js +40 -0
- package/lib/util/debug.js.map +1 -0
- package/{dist → lib}/util/ns.js +2 -2
- package/{dist → lib}/util/ns.js.map +1 -1
- package/{dist → lib}/util/utilityLogic.d.ts +1 -1
- package/{dist → lib}/util/utilityLogic.d.ts.map +1 -1
- package/lib/util/utilityLogic.js +284 -0
- package/lib/util/utilityLogic.js.map +1 -0
- package/{dist → lib}/util/utils.d.ts +1 -1
- package/{dist → lib}/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +47 -0
- package/lib/util/utils.js.map +1 -0
- package/package.json +20 -58
- package/src/acl/aclLogic.ts +156 -0
- package/src/authSession/authSession.ts +7 -0
- package/src/authn/SolidAuthnLogic.ts +127 -0
- package/src/authn/authUtil.ts +70 -0
- package/src/chat/chatLogic.ts +226 -0
- package/src/inbox/inboxLogic.ts +59 -0
- package/src/index.ts +22 -0
- package/src/issuer/issuerLogic.ts +40 -0
- package/src/logic/CustomError.ts +29 -0
- package/src/logic/solidLogic.ts +76 -0
- package/src/logic/solidLogicSingleton.ts +20 -0
- package/src/profile/profileLogic.ts +125 -0
- package/src/typeIndex/typeIndexLogic.ts +198 -0
- package/src/types.ts +122 -0
- package/{dist/util/containerLogic.js → src/util/containerLogic.ts} +25 -20
- package/src/util/debug.ts +20 -0
- package/src/util/ns.ts +5 -0
- package/src/util/utilityLogic.ts +156 -0
- package/src/util/utils.ts +52 -0
- package/test/aclLogic.test.ts +24 -0
- package/test/authUtil.test.ts +23 -0
- package/test/chatLogic.test.ts +316 -0
- package/test/container.test.ts +58 -0
- package/test/helpers/dataSetup.ts +134 -0
- package/test/helpers/setup.ts +17 -0
- package/test/inboxLogic.test.ts +218 -0
- package/test/logic.test.ts +29 -0
- package/test/profileLogic.test.ts +246 -0
- package/test/solidAuthLogic.test.ts +49 -0
- package/test/typeIndexLogic.test.ts +255 -0
- package/test/utilityLogic.test.ts +179 -0
- package/test/utils.test.ts +32 -0
- package/tsconfig.json +75 -0
- package/dist/789.solid-logic.js +0 -11
- package/dist/789.solid-logic.js.map +0 -1
- package/dist/789.solid-logic.min.js +0 -1
- package/dist/841.solid-logic.js +0 -12133
- package/dist/841.solid-logic.js.map +0 -1
- package/dist/841.solid-logic.min.js +0 -73
- package/dist/841.solid-logic.min.js.map +0 -1
- package/dist/acl/aclLogic.d.ts +0 -5
- package/dist/acl/aclLogic.js +0 -122
- package/dist/acl/aclLogic.js.map +0 -1
- package/dist/authn/SolidAuthnLogic.js +0 -147
- package/dist/authn/SolidAuthnLogic.js.map +0 -1
- package/dist/authn/authUtil.js.map +0 -1
- package/dist/chat/chatLogic.js +0 -160
- package/dist/chat/chatLogic.js.map +0 -1
- package/dist/inbox/inboxLogic.js +0 -55
- package/dist/inbox/inboxLogic.js.map +0 -1
- package/dist/issuer/issuerLogic.js +0 -40
- package/dist/issuer/issuerLogic.js.map +0 -1
- package/dist/logic/CustomError.js +0 -38
- package/dist/logic/CustomError.js.map +0 -1
- package/dist/logic/solidLogic.d.ts +0 -6
- package/dist/logic/solidLogic.js.map +0 -1
- package/dist/logic/solidLogicSingleton.js +0 -54
- package/dist/logic/solidLogicSingleton.js.map +0 -1
- package/dist/profile/profileLogic.js +0 -165
- package/dist/profile/profileLogic.js.map +0 -1
- package/dist/solid-logic.esm.external.js +0 -12725
- package/dist/solid-logic.esm.external.js.map +0 -1
- package/dist/solid-logic.esm.external.min.js +0 -32
- package/dist/solid-logic.esm.external.min.js.map +0 -1
- package/dist/solid-logic.external.js +0 -12802
- package/dist/solid-logic.external.js.map +0 -1
- package/dist/solid-logic.external.min.js +0 -32
- package/dist/solid-logic.external.min.js.map +0 -1
- package/dist/solid-logic.js +0 -40921
- package/dist/solid-logic.js.map +0 -1
- package/dist/solid-logic.min.js +0 -41
- package/dist/solid-logic.min.js.map +0 -1
- package/dist/typeIndex/typeIndexLogic.js +0 -222
- package/dist/typeIndex/typeIndexLogic.js.map +0 -1
- package/dist/util/containerLogic.js.map +0 -1
- package/dist/util/debug.d.ts.map +0 -1
- package/dist/util/debug.js +0 -20
- package/dist/util/debug.js.map +0 -1
- package/dist/util/utilityLogic.js +0 -180
- package/dist/util/utilityLogic.js.map +0 -1
- package/dist/util/utils.js +0 -47
- package/dist/util/utils.js.map +0 -1
- package/dist/versionInfo.js +0 -33
- package/dist/versionInfo.js.map +0 -1
- /package/{dist → lib}/authSession/authSession.d.ts +0 -0
- /package/{dist → lib}/authSession/authSession.d.ts.map +0 -0
- /package/{dist → lib}/authn/authUtil.d.ts.map +0 -0
- /package/{dist → lib}/chat/chatLogic.d.ts.map +0 -0
- /package/{dist → lib}/issuer/issuerLogic.d.ts +0 -0
- /package/{dist → lib}/issuer/issuerLogic.d.ts.map +0 -0
- /package/{dist → lib}/logic/CustomError.d.ts +0 -0
- /package/{dist → lib}/logic/solidLogicSingleton.d.ts +0 -0
- /package/{dist → lib}/logic/solidLogicSingleton.d.ts.map +0 -0
- /package/{dist → lib}/profile/profileLogic.d.ts.map +0 -0
- /package/{dist → lib}/typeIndex/typeIndexLogic.d.ts +0 -0
- /package/{dist → lib}/typeIndex/typeIndexLogic.d.ts.map +0 -0
- /package/{dist → lib}/types.d.ts.map +0 -0
- /package/{dist → lib}/types.js +0 -0
- /package/{dist → lib}/types.js.map +0 -0
- /package/{dist → lib}/util/debug.d.ts +0 -0
- /package/{dist → lib}/util/ns.d.ts +0 -0
- /package/{dist → lib}/util/ns.d.ts.map +0 -0
package/dist/solid-logic.min.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SolidLogic=t():e.SolidLogic=t()}(this,()=>(()=>{var e,t,r,n,i={149:(e,t,r)=>{"use strict";function n(e){if("object"!=typeof(t=e)||null===t||"[object Object]"!==Object.prototype.toString.call(e))return!1;var t;if(null===Object.getPrototypeOf(e))return!0;let r=e;for(;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r}r.d(t,{A:()=>n})},182:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version=t.validate=t.v7=t.v6ToV1=t.v6=t.v5=t.v4=t.v3=t.v1ToV6=t.v1=t.stringify=t.parse=t.NIL=t.MAX=void 0;var n=r(2196);Object.defineProperty(t,"MAX",{enumerable:!0,get:function(){return n.default}});var i=r(3465);Object.defineProperty(t,"NIL",{enumerable:!0,get:function(){return i.default}});var o=r(1797);Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return o.default}});var s=r(6011);Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return s.default}});var a=r(1425);Object.defineProperty(t,"v1",{enumerable:!0,get:function(){return a.default}});var c=r(6568);Object.defineProperty(t,"v1ToV6",{enumerable:!0,get:function(){return c.default}});var u=r(591);Object.defineProperty(t,"v3",{enumerable:!0,get:function(){return u.default}});var l=r(8286);Object.defineProperty(t,"v4",{enumerable:!0,get:function(){return l.default}});var h=r(4557);Object.defineProperty(t,"v5",{enumerable:!0,get:function(){return h.default}});var d=r(6356);Object.defineProperty(t,"v6",{enumerable:!0,get:function(){return d.default}});var f=r(268);Object.defineProperty(t,"v6ToV1",{enumerable:!0,get:function(){return f.default}});var p=r(4299);Object.defineProperty(t,"v7",{enumerable:!0,get:function(){return p.default}});var g=r(9746);Object.defineProperty(t,"validate",{enumerable:!0,get:function(){return g.default}});var y=r(2770);Object.defineProperty(t,"version",{enumerable:!0,get:function(){return y.default}})},251:(e,t)=>{
|
|
2
|
-
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
3
|
-
t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,c=(1<<a)-1,u=c>>1,l=-7,h=r?i-1:0,d=r?-1:1,f=e[t+h];for(h+=d,o=f&(1<<-l)-1,f>>=-l,l+=a;l>0;o=256*o+e[t+h],h+=d,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+e[t+h],h+=d,l-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),o-=u}return(f?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,c,u=8*o-i-1,l=(1<<u)-1,h=l>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(t*c-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[r+f]=255&s,f+=p,s/=256,u-=8);e[r+f-p]|=128*g}},268:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1797),i=r(6011);t.default=function(e){const t=function(e){return Uint8Array.of((15&e[3])<<4|e[4]>>4&15,(15&e[4])<<4|(240&e[5])>>4,(15&e[5])<<4|15&e[6],e[7],(15&e[1])<<4|(240&e[2])>>4,(15&e[2])<<4|(240&e[3])>>4,16|(240&e[0])>>4,(15&e[0])<<4|(240&e[1])>>4,e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}("string"==typeof e?(0,n.default)(e):e);return"string"==typeof e?(0,i.unsafeStringify)(t):t}},338:(e,t)=>{"use strict";function r(e){return 14+(e+64>>>9<<4)+1}function n(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function i(e,t,r,i,o,s){return n((a=n(n(t,e),n(i,s)))<<(c=o)|a>>>32-c,r);var a,c}function o(e,t,r,n,o,s,a){return i(t&r|~t&n,e,t,o,s,a)}function s(e,t,r,n,o,s,a){return i(t&n|r&~n,e,t,o,s,a)}function a(e,t,r,n,o,s,a){return i(t^r^n,e,t,o,s,a)}function c(e,t,r,n,o,s,a){return i(r^(t|~n),e,t,o,s,a)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(e){const t=new Uint8Array(4*e.length);for(let r=0;r<4*e.length;r++)t[r]=e[r>>2]>>>r%4*8&255;return t}(function(e,t){const i=new Uint32Array(r(t)).fill(0);i.set(e),i[t>>5]|=128<<t%32,i[i.length-1]=t,e=i;let u=1732584193,l=-271733879,h=-1732584194,d=271733878;for(let t=0;t<e.length;t+=16){const r=u,i=l,f=h,p=d;u=o(u,l,h,d,e[t],7,-680876936),d=o(d,u,l,h,e[t+1],12,-389564586),h=o(h,d,u,l,e[t+2],17,606105819),l=o(l,h,d,u,e[t+3],22,-1044525330),u=o(u,l,h,d,e[t+4],7,-176418897),d=o(d,u,l,h,e[t+5],12,1200080426),h=o(h,d,u,l,e[t+6],17,-1473231341),l=o(l,h,d,u,e[t+7],22,-45705983),u=o(u,l,h,d,e[t+8],7,1770035416),d=o(d,u,l,h,e[t+9],12,-1958414417),h=o(h,d,u,l,e[t+10],17,-42063),l=o(l,h,d,u,e[t+11],22,-1990404162),u=o(u,l,h,d,e[t+12],7,1804603682),d=o(d,u,l,h,e[t+13],12,-40341101),h=o(h,d,u,l,e[t+14],17,-1502002290),l=o(l,h,d,u,e[t+15],22,1236535329),u=s(u,l,h,d,e[t+1],5,-165796510),d=s(d,u,l,h,e[t+6],9,-1069501632),h=s(h,d,u,l,e[t+11],14,643717713),l=s(l,h,d,u,e[t],20,-373897302),u=s(u,l,h,d,e[t+5],5,-701558691),d=s(d,u,l,h,e[t+10],9,38016083),h=s(h,d,u,l,e[t+15],14,-660478335),l=s(l,h,d,u,e[t+4],20,-405537848),u=s(u,l,h,d,e[t+9],5,568446438),d=s(d,u,l,h,e[t+14],9,-1019803690),h=s(h,d,u,l,e[t+3],14,-187363961),l=s(l,h,d,u,e[t+8],20,1163531501),u=s(u,l,h,d,e[t+13],5,-1444681467),d=s(d,u,l,h,e[t+2],9,-51403784),h=s(h,d,u,l,e[t+7],14,1735328473),l=s(l,h,d,u,e[t+12],20,-1926607734),u=a(u,l,h,d,e[t+5],4,-378558),d=a(d,u,l,h,e[t+8],11,-2022574463),h=a(h,d,u,l,e[t+11],16,1839030562),l=a(l,h,d,u,e[t+14],23,-35309556),u=a(u,l,h,d,e[t+1],4,-1530992060),d=a(d,u,l,h,e[t+4],11,1272893353),h=a(h,d,u,l,e[t+7],16,-155497632),l=a(l,h,d,u,e[t+10],23,-1094730640),u=a(u,l,h,d,e[t+13],4,681279174),d=a(d,u,l,h,e[t],11,-358537222),h=a(h,d,u,l,e[t+3],16,-722521979),l=a(l,h,d,u,e[t+6],23,76029189),u=a(u,l,h,d,e[t+9],4,-640364487),d=a(d,u,l,h,e[t+12],11,-421815835),h=a(h,d,u,l,e[t+15],16,530742520),l=a(l,h,d,u,e[t+2],23,-995338651),u=c(u,l,h,d,e[t],6,-198630844),d=c(d,u,l,h,e[t+7],10,1126891415),h=c(h,d,u,l,e[t+14],15,-1416354905),l=c(l,h,d,u,e[t+5],21,-57434055),u=c(u,l,h,d,e[t+12],6,1700485571),d=c(d,u,l,h,e[t+3],10,-1894986606),h=c(h,d,u,l,e[t+10],15,-1051523),l=c(l,h,d,u,e[t+1],21,-2054922799),u=c(u,l,h,d,e[t+8],6,1873313359),d=c(d,u,l,h,e[t+15],10,-30611744),h=c(h,d,u,l,e[t+6],15,-1560198380),l=c(l,h,d,u,e[t+13],21,1309151649),u=c(u,l,h,d,e[t+4],6,-145523070),d=c(d,u,l,h,e[t+11],10,-1120210379),h=c(h,d,u,l,e[t+2],15,718787259),l=c(l,h,d,u,e[t+9],21,-343485551),u=n(u,r),l=n(l,i),h=n(h,f),d=n(d,p)}return Uint32Array.of(u,l,h,d)}(function(e){if(0===e.length)return new Uint32Array;const t=new Uint32Array(r(8*e.length)).fill(0);for(let r=0;r<e.length;r++)t[r>>2]|=(255&e[r])<<r%4*8;return t}(e),8*e.length))}},390:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchError=t.WebOperationError=t.NotEditableError=t.NotFoundError=t.SameOriginForbiddenError=t.CrossOriginForbiddenError=t.UnauthorizedError=void 0;class r extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype),this.name=new.target.name}}t.UnauthorizedError=class extends r{};t.CrossOriginForbiddenError=class extends r{};t.SameOriginForbiddenError=class extends r{};t.NotFoundError=class extends r{};t.NotEditableError=class extends r{};t.WebOperationError=class extends r{};t.FetchError=class extends r{status;constructor(e,t){super(t),this.status=e}}},458:(e,t,r)=>{"use strict";r.d(t,{w:()=>l});var n=r(8278),i=r(7493),o=r(149);function s(e){return(0,o.A)(e)}function a(e){return"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}class c{constructor(e){if(this._cached=new WeakMap,!function(e){return e&&"object"==typeof e&&Array.isArray(e.keys)&&e.keys.every(s)}(e))throw new i.JWKSInvalid("JSON Web Key Set malformed");this._jwks=a(e)}async getKey(e,t){const{alg:r,kid:n}={...e,...t?.header},o=function(e){switch("string"==typeof e&&e.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new i.JOSENotSupported('Unsupported "alg" value for a JSON Web Key Set')}}(r),s=this._jwks.keys.filter(e=>{let t=o===e.kty;if(t&&"string"==typeof n&&(t=n===e.kid),t&&"string"==typeof e.alg&&(t=r===e.alg),t&&"string"==typeof e.use&&(t="sig"===e.use),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes("verify")),t)switch(r){case"ES256":t="P-256"===e.crv;break;case"ES256K":t="secp256k1"===e.crv;break;case"ES384":t="P-384"===e.crv;break;case"ES512":t="P-521"===e.crv;break;case"Ed25519":t="Ed25519"===e.crv;break;case"EdDSA":t="Ed25519"===e.crv||"Ed448"===e.crv}return t}),{0:a,length:c}=s;if(0===c)throw new i.JWKSNoMatchingKey;if(1!==c){const e=new i.JWKSMultipleMatchingKeys,{_cached:t}=this;throw e[Symbol.asyncIterator]=async function*(){for(const e of s)try{yield await u(t,e,r)}catch{}},e}return u(this._cached,a,r)}}async function u(e,t,r){const o=e.get(t)||e.set(t,{}).get(t);if(void 0===o[r]){const e=await(0,n.Og)({...t,ext:!0},r);if(e instanceof Uint8Array||"public"!==e.type)throw new i.JWKSInvalid("JSON Web Key Set members must be public keys");o[r]=e}return o[r]}function l(e){const t=new c(e),r=async(e,r)=>t.getKey(e,r);return Object.defineProperties(r,{jwks:{value:()=>a(t._jwks),enumerable:!0,configurable:!1,writable:!1}}),r}},591:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.URL=t.DNS=void 0;const n=r(338),i=r(2988);var o=r(2988);function s(e,t,r,o){return(0,i.default)(48,n.default,e,t,r,o)}Object.defineProperty(t,"DNS",{enumerable:!0,get:function(){return o.DNS}}),Object.defineProperty(t,"URL",{enumerable:!0,get:function(){return o.URL}}),s.DNS=i.DNS,s.URL=i.URL,t.default=s},610:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(7991);const i=async(e,t)=>{const r=`SHA-${e.slice(-3)}`;return new Uint8Array(await n.A.subtle.digest(r,t))}},676:(e,t,r)=>{"use strict";r.d(t,{A:()=>c});var n=r(7991),i=r(2698),o=r(1575),s=r(5994),a=r(3139);async function c(e,t,r){if("sign"===r&&(t=await a.A.normalizePrivateKey(t,e)),"verify"===r&&(t=await a.A.normalizePublicKey(t,e)),(0,n.R)(t))return(0,i.Y)(t,e,r),t;if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError((0,o.A)(t,...s.g));return n.A.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError((0,o.A)(t,...s.g,"Uint8Array","JSON Web Key"))}},699:function(e,t,r){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.createUtilityLogic=function(e,t,r){async function n(t){let r;try{r=await e.fetcher.load(t)}catch(r){if(404!==r.response.status){if(401===r.response.status)throw new c.UnauthorizedError;if(403===r.response.status){if((0,l.differentOrigin)(t))throw new c.CrossOriginForbiddenError;throw new c.SameOriginForbiddenError}const e="createIfNotExists doc load error NOT 404: "+t+": "+r;throw new c.FetchError(r.status,r.message+e)}try{await e.fetcher.webOperation("PUT",t,{data:"",contentType:"text/turtle"})}catch(e){const r="createIfNotExists: PUT FAILED: "+t+": "+e;throw new c.WebOperationError(r)}await e.fetcher.load(t)}return r}return{recursiveDelete:async function n(i){try{if(r.isContainer(i)){const o=await t.findAclDocUrl(i);await e.fetcher._fetch(o,{method:"DELETE"});const s=await r.getContainerMembers(i);await Promise.all(s.map(e=>n(e)))}const o=i.value;return e.fetcher._fetch(o,{method:"DELETE"})}catch(e){u.log(`Please manually remove ${i.value} from your system.`,e)}},setSinglePeerAccess:async function(r){let n=["@prefix acl: <http://www.w3.org/ns/auth/acl#>.","",`<#alice> a acl:Authorization;\n acl:agent <${r.ownerWebId}>;`,` acl:accessTo <${r.target}>;`,` acl:default <${r.target}>;`," acl:mode acl:Read, acl:Write, acl:Control.",""].join("\n");r.accessToModes&&(n+=["<#bobAccessTo> a acl:Authorization;",` acl:agent <${r.peerWebId}>;`,` acl:accessTo <${r.target}>;`,` acl:mode ${r.accessToModes}.`,""].join("\n")),r.defaultModes&&(n+=["<#bobDefault> a acl:Authorization;",` acl:agent <${r.peerWebId}>;`,` acl:default <${r.target}>;`,` acl:mode ${r.defaultModes}.`,""].join("\n"));const i=await t.findAclDocUrl((0,a.sym)(r.target));return e.fetcher._fetch(i,{method:"PUT",body:n,headers:[["Content-Type","text/turtle"]]})},createEmptyRdfDoc:async function(t,r){await e.fetcher.webOperation("PUT",t.uri,{data:`# ${new Date} ${r}\n `,contentType:"text/turtle"})},followOrCreateLink:async function(t,r,i,o){await e.fetcher.load(o);const s=e.any(t,r,null,o);if(s)return s;if(!e.updater.editable(o)){const e=`followOrCreateLink: cannot edit ${o.value}`;throw u.warn(e),new c.NotEditableError(e)}try{await e.updater.update([],[(0,a.st)(t,r,i,o)])}catch(e){const t=`followOrCreateLink: Error making link in ${o} to ${i}: ${e}`;throw u.warn(t),new c.WebOperationError(e)}try{await n(i)}catch(e){throw u.warn(`followOrCreateLink: Error loading or saving new linked document: ${i}: ${e}`),e}return i},loadOrCreateIfNotExists:n}};const a=r(4090),c=r(390),u=s(r(9378)),l=r(6848)},942:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createContainerLogic=function(e){function t(t){return e.statementsMatching(t,(0,n.sym)("http://www.w3.org/ns/ldp#contains"),void 0).map(e=>e.object)}function r(e){const t=e.value;return"/"===t.charAt(t.length-1)}return{isContainer:r,createContainer:async function(t){if(!r((0,n.sym)(t)))throw new Error(`Not a container URL ${t}`);const i=await e.fetcher._fetch(t,{method:"PUT",headers:{"Content-Type":"text/turtle","If-None-Match":"*",Link:'<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"'},body:" "});if("2"!==i.status.toString()[0])throw new Error(`Not OK: got ${i.status} response while creating container at ${t}`)},getContainerElements:t,getContainerMembers:async function(r){return await e.fetcher.load(r),t(r)}}};const n=r(4090)},1020:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(7493);function i(e,t){const r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":return{name:"Ed25519"};case"EdDSA":return{name:t.name};default:throw new n.JOSENotSupported(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}},1059:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});const n={Literal:1,Collection:3,Graph:4,NamedNode:5,BlankNode:6,Variable:7}},1177:function(e,t,r){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.createTypeIndexLogic=function(e,t,r,n){const i=u.ns;async function o(t){if(!t)throw new Error("loadTypeIndexesFor: No user given");const o=await r.loadProfile(t),s=f(t);let a;try{a=await n.followOrCreateLink(t,i.solid("publicTypeIndex"),s,o)}catch(e){const r=`User ${t} has no pointer in profile to publicTypeIndex file.`;c.warn(r)}const u=a?[{label:"public",index:a,agent:t}]:[];let l,h;try{l=await r.silencedLoadPreferences(t)}catch(e){l=null}if(l){const r=p(l);let s;try{s=e.any(t,i.solid("privateTypeIndex"),void 0,o)||await n.followOrCreateLink(t,i.solid("privateTypeIndex"),r,l)}catch(e){const r=`User ${t} has no pointer in preference file to privateTypeIndex file.`;c.warn(r)}h=s?[{label:"private",index:s,agent:t}]:[]}else h=[];const d=u.concat(h);if(0===d.length)return d;const g=d.map(e=>e.index);try{await e.fetcher.load(g)}catch(e){c.warn("Problems loading type index: ",e)}return d}async function s(t){let n;try{n=await r.silencedLoadPreferences(t)}catch(e){const r=`User ${t} has no pointer in profile to preferences file.`;c.warn(r)}if(n){const r=e.each(t,i.solid("community"),void 0,n).concat(e.each(t,i.solid("community"),void 0,t.doc()));let s=[];for(const e of r)s=s.concat(await o(e));return s}return[]}async function h(e){return(await o(e)).concat((await s(e)).flat())}async function d(e,t){const r=await h(t);let n=[];for(const t of r){const r=await g(t,e);n=n.concat(r)}return n}function f(e){return(0,a.sym)(e.doc().dir()?.uri+"publicTypeIndex.ttl")}function p(e){return(0,a.sym)(e.doc().dir()?.uri+"privateTypeIndex.ttl")}async function g(t,r){const n=t.index,o=[],s=e.statementsMatching(null,i.solid("instance"),null,n).concat(e.statementsMatching(null,i.solid("instanceContainer"),null,n)).map(e=>e.subject);for(const c of s){const s=e.any(c,i.solid("forClass"),null,n);if(!r||s.sameTerm(r)){const r=e.each(c,i.solid("instance"),null,n);for(const e of r)o.push({instance:e,type:s,scope:t});const u=e.each(c,i.solid("instanceContainer"),null,n);for(const r of u)await e.fetcher.load(r),o.push({instance:(0,a.sym)(r.value),type:s,scope:t})}}return o}return{registerInTypeIndex:async function(t,r,n){const o=(0,l.newThing)(r),s=[(0,a.st)(o,i.rdf("type"),i.solid("TypeRegistration"),r),(0,a.st)(o,i.solid("forClass"),n,r),(0,a.st)(o,i.solid("instance"),t,r)];try{await e.updater.update([],s)}catch(e){const n=`Unable to register ${t} in index ${r}: ${e}`;return console.warn(n),null}return o},getRegistrations:function(t,r){return e.each(void 0,i.solid("instance"),t).filter(t=>e.holds(t,i.solid("forClass"),r))},loadTypeIndexesFor:o,loadCommunityTypeIndexes:s,loadAllTypeIndexes:h,getScopedAppInstances:d,getAppInstances:async function(e){const r=t.currentUser();if(!r)throw new Error("getAppInstances: Must be logged in to find apps.");return(await d(e,r)).map(e=>e.instance)},suggestPublicTypeIndex:f,suggestPrivateTypeIndex:p,deleteTypeIndexRegistration:async function(t){const r=e.the(null,i.solid("instance"),t.instance,t.scope.index);if(!r)throw new Error(`deleteTypeIndexRegistration: No registration found for ${t.instance}`);const n=e.statementsMatching(r,null,null,t.scope.index);await e.updater.update(n,[])},getScopedAppsFromIndex:g}};const a=r(4090),c=s(r(9378)),u=r(6118),l=r(6848)},1425:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateV1State=void 0;const n=r(2291),i=r(6011),o={};function s(e,t,r){return e.msecs??=-1/0,e.nsecs??=0,t===e.msecs?(e.nsecs++,e.nsecs>=1e4&&(e.node=void 0,e.nsecs=0)):t>e.msecs?e.nsecs=0:t<e.msecs&&(e.node=void 0),e.node||(e.node=r.slice(10,16),e.node[0]|=1,e.clockseq=16383&(r[8]<<8|r[9])),e.msecs=t,e}function a(e,t,r,n,i,o,s=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(o){if(s<0||s+16>o.length)throw new RangeError(`UUID byte range ${s}:${s+15} is out of buffer bounds`)}else o=new Uint8Array(16),s=0;t??=Date.now(),r??=0,n??=16383&(e[8]<<8|e[9]),i??=e.slice(10,16);const a=(1e4*(268435455&(t+=122192928e5))+r)%4294967296;o[s++]=a>>>24&255,o[s++]=a>>>16&255,o[s++]=a>>>8&255,o[s++]=255&a;const c=t/4294967296*1e4&268435455;o[s++]=c>>>8&255,o[s++]=255&c,o[s++]=c>>>24&15|16,o[s++]=c>>>16&255,o[s++]=n>>>8|128,o[s++]=255&n;for(let e=0;e<6;++e)o[s++]=i[e];return o}t.updateV1State=s,t.default=function(e,t,r){let c;const u=e?._v6??!1;if(e){const t=Object.keys(e);1===t.length&&"_v6"===t[0]&&(e=void 0)}if(e)c=a(e.random??e.rng?.()??(0,n.default)(),e.msecs,e.nsecs,e.clockseq,e.node,t,r);else{const e=Date.now(),i=(0,n.default)();s(o,e,i),c=a(i,o.msecs,o.nsecs,u?void 0:o.clockseq,u?void 0:o.node,t,r)}return t??(0,i.unsafeStringify)(c)}},1436:(e,t,r)=>{"use strict";r.d(t,{D4:()=>a,WG:()=>i,lF:()=>o,y4:()=>s});var n=r(1476);const i=e=>{let t=e;"string"==typeof t&&(t=n.Rd.encode(t));const r=[];for(let e=0;e<t.length;e+=32768)r.push(String.fromCharCode.apply(null,t.subarray(e,e+32768)));return btoa(r.join(""))},o=e=>i(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),s=e=>{const t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r},a=e=>{let t=e;t instanceof Uint8Array&&(t=n.D0.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return s(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}}},1476:(e,t,r)=>{"use strict";r.d(t,{D0:()=>o,Kp:()=>d,MT:()=>c,Rd:()=>i,VS:()=>h,mx:()=>l,xW:()=>a,yI:()=>f});var n=r(610);const i=new TextEncoder,o=new TextDecoder,s=2**32;function a(...e){const t=e.reduce((e,{length:t})=>e+t,0),r=new Uint8Array(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return r}function c(e,t){return a(i.encode(e),new Uint8Array([0]),t)}function u(e,t,r){if(t<0||t>=s)throw new RangeError(`value must be >= 0 and <= ${s-1}. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,255&t],r)}function l(e){const t=Math.floor(e/s),r=e%s,n=new Uint8Array(8);return u(n,t,0),u(n,r,4),n}function h(e){const t=new Uint8Array(4);return u(t,e),t}function d(e){return a(h(e.length),e)}async function f(e,t,r){const i=Math.ceil((t>>3)/32),o=new Uint8Array(32*i);for(let t=0;t<i;t++){const i=new Uint8Array(4+e.length+r.length);i.set(h(t+1)),i.set(e,4),i.set(r,4+e.length),o.set(await(0,n.A)("sha256",i),32*t)}return o.slice(0,t>>3)}},1542:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var n=r(7991),i=r(7493);const o=async e=>{if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:t,keyUsages:r}=function(e){let t,r;switch(e.kty){case"RSA":switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new i.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"EC":switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"},r=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"},r=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new i.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"OKP":switch(e.alg){case"Ed25519":t={name:"Ed25519"},r=e.d?["sign"]:["verify"];break;case"EdDSA":t={name:e.crv},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new i.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;default:throw new i.JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}(e),o=[t,e.ext??!1,e.key_ops??r],s={...e};return delete s.alg,delete s.use,n.A.subtle.importKey("jwk",s,...o)}},1575:(e,t,r)=>{"use strict";function n(e,t,...r){if((r=r.filter(Boolean)).length>2){const t=r.pop();e+=`one of type ${r.join(", ")}, or ${t}.`}else 2===r.length?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return null==t?e+=` Received ${t}`:"function"==typeof t&&t.name?e+=` Received function ${t.name}`:"object"==typeof t&&null!=t&&t.constructor?.name&&(e+=` Received an instance of ${t.constructor.name}`),e}r.d(t,{A:()=>i,t:()=>o});const i=(e,...t)=>n("Key must be ",e,...t);function o(e,t,...r){return n(`Key for the ${e} algorithm must be `,t,...r)}},1781:function(e,t,r){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.solidLogicSingleton=void 0;const a=s(r(9378)),c=r(9095),u=(0,r(2262).createSolidLogic)({fetch:async(e,t)=>{const r=t&&t.credentials&&"omit"==t.credentials;return c.authSession.info.webId&&!r?c.authSession.fetch(e,t):window.fetch(e,t)}},c.authSession);t.solidLogicSingleton=u,a.log("Unique quadstore initialized.")},1797:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(9746);t.default=function(e){if(!(0,n.default)(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,255&t,(t=parseInt(e.slice(9,13),16))>>>8,255&t,(t=parseInt(e.slice(14,18),16))>>>8,255&t,(t=parseInt(e.slice(19,23),16))>>>8,255&t,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,255&t)}},2168:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(7493);const i=function(e,t,r,i,o){if(void 0!==o.crit&&void 0===i?.crit)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!i||void 0===i.crit)return new Set;if(!Array.isArray(i.crit)||0===i.crit.length||i.crit.some(e=>"string"!=typeof e||0===e.length))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let s;s=void 0!==r?new Map([...Object.entries(r),...t.entries()]):t;for(const t of i.crit){if(!s.has(t))throw new n.JOSENotSupported(`Extension Header Parameter "${t}" is not recognized`);if(void 0===o[t])throw new e(`Extension Header Parameter "${t}" is missing`);if(s.get(t)&&void 0===i[t])throw new e(`Extension Header Parameter "${t}" MUST be integrity protected`)}return new Set(i.crit)}},2196:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default="ffffffff-ffff-ffff-ffff-ffffffffffff"},2222:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});const n=e=>Math.floor(e.getTime()/1e3)},2233:function(e,t,r){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.appContext=void 0,t.offlineTestID=function(){const{$SolidTestEnvironment:e}=window;if(void 0!==e&&e.username)return c.log("Assuming the user is "+e.username),(0,a.sym)(e.username);if("undefined"!=typeof document&&document.location&&"http://localhost"===(""+document.location).slice(0,16)){const e=document.getElementById("appTarget");if(!e)return null;const t=e.getAttribute("testID");return t?(c.log("Assuming user is "+t),(0,a.sym)(t)):null}return null};const a=r(4090),c=s(r(9378));t.appContext=()=>{let{SolidAppContext:e}=window;if(e||={},e.viewingNoAuthPage=!1,e.noAuth&&window.document){if(window.document.location.href.startsWith(e.noAuth)){e.viewingNoAuthPage=!0;const t=new URLSearchParams(window.document.location.search);if(t){let r=e.viewedPage=t.get("uri")||null;if(r&&(r=decodeURI(r),!r.startsWith(e.noAuth))){const t=r.split(/\//);e.idp=t[0]+"//"+t[2],e.viewingNoAuthPage=!1}}}}return e}},2262:function(e,t,r){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.createSolidLogic=function(e,t){y.log("SolidLogic: Unique instance created. There should only be one of these.");const r=a.graph();a.fetcher(r,{fetch:e.fetch}),r.updater=new a.UpdateManager(r),r.features=[];const n=new u.SolidAuthnLogic(t),i=(0,c.createAclLogic)(r),o=(0,p.createContainerLogic)(r),s=(0,g.createUtilityLogic)(r,i,o),m=(0,d.createProfileLogic)(r,n,s),v=(0,l.createChatLogic)(r,m),w=(0,h.createInboxLogic)(r,m,s,o,i),b=(0,f.createTypeIndexLogic)(r,n,m,s);return y.log("SolidAuthnLogic initialized"),{store:r,authn:n,acl:i,inbox:w,chat:v,profile:m,typeIndex:b,load:function(e){return r.fetcher.load(e)},updatePromise:function(e,t=[]){return new Promise((n,i)=>{r.updater.update(e,t,function(e,t,r){t?n():i(new Error(r))})})},clearStore:function(){r.statements.slice().forEach(r.remove.bind(r))}}};const a=s(r(4090)),c=r(6769),u=r(4746),l=r(3091),h=r(7813),d=r(3029),f=r(1177),p=r(942),g=r(699),y=s(r(9378))},2291:(e,t)=>{"use strict";let r;Object.defineProperty(t,"__esModule",{value:!0});const n=new Uint8Array(16);t.default=function(){if(!r){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");r=crypto.getRandomValues.bind(crypto)}return r(n)}},2452:(e,t,r)=>{"use strict";var n=r(4667),i=r(182),o=r(7007),s=r(8134);class a extends n.StorageUtility{constructor(e,t){super(e,t)}}class c extends n.ClientAuthentication{login=async(e,t)=>{"none"!==e.prompt&&await this.sessionInfoManager.clear(e.sessionId);const r=e.redirectUrl??s.normalizeCallbackUrl(window.location.href);if(!n.isValidRedirectUrl(r))throw new Error(`${r} is not a valid redirect URL, it is either a malformed IRI, includes a hash fragment, or reserved query parameters ('code' or 'state').`);await this.loginHandler.handle({...e,redirectUrl:r,clientName:e.clientName??e.clientId,eventEmitter:t})};validateCurrentSession=async e=>{const t=await this.sessionInfoManager.get(e);return void 0===t||void 0===t.clientAppId||void 0===t.issuer?null:t};handleIncomingRedirect=async(e,t)=>{try{const r=await this.redirectHandler.handle(e,t,void 0);return this.fetch=r.fetch.bind(window),this.boundLogout=r.getLogoutUrl,await this.cleanUrlAfterRedirect(e),{isLoggedIn:r.isLoggedIn,webId:r.webId,sessionId:r.sessionId,expirationDate:r.expirationDate,clientAppId:r.clientAppId}}catch(r){return await this.cleanUrlAfterRedirect(e),void t.emit(n.EVENTS.ERROR,"redirect",r)}};async cleanUrlAfterRedirect(e){const t=n.removeOpenIdParams(e).href;for(window.history.replaceState(null,"",t);window.location.href!==t;)await new Promise(e=>{setTimeout(()=>e(),1)})}}function u(e){return"string"==typeof e.oidcIssuer}function l(e){return"string"==typeof e.redirectUrl}class h{storageUtility;oidcHandler;issuerConfigFetcher;clientRegistrar;constructor(e,t,r,n){this.storageUtility=e,this.oidcHandler=t,this.issuerConfigFetcher=r,this.clientRegistrar=n,this.storageUtility=e,this.oidcHandler=t,this.issuerConfigFetcher=r,this.clientRegistrar=n}async canHandle(e){return u(e)&&l(e)}async handle(e){if(!u(e))throw new n.ConfigurationError(`OidcLoginHandler requires an OIDC issuer: missing property 'oidcIssuer' in ${JSON.stringify(e)}`);if(!l(e))throw new n.ConfigurationError(`OidcLoginHandler requires a redirect URL: missing property 'redirectUrl' in ${JSON.stringify(e)}`);const t=await this.issuerConfigFetcher.fetchConfig(e.oidcIssuer),r=await n.handleRegistration(e,t,this.storageUtility,this.clientRegistrar),i={issuer:t.issuer,dpop:"dpop"===e.tokenType.toLowerCase(),...e,issuerConfiguration:t,client:r,scopes:n.normalizeScopes(e.customScopes)};return this.oidcHandler.handle(i)}}class d extends n.AuthorizationCodeWithPkceOidcHandlerBase{async handle(e){const t={authority:e.issuer.toString(),client_id:e.client.clientId,client_secret:e.client.clientSecret,redirect_uri:e.redirectUrl,response_type:"code",scope:e.scopes.join(" "),filterProtocolClaims:!0,loadUserInfo:!1,code_verifier:!0,prompt:e.prompt??"consent"},r=new s.OidcClient(t);try{const t=await r.createSigninRequest();return await this.setupRedirectHandler({oidcLoginOptions:e,state:t.state._id,codeVerifier:t.state._code_verifier,targetUrl:t.url.toString()})}catch(e){console.error(e)}}}const f={issuer:{toKey:"issuer",convertToUrl:!0},authorization_endpoint:{toKey:"authorizationEndpoint",convertToUrl:!0},token_endpoint:{toKey:"tokenEndpoint",convertToUrl:!0},userinfo_endpoint:{toKey:"userinfoEndpoint",convertToUrl:!0},jwks_uri:{toKey:"jwksUri",convertToUrl:!0},registration_endpoint:{toKey:"registrationEndpoint",convertToUrl:!0},end_session_endpoint:{toKey:"endSessionEndpoint",convertToUrl:!0},scopes_supported:{toKey:"scopesSupported"},response_types_supported:{toKey:"responseTypesSupported"},response_modes_supported:{toKey:"responseModesSupported"},grant_types_supported:{toKey:"grantTypesSupported"},acr_values_supported:{toKey:"acrValuesSupported"},subject_types_supported:{toKey:"subjectTypesSupported"},id_token_signing_alg_values_supported:{toKey:"idTokenSigningAlgValuesSupported"},id_token_encryption_alg_values_supported:{toKey:"idTokenEncryptionAlgValuesSupported"},id_token_encryption_enc_values_supported:{toKey:"idTokenEncryptionEncValuesSupported"},userinfo_signing_alg_values_supported:{toKey:"userinfoSigningAlgValuesSupported"},userinfo_encryption_alg_values_supported:{toKey:"userinfoEncryptionAlgValuesSupported"},userinfo_encryption_enc_values_supported:{toKey:"userinfoEncryptionEncValuesSupported"},request_object_signing_alg_values_supported:{toKey:"requestObjectSigningAlgValuesSupported"},request_object_encryption_alg_values_supported:{toKey:"requestObjectEncryptionAlgValuesSupported"},request_object_encryption_enc_values_supported:{toKey:"requestObjectEncryptionEncValuesSupported"},token_endpoint_auth_methods_supported:{toKey:"tokenEndpointAuthMethodsSupported"},token_endpoint_auth_signing_alg_values_supported:{toKey:"tokenEndpointAuthSigningAlgValuesSupported"},display_values_supported:{toKey:"displayValuesSupported"},claim_types_supported:{toKey:"claimTypesSupported"},claims_supported:{toKey:"claimsSupported"},service_documentation:{toKey:"serviceDocumentation"},claims_locales_supported:{toKey:"claimsLocalesSupported"},ui_locales_supported:{toKey:"uiLocalesSupported"},claims_parameter_supported:{toKey:"claimsParameterSupported"},request_parameter_supported:{toKey:"requestParameterSupported"},request_uri_parameter_supported:{toKey:"requestUriParameterSupported"},require_request_uri_registration:{toKey:"requireRequestUriRegistration"},op_policy_uri:{toKey:"opPolicyUri",convertToUrl:!0},op_tos_uri:{toKey:"opTosUri",convertToUrl:!0}};class p{storageUtility;constructor(e){this.storageUtility=e,this.storageUtility=e}static getLocalStorageKey(e){return`issuerConfig:${e}`}async fetchConfig(e){let t;const r=new URL(".well-known/openid-configuration",e.endsWith("/")?e:`${e}/`).href,i=await fetch(r);try{t=function(e){const t={};return Object.keys(e).forEach(r=>{f[r]&&(t[f[r].toKey]=e[r])}),Array.isArray(t.scopesSupported)||(t.scopesSupported=["openid"]),t}(await i.json())}catch(t){throw new n.ConfigurationError(`[${e.toString()}] has an invalid configuration: ${t.message}`)}return await this.storageUtility.set(p.getLocalStorageKey(e),JSON.stringify(t)),t}}class g extends n.SessionInfoManagerBase{async get(e){const[t,r,i,o,s,a,c,u]=await Promise.all([this.storageUtility.getForUser(e,"isLoggedIn",{secure:!0}),this.storageUtility.getForUser(e,"webId",{secure:!0}),this.storageUtility.getForUser(e,"clientId",{secure:!1}),this.storageUtility.getForUser(e,"clientSecret",{secure:!1}),this.storageUtility.getForUser(e,"redirectUrl",{secure:!1}),this.storageUtility.getForUser(e,"refreshToken",{secure:!0}),this.storageUtility.getForUser(e,"issuer",{secure:!1}),this.storageUtility.getForUser(e,"tokenType",{secure:!1})]);if("string"!=typeof s||n.isValidRedirectUrl(s)){if(void 0!==u&&!n.isSupportedTokenType(u))throw new Error(`Tokens of type [${u}] are not supported.`);if(void 0!==i||void 0!==t||void 0!==r||void 0!==a)return{sessionId:e,webId:r,isLoggedIn:"true"===t,redirectUrl:s,refreshToken:a,issuer:c,clientAppId:i,clientAppSecret:o,tokenType:u??"DPoP"}}else await Promise.all([this.storageUtility.deleteAllUserData(e,{secure:!1}),this.storageUtility.deleteAllUserData(e,{secure:!0})])}async clear(e){return async function(e,t){await n.clear(e,t),await s.clearOidcPersistentStorage()}(e,this.storageUtility)}}class y{async canHandle(e){try{return new URL(e),!0}catch(t){throw new Error(`[${e}] is not a valid URL, and cannot be used as a redirect URL: ${t}`)}}async handle(e){return n.getUnauthenticatedSession()}}class m{storageUtility;sessionInfoManager;issuerConfigFetcher;clientRegistrar;tokerRefresher;constructor(e,t,r,n,i){this.storageUtility=e,this.sessionInfoManager=t,this.issuerConfigFetcher=r,this.clientRegistrar=n,this.tokerRefresher=i,this.storageUtility=e,this.sessionInfoManager=t,this.issuerConfigFetcher=r,this.clientRegistrar=n,this.tokerRefresher=i}async canHandle(e){try{const t=new URL(e);return null!==t.searchParams.get("code")&&null!==t.searchParams.get("state")}catch(t){throw new Error(`[${e}] is not a valid URL, and cannot be used as a redirect URL: ${t}`)}}async handle(e,t){if(!await this.canHandle(e))throw new Error(`AuthCodeRedirectHandler cannot handle [${e}]: it is missing one of [code, state].`);const r=new URL(e),i=r.searchParams.get("state"),o=await this.storageUtility.getForUser(i,"sessionId",{errorIfNull:!0}),{issuerConfig:a,codeVerifier:c,redirectUrl:u,dpop:l}=await n.loadOidcContextFromStorage(o,this.storageUtility,this.issuerConfigFetcher),h=r.searchParams.get("iss");if("string"==typeof h&&h!==a.issuer)throw new Error(`The value of the iss parameter (${h}) does not match the issuer identifier of the authorization server (${a.issuer}). See [rfc9207](https://www.rfc-editor.org/rfc/rfc9207.html#section-2.3-3.1.1)`);if(void 0===c)throw new Error(`The code verifier for session ${o} is missing from storage.`);if(void 0===u)throw new Error(`The redirect URL for session ${o} is missing from storage.`);const d=await this.clientRegistrar.getClient({sessionId:o},a),f=Date.now(),p=await s.getTokens(a,d,{grantType:"authorization_code",code:r.searchParams.get("code"),codeVerifier:c,redirectUrl:u},l);let g;window.localStorage.removeItem(`oidc.${i}`),void 0!==p.refreshToken&&(g={sessionId:o,refreshToken:p.refreshToken,tokenRefresher:this.tokerRefresher});const y=n.buildAuthenticatedFetch(p.accessToken,{dpopKey:p.dpopKey,refreshOptions:g,eventEmitter:t,expiresIn:p.expiresIn});await n.saveSessionInfoToStorage(this.storageUtility,o,p.webId,p.clientId,"true",void 0,!0);const m=await this.sessionInfoManager.get(o);if(!m)throw new Error(`Could not retrieve session: [${o}].`);return Object.assign(m,{fetch:y,getLogoutUrl:n.maybeBuildRpInitiatedLogout({idTokenHint:p.idToken,endSessionEndpoint:a.endSessionEndpoint}),expirationDate:"number"==typeof p.expiresIn?f+1e3*p.expiresIn:void 0})}}class v extends n.AggregateHandler{constructor(e){super(e)}}class w{get storage(){return window.localStorage}async get(e){return this.storage.getItem(e)||void 0}async set(e,t){this.storage.setItem(e,t)}async delete(e){this.storage.removeItem(e)}}class b{redirect(e,t){t&&t.handleRedirect?t.handleRedirect(e):t&&t.redirectByReplacingState?window.history.replaceState({},"",e):window.location.href=e}}class _{storageUtility;constructor(e){this.storageUtility=e,this.storageUtility=e}async getClient(e,t){const[r,i,o,a,c]=await Promise.all([this.storageUtility.getForUser(e.sessionId,"clientId",{secure:!1}),this.storageUtility.getForUser(e.sessionId,"clientSecret",{secure:!1}),this.storageUtility.getForUser(e.sessionId,"expiresAt",{secure:!1}),this.storageUtility.getForUser(e.sessionId,"clientName",{secure:!1}),this.storageUtility.getForUser(e.sessionId,"clientType",{secure:!1})]),u=void 0!==o?Number.parseInt(o,10):-1,l=void 0!==i&&0!==u&&Math.floor(Date.now()/1e3)>u;if(r&&n.isKnownClientType(c)&&!l)return void 0!==i?{clientId:r,clientSecret:i,clientName:a,clientType:"dynamic",expiresAt:u}:{clientId:r,clientName:a,clientType:c};try{const r=await s.registerClient(e,t),n={clientId:r.clientId,clientType:"dynamic"};return void 0!==r.clientSecret&&(n.clientSecret=r.clientSecret,n.expiresAt=String(r.expiresAt)),r.idTokenSignedResponseAlg&&(n.idTokenSignedResponseAlg=r.idTokenSignedResponseAlg),await this.storageUtility.setForUser(e.sessionId,n,{secure:!1}),r}catch(e){throw new Error("Client registration failed.",{cause:e})}}}class S{async canHandle(e){try{return new URL(e).searchParams.has("error")}catch(t){throw new Error(`[${e}] is not a valid URL, and cannot be used as a redirect URL: ${t}`)}}async handle(e,t){if(void 0!==t){const r=new URL(e),i=r.searchParams.get("error"),o=r.searchParams.get("error_description");t.emit(n.EVENTS.ERROR,i,o)}return n.getUnauthenticatedSession()}}class E{storageUtility;issuerConfigFetcher;clientRegistrar;constructor(e,t,r){this.storageUtility=e,this.issuerConfigFetcher=t,this.clientRegistrar=r,this.storageUtility=e,this.issuerConfigFetcher=t,this.clientRegistrar=r}async refresh(e,t,r,i){const o=await n.loadOidcContextFromStorage(e,this.storageUtility,this.issuerConfigFetcher),a=await this.clientRegistrar.getClient({sessionId:e},o.issuerConfig);if(void 0===t)throw new Error(`Session [${e}] has no refresh token to allow it to refresh its access token.`);if(o.dpop&&void 0===r)throw new Error(`For session [${e}], the key bound to the DPoP access token must be provided to refresh said access token.`);const c=await s.refresh(t,o.issuerConfig,a,r);return void 0!==c.refreshToken&&i?.emit(n.EVENTS.NEW_REFRESH_TOKEN,c.refreshToken),c}}function A(e){const t=new n.InMemoryStorage,r=e.secureStorage||t,i=e.insecureStorage||new w,o=new a(r,i),s=new p(o),u=new _(o),l=new g(o),f=new E(o,s,u),A=new b,x=new h(o,new d(o,A),s,u),T=new v([new S,new m(o,l,s,u,f),new y]);return new c(x,T,new n.IWaterfallLogoutHandler(l,A),l,s)}const x=`${n.SOLID_CLIENT_AUTHN_KEY_PREFIX}currentSession`,T=`${n.SOLID_CLIENT_AUTHN_KEY_PREFIX}currentUrl`;class F{info;events;clientAuthentication;tokenRequestInProgress=!1;constructor(e={},t=void 0){this.events=new o,e.clientAuthentication?this.clientAuthentication=e.clientAuthentication:e.secureStorage&&e.insecureStorage?this.clientAuthentication=A({secureStorage:e.secureStorage,insecureStorage:e.insecureStorage}):this.clientAuthentication=A({}),e.sessionInfo?this.info={sessionId:e.sessionInfo.sessionId,isLoggedIn:!1,webId:e.sessionInfo.webId,clientAppId:e.sessionInfo.clientAppId}:this.info={sessionId:t??i.v4(),isLoggedIn:!1},this.events.on(n.EVENTS.LOGIN,()=>window.localStorage.setItem(x,this.info.sessionId)),this.events.on(n.EVENTS.SESSION_EXPIRED,()=>this.internalLogout(!1)),this.events.on(n.EVENTS.ERROR,()=>this.internalLogout(!1))}login=async e=>(await this.clientAuthentication.login({sessionId:this.info.sessionId,...e,tokenType:e.tokenType??"DPoP"},this.events),new Promise(()=>{}));fetch=(e,t)=>this.clientAuthentication.fetch(e,t);internalLogout=async(e,t)=>{window.localStorage.removeItem(x),await this.clientAuthentication.logout(this.info.sessionId,t),this.info.isLoggedIn=!1,e&&this.events.emit(n.EVENTS.LOGOUT)};logout=async e=>this.internalLogout(!0,e);handleIncomingRedirect=async(e={})=>{if(this.info.isLoggedIn)return this.info;if(this.tokenRequestInProgress)return;const t="string"==typeof e?{url:e}:e,r=t.url??window.location.href;this.tokenRequestInProgress=!0;const i=await this.clientAuthentication.handleIncomingRedirect(r,this.events);if(function(e){return!!e?.isLoggedIn}(i)){this.setSessionInfo(i);const e=window.localStorage.getItem(T);null===e?this.events.emit(n.EVENTS.LOGIN):(window.localStorage.removeItem(T),this.events.emit(n.EVENTS.SESSION_RESTORED,e))}else if(!0===t.restorePreviousSession){const e=window.localStorage.getItem(x);if(null!==e){if(await async function(e,t,r){const n=await t.validateCurrentSession(e);return null!==n&&(window.localStorage.setItem(T,window.location.href),await t.login({sessionId:e,prompt:"none",oidcIssuer:n.issuer,redirectUrl:n.redirectUrl,clientId:n.clientAppId,clientSecret:n.clientAppSecret,tokenType:n.tokenType??"DPoP"},r.events),!0)}(e,this.clientAuthentication,this))return new Promise(()=>{})}}return this.tokenRequestInProgress=!1,i};setSessionInfo(e){this.info.isLoggedIn=e.isLoggedIn,this.info.webId=e.webId,this.info.sessionId=e.sessionId,this.info.clientAppId=e.clientAppId,this.info.expirationDate=e.expirationDate,this.events.on(n.EVENTS.SESSION_EXTENDED,e=>{this.info.expirationDate=Date.now()+1e3*e})}}let k;function I(){return void 0===k&&(k=new F),k}Object.defineProperty(t,"ConfigurationError",{enumerable:!0,get:function(){return n.ConfigurationError}}),Object.defineProperty(t,"EVENTS",{enumerable:!0,get:function(){return n.EVENTS}}),Object.defineProperty(t,"InMemoryStorage",{enumerable:!0,get:function(){return n.InMemoryStorage}}),Object.defineProperty(t,"NotImplementedError",{enumerable:!0,get:function(){return n.NotImplementedError}}),t.Session=F,t.events=()=>I().events,t.fetch=(...e)=>I().fetch(...e),t.getDefaultSession=I,t.handleIncomingRedirect=(...e)=>I().handleIncomingRedirect(...e),t.login=(...e)=>I().login(...e),t.logout=(...e)=>I().logout(...e)},2609:(e,t,r)=>{"use strict";r.d(t,{T:()=>i});var n=r(5550);class i{constructor(e){this._flattened=new n.n(e)}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}async sign(e,t){const r=await this._flattened.sign(e,t);if(void 0===r.payload)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${r.protected}.${r.payload}.${r.signature}`}}},2698:(e,t,r)=>{"use strict";function n(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function i(e,t){return e.name===t}function o(e){return parseInt(e.name.slice(4),10)}function s(e,t){if(t.length&&!t.some(t=>e.usages.includes(t))){let e="CryptoKey does not support this operation, its usages must include ";if(t.length>2){const r=t.pop();e+=`one of ${t.join(", ")}, or ${r}.`}else 2===t.length?e+=`one of ${t[0]} or ${t[1]}.`:e+=`${t[0]}.`;throw new TypeError(e)}}function a(e,t,...r){switch(t){case"HS256":case"HS384":case"HS512":{if(!i(e.algorithm,"HMAC"))throw n("HMAC");const r=parseInt(t.slice(2),10);if(o(e.algorithm.hash)!==r)throw n(`SHA-${r}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!i(e.algorithm,"RSASSA-PKCS1-v1_5"))throw n("RSASSA-PKCS1-v1_5");const r=parseInt(t.slice(2),10);if(o(e.algorithm.hash)!==r)throw n(`SHA-${r}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!i(e.algorithm,"RSA-PSS"))throw n("RSA-PSS");const r=parseInt(t.slice(2),10);if(o(e.algorithm.hash)!==r)throw n(`SHA-${r}`,"algorithm.hash");break}case"EdDSA":if("Ed25519"!==e.algorithm.name&&"Ed448"!==e.algorithm.name)throw n("Ed25519 or Ed448");break;case"Ed25519":if(!i(e.algorithm,"Ed25519"))throw n("Ed25519");break;case"ES256":case"ES384":case"ES512":{if(!i(e.algorithm,"ECDSA"))throw n("ECDSA");const r=function(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}(t);if(e.algorithm.namedCurve!==r)throw n(r,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}s(e,r)}function c(e,t,...r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!i(e.algorithm,"AES-GCM"))throw n("AES-GCM");const r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw n(r,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!i(e.algorithm,"AES-KW"))throw n("AES-KW");const r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw n(r,"algorithm.length");break}case"ECDH":switch(e.algorithm.name){case"ECDH":case"X25519":case"X448":break;default:throw n("ECDH, X25519, or X448")}break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!i(e.algorithm,"PBKDF2"))throw n("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!i(e.algorithm,"RSA-OAEP"))throw n("RSA-OAEP");const r=parseInt(t.slice(9),10)||1;if(o(e.algorithm.hash)!==r)throw n(`SHA-${r}`,"algorithm.hash");break}default:throw new TypeError("CryptoKey does not support this operation")}s(e,r)}r.d(t,{$:()=>c,Y:()=>a})},2727:(e,t,r)=>{"use strict";r.r(t),r.d(t,{docpart:()=>o,document:()=>s,hostpart:()=>a,join:()=>c,protocol:()=>u,refTo:()=>l});var n=r(5108),i=i||console.log;function o(e){var t;return(t=e.indexOf("#"))<0?e:e.slice(0,t)}function s(e){return new n.A(o(e))}function a(e){var t=/[^\/]*\/\/([^\/]*)\//.exec(e);return t?t[1]:""}function c(e,t){var r,n,o,s,a,c=t.indexOf("#");if(c>0&&(t=t.slice(0,c)),0===e.length)return t;if(0===e.indexOf("#"))return t+e;if(e.indexOf(":")>=0)return e;if(r=t.indexOf(":"),0===t.length)return e;if(r<0)return i("Invalid base: "+t+" in join with given: "+e),e;if(n=t.slice(0,+r+1||9e9),0===e.indexOf("//"))return n+e;if(t.indexOf("//",r)===r+1){if((o=t.indexOf("/",r+3))<0)return t.length-r-3>0?t+"/"+e:n+e}else if((o=t.indexOf("/",r+1))<0)return t.length-r-1>0?t+"/"+e:n+e;if(0===e.indexOf("/"))return t.slice(0,o)+e;if((s=(a=t.slice(o)).lastIndexOf("/"))<0)return n+e;for(s>=0&&s<a.length-1&&(a=a.slice(0,+s+1||9e9)),a+=e;a.match(/[^\/]*\/\.\.\//);)a=a.replace(/[^\/]*\/\.\.\//,"");return a=(a=a.replace(/\.\//g,"")).replace(/\/\.$/,"/"),t.slice(0,o)+a}function u(e){const t=e.indexOf(":");return t<0?null:e.slice(0,t)}function l(e,t){var r,n,i,o,s,a,c,u,l,h,d,f,p=new RegExp("^[-_a-zA-Z0-9.]+:(//[^/]*)?/[^/]*$");if(!e)return t;if(e===t)return"";for(r=c=0,o=t.length;c<o;r=++c){if(t[r]!==e[r])break}if(e.slice(0,r).match(p)&&((n=t.indexOf("//"))<0&&(n=-2),i=t.indexOf("/",n+2),"/"!==t[i+1]&&"/"!==e[i+1]&&t.slice(0,i)===e.slice(0,i)))return t.slice(i);if("#"===t[r]&&e.length===r)return t.slice(r);for(;r>0&&"/"!==t[r-1];)r--;if(r<3)return t;if(e.indexOf("//",r-2)>0||t.indexOf("//",r-2)>0)return t;if(e.indexOf(":",r)>0)return t;for(a=0,u=0,s=(h=e.slice(r)).length;u<s;u++)"/"===h[u]&&a++;if(0===a&&r<t.length&&"#"===t[r])return"./"+t.slice(r);if(0===a&&r===t.length)return"./";if(f="",a>0)for(l=1,d=a;d>=1?l<=d:l>=d;d>=1?++l:--l)f+="../";return f+t.slice(r)}},2770:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(9746);t.default=function(e){if(!(0,n.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}},2829:(e,t)=>{"use strict";function r(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:case 3:return t^r^n;case 2:return t&r^t&n^r&n}}function n(e,t){return e<<t|e>>>32-t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){const t=[1518500249,1859775393,2400959708,3395469782],i=[1732584193,4023233417,2562383102,271733878,3285377520],o=new Uint8Array(e.length+1);o.set(e),o[e.length]=128;const s=(e=o).length/4+2,a=Math.ceil(s/16),c=new Array(a);for(let t=0;t<a;++t){const r=new Uint32Array(16);for(let n=0;n<16;++n)r[n]=e[64*t+4*n]<<24|e[64*t+4*n+1]<<16|e[64*t+4*n+2]<<8|e[64*t+4*n+3];c[t]=r}c[a-1][14]=8*(e.length-1)/Math.pow(2,32),c[a-1][14]=Math.floor(c[a-1][14]),c[a-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<a;++e){const o=new Uint32Array(80);for(let t=0;t<16;++t)o[t]=c[e][t];for(let e=16;e<80;++e)o[e]=n(o[e-3]^o[e-8]^o[e-14]^o[e-16],1);let s=i[0],a=i[1],u=i[2],l=i[3],h=i[4];for(let e=0;e<80;++e){const i=Math.floor(e/20),c=n(s,5)+r(i,a,u,l)+h+t[i]+o[e]>>>0;h=l,l=u,u=n(a,30)>>>0,a=s,s=c}i[0]=i[0]+s>>>0,i[1]=i[1]+a>>>0,i[2]=i[2]+u>>>0,i[3]=i[3]+l>>>0,i[4]=i[4]+h>>>0}return Uint8Array.of(i[0]>>24,i[0]>>16,i[0]>>8,i[0],i[1]>>24,i[1]>>16,i[1]>>8,i[1],i[2]>>24,i[2]>>16,i[2]>>8,i[2],i[3]>>24,i[3]>>16,i[3]>>8,i[3],i[4]>>24,i[4]>>16,i[4]>>8,i[4])}},2915:(e,t,r)=>{"use strict";r.d(t,{CZ:()=>c,D0:()=>h,DJ:()=>a,DZ:()=>l,GE:()=>v,P3:()=>s,RN:()=>w,SH:()=>i,Y2:()=>p,YC:()=>m,aF:()=>f,c$:()=>d,fY:()=>u,hr:()=>y,jt:()=>g,ok:()=>o});var n=r(9403);function i(e){return"object"==typeof e&&null!==e&&"subject"in e}function o(e){return"object"==typeof e&&null!==e&&"statements"in e}function s(e){return h(e)&&e.termType===n.r0}function a(e){return e&&Object.prototype.hasOwnProperty.call(e,"termType")&&(e.termType===n.Kk||e.termType===n.P2||e.termType===n.$Q||e.termType===n.r0||e.termType===n.QW||e.termType===n.bD)}function c(e){return e&&Object.prototype.hasOwnProperty.call(e,"termType")&&(e.termType===n.Kk||e.termType===n.P2||e.termType===n.$Q||e.termType===n.r0||e.termType===n.QW||e.termType===n.bD)}function u(e){return h(e)&&(e.termType===n.Kk||e.termType===n.$Q||e.termType===n.P2)}function l(e){return h(e)&&e.termType===n.P2}function h(e){return"object"==typeof e&&null!==e&&"termType"in e}function d(e){return e.termType===n.QW}function f(e){return"object"==typeof e&&null!==e&&"subject"in e&&"predicate"in e&&"object"in e}function p(e){return h(e)&&"NamedNode"===e.termType}function g(e){return h(e)&&"termType"in e&&"BlankNode"===e.termType}function y(e){return h(e)&&(e.termType===n.Kk||e.termType===n.P2||e.termType===n.$Q)}function m(e){return h(e)&&(e.termType===n.Kk||e.termType===n.P2)}function v(e){return h(e)&&(e.termType===n.Kk||e.termType===n.P2||e.termType===n.$Q||e.termType===n.QW)}function w(e){return h(e)&&(e.termType===n.Kk||e.termType===n.P2||e.termType===n.$Q||e.termType===n.ic)}},2931:(e,t,r)=>{"use strict";function n(e){return"string"==typeof e?e:e.value}r.d(t,{E:()=>n})},2988:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.URL=t.DNS=t.stringToBytes=void 0;const n=r(1797),i=r(6011);function o(e){e=unescape(encodeURIComponent(e));const t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}t.stringToBytes=o,t.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",t.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",t.default=function(e,t,r,s,a,c){const u="string"==typeof r?o(r):r,l="string"==typeof s?(0,n.default)(s):s;if("string"==typeof s&&(s=(0,n.default)(s)),16!==s?.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let h=new Uint8Array(16+u.length);if(h.set(l),h.set(u,l.length),h=t(h),h[6]=15&h[6]|e,h[8]=63&h[8]|128,a){c=c||0;for(let e=0;e<16;++e)a[c+e]=h[e];return a}return(0,i.unsafeStringify)(h)}},3029:function(e,t,r){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.createProfileLogic=function(e,t,r){const n=u.ns;async function i(t){await o(t);const i=(0,l.suggestPreferencesFile)(t);let s;try{s=await r.followOrCreateLink(t,n.space("preferencesFile"),i,t.doc())}catch(e){const r=`User ${t} has no pointer in profile to preferences file.`;if(c.warn(r),e instanceof a.NotEditableError)throw e;if(e instanceof a.WebOperationError)throw e;if(e instanceof a.UnauthorizedError)throw e;if(e instanceof a.CrossOriginForbiddenError)throw e;if(e instanceof a.SameOriginForbiddenError)throw e;if(e instanceof a.FetchError)throw e;throw e}try{await e.fetcher.load(s)}catch(e){const r=`Unable to load preference of user ${t}: ${e}`;if(c.warn(r),401===e.response.status)throw new a.UnauthorizedError;if(403===e.response.status){if((0,l.differentOrigin)(s))throw new a.CrossOriginForbiddenError;throw new a.SameOriginForbiddenError}throw new Error(r)}return s}async function o(t){if(!t)throw new Error("loadProfile: no user given.");try{await e.fetcher.load(t.doc())}catch(e){throw new Error(`Unable to load profile of user ${t}: ${e}`)}return t.doc()}function s(t){return e.any(t,n.space("storage"),void 0,t.doc())}return{loadMe:async function(){const r=t.currentUser();if(null===r)throw new Error("Current user not found! Not logged in?");return await e.fetcher.load(r.doc()),r},getPodRoot:function(e){const t=s(e);if(!t)throw new Error("User pod root not found!");return t},getMainInbox:async function(t){await e.fetcher.load(t);const r=e.any(t,n.ldp("inbox"),void 0,t.doc());if(!r)throw new Error("User main inbox not found!");return r},findStorage:s,loadPreferences:i,loadProfile:o,silencedLoadPreferences:async function(e){try{return await i(e)}catch(e){return}}}};const a=r(390),c=s(r(9378)),u=r(6118),l=r(6848)},3085:(e,t,r)=>{"use strict";r.d(t,{G:()=>a});var n=r(2222),i=r(149),o=r(6957);function s(e,t){if(!Number.isFinite(t))throw new TypeError(`Invalid ${e} input`);return t}class a{constructor(e={}){if(!(0,i.A)(e))throw new TypeError("JWT Claims Set MUST be an object");this._payload=e}setIssuer(e){return this._payload={...this._payload,iss:e},this}setSubject(e){return this._payload={...this._payload,sub:e},this}setAudience(e){return this._payload={...this._payload,aud:e},this}setJti(e){return this._payload={...this._payload,jti:e},this}setNotBefore(e){return"number"==typeof e?this._payload={...this._payload,nbf:s("setNotBefore",e)}:e instanceof Date?this._payload={...this._payload,nbf:s("setNotBefore",(0,n.A)(e))}:this._payload={...this._payload,nbf:(0,n.A)(new Date)+(0,o.A)(e)},this}setExpirationTime(e){return"number"==typeof e?this._payload={...this._payload,exp:s("setExpirationTime",e)}:e instanceof Date?this._payload={...this._payload,exp:s("setExpirationTime",(0,n.A)(e))}:this._payload={...this._payload,exp:(0,n.A)(new Date)+(0,o.A)(e)},this}setIssuedAt(e){return void 0===e?this._payload={...this._payload,iat:(0,n.A)(new Date)}:e instanceof Date?this._payload={...this._payload,iat:s("setIssuedAt",(0,n.A)(e))}:this._payload="string"==typeof e?{...this._payload,iat:s("setIssuedAt",(0,n.A)(new Date)+(0,o.A)(e))}:{...this._payload,iat:s("setIssuedAt",e)},this}}},3091:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createChatLogic=function(e,t){const r=i.ns;async function a(t,r,i){await e.fetcher.load(t);const o=e.any(t,new n.NamedNode("http://www.iana.org/assignments/link-relations/acl"));if(!o)throw new Error("Chat ACL doc not found!");const s=`\n @prefix acl: <http://www.w3.org/ns/auth/acl#>.\n <#owner>\n a acl:Authorization;\n acl:agent <${r.value}>;\n acl:accessTo <.>;\n acl:default <.>;\n acl:mode\n acl:Read, acl:Write, acl:Control.\n <#invitee>\n a acl:Authorization;\n acl:agent <${i.value}>;\n acl:accessTo <.>;\n acl:default <.>;\n acl:mode\n acl:Read, acl:Append.\n `;await e.fetcher.webOperation("PUT",o.value,{data:s,contentType:"text/turtle"})}async function c(t,i){const s=e.any(i,r.solid("privateTypeIndex"));if(!s)throw new Error("Private type index not found!");await e.fetcher.load(s);const a=(0,o.newThing)(s),c=[(0,n.st)(a,r.rdf("type"),r.solid("TypeRegistration"),s.doc()),(0,n.st)(a,r.solid("forClass"),r.meeting("LongChat"),s.doc()),(0,n.st)(a,r.solid("instance"),t,s.doc())];await new Promise((t,r)=>{e.updater.update([],c,function(e,n,i){n?t(null):r(new Error(i))})})}async function u(r){const i=await t.loadMe(),s=await t.getPodRoot(i),a=(0,o.determineChatContainer)(r,s);let c=!0;try{await e.fetcher.load(new n.NamedNode(a.value+"index.ttl#this"))}catch(e){c=!1}return{me:i,chatContainer:a,exists:c}}async function l(e,t){return(await h({me:t,newBase:e.value})).newInstance}function h(t){const i=e,o=i.updater;if(t.me&&!t.me.uri)throw new Error("chat mintNew: Invalid userid "+t.me);const a=t.newInstance=t.newInstance||i.sym(t.newBase+s),c=a.doc();return i.add(a,r.rdf("type"),r.meeting("LongChat"),c),i.add(a,r.dc("title"),"Chat channel",c),i.add(a,r.dc("created"),(0,n.term)(new Date(Date.now())),c),t.me&&i.add(a,r.dc("author"),t.me,c),new Promise(function(e,r){o?.put(c,i.statementsMatching(void 0,void 0,void 0,c),"text/turtle",function(n,i,o){i?e({...t,newInstance:a}):r(new Error("FAILED to save new chat channel at: "+n+" : "+o))})})}async function d(t,n){await e.fetcher.load(t.doc());const i=e.any(t,r.ldp("inbox"),void 0,t.doc());if(!i)throw new Error(`Invitee inbox not found! ${t.value}`);const o=`\n <> a <http://www.w3.org/ns/pim/meeting#LongChatInvite> ;\n ${r.rdf("seeAlso")} <${n.value}> .\n `,s=await(e.fetcher?.webOperation("POST",i.value,{data:o,contentType:"text/turtle"})),a=s?.headers.get("location");if(!a)throw new Error(`Invite sending returned a ${s?.status}`)}return{setAcl:a,addToPrivateTypeIndex:c,findChat:u,createChatThing:l,getChat:async function(e,t=!0){const{me:r,chatContainer:i,exists:o}=await u(e);if(o)return new n.NamedNode(i.value+s);if(t){const t=await l(i,r);return await d(e,t),await a(i,r,e),await c(t,r),t}return null},sendInvite:d,mintNew:h}};const n=r(4090),i=r(6118),o=r(6848),s="index.ttl#this"},3121:(e,t,r)=>{"use strict";r.r(t),r.d(t,{CompactEncrypt:()=>Z,CompactSign:()=>ee.T,EmbeddedJWK:()=>he,EncryptJWT:()=>se,FlattenedEncrypt:()=>W,FlattenedSign:()=>te.n,GeneralEncrypt:()=>V,GeneralSign:()=>ne,SignJWT:()=>ie.P,UnsecuredJWT:()=>pe,base64url:()=>n,calculateJwkThumbprint:()=>ue,calculateJwkThumbprintUri:()=>le,compactDecrypt:()=>M,compactVerify:()=>$.B,createLocalJWKSet:()=>de.w,createRemoteJWKSet:()=>fe.RD,cryptoRuntime:()=>Se,decodeJwt:()=>ve,decodeProtectedHeader:()=>me,errors:()=>s,experimental_jwksCache:()=>fe.tK,exportJWK:()=>q.JU,exportPKCS8:()=>q.Yp,exportSPKI:()=>q.Y5,flattenedDecrypt:()=>j,flattenedVerify:()=>z.Z,generalDecrypt:()=>H,generalVerify:()=>G,generateKeyPair:()=>we.T,generateSecret:()=>_e,importJWK:()=>R.Og,importPKCS8:()=>R.Lf,importSPKI:()=>R.jU,importX509:()=>R.Mh,jwksCache:()=>fe.gE,jwtDecrypt:()=>Q,jwtVerify:()=>X.V});var n={};r.r(n),r.d(n,{decode:()=>ye,encode:()=>ge});var i=r(1436),o=r(1476),s=r(7493),a=r(8057);function c(e){switch(e){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new s.JOSENotSupported(`Unsupported JWE Algorithm: ${e}`)}}const u=(e,t)=>{if(t.length<<3!==c(e))throw new s.JWEInvalid("Invalid Initialization Vector length")},l=(e,t)=>{const r=e.byteLength<<3;if(r!==t)throw new s.JWEInvalid(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)},h=(e,t)=>{if(!(e instanceof Uint8Array))throw new TypeError("First argument must be a buffer");if(!(t instanceof Uint8Array))throw new TypeError("Second argument must be a buffer");if(e.length!==t.length)throw new TypeError("Input buffers must have the same length");const r=e.length;let n=0,i=-1;for(;++i<r;)n|=e[i]^t[i];return 0===n};var d=r(7991),f=r(2698),p=r(1575),g=r(5994);const y=async(e,t,r,n,i,a)=>{if(!((0,d.R)(t)||t instanceof Uint8Array))throw new TypeError((0,p.A)(t,...g.g,"Uint8Array"));if(!n)throw new s.JWEInvalid("JWE Initialization Vector missing");if(!i)throw new s.JWEInvalid("JWE Authentication Tag missing");switch(u(e,n),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return t instanceof Uint8Array&&l(t,parseInt(e.slice(-3),10)),async function(e,t,r,n,i,a){if(!(t instanceof Uint8Array))throw new TypeError((0,p.A)(t,"Uint8Array"));const c=parseInt(e.slice(1,4),10),u=await d.A.subtle.importKey("raw",t.subarray(c>>3),"AES-CBC",!1,["decrypt"]),l=await d.A.subtle.importKey("raw",t.subarray(0,c>>3),{hash:"SHA-"+(c<<1),name:"HMAC"},!1,["sign"]),f=(0,o.xW)(a,n,r,(0,o.mx)(a.length<<3)),g=new Uint8Array((await d.A.subtle.sign("HMAC",l,f)).slice(0,c>>3));let y,m;try{y=h(i,g)}catch{}if(!y)throw new s.JWEDecryptionFailed;try{m=new Uint8Array(await d.A.subtle.decrypt({iv:n,name:"AES-CBC"},u,r))}catch{}if(!m)throw new s.JWEDecryptionFailed;return m}(e,t,r,n,i,a);case"A128GCM":case"A192GCM":case"A256GCM":return t instanceof Uint8Array&&l(t,parseInt(e.slice(1,4),10)),async function(e,t,r,n,i,a){let c;t instanceof Uint8Array?c=await d.A.subtle.importKey("raw",t,"AES-GCM",!1,["decrypt"]):((0,f.$)(t,e,"decrypt"),c=t);try{return new Uint8Array(await d.A.subtle.decrypt({additionalData:a,iv:n,name:"AES-GCM",tagLength:128},c,(0,o.xW)(r,i)))}catch{throw new s.JWEDecryptionFailed}}(e,t,r,n,i,a);default:throw new s.JOSENotSupported("Unsupported JWE Content Encryption Algorithm")}};var m=r(9874),v=r(149);const w=[{hash:"SHA-256",name:"HMAC"},!0,["sign"]];function b(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw new TypeError(`Invalid key size for alg: ${t}`)}function _(e,t,r){if((0,d.R)(e))return(0,f.$)(e,t,r),e;if(e instanceof Uint8Array)return d.A.subtle.importKey("raw",e,"AES-KW",!0,[r]);throw new TypeError((0,p.A)(e,...g.g,"Uint8Array"))}const S=async(e,t,r)=>{const n=await _(t,e,"wrapKey");b(n,e);const i=await d.A.subtle.importKey("raw",r,...w);return new Uint8Array(await d.A.subtle.wrapKey("raw",i,n,"AES-KW"))},E=async(e,t,r)=>{const n=await _(t,e,"unwrapKey");b(n,e);const i=await d.A.subtle.unwrapKey("raw",r,n,"AES-KW",...w);return new Uint8Array(await d.A.subtle.exportKey("raw",i))};async function A(e,t,r,n,i=new Uint8Array(0),s=new Uint8Array(0)){if(!(0,d.R)(e))throw new TypeError((0,p.A)(e,...g.g));if((0,f.$)(e,"ECDH"),!(0,d.R)(t))throw new TypeError((0,p.A)(t,...g.g));(0,f.$)(t,"ECDH","deriveBits");const a=(0,o.xW)((0,o.Kp)(o.Rd.encode(r)),(0,o.Kp)(i),(0,o.Kp)(s),(0,o.VS)(n));let c;c="X25519"===e.algorithm.name?256:"X448"===e.algorithm.name?448:Math.ceil(parseInt(e.algorithm.namedCurve.substr(-3),10)/8)<<3;const u=new Uint8Array(await d.A.subtle.deriveBits({name:e.algorithm.name,public:e},t,c));return(0,o.yI)(u,n,a)}function x(e){if(!(0,d.R)(e))throw new TypeError((0,p.A)(e,...g.g));return["P-256","P-384","P-521"].includes(e.algorithm.namedCurve)||"X25519"===e.algorithm.name||"X448"===e.algorithm.name}async function T(e,t,r,n){!function(e){if(!(e instanceof Uint8Array)||e.length<8)throw new s.JWEInvalid("PBES2 Salt Input must be 8 or more octets")}(e);const i=(0,o.MT)(t,e),a=parseInt(t.slice(13,16),10),c={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:i},u={length:a,name:"AES-KW"},l=await function(e,t){if(e instanceof Uint8Array)return d.A.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);if((0,d.R)(e))return(0,f.$)(e,t,"deriveBits","deriveKey"),e;throw new TypeError((0,p.A)(e,...g.g,"Uint8Array"))}(n,t);if(l.usages.includes("deriveBits"))return new Uint8Array(await d.A.subtle.deriveBits(c,l,a));if(l.usages.includes("deriveKey"))return d.A.subtle.deriveKey(c,l,u,!1,["wrapKey","unwrapKey"]);throw new TypeError('PBKDF2 key "usages" must include "deriveBits" or "deriveKey"')}function F(e){switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new s.JOSENotSupported(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}var k=r(4495);var I=r(3139);function C(e){switch(e){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new s.JOSENotSupported(`Unsupported JWE Algorithm: ${e}`)}}const N=e=>(0,a.A)(new Uint8Array(C(e)>>3));var R=r(8278),P=r(8858);const O=async(e,t,r,n,i)=>{if(!((0,d.R)(r)||r instanceof Uint8Array))throw new TypeError((0,p.A)(r,...g.g,"Uint8Array"));var h;switch(n?u(e,n):(h=e,n=(0,a.A)(new Uint8Array(c(h)>>3))),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&l(r,parseInt(e.slice(-3),10)),async function(e,t,r,n,i){if(!(r instanceof Uint8Array))throw new TypeError((0,p.A)(r,"Uint8Array"));const s=parseInt(e.slice(1,4),10),a=await d.A.subtle.importKey("raw",r.subarray(s>>3),"AES-CBC",!1,["encrypt"]),c=await d.A.subtle.importKey("raw",r.subarray(0,s>>3),{hash:"SHA-"+(s<<1),name:"HMAC"},!1,["sign"]),u=new Uint8Array(await d.A.subtle.encrypt({iv:n,name:"AES-CBC"},a,t)),l=(0,o.xW)(i,n,u,(0,o.mx)(i.length<<3));return{ciphertext:u,tag:new Uint8Array((await d.A.subtle.sign("HMAC",c,l)).slice(0,s>>3)),iv:n}}(e,t,r,n,i);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&l(r,parseInt(e.slice(1,4),10)),async function(e,t,r,n,i){let o;r instanceof Uint8Array?o=await d.A.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):((0,f.$)(r,e,"encrypt"),o=r);const s=new Uint8Array(await d.A.subtle.encrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},o,t)),a=s.slice(-16);return{ciphertext:s.slice(0,-16),tag:a,iv:n}}(e,t,r,n,i);default:throw new s.JOSENotSupported("Unsupported JWE Content Encryption Algorithm")}};const D=async function(e,t,r,n,o){switch((0,P.A)(e,t,"decrypt"),t=await(I.A.normalizePrivateKey?.(t,e))||t,e){case"dir":if(void 0!==r)throw new s.JWEInvalid("Encountered unexpected JWE Encrypted Key");return t;case"ECDH-ES":if(void 0!==r)throw new s.JWEInvalid("Encountered unexpected JWE Encrypted Key");case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!(0,v.A)(n.epk))throw new s.JWEInvalid('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');if(!x(t))throw new s.JOSENotSupported("ECDH with the provided key is not allowed or not supported by your javascript runtime");const o=await(0,R.Og)(n.epk,e);let a,c;if(void 0!==n.apu){if("string"!=typeof n.apu)throw new s.JWEInvalid('JOSE Header "apu" (Agreement PartyUInfo) invalid');try{a=(0,i.D4)(n.apu)}catch{throw new s.JWEInvalid("Failed to base64url decode the apu")}}if(void 0!==n.apv){if("string"!=typeof n.apv)throw new s.JWEInvalid('JOSE Header "apv" (Agreement PartyVInfo) invalid');try{c=(0,i.D4)(n.apv)}catch{throw new s.JWEInvalid("Failed to base64url decode the apv")}}const u=await A(o,t,"ECDH-ES"===e?n.enc:e,"ECDH-ES"===e?C(n.enc):parseInt(e.slice(-5,-2),10),a,c);if("ECDH-ES"===e)return u;if(void 0===r)throw new s.JWEInvalid("JWE Encrypted Key missing");return E(e.slice(-6),u,r)}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":if(void 0===r)throw new s.JWEInvalid("JWE Encrypted Key missing");return(async(e,t,r)=>{if(!(0,d.R)(t))throw new TypeError((0,p.A)(t,...g.g));if((0,f.$)(t,e,"decrypt","unwrapKey"),(0,k.A)(e,t),t.usages.includes("decrypt"))return new Uint8Array(await d.A.subtle.decrypt(F(e),t,r));if(t.usages.includes("unwrapKey")){const n=await d.A.subtle.unwrapKey("raw",r,t,F(e),...w);return new Uint8Array(await d.A.subtle.exportKey("raw",n))}throw new TypeError('RSA-OAEP key "usages" must include "decrypt" or "unwrapKey" for this operation')})(e,t,r);case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{if(void 0===r)throw new s.JWEInvalid("JWE Encrypted Key missing");if("number"!=typeof n.p2c)throw new s.JWEInvalid('JOSE Header "p2c" (PBES2 Count) missing or invalid');const a=o?.maxPBES2Count||1e4;if(n.p2c>a)throw new s.JWEInvalid('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if("string"!=typeof n.p2s)throw new s.JWEInvalid('JOSE Header "p2s" (PBES2 Salt) missing or invalid');let c;try{c=(0,i.D4)(n.p2s)}catch{throw new s.JWEInvalid("Failed to base64url decode the p2s")}return(async(e,t,r,n,i)=>{const o=await T(i,e,n,t);return E(e.slice(-6),o,r)})(e,t,r,n.p2c,c)}case"A128KW":case"A192KW":case"A256KW":if(void 0===r)throw new s.JWEInvalid("JWE Encrypted Key missing");return E(e,t,r);case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{if(void 0===r)throw new s.JWEInvalid("JWE Encrypted Key missing");if("string"!=typeof n.iv)throw new s.JWEInvalid('JOSE Header "iv" (Initialization Vector) missing or invalid');if("string"!=typeof n.tag)throw new s.JWEInvalid('JOSE Header "tag" (Authentication Tag) missing or invalid');let o,a;try{o=(0,i.D4)(n.iv)}catch{throw new s.JWEInvalid("Failed to base64url decode the iv")}try{a=(0,i.D4)(n.tag)}catch{throw new s.JWEInvalid("Failed to base64url decode the tag")}return async function(e,t,r,n,i){const o=e.slice(0,7);return y(o,t,r,n,i,new Uint8Array(0))}(e,t,r,o,a)}default:throw new s.JOSENotSupported('Invalid or unsupported "alg" (JWE Algorithm) header value')}};var U=r(2168),L=r(4618);async function j(e,t,r){if(!(0,v.A)(e))throw new s.JWEInvalid("Flattened JWE must be an object");if(void 0===e.protected&&void 0===e.header&&void 0===e.unprotected)throw new s.JWEInvalid("JOSE Header missing");if(void 0!==e.iv&&"string"!=typeof e.iv)throw new s.JWEInvalid("JWE Initialization Vector incorrect type");if("string"!=typeof e.ciphertext)throw new s.JWEInvalid("JWE Ciphertext missing or incorrect type");if(void 0!==e.tag&&"string"!=typeof e.tag)throw new s.JWEInvalid("JWE Authentication Tag incorrect type");if(void 0!==e.protected&&"string"!=typeof e.protected)throw new s.JWEInvalid("JWE Protected Header incorrect type");if(void 0!==e.encrypted_key&&"string"!=typeof e.encrypted_key)throw new s.JWEInvalid("JWE Encrypted Key incorrect type");if(void 0!==e.aad&&"string"!=typeof e.aad)throw new s.JWEInvalid("JWE AAD incorrect type");if(void 0!==e.header&&!(0,v.A)(e.header))throw new s.JWEInvalid("JWE Shared Unprotected Header incorrect type");if(void 0!==e.unprotected&&!(0,v.A)(e.unprotected))throw new s.JWEInvalid("JWE Per-Recipient Unprotected Header incorrect type");let n;if(e.protected)try{const t=(0,i.D4)(e.protected);n=JSON.parse(o.D0.decode(t))}catch{throw new s.JWEInvalid("JWE Protected Header is invalid")}if(!(0,m.A)(n,e.header,e.unprotected))throw new s.JWEInvalid("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");const a={...n,...e.header,...e.unprotected};if((0,U.A)(s.JWEInvalid,new Map,r?.crit,n,a),void 0!==a.zip)throw new s.JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');const{alg:c,enc:u}=a;if("string"!=typeof c||!c)throw new s.JWEInvalid("missing JWE Algorithm (alg) in JWE Header");if("string"!=typeof u||!u)throw new s.JWEInvalid("missing JWE Encryption Algorithm (enc) in JWE Header");const l=r&&(0,L.A)("keyManagementAlgorithms",r.keyManagementAlgorithms),h=r&&(0,L.A)("contentEncryptionAlgorithms",r.contentEncryptionAlgorithms);if(l&&!l.has(c)||!l&&c.startsWith("PBES2"))throw new s.JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');if(h&&!h.has(u))throw new s.JOSEAlgNotAllowed('"enc" (Encryption Algorithm) Header Parameter value not allowed');let d;if(void 0!==e.encrypted_key)try{d=(0,i.D4)(e.encrypted_key)}catch{throw new s.JWEInvalid("Failed to base64url decode the encrypted_key")}let f,p,g,w=!1;"function"==typeof t&&(t=await t(n,e),w=!0);try{f=await D(c,t,d,a,r)}catch(e){if(e instanceof TypeError||e instanceof s.JWEInvalid||e instanceof s.JOSENotSupported)throw e;f=N(u)}if(void 0!==e.iv)try{p=(0,i.D4)(e.iv)}catch{throw new s.JWEInvalid("Failed to base64url decode the iv")}if(void 0!==e.tag)try{g=(0,i.D4)(e.tag)}catch{throw new s.JWEInvalid("Failed to base64url decode the tag")}const b=o.Rd.encode(e.protected??"");let _,S;_=void 0!==e.aad?(0,o.xW)(b,o.Rd.encode("."),o.Rd.encode(e.aad)):b;try{S=(0,i.D4)(e.ciphertext)}catch{throw new s.JWEInvalid("Failed to base64url decode the ciphertext")}const E={plaintext:await y(u,f,S,p,g,_)};if(void 0!==e.protected&&(E.protectedHeader=n),void 0!==e.aad)try{E.additionalAuthenticatedData=(0,i.D4)(e.aad)}catch{throw new s.JWEInvalid("Failed to base64url decode the aad")}return void 0!==e.unprotected&&(E.sharedUnprotectedHeader=e.unprotected),void 0!==e.header&&(E.unprotectedHeader=e.header),w?{...E,key:t}:E}async function M(e,t,r){if(e instanceof Uint8Array&&(e=o.D0.decode(e)),"string"!=typeof e)throw new s.JWEInvalid("Compact JWE must be a string or Uint8Array");const{0:n,1:i,2:a,3:c,4:u,length:l}=e.split(".");if(5!==l)throw new s.JWEInvalid("Invalid Compact JWE");const h=await j({ciphertext:c,iv:a||void 0,protected:n,tag:u||void 0,encrypted_key:i||void 0},t,r),d={plaintext:h.plaintext,protectedHeader:h.protectedHeader};return"function"==typeof t?{...d,key:h.key}:d}async function H(e,t,r){if(!(0,v.A)(e))throw new s.JWEInvalid("General JWE must be an object");if(!Array.isArray(e.recipients)||!e.recipients.every(v.A))throw new s.JWEInvalid("JWE Recipients missing or incorrect type");if(!e.recipients.length)throw new s.JWEInvalid("JWE Recipients has no members");for(const n of e.recipients)try{return await j({aad:e.aad,ciphertext:e.ciphertext,encrypted_key:n.encrypted_key,header:n.header,iv:e.iv,protected:e.protected,tag:e.tag,unprotected:e.unprotected},t,r)}catch{}throw new s.JWEDecryptionFailed}const B=Symbol();var q=r(5130);const K=async function(e,t,r,n,o={}){let c,u,l;switch((0,P.A)(e,r,"encrypt"),r=await(I.A.normalizePublicKey?.(r,e))||r,e){case"dir":l=r;break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!x(r))throw new s.JOSENotSupported("ECDH with the provided key is not allowed or not supported by your javascript runtime");const{apu:a,apv:h}=o;let{epk:f}=o;f||(f=(await async function(e){if(!(0,d.R)(e))throw new TypeError((0,p.A)(e,...g.g));return d.A.subtle.generateKey(e.algorithm,!0,["deriveBits"])}(r)).privateKey);const{x:y,y:m,crv:v,kty:w}=await(0,q.JU)(f),b=await A(r,f,"ECDH-ES"===e?t:e,"ECDH-ES"===e?C(t):parseInt(e.slice(-5,-2),10),a,h);if(u={epk:{x:y,crv:v,kty:w}},"EC"===w&&(u.epk.y=m),a&&(u.apu=(0,i.lF)(a)),h&&(u.apv=(0,i.lF)(h)),"ECDH-ES"===e){l=b;break}l=n||N(t);const _=e.slice(-6);c=await S(_,b,l);break}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":l=n||N(t),c=await(async(e,t,r)=>{if(!(0,d.R)(t))throw new TypeError((0,p.A)(t,...g.g));if((0,f.$)(t,e,"encrypt","wrapKey"),(0,k.A)(e,t),t.usages.includes("encrypt"))return new Uint8Array(await d.A.subtle.encrypt(F(e),t,r));if(t.usages.includes("wrapKey")){const n=await d.A.subtle.importKey("raw",r,...w);return new Uint8Array(await d.A.subtle.wrapKey("raw",n,t,F(e)))}throw new TypeError('RSA-OAEP key "usages" must include "encrypt" or "wrapKey" for this operation')})(e,r,l);break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{l=n||N(t);const{p2c:s,p2s:h}=o;({encryptedKey:c,...u}=await(async(e,t,r,n=2048,o=(0,a.A)(new Uint8Array(16)))=>{const s=await T(o,e,n,t);return{encryptedKey:await S(e.slice(-6),s,r),p2c:n,p2s:(0,i.lF)(o)}})(e,r,l,s,h));break}case"A128KW":case"A192KW":case"A256KW":l=n||N(t),c=await S(e,r,l);break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{l=n||N(t);const{iv:s}=o;({encryptedKey:c,...u}=await async function(e,t,r,n){const o=e.slice(0,7),s=await O(o,r,t,n,new Uint8Array(0));return{encryptedKey:s.ciphertext,iv:(0,i.lF)(s.iv),tag:(0,i.lF)(s.tag)}}(e,r,l,s));break}default:throw new s.JOSENotSupported('Invalid or unsupported "alg" (JWE Algorithm) header value')}return{cek:l,encryptedKey:c,parameters:u}};class W{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("plaintext must be an instance of Uint8Array");this._plaintext=e}setKeyManagementParameters(e){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=e,this}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setSharedUnprotectedHeader(e){if(this._sharedUnprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._sharedUnprotectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}setAdditionalAuthenticatedData(e){return this._aad=e,this}setContentEncryptionKey(e){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=e,this}setInitializationVector(e){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=e,this}async encrypt(e,t){if(!this._protectedHeader&&!this._unprotectedHeader&&!this._sharedUnprotectedHeader)throw new s.JWEInvalid("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!(0,m.A)(this._protectedHeader,this._unprotectedHeader,this._sharedUnprotectedHeader))throw new s.JWEInvalid("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const r={...this._protectedHeader,...this._unprotectedHeader,...this._sharedUnprotectedHeader};if((0,U.A)(s.JWEInvalid,new Map,t?.crit,this._protectedHeader,r),void 0!==r.zip)throw new s.JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');const{alg:n,enc:a}=r;if("string"!=typeof n||!n)throw new s.JWEInvalid('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("string"!=typeof a||!a)throw new s.JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');let c,u,l,h,d;if(this._cek&&("dir"===n||"ECDH-ES"===n))throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${n}`);{let r;({cek:u,encryptedKey:c,parameters:r}=await K(n,a,e,this._cek,this._keyManagementParameters)),r&&(t&&B in t?this._unprotectedHeader?this._unprotectedHeader={...this._unprotectedHeader,...r}:this.setUnprotectedHeader(r):this._protectedHeader?this._protectedHeader={...this._protectedHeader,...r}:this.setProtectedHeader(r))}h=this._protectedHeader?o.Rd.encode((0,i.lF)(JSON.stringify(this._protectedHeader))):o.Rd.encode(""),this._aad?(d=(0,i.lF)(this._aad),l=(0,o.xW)(h,o.Rd.encode("."),o.Rd.encode(d))):l=h;const{ciphertext:f,tag:p,iv:g}=await O(a,this._plaintext,u,this._iv,l),y={ciphertext:(0,i.lF)(f)};return g&&(y.iv=(0,i.lF)(g)),p&&(y.tag=(0,i.lF)(p)),c&&(y.encrypted_key=(0,i.lF)(c)),d&&(y.aad=d),this._protectedHeader&&(y.protected=o.D0.decode(h)),this._sharedUnprotectedHeader&&(y.unprotected=this._sharedUnprotectedHeader),this._unprotectedHeader&&(y.header=this._unprotectedHeader),y}}class J{constructor(e,t,r){this.parent=e,this.key=t,this.options=r}setUnprotectedHeader(e){if(this.unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this.unprotectedHeader=e,this}addRecipient(...e){return this.parent.addRecipient(...e)}encrypt(...e){return this.parent.encrypt(...e)}done(){return this.parent}}class V{constructor(e){this._recipients=[],this._plaintext=e}addRecipient(e,t){const r=new J(this,e,{crit:t?.crit});return this._recipients.push(r),r}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setSharedUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}setAdditionalAuthenticatedData(e){return this._aad=e,this}async encrypt(){if(!this._recipients.length)throw new s.JWEInvalid("at least one recipient must be added");if(1===this._recipients.length){const[e]=this._recipients,t=await new W(this._plaintext).setAdditionalAuthenticatedData(this._aad).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(e.unprotectedHeader).encrypt(e.key,{...e.options}),r={ciphertext:t.ciphertext,iv:t.iv,recipients:[{}],tag:t.tag};return t.aad&&(r.aad=t.aad),t.protected&&(r.protected=t.protected),t.unprotected&&(r.unprotected=t.unprotected),t.encrypted_key&&(r.recipients[0].encrypted_key=t.encrypted_key),t.header&&(r.recipients[0].header=t.header),r}let e;for(let t=0;t<this._recipients.length;t++){const r=this._recipients[t];if(!(0,m.A)(this._protectedHeader,this._unprotectedHeader,r.unprotectedHeader))throw new s.JWEInvalid("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const n={...this._protectedHeader,...this._unprotectedHeader,...r.unprotectedHeader},{alg:i}=n;if("string"!=typeof i||!i)throw new s.JWEInvalid('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("dir"===i||"ECDH-ES"===i)throw new s.JWEInvalid('"dir" and "ECDH-ES" alg may only be used with a single recipient');if("string"!=typeof n.enc||!n.enc)throw new s.JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(e){if(e!==n.enc)throw new s.JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients')}else e=n.enc;if((0,U.A)(s.JWEInvalid,new Map,r.options.crit,this._protectedHeader,n),void 0!==n.zip)throw new s.JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.')}const t=N(e),r={ciphertext:"",iv:"",recipients:[],tag:""};for(let n=0;n<this._recipients.length;n++){const o=this._recipients[n],s={};r.recipients.push(s);const a={...this._protectedHeader,...this._unprotectedHeader,...o.unprotectedHeader}.alg.startsWith("PBES2")?2048+n:void 0;if(0===n){const e=await new W(this._plaintext).setAdditionalAuthenticatedData(this._aad).setContentEncryptionKey(t).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(o.unprotectedHeader).setKeyManagementParameters({p2c:a}).encrypt(o.key,{...o.options,[B]:!0});r.ciphertext=e.ciphertext,r.iv=e.iv,r.tag=e.tag,e.aad&&(r.aad=e.aad),e.protected&&(r.protected=e.protected),e.unprotected&&(r.unprotected=e.unprotected),s.encrypted_key=e.encrypted_key,e.header&&(s.header=e.header);continue}const{encryptedKey:c,parameters:u}=await K(o.unprotectedHeader?.alg||this._protectedHeader?.alg||this._unprotectedHeader?.alg,e,o.key,t,{p2c:a});s.encrypted_key=(0,i.lF)(c),(o.unprotectedHeader||u)&&(s.header={...o.unprotectedHeader,...u})}return r}}var $=r(5609),z=r(6711);async function G(e,t,r){if(!(0,v.A)(e))throw new s.JWSInvalid("General JWS must be an object");if(!Array.isArray(e.signatures)||!e.signatures.every(v.A))throw new s.JWSInvalid("JWS Signatures missing or incorrect type");for(const n of e.signatures)try{return await(0,z.Z)({header:n.header,payload:e.payload,protected:n.protected,signature:n.signature},t,r)}catch{}throw new s.JWSSignatureVerificationFailed}var X=r(9380),Y=r(9803);async function Q(e,t,r){const n=await M(e,t,r),i=(0,Y.A)(n.protectedHeader,n.plaintext,r),{protectedHeader:o}=n;if(void 0!==o.iss&&o.iss!==i.iss)throw new s.JWTClaimValidationFailed('replicated "iss" claim header parameter mismatch',i,"iss","mismatch");if(void 0!==o.sub&&o.sub!==i.sub)throw new s.JWTClaimValidationFailed('replicated "sub" claim header parameter mismatch',i,"sub","mismatch");if(void 0!==o.aud&&JSON.stringify(o.aud)!==JSON.stringify(i.aud))throw new s.JWTClaimValidationFailed('replicated "aud" claim header parameter mismatch',i,"aud","mismatch");const a={payload:i,protectedHeader:o};return"function"==typeof t?{...a,key:n.key}:a}class Z{constructor(e){this._flattened=new W(e)}setContentEncryptionKey(e){return this._flattened.setContentEncryptionKey(e),this}setInitializationVector(e){return this._flattened.setInitializationVector(e),this}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}setKeyManagementParameters(e){return this._flattened.setKeyManagementParameters(e),this}async encrypt(e,t){const r=await this._flattened.encrypt(e,t);return[r.protected,r.encrypted_key,r.iv,r.ciphertext,r.tag].join(".")}}var ee=r(2609),te=r(5550);class re{constructor(e,t,r){this.parent=e,this.key=t,this.options=r}setProtectedHeader(e){if(this.protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this.protectedHeader=e,this}setUnprotectedHeader(e){if(this.unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this.unprotectedHeader=e,this}addSignature(...e){return this.parent.addSignature(...e)}sign(...e){return this.parent.sign(...e)}done(){return this.parent}}class ne{constructor(e){this._signatures=[],this._payload=e}addSignature(e,t){const r=new re(this,e,t);return this._signatures.push(r),r}async sign(){if(!this._signatures.length)throw new s.JWSInvalid("at least one signature must be added");const e={signatures:[],payload:""};for(let t=0;t<this._signatures.length;t++){const r=this._signatures[t],n=new te.n(this._payload);n.setProtectedHeader(r.protectedHeader),n.setUnprotectedHeader(r.unprotectedHeader);const{payload:i,...o}=await n.sign(r.key,r.options);if(0===t)e.payload=i;else if(e.payload!==i)throw new s.JWSInvalid("inconsistent use of JWS Unencoded Payload (RFC7797)");e.signatures.push(o)}return e}}var ie=r(7248),oe=r(3085);class se extends oe.G{setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setKeyManagementParameters(e){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=e,this}setContentEncryptionKey(e){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=e,this}setInitializationVector(e){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=e,this}replicateIssuerAsHeader(){return this._replicateIssuerAsHeader=!0,this}replicateSubjectAsHeader(){return this._replicateSubjectAsHeader=!0,this}replicateAudienceAsHeader(){return this._replicateAudienceAsHeader=!0,this}async encrypt(e,t){const r=new Z(o.Rd.encode(JSON.stringify(this._payload)));return this._replicateIssuerAsHeader&&(this._protectedHeader={...this._protectedHeader,iss:this._payload.iss}),this._replicateSubjectAsHeader&&(this._protectedHeader={...this._protectedHeader,sub:this._payload.sub}),this._replicateAudienceAsHeader&&(this._protectedHeader={...this._protectedHeader,aud:this._payload.aud}),r.setProtectedHeader(this._protectedHeader),this._iv&&r.setInitializationVector(this._iv),this._cek&&r.setContentEncryptionKey(this._cek),this._keyManagementParameters&&r.setKeyManagementParameters(this._keyManagementParameters),r.encrypt(e,t)}}var ae=r(610);const ce=(e,t)=>{if("string"!=typeof e||!e)throw new s.JWKInvalid(`${t} missing or invalid`)};async function ue(e,t){if(!(0,v.A)(e))throw new TypeError("JWK must be an object");if(t??(t="sha256"),"sha256"!==t&&"sha384"!==t&&"sha512"!==t)throw new TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');let r;switch(e.kty){case"EC":ce(e.crv,'"crv" (Curve) Parameter'),ce(e.x,'"x" (X Coordinate) Parameter'),ce(e.y,'"y" (Y Coordinate) Parameter'),r={crv:e.crv,kty:e.kty,x:e.x,y:e.y};break;case"OKP":ce(e.crv,'"crv" (Subtype of Key Pair) Parameter'),ce(e.x,'"x" (Public Key) Parameter'),r={crv:e.crv,kty:e.kty,x:e.x};break;case"RSA":ce(e.e,'"e" (Exponent) Parameter'),ce(e.n,'"n" (Modulus) Parameter'),r={e:e.e,kty:e.kty,n:e.n};break;case"oct":ce(e.k,'"k" (Key Value) Parameter'),r={k:e.k,kty:e.kty};break;default:throw new s.JOSENotSupported('"kty" (Key Type) Parameter missing or unsupported')}const n=o.Rd.encode(JSON.stringify(r));return(0,i.lF)(await(0,ae.A)(t,n))}async function le(e,t){t??(t="sha256");const r=await ue(e,t);return`urn:ietf:params:oauth:jwk-thumbprint:sha-${t.slice(-3)}:${r}`}async function he(e,t){const r={...e,...t?.header};if(!(0,v.A)(r.jwk))throw new s.JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a JSON object');const n=await(0,R.Og)({...r.jwk,ext:!0},r.alg);if(n instanceof Uint8Array||"public"!==n.type)throw new s.JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a public key');return n}var de=r(458),fe=r(3584);class pe extends oe.G{encode(){return`${i.lF(JSON.stringify({alg:"none"}))}.${i.lF(JSON.stringify(this._payload))}.`}static decode(e,t){if("string"!=typeof e)throw new s.JWTInvalid("Unsecured JWT must be a string");const{0:r,1:n,2:a,length:c}=e.split(".");if(3!==c||""!==a)throw new s.JWTInvalid("Invalid Unsecured JWT");let u;try{if(u=JSON.parse(o.D0.decode(i.D4(r))),"none"!==u.alg)throw new Error}catch{throw new s.JWTInvalid("Invalid Unsecured JWT")}return{payload:(0,Y.A)(u,i.D4(n),t),header:u}}}const ge=i.lF,ye=i.D4;function me(e){let t;if("string"==typeof e){const r=e.split(".");3!==r.length&&5!==r.length||([t]=r)}else if("object"==typeof e&&e){if(!("protected"in e))throw new TypeError("Token does not contain a Protected Header");t=e.protected}try{if("string"!=typeof t||!t)throw new Error;const e=JSON.parse(o.D0.decode(ye(t)));if(!(0,v.A)(e))throw new Error;return e}catch{throw new TypeError("Invalid Token or Protected Header formatting")}}function ve(e){if("string"!=typeof e)throw new s.JWTInvalid("JWTs must use Compact JWS serialization, JWT must be a string");const{1:t,length:r}=e.split(".");if(5===r)throw new s.JWTInvalid("Only JWTs using Compact JWS serialization can be decoded");if(3!==r)throw new s.JWTInvalid("Invalid JWT");if(!t)throw new s.JWTInvalid("JWTs must contain a payload");let n,i;try{n=ye(t)}catch{throw new s.JWTInvalid("Failed to base64url decode the payload")}try{i=JSON.parse(o.D0.decode(n))}catch{throw new s.JWTInvalid("Failed to parse the decoded payload as JSON")}if(!(0,v.A)(i))throw new s.JWTInvalid("Invalid JWT Claims Set");return i}var we=r(7307),be=r(8793);async function _e(e,t){return(0,be.K)(e,t)}const Se="WebCryptoAPI"},3139:(e,t,r)=>{"use strict";r.d(t,{A:()=>h});var n=r(5500),i=r(1436),o=r(1542);const s=e=>(0,i.D4)(e);let a,c;const u=e=>"KeyObject"===e?.[Symbol.toStringTag],l=async(e,t,r,n,i=!1)=>{let s=e.get(t);if(s?.[n])return s[n];const a=await(0,o.A)({...r,alg:n});return i&&Object.freeze(t),s?s[n]=a:e.set(t,{[n]:a}),a},h={normalizePublicKey:(e,t)=>{if(u(e)){let r=e.export({format:"jwk"});return delete r.d,delete r.dp,delete r.dq,delete r.p,delete r.q,delete r.qi,r.k?s(r.k):(c||(c=new WeakMap),l(c,e,r,t))}if((0,n.ll)(e)){if(e.k)return(0,i.D4)(e.k);c||(c=new WeakMap);return l(c,e,e,t,!0)}return e},normalizePrivateKey:(e,t)=>{if(u(e)){let r=e.export({format:"jwk"});return r.k?s(r.k):(a||(a=new WeakMap),l(a,e,r,t))}if((0,n.ll)(e)){if(e.k)return(0,i.D4)(e.k);a||(a=new WeakMap);return l(a,e,e,t,!0)}return e}}},3465:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default="00000000-0000-0000-0000-000000000000"},3584:(e,t,r)=>{"use strict";r.d(t,{RD:()=>l,tK:()=>h,gE:()=>c});var n=r(7493);const i=async(e,t,r)=>{let i,o,s=!1;"function"==typeof AbortController&&(i=new AbortController,o=setTimeout(()=>{s=!0,i.abort()},t));const a=await fetch(e.href,{signal:i?i.signal:void 0,redirect:"manual",headers:r.headers}).catch(e=>{if(s)throw new n.JWKSTimeout;throw e});if(void 0!==o&&clearTimeout(o),200!==a.status)throw new n.JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await a.json()}catch{throw new n.JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON")}};var o=r(458),s=r(149);let a;if("undefined"==typeof navigator||!navigator.userAgent?.startsWith?.("Mozilla/5.0 ")){a=`${"jose"}/${"v5.10.0"}`}const c=Symbol();class u{constructor(e,t){if(!(e instanceof URL))throw new TypeError("url must be an instance of URL");var r,n;this._url=new URL(e.href),this._options={agent:t?.agent,headers:t?.headers},this._timeoutDuration="number"==typeof t?.timeoutDuration?t?.timeoutDuration:5e3,this._cooldownDuration="number"==typeof t?.cooldownDuration?t?.cooldownDuration:3e4,this._cacheMaxAge="number"==typeof t?.cacheMaxAge?t?.cacheMaxAge:6e5,void 0!==t?.[c]&&(this._cache=t?.[c],r=t?.[c],n=this._cacheMaxAge,"object"==typeof r&&null!==r&&"uat"in r&&"number"==typeof r.uat&&!(Date.now()-r.uat>=n)&&"jwks"in r&&(0,s.A)(r.jwks)&&Array.isArray(r.jwks.keys)&&Array.prototype.every.call(r.jwks.keys,s.A)&&(this._jwksTimestamp=this._cache.uat,this._local=(0,o.w)(this._cache.jwks)))}coolingDown(){return"number"==typeof this._jwksTimestamp&&Date.now()<this._jwksTimestamp+this._cooldownDuration}fresh(){return"number"==typeof this._jwksTimestamp&&Date.now()<this._jwksTimestamp+this._cacheMaxAge}async getKey(e,t){this._local&&this.fresh()||await this.reload();try{return await this._local(e,t)}catch(r){if(r instanceof n.JWKSNoMatchingKey&&!1===this.coolingDown())return await this.reload(),this._local(e,t);throw r}}async reload(){this._pendingFetch&&("undefined"!=typeof WebSocketPair||"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"undefined"!=typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&(this._pendingFetch=void 0);const e=new Headers(this._options.headers);a&&!e.has("User-Agent")&&(e.set("User-Agent",a),this._options.headers=Object.fromEntries(e.entries())),this._pendingFetch||(this._pendingFetch=i(this._url,this._timeoutDuration,this._options).then(e=>{this._local=(0,o.w)(e),this._cache&&(this._cache.uat=Date.now(),this._cache.jwks=e),this._jwksTimestamp=Date.now(),this._pendingFetch=void 0}).catch(e=>{throw this._pendingFetch=void 0,e})),await this._pendingFetch}}function l(e,t){const r=new u(e,t),n=async(e,t)=>r.getKey(e,t);return Object.defineProperties(n,{coolingDown:{get:()=>r.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>r.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>r.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>!!r._pendingFetch,enumerable:!0,configurable:!1},jwks:{value:()=>r._local?.jwks(),enumerable:!0,configurable:!1,writable:!1}}),n}const h=c},3779:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r="undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);t.default={randomUUID:r}},4011:(e,t,r)=>{"use strict";r.r(t),r.d(t,{DOMParserFactory:()=>h,RDFArrayRemove:()=>w,callbackify:()=>l,domToString:()=>d,dtstamp:()=>p,dumpNode:()=>f,heavyCompare:()=>g,heavyCompareSPO:()=>y,linkRelationProperty:()=>u,log:()=>n.A,mediaTypeClass:()=>c,output:()=>m,parseXML:()=>v,stackString:()=>_,string:()=>a,string_startswith:()=>b,uri:()=>i});var n=r(4940),i=r(2727),o=r(5108),s=r(8978);e=r.hmd(e);const a={template:function(e,t){for(var r=e.split("%s"),n="",i=0;i<t.length;i++)t[i]+="",n+=r[i]+t[i];return n+r.slice(t.length).join()}};function c(e){return e=e.split(";")[0].trim(),new o.A("http://www.w3.org/ns/iana/media-types/"+e+"#Resource")}function u(e){return new o.A("http://www.w3.org/ns/iana/link-relations/relation#"+e.trim())}function l(e,t){e.callbacks={};for(var r=t.length-1;r>=0;r--)e.callbacks[t[r]]=[];e.addHook=function(t){e.callbacks[t]||(e.callbacks[t]=[])},e.addCallback=function(t,r){e.callbacks[t].push(r)},e.removeCallback=function(t,r){for(var n=0;n<e.callbacks[t].length;n++)if(e.callbacks[t][n].name===r)return e.callbacks[t].splice(n,1),!0;return!1},e.insertCallback=function(t,r){e.callbacks[t].unshift(r)},e.fireCallbacks=function(t,r){var n,i=[],o=[],s=e.callbacks[t].length;let a;for(n=s-1;n>=0;n--)a=e.callbacks[t][n],a&&a.apply(e,r)&&i.push(a);for(n=i.length-1;n>=0;n--)o.push(i[n]);for(n=s;n<e.callbacks[t].length;n++)o.push(e.callbacks[t][n]);e.callbacks[t]=o}}function h(){return window.DOMParser?new s.DOMParser:!!window.ActiveXObject&&new ActiveXObject("Microsoft.XMLDOM")}function d(e,t){var r=[];(t=t||{})&&t.selfClosing&&t.selfClosing.split(" ").forEach(function(e){r[e]=!0});var n=[];return t&&t.skipAttributes&&t.skipAttributes.split(" ").forEach(function(e){n[e]=!0}),f(e,t,r,n)}function f(e,t,r,n){var i,o="",s=[!1];if(void 0===e.nodeType)return o;if(1===e.nodeType){if(e.hasAttribute("class")&&t&&t.classWithChildText&&e.matches(t.classWithChildText.class))o+=e.querySelector(t.classWithChildText.element).textContent;else if(!(t&&t.skipNodeWithClass&&e.matches("."+t.skipNodeWithClass))){var a=e.nodeName.toLowerCase();o+="<"+a;var c=[];for(i=e.attributes.length-1;i>=0;i--){var u=e.attributes[i];if(!(n&&n.length>0&&n[u.name])&&!/^\d+$/.test(u.name)){if("class"===u.name&&t&&t.replaceClassItemWith&&u.value.split(" ").indexOf(t.replaceClassItemWith.source)>-1){var l=new RegExp(t.replaceClassItemWith.source,"g");u.value=u.value.replace(l,t.replaceClassItemWith.target).trim()}"class"===u.name&&t&&t.skipClassWithValue&&t.skipClassWithValue===u.value||c.push(u.name+"='"+u.value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,""")+"'")}}if(c.length>0&&(t&&t.sortAttributes&&c.sort(function(e,t){return e.toLowerCase().localeCompare(t.toLowerCase())}),o+=" "+c.join(" ")),r&&r.ename)o+=" />";else{for(o+=">",o+="html"===a?"\n ":"",s.push("style"===a||"script"===a),i=0;i<e.childNodes.length;i++)o+=f(e.childNodes[i]);s.pop(),o+="body"===a?"</"+a+">\n":"</"+a+">"}}}else if(8===e.nodeType)o+="\x3c!--"+e.nodeValue+"--\x3e";else if(3===e.nodeType||4===e.nodeType){var h=e.nodeValue.replace(/\n+$/,"");o+=s[s.length-1]?h:h.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}else console.log("Warning; Cannot handle serialising nodes of type: "+e.nodeType),console.log(e);return o}function p(){var e=new Date,t=e.getYear()+1900,r=e.getMonth()+1,n=e.getDate(),i=e.getUTCHours(),o=e.getUTCMinutes(),s=e.getSeconds();return r<10&&(r="0"+r),n<10&&(n="0"+n),i<10&&(i="0"+i),o<10&&(o="0"+o),s<10&&(s="0"+s),t+"-"+r+"-"+n+"T"+i+":"+o+":"+s+"Z"}function g(e,t,r,n){var i=function(e){return"BlankNode"===e.termType?null:e},o=function(e){var t=r.statementsMatching(e).map(function(e){return i(e.subject)+" "+i(e.predicate)+" "+i(e.object)}).concat(r.statementsMatching(void 0,void 0,e).map(function(e){return i(e.subject)+" "+i(e.predicate)+" "+i(e.object)}));return t.sort(),t.join("\n")};const s=Object.prototype.hasOwnProperty.call(r,"compareTerms")?r.compareTerms(e,t):e.compareTerm(t);return"BlankNode"===e.termType&&"BlankNode"===t.termType?0===s?0:o(e)>o(t)?1:o(e)<o(t)?-1:s:n&&e.uri&&t.uri?(n[e.uri]||e.uri).localeCompare(n[t.uri]||t.uri):s}function y(e,t,r,n){return g(e.subject,t.subject,r,n)||g(e.predicate,t.predicate,r,n)||g(e.object,t.object,r,n)}function m(e){var t=document.createElement("div");t.textContent=e,document.body.appendChild(t)}function v(t,r){return r=r||{},e&&e.exports?(new s.DOMParser).parseFromString(t,r.contentType||"application/xhtml+xml"):("undefined"!=typeof window&&window.DOMParser?new window.DOMParser:new s.DOMParser).parseFromString(t,"application/xml")}function w(e,t){for(var r=0;r<e.length;r++)if(e[r].subject.equals(t.subject)&&e[r].predicate.equals(t.predicate)&&e[r].object.equals(t.object)&&e[r].why.equals(t.why))return void e.splice(r,1);throw new Error("RDFArrayRemove: Array did not contain "+t+" "+t.why)}function b(e,t){return e.slice(0,t.length)===t}function _(e){var t=e+"\n";if(!e.stack)return t+"No stack available.\n";for(var r=e.stack.toString().split("\n"),n=[],i=0;i<r.length;i++){var o=r[i];if(o.indexOf("ecmaunit.js")>-1)break;"("==o.charAt(0)&&(o="function"+o);var s=o.split("@");n.push(s)}for(i=0;i<n.length;i++)t+=" "+n[i][1]+"\n "+n[i][0];return t}},4090:(e,t,r)=>{"use strict";r.r(t),r.d(t,{BlankNode:()=>a,Collection:()=>f,ConnectedStore:()=>ir,DataFactory:()=>Mt,Empty:()=>p,Fetcher:()=>Pt,Formula:()=>H,IndexedFormula:()=>G,Literal:()=>h,LiveStore:()=>or,N3Parser:()=>ve,NamedNode:()=>c.A,Namespace:()=>F,NextId:()=>nr,Node:()=>B,Query:()=>K,RDFParser:()=>ft,RDFaProcessor:()=>ht,SPARQLToQuery:()=>Ut,Serializer:()=>P,Statement:()=>w,Store:()=>G,UpdateManager:()=>Lt,UpdatesSocket:()=>Ht,UpdatesVia:()=>Bt,Util:()=>k,Variable:()=>_,blankNode:()=>Gt,defaultGraph:()=>Xt,fetcher:()=>Kt,fromNT:()=>tr,graph:()=>Wt,isBlankNode:()=>u.jt,isCollection:()=>u.P3,isGraph:()=>u.RN,isLiteral:()=>u.c$,isNamedNode:()=>u.Y2,isPredicate:()=>u.YC,isQuad:()=>u.aF,isRDFObject:()=>u.GE,isRDFlibObject:()=>u.DJ,isRDFlibPredicate:()=>u.fY,isRDFlibSubject:()=>u.CZ,isStatement:()=>u.SH,isStore:()=>u.ok,isSubject:()=>u.hr,isTerm:()=>u.D0,isVariable:()=>u.DZ,jsonParser:()=>Ot,lit:()=>Jt,literal:()=>Yt,log:()=>T.A,namedNode:()=>$t,parse:()=>gt,quad:()=>Qt,queryToSPARQL:()=>Dt,serialize:()=>D,sparqlUpdateParser:()=>pt,st:()=>Vt,sym:()=>$t,term:()=>rr,termValue:()=>vt.E,triple:()=>Zt,uri:()=>b,variable:()=>zt});var n=r(4705),i=r(1059),o=r(8936),s=r(9403);class a extends o.A{static getId(e){if(e){if("string"!=typeof e)throw new Error("Bad id argument to new blank node: "+e);if(e.includes("#")){let t=e.split("#");return t[t.length-1]}return e}return"n"+a.nextId++}constructor(e){super(a.getId(e)),(0,n.A)(this,"termType",s.$Q),(0,n.A)(this,"classOrder",i.A.BlankNode),(0,n.A)(this,"isBlank",1),(0,n.A)(this,"isVar",1)}get id(){return this.value}set id(e){this.value=e}compareTerm(e){return this.classOrder<e.classOrder?-1:this.classOrder>e.classOrder?1:this.id<e.id?-1:this.id>e.id?1:0}copy(e){var t=new a;return e.copyTo(this,t),t}toCanonical(){return a.NTAnonymousNodePrefix+this.value}toString(){return a.NTAnonymousNodePrefix+this.id}}(0,n.A)(a,"nextId",0),(0,n.A)(a,"NTAnonymousNodePrefix","_:");var c=r(5108),u=r(2915);const l={boolean:new c.A("http://www.w3.org/2001/XMLSchema#boolean"),dateTime:new c.A("http://www.w3.org/2001/XMLSchema#dateTime"),decimal:new c.A("http://www.w3.org/2001/XMLSchema#decimal"),double:new c.A("http://www.w3.org/2001/XMLSchema#double"),integer:new c.A("http://www.w3.org/2001/XMLSchema#integer"),langString:new c.A("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),string:new c.A("http://www.w3.org/2001/XMLSchema#string")};class h extends o.A{constructor(e,t,r){super(e),(0,n.A)(this,"termType",s.QW),(0,n.A)(this,"classOrder",i.A.Literal),(0,n.A)(this,"datatype",l.string),(0,n.A)(this,"isVar",0),(0,n.A)(this,"language",""),t?(this.language=t,this.datatype=l.langString):this.datatype=r?c.A.fromValue(r):l.string}copy(){return new h(this.value,this.lang,this.datatype)}equals(e){return!!e&&(this.termType===e.termType&&this.value===e.value&&this.language===e.language&&(!this.datatype&&!e.datatype||this.datatype&&this.datatype.equals(e.datatype)))}get lang(){return this.language}set lang(e){this.language=e||""}toNT(){return h.toNT(this)}static toNT(e){if("number"==typeof e.value)return""+e.value;if("string"!=typeof e.value)throw new Error("Value of RDF literal is not string or number: "+e.value);var t=e.value;return t='"'+(t=(t=(t=(t=t.replace(/\\/g,"\\\\")).replace(/\"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r"))+'"',e.language?t+="@"+e.language:e.datatype.equals(l.string)||(t+="^^"+e.datatype.toCanonical()),t}toString(){return""+this.value}static fromBoolean(e){return new h(e?"1":"0",null,l.boolean)}static fromDate(e){if(!(e instanceof Date))throw new TypeError("Invalid argument to Literal.fromDate()");let t=function(e){return(""+(100+e)).slice(1,3)},r=e.getUTCFullYear()+"-"+t(e.getUTCMonth()+1)+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())+"Z";return new h(r,null,l.dateTime)}static fromNumber(e){if("number"!=typeof e)throw new TypeError("Invalid argument to Literal.fromNumber()");let t;const r=e.toString();return t=r.indexOf("e")<0&&Math.abs(e)<=Number.MAX_SAFE_INTEGER?Number.isInteger(e)?l.integer:l.decimal:l.double,new h(r,null,t)}static fromValue(e){if((0,u.c$)(e))return e;switch(typeof e){case"object":if(e instanceof Date)return h.fromDate(e);case"boolean":return h.fromBoolean(e);case"number":return h.fromNumber(e);case"string":return new h(e)}throw new Error("Can't make literal from "+e+" of type "+typeof e)}}function d(e){return null==e||(0,u.D0)(e)?e:Array.isArray(e)?new f(e):h.fromValue(e)}class f extends o.A{constructor(e){super((a.nextId++).toString()),(0,n.A)(this,"termType",s.r0),(0,n.A)(this,"classOrder",i.A.Collection),(0,n.A)(this,"closed",!1),(0,n.A)(this,"compareTerm",a.prototype.compareTerm),(0,n.A)(this,"elements",[]),(0,n.A)(this,"isVar",0),e&&e.length>0&&e.forEach(e=>{this.elements.push(d(e))})}get id(){return this.value}set id(e){this.value=e}append(e){return this.elements.push(e)}close(){return this.closed=!0,this.closed}shift(){return this.elements.shift()}substitute(e){const t=this.elements.map(t=>t.substitute(e));return new f(t)}toNT(){return f.toNT(this)}static toNT(e){return a.NTAnonymousNodePrefix+e.id}toString(){return"("+this.elements.join(" ")+")"}unshift(e){return this.elements.unshift(e)}}(0,n.A)(f,"termType",s.r0);class p extends o.A{constructor(){super(""),(0,n.A)(this,"termType",s.S)}toString(){return"()"}}const g="chrome:theSession";new c.A(g);class y extends o.A{constructor(){super(""),(0,n.A)(this,"value",""),(0,n.A)(this,"termType",s.ic),(0,n.A)(this,"uri",g)}toCanonical(){return this.value}toString(){return"DefaultGraph"}}function m(e){return!!e&&e.termType===s.ic}const v=new y;class w{constructor(e,t,r,i){(0,n.A)(this,"subject",void 0),(0,n.A)(this,"predicate",void 0),(0,n.A)(this,"object",void 0),(0,n.A)(this,"graph",void 0),this.subject=o.A.fromValue(e),this.predicate=o.A.fromValue(t),this.object=o.A.fromValue(r),this.graph=null==i?v:o.A.fromValue(i)}get why(){return this.graph}set why(e){this.graph=e}equals(e){return e.subject.equals(this.subject)&&e.predicate.equals(this.predicate)&&e.object.equals(this.object)&&e.graph.equals(this.graph)}substitute(e){return new w(this.subject.substitute(e),this.predicate.substitute(e),this.object.substitute(e),m(this.graph)?this.graph:this.graph.substitute(e))}toCanonical(){let e=[this.subject.toCanonical(),this.predicate.toCanonical(),this.object.toCanonical()];return this.graph&&this.graph.termType!==s.ic&&e.push(this.graph.toCanonical()),e.join(" ")+" ."}toNT(){return[this.subject.toNT(),this.predicate.toNT(),this.object.toNT()].join(" ")+" ."}toNQ(){return[this.subject.toNT(),this.predicate.toNT(),this.object.toNT(),m(this.graph)?"":this.graph.toNT()].join(" ")+" ."}toString(){return this.toNT()}}var b=r(2727);class _ extends o.A{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";super(e),(0,n.A)(this,"termType",s.P2),(0,n.A)(this,"base","varid:"),(0,n.A)(this,"classOrder",i.A.Variable),(0,n.A)(this,"isVar",1),(0,n.A)(this,"uri",void 0),this.base="varid:",this.uri=b.join(e,this.base)}equals(e){return!!e&&(this.termType===e.termType&&this.value===e.value)}hashString(){return this.toString()}substitute(e){var t;return null!=(t=e[this.toNT()])?t:this}toString(){return _.toString(this)}static toString(e){return e.uri.slice(0,e.base.length)===e.base?`?${e.uri.slice(e.base.length)}`:`?${e.uri}`}}let S=function(e){return e.collections="COLLECTIONS",e.defaultGraphType="DEFAULT_GRAPH_TYPE",e.equalsMethod="EQUALS_METHOD",e.id="ID",e.identity="IDENTITY",e.reversibleId="REVERSIBLE_ID",e.variableType="VARIABLE_TYPE",e}({});const E=new y,A={supports:{[S.collections]:!1,[S.defaultGraphType]:!1,[S.equalsMethod]:!0,[S.identity]:!1,[S.id]:!0,[S.reversibleId]:!1,[S.variableType]:!0},blankNode:e=>new a(e),defaultGraph:()=>E,equals(e,t){return e===t||!e||!t||((0,u.aF)(e)||(0,u.aF)(t)?!(!(0,u.aF)(e)||!(0,u.aF)(t))&&(this.equals(e.subject,t.subject)&&this.equals(e.predicate,t.predicate)&&this.equals(e.object,t.object)&&this.equals(e.graph,t.graph)):!(!(0,u.D0)(e)||!(0,u.D0)(t))&&this.id(e)===this.id(t))},id(e){if(!e)return"undefined";if((0,u.aF)(e))return this.quadToNQ(e);switch(e.termType){case s.ic:return"defaultGraph";case s.P2:return _.toString(e);default:const t=this.termToNQ(e);if(t)return t;throw new Error(`Can't id term with type '${e.termType}'`)}},isQuad:e=>e instanceof w,literal(e,t){if("string"!=typeof e&&!t)return h.fromValue(e);const r="string"==typeof e?e:""+e;return"string"==typeof t?-1===t.indexOf(":")?new h(r,t):new h(r,null,this.namedNode(t)):new h(r,null,t)},namedNode:e=>new c.A(e),quad:(e,t,r,n)=>new w(e,t,r,n||E),triple(e,t,r,n){return this.quad(e,t,r,n)},quadToNQ(e){return`${this.termToNQ(e.subject)} ${this.termToNQ(e.predicate)} ${this.termToNQ(e.object)} ${this.termToNQ(e.graph)} .`},termToNQ(e){switch(e.termType){case s.$Q:return"_:"+e.value;case s.ic:return"";case s.S:return"<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>";case s.QW:return h.toNT(e);case s.bD:case s.Kk:return"<"+e.value+">";case s.r0:return"("+e.elements.map(e=>this.termToNQ(e)).join(" ")+")";default:throw new Error(`Can't serialize nonstandard term type (was '${e.termType}')`)}},toNQ(e){return this.isQuad(e)?this.quadToNQ(e):this.termToNQ(e)},variable:e=>new _(e)},x=A;var T=r(4940);function F(e,t){const r=t||{namedNode:e=>new c.A(e)};return function(t){return r.namedNode(e+(t||""))}}var k=r(4011);function I(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:x;return{boolean:e.namedNode("http://www.w3.org/2001/XMLSchema#boolean"),dateTime:e.namedNode("http://www.w3.org/2001/XMLSchema#dateTime"),decimal:e.namedNode("http://www.w3.org/2001/XMLSchema#decimal"),double:e.namedNode("http://www.w3.org/2001/XMLSchema#double"),integer:e.namedNode("http://www.w3.org/2001/XMLSchema#integer"),langString:e.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),string:e.namedNode("http://www.w3.org/2001/XMLSchema#string")}}I(x);var C=r(5386),N=r.n(C),R=r(5306);function P(e){return new O(e)}class O{constructor(e){(0,n.A)(this,"_notQNameChars","\t\r\n !\"#$%&'()*.,+/;<=>?@[\\]^`{|}~"),(0,n.A)(this,"_notNameChars",this._notQNameChars+":"),(0,n.A)(this,"validPrefix",new RegExp(/^[a-zA-Z][a-zA-Z0-9]*$/)),(0,n.A)(this,"forbidden1",new RegExp(/[\\"\b\f\r\v\t\n\u0080-\uffff]/gm)),(0,n.A)(this,"forbidden3",new RegExp(/[\\"\b\f\r\v\u0080-\uffff]/gm)),this.flags="",this.base=null,this.prefixes=[],this.namespaces=[];const t=Object.keys(N()());for(const e in t){const r=N()()[t[e]](""),n=t[e];this.prefixes[r]=n,this.namespaces[n]=r}this.suggestPrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#"),this.suggestPrefix("xml","reserved:reservedForFutureUse"),this.namespacesUsed=[],this.keywords=["a"],this.prefixchars="abcdefghijklmnopqustuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",this.incoming=null,this.formulas=[],this.store=e,this.rdfFactory=e.rdfFactory||x,this.xsd=I(this.rdfFactory)}setBase(e){return this.base=e,this}setFlags(e){return this.flags=e||"",this}toStr(e){var t=e.toNT();return"Graph"===e.termType&&(this.formulas[t]=e),t}fromStr(e){if("{"===e[0]){var t=this.formulas[e];return t||console.log("No formula object for "+e),t}return this.store.fromNT(e)}setNamespaces(e){for(var t in e)this.setPrefix(t,e[t]);return this}setPrefix(e,t){if("default"!==e.slice(0,7)&&"ns"!==e.slice(0,2)&&e&&t){for(let t in this.prefixes)this.prefixes[t]==e&&delete this.prefixes[t];this.prefixes[t]=e,this.namespaces[e]=t}}suggestPrefix(e,t){"default"!==e.slice(0,7)&&"ns"!==e.slice(0,2)&&e&&t&&(e in this.namespaces||t in this.prefixes||(this.prefixes[t]=e,this.namespaces[e]=t))}suggestNamespaces(e){for(var t in e)this.suggestPrefix(t,e[t]);return this}checkIntegrity(){var e,t;for(e in this.namespaces)if(this.prefixes[this.namespaces[e]]!==e)throw new Error("Serializer integity error 1: "+e+", "+this.namespaces[e]+", "+this.prefixes[this.namespaces[e]]+"!");for(t in this.prefixes)if(this.namespaces[this.prefixes[t]]!==t)throw new Error("Serializer integity error 2: "+t+", "+this.prefixs[t]+", "+this.namespaces[this.prefixes[t]]+"!")}makeUpPrefix(e){var t=e;var r=function(t){return!!this.validPrefix.test(t)&&("ns"!==t&&(!(t in this.namespaces)&&(this.prefixes[e]=t,this.namespaces[t]=e,t)))}.bind(this);"#/".indexOf(t[t.length-1])>=0&&(t=t.slice(0,-1));var n=t.lastIndexOf("/");n>=0&&(t=t.slice(n+1));for(var i=0;i<t.length&&this.prefixchars.indexOf(t[i]);)i++;if((t=t.slice(0,i)).length<6&&r(t))return t;if(r(t.slice(0,3)))return t.slice(0,3);if(r(t.slice(0,2)))return t.slice(0,2);if(r(t.slice(0,4)))return t.slice(0,4);if(r(t.slice(0,1)))return t.slice(0,1);if(r(t.slice(0,5)))return t.slice(0,5);this.validPrefix.test(t)||(t="n");for(var o=0;;o++)if(r(t.slice(0,3)+o))return t.slice(0,3)+o}rootSubjects(e){for(var t={},r={},n={},i=0;i<e.length;i++){var o=e[i],s=function(e){t.hasOwnProperty(e)||(t[e]=[]),t[e].push(o.subject)};[o.subject,o.predicate,o.object].map(function(e){"BlankNode"===e.termType?n[e.toNT()]=!0:"Collection"===e.termType&&e.elements.forEach(function(e){s(e)})}),s(e[i].object);var a=r[this.toStr(o.subject)];a||(a=[]),a.push(o),r[this.toStr(o.subject)]=a}var c=[];for(var u in r)if(r.hasOwnProperty(u)){var l=this.fromStr(u);"BlankNode"===l.termType&&t[l]&&1===t[l].length||c.push(l)}this.incoming=t;for(var h={},d=0;d<c.length;d++)h[c[d].toNT()]=!0;return{roots:c,subjects:r,rootsHash:h,incoming:t}}toN3(e){return this.statementsToN3(e.statements)}explicitURI(e){var t;return this.flags.indexOf("r")<0&&this.base?e=b.refTo(this.base,e):this.flags.indexOf("u")>=0?e=function(e){for(var t,r="",n=0;n<e.length;n++)r+=(t=e.charCodeAt(n))>65535?"\\U"+("00000000"+t.toString(16)).slice(-8):t>126?"\\u"+("0000"+t.toString(16)).slice(-4):e[n];return r}(e):(t=decodeURI(e),e=encodeURI(t)),"<"+e+">"}statementsToNTriples(e){var t=e.slice();t.sort();for(var r="",n="http://www.w3.org/1999/02/22-rdf-syntax-ns#",i=this,o=this.store,s=this.rdfFactory,a=function(e){if("Collection"!==e.termType)return i.atomicTermToN3(e);for(var t=e.elements,c=o.sym(n+"nill"),u=t.length-1;u>=0;u--){var l=s.blankNode();r+=a(l)+" "+a(o.sym(n+"first"))+" "+a(t[u])+".\n",r+=a(l)+" "+a(o.sym(n+"rest"))+" "+a(c)+".\n",c=l}return i.atomicTermToN3(c)},c=0;c<t.length;c++){var u=t[c],l="";l+=a(u.subject)+" ",l+=a(u.predicate)+" ",l+=a(u.object)+" ",this.flags.indexOf("q")>=0&&(l+=a(u.why)+" "),r+=l+=".\n"}return r}statementsToN3(e){var t=this.store,r={"http://www.w3.org/1999/02/22-rdf-syntax-ns#type":"aaa:00"};e.sort(function(e,n){return k.heavyCompareSPO(e,n,t,r)}),this.base&&!this.defaultNamespace&&(this.defaultNamespace=this.base+"#");var n={};this.flags.indexOf("s")<0&&(n["http://www.w3.org/2002/07/owl#sameAs"]="="),this.flags.indexOf("t")<0&&(n["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]="a"),this.flags.indexOf("i")<0&&(n["http://www.w3.org/2000/10/swap/log#implies"]="=>");var i=function(e){for(var t="",r=0;r<e;r++)t+=" ";return t},o=function(e){for(var t="",r=0;r<e.length;r++){var n=e[r],i="string"==typeof n?n:o(n);if(0!==r){var s=t.slice(-1)||" ";","===i||";"===i||("."!==i||"0123456789.:".includes(s))&&(t+=" ")}t+=i}return t},s=function(e,t){var r="",n=1e5;void 0===t&&(t=-1);for(var a=0;a<e.length;a++){var c=e[a];if("string"!=typeof c){var u=s(c,t+1);if(u.length<10*(80-4*t)&&u.indexOf('"""')<0){var l=o(c);l.length<80-4*t&&(c=l,u="")}u&&(n=1e4),r+=u}if("string"==typeof c){if(1===c.length&&"\n"===r.slice(-1)&&",.;".indexOf(c)>=0){r=r.slice(0,-1),"."==c&&"0123456789.:".includes(r.charAt(r.length-1))&&(r+=" ",n+=1),r+=c+"\n",n+=1;continue}if(n<4*t+4||n+c.length+1<80&&";.".indexOf(r[r.length-2])<0)r=r.slice(0,-1)+" "+c+"\n",n+=c.length+1;else{let e=i(4*t)+c;r+=e+"\n",n=e.length,t<0&&(r+="\n",n=1e5)}}}return r};var a=function(e){for(var t=this.rootSubjects(e),r=t.roots,n=[],i=0;i<r.length;i++){var o=r[i];n.push(c(o,t))}return n}.bind(this);function c(e,t){return"BlankNode"!==e.termType||t.incoming[e]?[h(e,t)].concat([u(e,t)]).concat(["."]):l(e,t,!0).concat(["."])}var u=function(e,t){var r=[],i=null,o=t.subjects[this.toStr(e)]||[];if(void 0===o)throw new Error("Cant find statements for "+e);for(var s=[],a=0;a<o.length;a++){var c=o[a];c.predicate.uri===i?s.push(","):(i&&(r=r.concat([s]).concat([";"]),s=[]),r.push(n[c.predicate.uri]?n[c.predicate.uri]:h(c.predicate,t))),i=c.predicate.uri,s.push(l(c.object,t))}return r=r.concat([s])}.bind(this);var l=function(e,t,r){return"BlankNode"!==e.termType||!r&&void 0!==t.rootsHash[e.toNT()]?h(e,t):t.subjects[this.toStr(e)]?["[",u(e,t),"]"]:"[]"}.bind(this);O.prototype.termToN3=h;var h=function(e,t){var r,n;switch(e.termType){case"Graph":return(n=(n=["{"]).concat(a(e.statements))).concat(["}"]);case"Collection":for(n=["("],r=0;r<e.elements.length;r++)n.push([l(e.elements[r],t)]);return n.push(")"),n;default:return this.atomicTermToN3(e)}}.bind(this);var d=function(){var e="";for(var t in this.flags.indexOf("d")<0&&this.defaultNamespace&&(e+="@prefix : "+this.explicitURI(this.defaultNamespace)+".\n"),this.prefixes)this.prefixes.hasOwnProperty(t)&&this.namespacesUsed[t]&&(e+="@prefix "+this.prefixes[t]+": "+this.explicitURI(t)+".\n");return e+"\n"}.bind(this),f=a(e);return d()+s(f)}atomicTermToN3(e,t){switch(e.termType){case"BlankNode":case"Variable":return e.toNT();case"Literal":var r=e.value;if("string"!=typeof r)throw new TypeError("Value of RDF literal node must be a string");if(e.datatype&&this.flags.indexOf("x")<0)switch(e.datatype.uri){case"http://www.w3.org/2001/XMLSchema#integer":return r;case"http://www.w3.org/2001/XMLSchema#decimal":return r.indexOf(".")<0&&(r+=".0"),r;case"http://www.w3.org/2001/XMLSchema#double":{const e=r.toLowerCase().indexOf("e")>0;return r.indexOf(".")<0&&!e&&(r+=".0"),e||(r+="e0"),r}case"http://www.w3.org/2001/XMLSchema#boolean":return"1"===e.value?"true":"false"}var n=this.stringToN3(e.value,this.flags);return e.language?n+="@"+e.language:e.datatype.equals(this.xsd.string)||(n+="^^"+this.atomicTermToN3(e.datatype,t)),n;case"NamedNode":return this.symbolToN3(e);case"DefaultGraph":return"";default:throw new Error("Internal: atomicTermToN3 cannot handle "+e+" of termType: "+e.termType)}}stringToN3(e,t){t||(t="e");var r,n,i,o,s,a="";for(e.length>20&&'"'!==e.slice(-1)&&t.indexOf("n")<0&&(e.indexOf("\n")>0||e.indexOf('"')>0)?(o='"""',s=this.forbidden3):(o='"',s=this.forbidden1),r=0;r<e.length;){if(s.lastIndex=0,null==s.exec(e.slice(r)))break;n=r+s.lastIndex-1,a+=e.slice(r,n);var c=e[n];'"'===c&&'"""'===o&&'"""'!==e.slice(n,n+3)?a+=c:(i='\b\f\r\t\v\n\\"'.indexOf(c))>=0?a+="\\"+'bfrtvn\\"'[i]:t.indexOf("e")>=0?a+="\\u"+("000"+c.charCodeAt(0).toString(16).toLowerCase()).slice(-4):a+=c,r=n+1}return o+a+e.slice(r)+o}symbolToN3(e){var t=e.uri,r=t.indexOf("#");if(r<0&&this.flags.indexOf("/")<0&&(r=t.lastIndexOf("/")),r>=0&&this.flags.indexOf("p")<0&&(0===t.indexOf("http")||0===t.indexOf("ws")||0===t.indexOf("file"))){for(var n=!0,i=r+1;i<t.length;i++)if(this._notNameChars.indexOf(t[i])>=0){n=!1;break}if(n){var o=t.slice(r+1),s=t.slice(0,r+1);if(this.defaultNamespace&&this.defaultNamespace===s&&this.flags.indexOf("d")<0)return this.flags.indexOf("k")>=0&&this.keyords.indexOf(o)<0?o:":"+o;var a=this.prefixes[s];if(a||(a=this.makeUpPrefix(s)),a)return this.namespacesUsed[s]=!0,a+":"+o}}return this.explicitURI(t)}writeStore(e){var t=this.store,r=t.fetcher,n=r&&r.appNode,i=this.store.index[3];for(var o in i){var s=t.fromNT(o);n&&s.equals(n)||e("\n"+this.atomicTermToN3(s)+" "+this.atomicTermToN3(t.sym("http://www.w3.org/2000/10/swap/log#semantics"))+" { "+this.statementsToN3(t.statementsMatching(void 0,void 0,void 0,s))+" }.\n")}t.statementsMatching(void 0,t.sym("http://www.w3.org/2007/ont/link#requestedURI")).map(function(r){e("\n<"+r.object.value+"> log:metadata {\n");var n=t.statementsMatching(void 0,void 0,void 0,r.subject);e(this.statementsToN3(this.statementsToN3(n))),e("}.\n")});var a=[];n&&a.push(n);var c=[];a.map(function(e){c=c.concat(t.statementsMatching(void 0,void 0,void 0,e))}),e(this.statementsToN3(c))}statementsToXML(e){var t=[];t["http://www.w3.org/1999/02/22-rdf-syntax-ns#"]=!0;var r="http://www.w3.org/1999/02/22-rdf-syntax-ns#_",n=function(e){for(var t="",r=0;r<e;r++)t+=" ";return t},i=function(e){for(var t="",r=0;r<e.length;r++){var n=e[r];t+="string"==typeof n?n:i(n)}return t},o=function(e,t){var r,s="",a=1e5;t||(t=0);for(var c=0;c<e.length;c++){var u=e[c];if("string"!=typeof u){var l=o(u,t+1);l.length<10*(80-4*t)&&l.indexOf('"""')<0&&(r=i(u)).length<80-4*t&&(u=" "+r,l=""),l&&(a=1e4),s+=l}"string"==typeof u&&(a<4*t+4?(s=s.slice(0,-1)+" "+u+"\n",a+=u.length+1):(s+=(r=n(4*t)+u)+"\n",a=r.length))}return s};var s=function(e){this.suggestPrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");for(var t=this.rootSubjects(e),r=t.roots,n=[],i=0;i<r.length;i++){var o=r[i];n.push(u(o,t))}return n}.bind(this);function a(e){return void 0===e?"@@@undefined@@@@":e.replace(/[&<"]/g,function(e){switch(e[0]){case"&":return"&";case"<":return"<";case'"':return"""}})}var c=function(e){return a(this.base?b.refTo(this.base,e.uri):e.uri)}.bind(this);var u=function(e,t){var n,i,o,s,f=[],p=t.subjects[this.toStr(e)];if(void 0===p)return h(e,t);p.sort(function(e,t){var n=e.predicate.uri,i=t.predicate.uri;if(n.substring(0,44)===r||i.substring(0,44)===r)return n.localeCompare(i);var o=n.substring(44),s=i.substring(44),a=parseInt(o,10),c=parseInt(s,10);return isNaN(a)||isNaN(c)||a!==o||c!==s?n.localeCompare(i):a-c});for(var g=0;g<p.length;g++)if("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"!==(o=p[g]).predicate.uri||n||"NamedNode"!==o.object.termType){if((s=o.predicate).uri.substr(0,44)===r){var y=s.uri.substr(44);y===parseInt(y,10).toString()&&(s=this.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#li"))}switch(i=d(s),o.object.termType){case"BlankNode":f=1===t.incoming[o.object].length?f.concat(["<"+i+' rdf:parseType="Resource">',u(o.object,t),"</"+i+">"]):f.concat(["<"+i+' rdf:nodeID="'+o.object.toNT().slice(2)+'"/>']);break;case"NamedNode":f=f.concat(["<"+i+' rdf:resource="'+c(o.object)+'"/>']);break;case"Literal":f=f.concat(["<"+i+(o.object.datatype.equals(this.xsd.string)?"":' rdf:datatype="'+a(o.object.datatype.uri)+'"')+(o.object.language?' xml:lang="'+o.object.language+'"':"")+">"+a(o.object.value)+"</"+i+">"]);break;case"Collection":f=f.concat(["<"+i+' rdf:parseType="Collection">',l(o.object,t),"</"+i+">"]);break;default:throw new Error("Can't serialize object of type "+o.object.termType+" into XML")}}else n=o.object;var m=n?d(n):"rdf:Description",v="";return"BlankNode"===e.termType?t.incoming[e]&&1===t.incoming[e].length||(v=' rdf:nodeID="'+e.toNT().slice(2)+'"'):v=' rdf:about="'+c(e)+'"',["<"+m+v+">"].concat([f]).concat(["</"+m+">"])}.bind(this);function l(e,t){for(var r=[],n=0;n<e.elements.length;n++)r.push(u(e.elements[n],t));return r}var h=function(e,t){var r=[],n=t.subjects[this.toStr(e)];if(!n)return r;n.sort();for(var i=0;i<n.length;i++){var o=n[i];switch(o.object.termType){case"BlankNode":r=t.rootsHash[o.object.toNT()]?r.concat(["<"+d(o.predicate)+' rdf:nodeID="'+o.object.toNT().slice(2)+'">',"</"+d(o.predicate)+">"]):r.concat(["<"+d(o.predicate)+' rdf:parseType="Resource">',h(o.object,t),"</"+d(o.predicate)+">"]);break;case"NamedNode":r=r.concat(["<"+d(o.predicate)+' rdf:resource="'+c(o.object)+'"/>']);break;case"Literal":r=r.concat(["<"+d(o.predicate)+(o.object.datatype.equals(this.xsd.string)?"":' rdf:datatype="'+a(o.object.datatype.value)+'"')+(o.object.language?' xml:lang="'+o.object.language+'"':"")+">"+a(o.object.value)+"</"+d(o.predicate)+">"]);break;case"Collection":r=r.concat(["<"+d(o.predicate)+' rdf:parseType="Collection">',l(o.object,t),"</"+d(o.predicate)+">"]);break;default:throw new Error("Can't serialize object of type "+o.object.termType+" into XML")}}return r}.bind(this);var d=function(e){var r=e.uri,n=r.indexOf("#");if(n<0&&this.flags.indexOf("/")<0&&(n=r.lastIndexOf("/")),n<0)throw new Error("Cannot make qname out of <"+r+">");for(var i=n+1;i<r.length;i++)if(this._notNameChars.indexOf(r[i])>=0)throw new Error('Invalid character "'+r[i]+'" cannot be in XML qname for URI: '+r);var o=r.slice(n+1),s=r.slice(0,n+1);if(this.defaultNamespace&&this.defaultNamespace===s&&this.flags.indexOf("d")<0)return o;var a=this.prefixes[s];return a||(a=this.makeUpPrefix(s)),t[s]=!0,a+":"+o}.bind(this),f=s(e),p="<rdf:RDF";for(var g in this.defaultNamespace&&(p+=' xmlns="'+a(this.defaultNamespace)+'"'),t)if(t.hasOwnProperty(g)){var y=this.base&&this.flags.includes("z")?b.refTo(this.base,g):g;p+="\n xmlns:"+this.prefixes[g]+'="'+a(y)+'"'}return o([p+=">",f,"</rdf:RDF>"],-1)}statementsToJsonld(e){const t=this.statementsToN3(e),r=R.parse(t);return JSON.stringify(r,null,2)}}function D(e,t,r,n,i,o){r=r||e?.value;const a=o||{};n=n||s.sT;try{var c=P(t);a.flags&&c.setFlags(a.flags);var u=t.statementsMatching(void 0,void 0,void 0,e);switch("namespaces"in t&&c.suggestNamespaces(t.namespaces),a.namespaces&&c.setNamespaces(a.namespaces),c.setBase(r),n){case s.JG:return l(null,c.statementsToXML(u));case s.ny:case s.MG:return l(null,c.statementsToN3(u));case s.sT:case s.hu:return c.setFlags("si"),l(null,c.statementsToN3(u));case s.bM:return c.setFlags("deinprstux"),l(null,c.statementsToNTriples(u));case s.i2:return c.setFlags("si dr"),l(null,c.statementsToJsonld(u));case s._0:case s.BR:return c.setFlags("deinprstux q"),l(null,c.statementsToNTriples(u));default:throw new Error("Serialize: Content-type "+n+" not supported for data write.")}}catch(e){if(i)return i(e,void 0);throw e}function l(e,t){return i?void i(e,t):t}}const U=["blankNode","defaultGraph","literal","namedNode","quad","variable","supports"],L={first:"http://www.w3.org/1999/02/22-rdf-syntax-ns#first",rest:"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",nil:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"};function j(e,t,r){const n=[];return r.reduce((t,r,i,o)=>{let s;return n.push(e.quad(t,e.namedNode(L.first),o[i])),i<o.length-1?(s=e.blankNode(),n.push(e.quad(t,e.namedNode(L.rest),s))):n.push(e.quad(t,e.namedNode(L.rest),e.namedNode(L.nil))),s},t),n}function M(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;var n=e.length;for(r<0&&(r=n+r);r<n;r++)if(e[r]===t)return r;return-1}class H extends o.A{constructor(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],c=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};super(""),e=this,this.statements=t,this.constraints=r,this.initBindings=o,this.optional=a,(0,n.A)(this,"termType",s.bD),(0,n.A)(this,"classOrder",i.A.Graph),(0,n.A)(this,"fetcher",void 0),(0,n.A)(this,"isVar",0),(0,n.A)(this,"ns",F),(0,n.A)(this,"rdfFactory",void 0),this.rdfFactory=c&&c.rdfFactory||x;for(const t of U)this[t]=function(){return e.rdfFactory[t](...arguments)}}add(e,t,r,n){return 1===arguments.length&&e.forEach(e=>this.add(e.subject,e.predicate,e.object,e.graph)),this.statements.push(this.rdfFactory.quad(e,t,r,n))}addStatement(e){return this.add(e)}bnode(e){return this.rdfFactory.blankNode(e)}addAll(e){e.forEach(e=>{this.add(e.subject,e.predicate,e.object,e.graph)})}any(e,t,r,n){const i=this.anyStatementMatching(e,t,r,n);return null==i?null:null==e?i.subject:null==t?i.predicate:null==r?i.object:null}anyValue(e,t,r,n){const i=this.any(e,t,r,n);return i?i.value:void 0}anyJS(e,t,r,n){const i=this.any(e,t,r,n);return i?o.A.toJS(i):void 0}anyStatementMatching(e,t,r,n){let i=this.statementsMatching(e,t,r,n,!0);if(i&&0!==i.length)return i[0]}id(e){return this.rdfFactory.id(e)}statementsMatching(e,t,r,n,i){const o=this.statements.filter(i=>(!e||e.equals(i.subject))&&(!t||t.equals(i.predicate))&&(!r||r.equals(i.object))&&(!n||n.equals(i.graph)));return i?0===o.length?[]:[o[0]]:o}bottomTypeURIs(e){let t,r,n,i,o,s,a,c;t=[];for(let u in e)if(e.hasOwnProperty(u)){for(c=e[u],a=this.each(void 0,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),this.rdfFactory.namedNode(u)),r=!0,i=0,o=a.length;i<o;i++)if(n=a[i],s=n.uri,s in e){r=!1;break}r&&(t[u]=c)}return t}collection(){return new f}each(e,t,r,n){const i=[];let o=this.statementsMatching(e,t,r,n,!1);if(null==e)for(let e=0,t=o.length;e<t;e++)i.push(o[e].subject);else if(null==t)for(let e=0,t=o.length;e<t;e++)i.push(o[e].predicate);else if(null==r)for(let e=0,t=o.length;e<t;e++)i.push(o[e].object);else if(null==n)for(let e=0,t=o.length;e<t;e++)i.push(new c.A(o[e].graph.value));return i}equals(e){return!!e&&this.hashString()===e.hashString()}findMembersNT(e){let t,r,n,i,o,s,a,c,u,l,h,d,f,p;d={},d[e.toNT()]=!0,i={},s=this.transitiveClosure(d,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!0);for(let e in s)if(s.hasOwnProperty(e)){a=this.statementsMatching(void 0,this.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),this.fromNT(e));for(let e=0,t=a.length;e<t;e++)f=a[e],i[f.subject.toNT()]=f;c=this.each(void 0,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#domain"),this.fromNT(e));for(let e=0,r=c.length;e<r;e++)for(o=c[e],u=this.statementsMatching(void 0,o),n=0,t=u.length;n<t;n++)f=u[n],i[f.subject.toNT()]=f;l=this.each(void 0,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#range"),this.fromNT(e));for(let e=0,t=l.length;e<t;e++)for(o=l[e],h=this.statementsMatching(void 0,o),p=0,r=h.length;p<r;p++)f=h[p],i[f.object.toNT()]=f}return i}findMemberURIs(e){return this.NTtoURI(this.findMembersNT(e))}findSubClassesNT(e){let t={};return t[e.toNT()]=!0,this.transitiveClosure(t,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!0)}findSuperClassesNT(e){let t={};return t[e.toNT()]=!0,this.transitiveClosure(t,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!1)}findTypesNT(e){let t,r,n,i,o,s,a,c,u;n="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",u=[],i=this.statementsMatching(e,void 0,void 0);for(let e=0,t=i.length;e<t;e++)if(c=i[e],"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"===c.predicate.uri)u[c.object.toNT()]=c;else{o=this.each(c.predicate,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#domain"));for(let e=0,t=o.length;e<t;e++)r=o[e],u[r.toNT()]=c}s=this.statementsMatching(void 0,void 0,e);for(let e=0,r=s.length;e<r;e++){c=s[e],a=this.each(c.predicate,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#range"));for(let e=0,r=a.length;e<r;e++)t=a[e],u[t.toNT()]=c}return this.transitiveClosure(u,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!1)}findTypeURIs(e){return this.NTtoURI(this.findTypesNT(e))}connectedStatements(e,t,r){r=r||[];let n=[e],i={},o={},s=[],a=this,c=function(e){let c=function(e){"BlankNode"!==e.termType||i[e.value]||(i[e.value]=!0,n.push(e))},u=a.statementsMatching(null,null,e,t).concat(a.statementsMatching(e,null,null,t));u=u.filter(function(e){if(r[e.predicate.value])return!1;let t=e.toNT();return!o[t]&&(o[t]=!0,!0)}),u.forEach(function(e){c(e.subject),c(e.object)}),s=s.concat(u)};for(;n.length;)c(n.shift());return s}formula(e){return new H}fromNT(e){let t,r,n;switch(e[0]){case"<":return this.sym(e.slice(1,-1));case'"':if(n=void 0,t=void 0,r=e.lastIndexOf('"'),r<e.length-1)if("@"===e[r+1])n=e.slice(r+2);else{if("^^"!==e.slice(r+1,r+3))throw new Error("Can't convert string from NT: "+e);t=this.fromNT(e.slice(r+3))}return e=(e=(e=(e=e.slice(1,r)).replace(/\\"/g,'"')).replace(/\\n/g,"\n")).replace(/\\\\/g,"\\"),this.rdfFactory.literal(e,n||t);case"_":return this.rdfFactory.blankNode(e.slice(2));case"?":return new _(e.slice(1))}throw new Error("Can't convert from NT: "+e)}holds(e,t,r,n){let i;if(1===arguments.length){if(!e)return!0;if(e instanceof Array){for(i=0;i<e.length;i++)if(!this.holds(e[i]))return!1;return!0}if((0,u.SH)(e))return this.holds(e.subject,e.predicate,e.object,e.graph);if(e.statements)return this.holds(e.statements)}return null!=this.anyStatementMatching(e,t,r,n)}holdsStatement(e){return this.holds(e.subject,e.predicate,e.object,e.graph)}list(e,t){if(t.rdfFactory.supports.COLLECTIONS){const r=t.rdfFactory.collection();return e.forEach(function(e){r.append(e)}),r}{const r=t.rdfFactory.blankNode(),n=j(t.rdfFactory,r,e);return t.addAll(n),r}}NTtoURI(e){let t,r,n={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],"<"===t[0]&&(n[t.slice(1,-1)]=r));return n}serialize(e,t,r,n){return D(r,this,e,t,void 0,n)}substitute(e){let t=this.statements.map(function(t){return t.substitute(e)});const r=new H;return r.addAll(t),r}sym(e,t){if(t)throw new Error("This feature (kb.sym with 2 args) is removed. Do not assume prefix mappings.");return this.rdfFactory.namedNode(e)}the(e,t,r,n){let i=this.any(e,t,r,n);return null==i&&T.A.error("No value found for the() {"+e+" "+t+" "+r+"}."),i}transitiveClosure(e,t,r){let n,i,o,s,a,c,u={};Object.assign(u,e);let l={};for(;;){if(c=function(){for(let e in u)if(u.hasOwnProperty(e))return e}(),null==c)return l;for(a=r?this.each(void 0,t,this.fromNT(c)):this.each(this.fromNT(c),t),i=0,o=a.length;i<o;i++)n=a[i],s=n.toNT(),s in l||s in u||(u[s]=u[c]);l[c]=u[c],delete u[c]}}topTypeURIs(e){let t,r,n,i,o,s,a,c;for(n in a=[],e)if(e.hasOwnProperty(n)){for(c=e[n],o=0,s=this.each(this.rdfFactory.namedNode(n),this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf")),t=0,i=s.length;t<i;t++)if(r=s[t],"http://www.w3.org/2000/01/rdf-schema#Resource"!==r.uri){o++;break}o||(a[n]=c)}return a["http://www.w3.org/2000/01/rdf-schema#Resource"]&&delete a["http://www.w3.org/2000/01/rdf-schema#Resource"],a["http://www.w3.org/2002/07/owl#Thing"]&&delete a["http://www.w3.org/2002/07/owl#Thing"],a}toString(){return"{"+this.statements.join("\n")+"}"}variable(e){return new _(e)}whether(e,t,r,n){return this.statementsMatching(e,t,r,n,!1).length}}o.A.fromValue=d;const B=o.A,q={xsd:F("http://www.w3.org/2001/XMLSchema#")};o.A.toJS=function(e){return(0,u.P3)(e)?e.elements.map(o.A.toJS):(0,u.c$)(e)?e.datatype.equals(q.xsd("boolean"))?"1"===e.value||"true"===e.value:e.datatype.equals(q.xsd("dateTime"))||e.datatype.equals(q.xsd("date"))?new Date(e.value):e.datatype.equals(q.xsd("integer"))||e.datatype.equals(q.xsd("float"))||e.datatype.equals(q.xsd("decimal"))?Number(e.value):e.value:e};class K{constructor(e,t){this.pat=new G,this.vars=[],this.name=e,this.id=t}}function W(e,t,r,n){function i(e){var t,r="";for(t in e)e.hasOwnProperty(t)&&(r+=" "+t+" -> "+e[t]);return r}function o(e){var t,r="Bindings: ",n=e.length;for(t=0;t<n;t++)r+=i(e[t][0])+";\n\t";return r}function s(e,t,r,n){var i;if(e.length!==t.length)return[];if(!e.length)return[[[],null]];var o=function(e,t,r,n){var i=r[e];if(void 0===i){if(e.isVar){var o=[];return o[e]=t,[[o,null]]}i=e}if(!i.complexType)return n.redirections[i]&&(i=n.redirections[i]),n.redirections[t]&&(t=n.redirections[t]),i.equals(t)||i.uri&&i.uri===g?[[[],null]]:[];if(e instanceof Array)return t instanceof Array?s(e,t,r):[];throw new Error("query.js: oops - code not written yet")}(e[0],t[0],r,n);if(0===o.length)return o;var a,c,u,l,h,d,f,p=[],y=o.length;for(a=0;a<y;a++){for(h in f=[],c=o[a][0])c.hasOwnProperty(h)&&(f[h]=c[h]);for(h in r)r.hasOwnProperty(h)&&(f[h]=r[h]);for(l=(i=s(e.slice(1),t.slice(1),f,n)).length,u=0;u<l;u++){for(h in d=i[u][0],c)c.hasOwnProperty(h)&&(d[h]=c[h]);p.push([d,null])}}return p}function a(e,t){var r=t[e];return void 0===r?e:r}function c(e,t){var r,n={};for(r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);for(r in t)t.hasOwnProperty(r)&&(n[r]=t[r]);return n}function u(e,t){return this.trunkBindings=t,this.originalCallback=e,this.branches=[],this}function l(e,t){return this.count=0,this.success=!1,this.done=!1,this.callback=e,this.onDone=t,this}u.prototype.checkAllDone=function(){var e;for(e=0;e<this.branches.length;e++)if(!this.branches[e].done)return;T.A.debug("OPTIONAL BIDNINGS ALL DONE:"),this.doCallBacks(this.branches.length-1,this.trunkBindings)},u.prototype.doCallBacks=function(e,t){var r;if(e<0)return this.originalCallback(t);for(r=0;r<this.branches[e].results.length;r++)this.doCallBacks(e-1,c(t,this.branches[e].results[r]))},l.prototype.reportMatch=function(e){this.callback(e),this.success=!0},l.prototype.reportDone=function(){this.done=!0,T.A.info("Mandatory query branch finished.***"),void 0!==this.onDone&&this.onDone()};var h=function(e){return this.count=0,this.done=!1,this.results=[],this.junction=e,e.branches.push(this),this};function d(e,t,r){var n,i,o,s;for(t.nvars=0,t.index=null,n=[t.subject,t.predicate,t.object,t.why],s=[e.subjectIndex,e.predicateIndex,e.objectIndex,e.whyIndex],o=0;o<4;o++){let c=n[o];if(c.uri&&c.uri===g);else if(c.isVar&&void 0===r[c])t.nvars++;else{if(c=a(n[o],r),e.redirections[e.id(c)]&&(c=e.redirections[e.id(c)]),!(i=s[o][e.id(c)]))return t.index=[],!1;(null===t.index||t.index.length>i.length)&&(t.index=i)}}return null===t.index&&(t.index=e.statements),!0}function f(e,t){return e.nvars!==t.nvars?e.nvars-t.nvars:e.index.length-t.index.length}h.prototype.reportMatch=function(e){this.results.push(e)},h.prototype.reportDone=function(){T.A.debug("Optional branch finished - results.length = "+this.results.length),0===this.results.length&&(this.results.push({}),T.A.debug("Optional branch FAILED - that's OK.")),this.done=!0,this.junction.checkAllDone()};var p=function(e,r,n,o,s,a,c){T.A.debug("Match begins, Branch count now: "+c.count+" for "+c.pattern_debug);var l,d,f=r.statements;if(0===f.length){if(T.A.debug("FOUND MATCH WITH BINDINGS:"+i(n)),0===r.optional.length)c.reportMatch(n);else{T.A.debug("OPTIONAL: "+r.optional);var g,y=new u(t,n),v=[];for(g=0;g<r.optional.length;g++)v[g]=new h(y),v[g].pattern_debug=r.optional[g];for(g=0;g<r.optional.length;g++)v[g].count=v[g].count+1,p(e,r.optional[g],n,"",s,t,v[g])}return c.count--,void T.A.debug("Match ends -- success , Branch count now: "+c.count+" for "+c.pattern_debug)}var w=f.length;if(s){0;var _=function(t,i){var u=t.uri.split("#")[0];s.nowOrWhenFetched(u,void 0,function(i,u,l){i||console.log("Error following link to <"+t.uri+"> in query: "+u),p(e,r,n,o,s,a,c)})};for(d=0;d<w;d++){if(l=f[d],void 0!==n[l.subject]&&n[l.subject].uri&&s&&"unrequested"===s.getState((0,b.docpart)(n[l.subject].uri)))return void _(n[l.subject]);if(void 0!==n[l.object]&&n[l.object].uri&&s&&"unrequested"===s.getState((0,b.docpart)(n[l.object].uri)))return void _(n[l.object])}}m(e,r,n,o,s,a,c)},y=function(e,t){var r,n,i=!0;for(r in e)e.hasOwnProperty(r)&&t[r]&&(n=t[r].test)&&!n(e[r])&&(i=!1);return i},m=function(e,t,r,n,a,c,u){var l,h,g,m,v,w,b,_=t.statements,S=_.length;for(l=0;l<S;l++)d(e,b=_[l],r);_.sort(f),b=_[0];var E,A=e.formula();A.optional=t.optional,A.constraints=t.constraints,A.statements=_.slice(1),T.A.debug(n+"match2 searching "+b.index.length+" for "+b+"; bindings so far="+i(r));var x,F,k=b.index.length,I=0;for(E=0;E<k;E++)for(F=b.index[E],x=s([b.subject,b.predicate,b.object,b.why],[F.subject,F.predicate,F.object,F.why],r,e),T.A.info(n+" From first: "+x.length+": "+o(x)),g=x.length,h=0;h<g;h++)if(v=[],w=x[h][0],y(w,t.constraints)){for(m in w)w.hasOwnProperty(m)&&(v[m]=w[m]);for(m in r)r.hasOwnProperty(m)&&(v[m]=r[m]);u.count++,I++,p(e,A,v,n+" ",a,c,u)}else T.A.debug("Branch count CS: "+u.count);u.count--,0===I&&T.A.debug("Match2 fails completely on "+b),T.A.debug("Match2 ends, Branch count: "+u.count+" for "+u.pattern_debug),0===u.count&&(T.A.debug("Branch finished."),u.reportDone())},v=this;T.A.debug("Query on "+this.statements.length);var w=new l(t,n);w.count++,e.sync?p(v,e.pat,e.pat.initBindings,"",r,t,w):setTimeout(function(){p(v,e.pat,e.pat.initBindings,"",r,t,w)},0)}const J="http://www.w3.org/2002/07/owl#";function V(e,t,r,n){var i=e.any(t,r,void 0);return!!i&&(e.equate(i,n),!0)}function $(e,t,r,n){var i=e.any(void 0,r,n);return!!i&&(e.equate(i,t),!0)}function z(e,t,r,n,i){e.typeCallback&&e.typeCallback(e,n,i);var o=e.classActions[e.id(n)],s=!1;if(o)for(var a=0;a<o.length;a++)s=s||o[a](e,t,r,n,i);return s}class G extends H{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(void 0,void 0,void 0,void 0,t),(0,n.A)(this,"updater",void 0),(0,n.A)(this,"namespaces",void 0),(0,n.A)(this,"classActions",void 0),(0,n.A)(this,"propertyActions",void 0),(0,n.A)(this,"redirections",void 0),(0,n.A)(this,"aliases",void 0),(0,n.A)(this,"HTTPRedirects",void 0),(0,n.A)(this,"subjectIndex",void 0),(0,n.A)(this,"predicateIndex",void 0),(0,n.A)(this,"objectIndex",void 0),(0,n.A)(this,"whyIndex",void 0),(0,n.A)(this,"index",void 0),(0,n.A)(this,"features",void 0),(0,n.A)(this,"_universalVariables",void 0),(0,n.A)(this,"_existentialVariables",void 0),(0,n.A)(this,"rdfArrayRemove",void 0),(0,n.A)(this,"dataCallbacks",[]),(0,n.A)(this,"dataRemovalCallbacks",[]),this.propertyActions={},this.classActions={},this.redirections=[],this.aliases=[],this.HTTPRedirects=[],this.subjectIndex=[],this.predicateIndex=[],this.objectIndex=[],this.whyIndex=[],this.index=[this.subjectIndex,this.predicateIndex,this.objectIndex,this.whyIndex],this.namespaces={},this.features=e||[],this.rdfArrayRemove=t.rdfArrayRemove||k.RDFArrayRemove,t.dataCallback&&(this.dataCallbacks=[t.dataCallback]),t.dataRemovalCallback&&(this.dataRemovalCallbacks=[t.dataRemovalCallback]),this.initPropertyActions(this.features)}static get defaultGraphURI(){return g}substitute(e){var t=this.statements.map(function(t){return t.substitute(e)}),r=new G;return r.add(t),r}addDataCallback(e){this.dataCallbacks.push(e)}addDataRemovalCallback(e){this.dataRemovalCallbacks.push(e)}applyPatch(e,t,r){var n,i=this,o=null;function s(s){if(e.delete){n=e.delete,o&&(n=n.substitute(o)),n=n.statements;var a=[],c=n.map(function(e){var r=i.statementsMatching(e.subject,e.predicate,e.object,t);return 0===r.length?(a.push(e),null):r[0]});if(a.length)return r("Could not find to delete: "+a.join("\n or "));c.map(function(e){i.remove(e)})}e.insert&&(n=e.insert,o&&(n=n.substitute(o)),(n=n.statements).map(function(e){e.graph=t,i.add(e.subject,e.predicate,e.object,e.graph)})),s()}if(e.where){var a=new K("patch");a.pat=e.where,a.pat.statements.map(function(e){e.graph=$t(t.value)}),a.sync=!0;var c=[];i.query(a,function(e){c.push(e)},i.fetcher,function(){return 0===c.length?r("No match found to be patched:"+e.where):c.length>1?r("Patch ambiguous. No patch done."):(o=c[0],void s(r))})}else s(r)}declareExistential(e){return this._existentialVariables||(this._existentialVariables=[]),this._existentialVariables.push(e),e}initPropertyActions(e){this.propertyActions[this.rdfFactory.id(this.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))]=[z],M(e,"sameAs")>=0&&(this.propertyActions[this.rdfFactory.id(this.rdfFactory.namedNode(`${J}sameAs`))]=[function(e,t,r,n,i){return e.equate(t,n),!0}]),M(e,"InverseFunctionalProperty")>=0&&(this.classActions[this.rdfFactory.id(this.rdfFactory.namedNode(`${J}InverseFunctionalProperty`))]=[function(e,t,r,n,i){return e.newPropertyAction(t,$)}]),M(e,"FunctionalProperty")>=0&&(this.classActions[this.rdfFactory.id(this.rdfFactory.namedNode(`${J}FunctionalProperty`))]=[function(e,t,r,n,i){return e.newPropertyAction(t,V)}])}addStatement(e){return this.add(e.subject,e.predicate,e.object,e.graph),this.statements.length}add(e,t,r,n){var i,o,s;if(1===arguments.length){if(e instanceof Array)for(i=0;i<e.length;i++)this.add(e[i]);else(0,u.aF)(e)?this.add(e.subject,e.predicate,e.object,e.graph):(0,u.ok)(e)&&this.add(e.statements);return this}n||(n=this.fetcher?this.fetcher.appNode:this.rdfFactory.defaultGraph()),"string"==typeof e&&(e=this.rdfFactory.namedNode(e)),t=B.fromValue(t);const a=B.fromValue(r);if(n=B.fromValue(n),!(0,u.CZ)(e))throw new Error("Subject is not a subject type");if(!(0,u.fY)(t))throw new Error(`Predicate ${t} is not a predicate type`);if(!(0,u.DJ)(a))throw new Error(`Object ${a} is not an object type`);if(!(0,u.RN)(n))throw new Error("Why is not a graph type");this.predicateCallback&&this.predicateCallback(this,t,n);var c=this.id(this.canon(t)),l=!1;if(o=this.propertyActions[c])for(i=0;i<o.length;i++)l=l||o[i](this,e,t,a,n);if(this.holds(e,t,a,n))return null;var h=[this.id(this.canon(e)),c,this.id(this.canon(a)),this.id(this.canon(n))];for(s=this.rdfFactory.quad(e,t,a,n),i=0;i<4;i++){var d=this.index[i],f=h[i];d[f]||(d[f]=[]),d[f].push(s)}this.statements.push(s);for(const e of this.dataCallbacks)e(s);return s}canon(e){if(!e)return e;const t=this.redirections[this.id(e)];if(t)return t;switch(e.termType){case s.$Q:return new a(e.value);case s.r0:return e;case s.ic:return new y;case s.S:case s.bD:return e;case s.QW:return new h(e.value,e.language,e.datatype);case s.Kk:return new c.A(e.value);case s.P2:return new _(e.value);default:throw new Error(`Term Type not recognized for canonization: ${e.termType}`)}}check(){this.checkStatementList(this.statements);for(var e=0;e<4;e++){var t=this.index[e];for(var r in t)t.hasOwnProperty(r)&&this.checkStatementList(t[r],e)}}checkStatementList(e,t){void 0===t&&(t=0);for(var r,n=" found in "+["subject","predicate","object","why"][t]+" index.",i=0;i<e.length;i++){for(var o=[(r=e[i]).subject,r.predicate,r.object,r.graph],s=function(e,t){for(var r=0;r<e.length;r++)if(e[r].subject.equals(t.subject)&&e[r].predicate.equals(t.predicate)&&e[r].object.equals(t.object)&&e[r].why.equals(t.graph))return!0},a=0;a<4;a++){var c=this.canon(o[a]),u=this.id(c);this.index[a][u]&&s(this.index[a][u],r)}if(!s(this.statements,r))throw new Error("Statement list does not statement "+r+"@"+r.graph+n)}}close(){return this}compareTerms(e,t){return Object.prototype.hasOwnProperty.call(e,"compareTerm")?e.compareTerm(t):i.A[e.termType]<i.A[t.termType]?-1:i.A[e.termType]>i.A[t.termType]?1:e.value<t.value?-1:e.value>t.value?1:0}copyTo(e,t,r){r||(r=[]);var n=this.statementsMatching(e);-1!==M(r,"two-direction")&&n.concat(this.statementsMatching(void 0,void 0,e));for(var i=0;i<n.length;i++){var o=n[i];switch(o.object.termType){case"NamedNode":this.add(t,o.predicate,o.object);break;case"Literal":case"BlankNode":case"Collection":this.add(t,o.predicate,o.object.copy(this))}-1!==M(r,"delete")&&this.remove(o)}}equate(e,t){const r=this.canon(e),n=this.canon(t);var i=this.compareTerms(r,n);return!i||(i<0?this.replaceWith(n,r):this.replaceWith(r,n))}formula(e){return new G(e)}get length(){return this.statements.length}match(e,t,r,n){return this.statementsMatching(B.fromValue(e),B.fromValue(t),B.fromValue(r),B.fromValue(n))}mentionsURI(e){var t="<"+e+">";return!!this.subjectIndex[t]||!!this.objectIndex[t]||!!this.predicateIndex[t]}newExistential(e){if(!e)return this.bnode();var t=this.sym(e);return this.declareExistential(t)}newPropertyAction(e,t){var r=this.id(e);this.propertyActions[r]||(this.propertyActions[r]=[]),this.propertyActions[r].push(t);for(var n=this.statementsMatching(void 0,e,void 0),i=!1,o=0;o<n.length;o++)i=i||t(this,n[o].subject,e,n[o].object);return i}newUniversal(e){var t=this.sym(e);return this._universalVariables||(this._universalVariables=[]),this._universalVariables.push(t),t}variable(e){return new _(e)}nextSymbol(e){for(var t=0;;t++){var r=e.value+"#n"+t;if(!this.mentionsURI(r))return this.sym(r)}}query(e,t,r,n){return W.call(this,e,t,r,n)}querySync(e){var t=[];var r=!1;if(e.sync=!0,W.call(this,e,function(e){t.push(e)},null,function(){r=!0}),!r)throw new Error("Sync query should have called done function");return t}remove(e){if(e instanceof Array){for(var t=0;t<e.length;t++)this.remove(e[t]);return this}if((0,u.ok)(e))return this.remove(e.statements);var r=this.statementsMatching(e.subject,e.predicate,e.object,e.graph);if(!r.length)throw new Error("Statement to be removed is not on store: "+e);return this.removeStatement(r[0]),this}removeDocument(e){this.removeMetadata(e);for(var t=this.statementsMatching(void 0,void 0,void 0,e).slice(),r=0;r<t.length;r++)this.removeStatement(t[r]);return this.removeMatches(e,null,null),this}removeMetadata(e){const t=this.sym("chrome://TheCurrentSession"),r="http://www.w3.org/2007/ont/link#",n=this.statementsMatching(void 0,this.sym(`${r}requestedURI`),this.rdfFactory.literal(e.value),t).map(e=>e.subject);for(var i=0;i<n.length;i++){const e=n[i];if(null!=e){let n;const i=this.any(e,this.sym(`${r}status`),null,t);if(null!=i){n=this.statementsMatching(i,this.sym(`${r}status`),null,t).slice();for(var o=0;o<n.length;o++)this.removeStatement(n[o])}const s=this.any(e,this.sym(`${r}response`),null,t);if(null!=s){n=this.statementsMatching(s,null,null,t).slice();for(o=0;o<n.length;o++)this.removeStatement(n[o])}n=this.statementsMatching(e,null,null,t).slice();for(o=0;o<n.length;o++)this.removeStatement(n[o])}}return this.removeMatches(this.sym(e.value),null,null,t),this}removeMany(e,t,r,n,i){for(var o=this.statementsMatching(e,t,r,n,!1),s=[],a=0;a<o.length;a++)s.push(o[a]);for(i&&(s=s.slice(0,i)),a=0;a<s.length;a++)this.remove(s[a])}removeMatches(e,t,r,n){return this.removeMany(e,t,r,n),this}removeStatement(e){for(var t=[e.subject,e.predicate,e.object,e.graph],r=0;r<4;r++){var n=this.canon(t[r]),i=this.id(n);this.index[r][i]&&this.rdfArrayRemove(this.index[r][i],e)}this.rdfArrayRemove(this.statements,e);for(const t of this.dataRemovalCallbacks)t(e);return this}removeStatements(e){for(var t=0;t<e.length;t++)this.remove(e[t]);return this}replaceWith(e,t){for(var r=this.id(e),n=this.id(t),i=function(e){var t=e[r];if(t){var i=e[n];e[n]=i?t.concat(i):t,delete e[r]}},o=0;o<4;o++)i(this.index[o]);if(this.redirections[r]=t,e.value){if(this.aliases[n]||(this.aliases[n]=[]),this.aliases[n].push(e),this.aliases[r])for(o=0;o<this.aliases[r].length;o++)this.redirections[this.id(this.aliases[r][o])]=t,this.aliases[n].push(this.aliases[r][o]);this.add(t,this.sym("http://www.w3.org/2007/ont/link#uri"),e),this.fetcher&&this.fetcher.nowKnownAs(e,t)}return i(this.classActions),i(this.propertyActions),!0}allAliases(e){var t=this.aliases[this.id(this.canon(e))]||[];return t.push(this.canon(e)),t}sameThings(e,t){if(e.equals(t))return!0;var r=this.canon(e);if(!r)return!1;var n=this.canon(t);return!!n&&r.value===n.value}setPrefixForURI(e,t){if(("tab"!==e||!this.namespaces.tab)&&"ns"!==e.slice(0,2)&&"default"!==e.slice(0,7)){for(let e in this.namespaces)this.namespaces[e]==t&&delete this.namespaces[e];this.namespaces[e]=t}}statementsMatching(e,t,r,n,i){var o,s,a=[e,t,r,n],c=[],u=[],l=[],h=[];for(o=0;o<4;o++)c[o]=this.canon(B.fromValue(a[o])),c[o]?(h.push(o),u[o]=this.id(c[o])):l.push(o);if(0===h.length)return this.statements;if(1===h.length)return o=h[0],(s=this.index[o][u[o]])&&i&&s.length>1&&(s=s.slice(0,1)),s=s||[];var d,f,p=1e10;for(f=0;f<h.length;f++){if(o=h[f],!(s=this.index[o][u[o]]))return[];s.length<p&&(p=s.length,d=f)}for(var g=h[d],y=this.index[g][u[g]],m=h.slice(0,d).concat(h.slice(d+1)),v=[],w=["subject","predicate","object","why"],b=0;b<y.length;b++){var _=y[b];for(f=0;f<m.length;f++)if(o=m[f],!this.canon(_[w[o]]).equals(c[o])){_=null;break}if(null!=_&&(v.push(_),i))break}return v}uris(e){var t=this.canon(e),r=this.aliases[this.id(t)];if(!t.value)return[];var n=[t.value];if(r)for(var i=0;i<r.length;i++)n.push(r[i].uri);return n}serialize(e,t,r,n){return D(r,this,e,t,void 0,n={...n||{},namespaces:n?.namespaces?{...this.namespaces,...n.namespaces}:{...this.namespaces}})}}(0,n.A)(G,"handleRDFType",void 0),G.handleRDFType=z;const X=F("http://www.w3.org/1999/02/22-rdf-syntax-ns#");function Y(e,t){function r(n,i,o){const s=e.statementsMatching(n,X("rest"),null,t);if(1!==s.length)throw new Error(`Bad list structure: no rest at ${n}`);const a=e.statementsMatching(n,X("first"),null,t);if(1!==a.length)throw new Error(`Bad list structure: rest but ${a.length} firsts at ${n}`);const c=[a[0].object].concat(i),u=o.concat(s).concat(a),l=e.statementsMatching(null,X("rest"),n,t);if(0===l.length){const r=new f(c);return e.remove(u),void function(e,t,r,n){for(const i of e.statementsMatching(r,null,null,n)){const r=new w(t,i.predicate,i.object,n);e.remove(i),e.add(r)}for(const i of e.statementsMatching(null,r,null,n))e.remove(i),e.add(new w(i.subject,t,i.object,n));for(const i of e.statementsMatching(null,null,r,n))e.remove(i),e.add(new w(i.subject,i.predicate,t,n))}(e,r,n,t)}if(1!==l.length)throw new Error(`Bad list structure: ${l.length} pres at ${n}`);const h=l[0].subject;if("BlankNode"!==h.termType)throw new Error(`Bad list element node ${h} type: ${h.termType} `);r(h,c,u)}!function(e,t){const r=X("nil");for(const n of e.statementsMatching(r,null,null,t)){e.remove(n);const r=new f;e.add(new w(r,n.predicate,n.object,t))}for(const n of e.statementsMatching(null,null,r,t))if(!n.predicate.sameTerm(X("rest"))){e.remove(n);const r=new f;e.add(new w(n.subject,n.predicate,r,t))}}(e,t);e.statementsMatching(null,X("rest"),X("nil"),t).forEach(e=>{if("BlankNode"!==e.subject.termType)throw new Error(`Bad list element node ${e.subject} type: ${e.subject.termType} `);r(e.subject,[],[])})}var Q=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",r=0;r<e.length;r++){var n=e.charCodeAt(r);n<128?t+=String.fromCharCode(n):n>127&&n<2048?(t+=String.fromCharCode(n>>6|192),t+=String.fromCharCode(63&n|128)):(t+=String.fromCharCode(n>>12|224),t+=String.fromCharCode(n>>6&63|128),t+=String.fromCharCode(63&n|128))}return t},Z="http://www.w3.org/2000/10/swap/log#",ee=function(e){return e},te=function(e){return e},re=function(e){if(e.length>0)throw"missing.js: oops nnonempty dict not imp";return[]},ne=function(e){return e.length},ie=function(e,t,r){if(void 0===e.slice)throw"@@ mising.js: No .slice function for "+e+" of type "+typeof e;return void 0===r||null==r?e.slice(t):e.slice(t,r)},oe=Error("dummy error stop iteration"),se=function(e){return this.last=0,this.li=e,this.next=function(){if(this.last==this.li.length)throw oe;return this.li[this.last++]},this},ae=function(e,t){return e.indexOf(t)},ce=function(e,t){if(!e){if(t)throw"python Assertion failed: "+t;throw"(python) Assertion failed."}};String.prototype.encode=function(e){if("utf-8"!=e)throw"UTF8_converter: can only do utf-8";return Q(this)},String.prototype.decode=function(e){if("utf-8"!=e)throw"UTF8_converter: can only do utf-8";return this};var ue=function(e,t){return b.join(t,e)},le="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil",he="http://www.w3.org/2002/07/owl#sameAs";var de="\t\r\n !\"#$%&'()*.,+/;<=>?@[\\]^`{|}~",fe=de+":",pe=new RegExp("^([-+]?[0-9]+)(\\.[0-9]+)?([eE][-+]?[0-9]+)?","g"),ge=new RegExp("^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9](T[0-9][0-9]:[0-9][0-9](:[0-9][0-9](\\.[0-9]*)?)?)?Z?"),ye=new RegExp('[\\\\\\r\\n\\"]',"g"),me=new RegExp("^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*","g");const ve=function(e,t,r,n,i,o,s,a){return new we(e,t,r,n,i,o,s,a)};class we{constructor(e,t,r,n,i,o,s,a){void 0===t&&(t=null),void 0===r&&(r=""),void 0===n&&(n=null),void 0===i&&(i=""),void 0===o&&(o=null),void 0===s&&(s=""),void 0===a&&(a=null),this._bindings=new re([]),this._flags=s,""!=r&&(ce(r.indexOf(":")>=0,"Document URI not absolute: "+r),this._bindings[""]=r+"#"),this._store=e,i&&e.setGenPrefix(i),this._thisDoc=r,this.source=e.sym(r),this.lines=0,this.statementCount=0,this.hasNil=!1,this.startOfLine=0,this.previousLine=0,this._genPrefix=i,this.keywords=new te(["a","this","bind","has","is","of","true","false"]),this.keywordsSet=0,this._anonymousNodes=new re([]),this._variables=new re([]),this._parentVariables=new re([]),this._reason=a,this._reason2=null,this._baseURI=n||(r||null),ce(!this._baseURI||this._baseURI.indexOf(":")>=0),this._genPrefix||(this._thisDoc?this._genPrefix=this._thisDoc+"#_g":this._genPrefix=RDFSink_uniqueURI()),null==t?this._thisDoc?this._formula=e.formula(r+"#_formula"):this._formula=e.formula():this._formula=t,this._context=this._formula,this._parentContext=null}here(e){return this._genPrefix+"_L"+this.lines+"C"+(e-this.startOfLine+1)}formula(){return this._formula}loadStream(e){return this.loadBuf(e.read())}loadBuf(e){return this.startDoc(),this.feed(e),this.endDoc()}feed(e){for(var t=e.decode("utf-8"),r=0;r>=0;){var n=this.skipSpace(t,r);if(n<0)return;if((r=this.directiveOrStatement(t,n))<0)throw _e(this._thisDoc,this.lines,t,n,"expected directive or statement")}}directiveOrStatement(e,t){var r,n=this.skipSpace(e,t);return n<0?n:(r=this.directive(e,n))>=0||(r=this.statement(e,n))>=0?this.checkDot(e,r):r}tok(e,t,r){if("@"==t.slice(r,r+1))r=r+1;else if(M(this.keywords,e)<0)return-1;var n=r+ne(e);return t.slice(r,n)==e&&de.indexOf(t.charAt(n))>=0?n:-1}directive(e,t){if((o=this.skipSpace(e,t))<0)return o;var r=new te([]);if((o=this.tok("bind",e,t))>0)throw _e(this._thisDoc,this.lines,e,t,"keyword bind is obsolete: use @prefix");if((o=this.tok("keywords",e,t))>0){if((t=this.commaSeparatedList(e,o,r,!1))<0)throw _e(this._thisDoc,this.lines,e,t,"'@keywords' needs comma separated list of words");return this.setKeywords(ie(r,null,null)),t}if((o=this.tok("forAll",e,t))>0){if((t=this.commaSeparatedList(e,o,r,!0))<0)throw _e(this._thisDoc,this.lines,e,t,"Bad variable list after @forAll");var n=new se(r);try{for(;;){var i=n.next();(M(this._variables,i)<0||M(this._parentVariables,i)>=0)&&(this._variables[i]=this._context.newUniversal(i))}}catch(e){if(e!=oe)throw e}return t}if((o=this.tok("forSome",e,t))>0){if((t=this.commaSeparatedList(e,o,r,this.uri_ref2))<0)throw _e(this._thisDoc,this.lines,e,t,"Bad variable list after @forSome");n=new se(r);try{for(;;){i=n.next();this._context.declareExistential(i)}}catch(e){if(e!=oe)throw e}return t}if((o=this.tok("prefix",e,t))>=0){var o,s=new te([]);if((t=this.qname(e,o,s))<0)throw _e(this._thisDoc,this.lines,e,o,"expected qname after @prefix");if((o=this.uri_ref2(e,t,s))<0)throw _e(this._thisDoc,this.lines,e,t,"expected <uriref> after @prefix _qname_");var a=s[1].uri;if(this._baseURI)a=ue(this._baseURI,a);else ce(a.indexOf(":")>=0,"With no base URI, cannot handle relative URI for NS");return ce(a.indexOf(":")>=0),this._bindings[s[0][0]]=a,this.bind(s[0][0],function(e){return encodeURI(e)}(a)),o}if((o=this.tok("base",e,t))>=0){s=new te([]);if((t=this.uri_ref2(e,o,s))<0)throw _e(this._thisDoc,this.lines,e,o,"expected <uri> after @base ");a=s[0].uri;if(!this._baseURI)throw _e(this._thisDoc,this.lines,e,o,"With no previous base URI, cannot use relative URI in @base <"+a+">");a=ue(this._baseURI,a);return ce(a.indexOf(":")>=0),this._baseURI=a,t}return-1}bind(e,t){""==e||this._store.setPrefixForURI(e,t)}setKeywords(e){null==e?this.keywordsSet=0:(this.keywords=e,this.keywordsSet=1)}startDoc(){}endDoc(){return this.hasNil&&this._store.rdfFactory.supports.COLLECTIONS&&Y(this._store,this.source),this._formula}makeStatement(e){e[0].add(e[2],e[1],e[3],this.source),(e[2].uri&&e[2].uri===le||e[3].uri&&e[3].uri===le)&&(this.hasNil=!0),this.statementCount+=1}statement(e,t){var r=new te([]);if((t=this.object(e,t,r))<0)return t;var n=this.property_list(e,t,r[0]);if(n<0)throw _e(this._thisDoc,this.lines,e,t,"expected propertylist");return n}subject(e,t,r){return this.item(e,t,r)}verb(e,t,r){if((i=this.skipSpace(e,t))<0)return i;var n=new te([]);if((i=this.tok("has",e,t))>=0){if((t=this.prop(e,i,n))<0)throw _e(this._thisDoc,this.lines,e,i,"expected property after 'has'");return r.push(new ee(["->",n[0]])),t}if((i=this.tok("is",e,t))>=0){if((t=this.prop(e,i,n))<0)throw _e(this._thisDoc,this.lines,e,i,"expected <property> after 'is'");if((i=this.skipSpace(e,t))<0)throw _e(this._thisDoc,this.lines,e,t,"End of file found, expected property after 'is'");var i;t=i;if((i=this.tok("of",e,t))<0)throw _e(this._thisDoc,this.lines,e,t,"expected 'of' after 'is' <prop>");return r.push(new ee(["<-",n[0]])),i}if((i=this.tok("a",e,t))>=0)return r.push(new ee(["->",this._store.sym("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")])),i;if("<="==e.slice(t,t+2))return r.push(new ee(["<-",this._store.sym(Z+"implies")])),t+2;if("="==e.slice(t,t+1))return">"==e.slice(t+1,t+2)?(r.push(new ee(["->",this._store.sym(Z+"implies")])),t+2):(r.push(new ee(["->",this._store.sym(he)])),t+1);if(":="==e.slice(t,t+2))return r.push(new ee(["->",Z+"becomes"])),t+2;if((i=this.prop(e,t,n))>=0)return r.push(new ee(["->",n[0]])),i;if(">-"==e.slice(t,t+2)||"<-"==e.slice(t,t+2))throw _e(this._thisDoc,this.lines,e,i,">- ... -> syntax is obsolete.");return-1}prop(e,t,r){return this.item(e,t,r)}item(e,t,r){return this.path(e,t,r)}blankNode(e){return this._context.bnode(e,this._reason2)}path(e,t,r){if((o=this.nodeOrLiteral(e,t,r))<0)return o;for(;"!^.".indexOf(e.slice(o,o+1))>=0;){var n=e.slice(o,o+1);if("."==n){var i=e.slice(o+1,o+2);if(!i||fe.indexOf(i)>=0&&":?<[{(".indexOf(i)<0)break}var o,s=r.pop(),a=this.blankNode(this.here(o));if((o=this.node(e,o+1,r))<0)throw _e(this._thisDoc,this.lines,e,o,"EOF found in middle of path syntax");var c=r.pop();"^"==n?this.makeStatement(new ee([this._context,c,a,s])):this.makeStatement(new ee([this._context,c,s,a])),r.push(a)}return o}anonymousNode(e){if(t=this._anonymousNodes[e])return t;var t=this._store.bnode(e);return this._anonymousNodes[e]=t,t}node(e,t,r,n){void 0===n&&(n=null);var i=n;if((l=this.skipSpace(e,t))<0)return l;t=l;var o=e.slice(t,t+1);if("["==o){var s=this.here(t);if((l=this.skipSpace(e,t+1))<0)throw _e(this._thisDoc,this.lines,e,t,"EOF after '['");if("="==e.slice(l,l+1)){var t=l+1,a=new te([]);if(!((l=this.objectList(e,t,a))>=0))throw _e(this._thisDoc,this.lines,e,t,"objectList expected after [= ");i=a[0];if(ne(a)>1){var c=new se(a);try{for(;;){var u=c.next();this.makeStatement(new ee([this._context,this._store.sym(he),i,u]))}}catch(e){if(e!=oe)throw e}}if((l=this.skipSpace(e,l))<0)throw _e(this._thisDoc,this.lines,e,t,"EOF when objectList expected after [ = ");if(";"==e.slice(l,l+1))var l=l+1}if(null==i)i=this.blankNode(s);if((t=this.property_list(e,l,i))<0)throw _e(this._thisDoc,this.lines,e,l,"property_list expected");if((l=this.skipSpace(e,t))<0)throw _e(this._thisDoc,this.lines,e,t,"EOF when ']' expected after [ <propertyList>");if("]"!=e.slice(l,l+1))throw _e(this._thisDoc,this.lines,e,l,"']' expected");return r.push(i),l+1}if("{"==o){if("$"==e.slice(t+1,t+2)){for(var l=(t+=1)+1,h=new te([]),d=!0;;){if((t=this.skipSpace(e,l))<0)throw _e(this._thisDoc,this.lines,e,t,"needed '$}', found end.");if("$}"==e.slice(t,t+2)){var l=t+2;break}if(d)d=!1;else{if(","!=e.slice(t,t+1))throw _e(this._thisDoc,this.lines,e,t,"expected: ','");t+=1}var f=new te([]);if((l=this.item(e,t,f))<0)throw _e(this._thisDoc,this.lines,e,t,"expected item in set or '$}'");h.push(f[0])}return r.push(this._store.newSet(h,this._context)),l}var l=t+1,p=this._parentContext;this._parentContext=this._context;var g=this._anonymousNodes,y=this._parentVariables;this._parentVariables=this._variables,this._anonymousNodes=new re([]),this._variables=this._variables.slice();var m=this._reason2;if(this._reason2=null,null==i)i=this._store.formula();for(this._context=i;;){if((t=this.skipSpace(e,l))<0)throw _e(this._thisDoc,this.lines,e,t,"needed '}', found end.");if("}"==e.slice(t,t+1)){var l=t+1;break}if((l=this.directiveOrStatement(e,t))<0)throw _e(this._thisDoc,this.lines,e,t,"expected statement or '}'")}return this._anonymousNodes=g,this._variables=this._parentVariables,this._parentVariables=y,this._context=this._parentContext,this._reason2=m,this._parentContext=p,r.push(i.close()),l}if("("==o){var v=this._store.list;if("$"==e.slice(t+1,t+2)){v=this._store.newSet;t+=1}for(l=t+1,h=new te([]);;){if((t=this.skipSpace(e,l))<0)throw _e(this._thisDoc,this.lines,e,t,"needed ')', found end.");if(")"==e.slice(t,t+1)){l=t+1;break}f=new te([]);if((l=this.item(e,t,f))<0)throw _e(this._thisDoc,this.lines,e,t,"expected item in list or ')'");h.push(f[0])}return r.push(v(h,this._context)),l}if((l=this.tok("this",e,t))>=0)throw _e(this._thisDoc,this.lines,e,t,"Keyword 'this' was ancient N3. Now use @forSome and @forAll keywords.");if((l=this.tok("true",e,t))>=0)return r.push(!0),l;if((l=this.tok("false",e,t))>=0)return r.push(!1),l;if(null==i&&(l=this.uri_ref2(e,t,r))>=0)return l;return-1}property_list(e,t,r){for(;;){if((l=this.skipSpace(e,t))<0)throw _e(this._thisDoc,this.lines,e,t,"EOF found when expected verb in property list");if(":-"!=e.slice(l,l+2)){t=l;var n=new te([]);if((l=this.verb(e,t,n))<=0)return t;var i=new te([]);if((t=this.objectList(e,l,i))<0)throw _e(this._thisDoc,this.lines,e,l,"objectList expected");var o=new se(i);try{for(;;){var s=o.next(),a=n[0],c=a[0],u=a[1];"->"==c?this.makeStatement(new ee([this._context,u,r,s])):this.makeStatement(new ee([this._context,u,s,r]))}}catch(e){if(e!=oe)throw e}if((l=this.skipSpace(e,t))<0)throw _e(this._thisDoc,this.lines,e,l,"EOF found in list of objects");if(";"!=e.slice(t,t+1))return t;t=t+1}else{var l,t=l+2,h=new te([]);if((l=this.node(e,t,h,r))<0)throw _e(this._thisDoc,this.lines,e,t,"bad {} or () or [] node after :- ");var t=l}}}commaSeparatedList(e,t,r,n){if((i=this.skipSpace(e,t))<0)throw _e(this._thisDoc,this.lines,e,i,"EOF found expecting comma sep list");if("."==e.charAt(i))return t;if(n)var i=this.uri_ref2(e,i,r);else i=this.bareWord(e,i,r);if(i<0)return-1;for(;;){if((t=this.skipSpace(e,i))<0)return t;var o=e.slice(t,t+1);if(","!=o)return"."!=o?-1:t;if(n)i=this.uri_ref2(e,t+1,r);else i=this.bareWord(e,t+1,r);if(i<0)throw _e(this._thisDoc,this.lines,e,i,"bad list content")}}objectList(e,t,r){if((t=this.object(e,t,r))<0)return-1;for(;;){var n=this.skipSpace(e,t);if(n<0)throw _e(this._thisDoc,this.lines,e,n,"EOF found after object");if(","!=e.slice(n,n+1))return n;if((t=this.object(e,n+1,r))<0)return t}}checkDot(e,t){var r=this.skipSpace(e,t);if(r<0)return r;if("."==e.slice(r,r+1))return r+1;if("}"==e.slice(r,r+1))return r;if("]"==e.slice(r,r+1))return r;throw _e(this._thisDoc,this.lines,e,r,"expected '.' or '}' or ']' at end of statement")}uri_ref2(e,t,r){var n=new te([]);if((d=this.qname(e,t,n))>=0){var i=n[0],o=i[0],s=i[1];if(null==o){ce(0,"not used?");var a=this._baseURI+"#"}else{if(!(a=this._bindings[o])){if("_"==o)return r.push(this.anonymousNode(s)),d;throw _e(this._thisDoc,this.lines,e,t,"Prefix "+o+" not bound.")}}var c=this._store.sym(a+s);return M(this._variables,c)>=0?r.push(this._variables[c]):r.push(c),d}if((t=this.skipSpace(e,t))<0)return-1;if("?"==e.charAt(t)){var u=new te([]);return(d=this.variable(e,t,u))>0?(r.push(u[0]),d):-1}if("<"==e.charAt(t)){for(var l=t=t+1;t<ne(e);){if(">"==e.charAt(t)){var h=e.slice(l,t);if(this._baseURI)h=ue(this._baseURI,h);else ce(h.indexOf(":")>=0,"With no base URI, cannot deal with relative URIs");if("#"==e.slice(t-1,t)&&"#"!=ie(h,-1,null))h=h+"#";c=this._store.sym(h);return M(this._variables,c)>=0?r.push(this._variables[c]):r.push(c),t+1}t=t+1}throw _e(this._thisDoc,this.lines,e,d,"unterminated URI reference")}if(this.keywordsSet){var d;u=new te([]);if((d=this.bareWord(e,t,u))<0)return-1;if(M(this.keywords,u[0])>=0)throw _e(this._thisDoc,this.lines,e,t,'Keyword "'+u[0]+'" not allowed here.');return r.push(this._store.sym(this._bindings[""]+u[0])),d}return-1}skipSpace(e,t){for(var r=t||0;r<e.length;r++){var n=e.charAt(r);if(" \n\r\t\f\v \u2028\u2029 ".indexOf(n)<0){if("#"!==e.charAt(r))return r;for(;;r++){if(r===e.length)return-1;if("\n"===e.charAt(r)){this.lines=this.lines+1;break}}}else"\n"===e.charAt(r)&&(this.lines=this.lines+1)}return-1}variable(e,t,r){if((n=this.skipSpace(e,t))<0)return-1;if("?"!=e.slice(n,n+1))return-1;var n;t=n+=1;if("0123456789-".indexOf(e.charAt(n))>=0)throw _e(this._thisDoc,this.lines,e,n,"Varible name can't start with '"+e.charAt(n)+"s'");for(;t<ne(e)&&fe.indexOf(e.charAt(t))<0;)t=t+1;if(null==this._parentContext)throw _e(this._thisDoc,this.lines,e,n,"Can't use ?xxx syntax for variable in outermost level: "+e.slice(n-1,t));return r.push(this._store.variable(e.slice(n,t))),t}bareWord(e,t,r){var n=this.skipSpace(e,t);if(n<0)return-1;var i=e.charAt(n);if("0123456789-".indexOf(i)>=0)return-1;if(fe.indexOf(i)>=0)return-1;for(t=n;t<ne(e)&&fe.indexOf(e.charAt(t))<0;)t=t+1;return r.push(e.slice(n,t)),t}qname(e,t,r){if((t=this.skipSpace(e,t))<0)return-1;var n=e.charAt(t);if("0123456789-+".indexOf(n)>=0)return-1;if(fe.indexOf(n)<0){var i=n;for(t=t+1;t<ne(e);){n=e.charAt(t);if(!(fe.indexOf(n)<0))break;i=i+n,t=t+1}}else i="";if(t<ne(e)&&":"==e.charAt(t)){var o=i;for(t=t+1,i="";t<ne(e);){n=e.charAt(t);if(!(fe.indexOf(n)<0))break;i=i+n,t=t+1}return r.push(new ee([o,i])),t}return i&&this.keywordsSet&&M(this.keywords,i)<0?(r.push(new ee(["",i])),t):-1}object(e,t,r){if((o=this.subject(e,t,r))>=0)return o;{if((o=this.skipSpace(e,t))<0)return-1;t=o;var n=null;let a=e.charAt(t);if('"'==a||"'"==a){n=e.slice(t,t+3==a+a)?a+a+a:a;t=t+ne(n);var i=this.strconst(e,t,n),o=i[0],s=i[1];return r.push(this._store.literal(s)),o}return-1}}nodeOrLiteral(e,t,r){if((c=this.node(e,t,r))>=0)return c;if((c=this.skipSpace(e,t))<0)return-1;t=c;var n=e.charAt(t);if("-+0987654321".indexOf(n)>=0){if(ge.lastIndex=0,null!=(h=ge.exec(e.slice(t)))){c=t+(i=h[0]).length,i.indexOf("T")>=0?r.push(this._store.literal(i,this._store.sym("http://www.w3.org/2001/XMLSchema#dateTime"))):r.push(this._store.literal(i,this._store.sym("http://www.w3.org/2001/XMLSchema#date")))}else{var i;if(pe.lastIndex=0,null==(h=pe.exec(e.slice(t))))throw _e(this._thisDoc,this.lines,e,t,"Bad number or date syntax");c=t+pe.lastIndex,(i=e.slice(t,c)).indexOf("e")>=0?r.push(this._store.literal(parseFloat(i),this._store.sym("http://www.w3.org/2001/XMLSchema#double"))):e.slice(t,c).indexOf(".")>=0?r.push(this._store.literal(parseFloat(i),this._store.sym("http://www.w3.org/2001/XMLSchema#decimal"))):r.push(this._store.literal(parseInt(i),this._store.sym("http://www.w3.org/2001/XMLSchema#integer")))}return c}if('"'==e.charAt(t)){if('"""'==e.slice(t,t+3))var o='"""';else o='"';t=t+ne(o);var s=null,a=this.strconst(e,t,o),c=a[0],u=a[1],l=null;if("@"==e.slice(c,c+1)){var h;if(me.lastIndex=0,null==(h=me.exec(e.slice(c+1))))throw _e(this._thisDoc,startline,e,t,"Bad language code syntax on string literal, after @");t=me.lastIndex+c+1,l=e.slice(c+1,t),c=t}if("^^"==e.slice(c,c+2)){var d=new te([]);c=this.uri_ref2(e,c+2,d),s=d[0]}return r.push(this._store.literal(u,l||s)),c}return-1}strconst(e,t,r){for(var n=t,i="",o=this.lines;n<ne(e);){t=n+ne(r);if(e.slice(n,t)==r)return new ee([t,i]);if('"'!=e.charAt(n)){if(ye.lastIndex=0,!ye.exec(e.slice(n)))throw _e(this._thisDoc,o,e,n,"Closing quote missing in string at ^ in "+e.slice(n-20,n)+"^"+e.slice(n,n+20));t=n+ye.lastIndex-1,i=i+e.slice(n,t);if('"'!=(c=e.charAt(t)))if("\r"!=c){if("\n"==c){if('"'==r)throw _e(this._thisDoc,o,e,t,"newline found in string literal");this.lines=this.lines+1;i=i+c,n=t+1;this.previousLine=this.startOfLine,this.startOfLine=n}else if("\\"==c){n=t+1;if(!(c=e.slice(n,n+1)))throw _e(this._thisDoc,o,e,t,"unterminated string literal (2)");var s=ae('abfrtvn\\"',c);if(s>=0)i=i+'a\b\f\r\t\v\n\\"'.charAt(s),n=n+1;else if("u"==c)n=(a=this.uEscape(e,n+1,o))[0],i=i+(c=a[1]);else{if("U"!=c)throw _e(this._thisDoc,this.lines,e,t,"bad escape");var a,c;n=(a=this.UEscape(e,n+1,o))[0],i=i+(c=a[1])}}}else var n=t+1;else var n=t}else var i=i+'"',n=n+1}throw _e(this._thisDoc,this.lines,e,t,"unterminated string literal")}uEscape(e,t,r){for(var n=t,i=0,o=0;i<4;){var s=e.slice(n,n+1).toLowerCase();n=n+1;if(""==s)throw _e(this._thisDoc,r,e,t,"unterminated string literal(3)");var a=ae("0123456789abcdef",s);if(a<0)throw _e(this._thisDoc,r,e,t,"bad string literal hex escape");o=16*o+a,i=i+1}var c=String.fromCharCode(o);return new ee([n,c])}UEscape(e,t,r){for(var n=t,i=0,o="\\U";i<8;){var s=e.slice(n,n+1).toLowerCase();n=n+1;if(""==s)throw _e(this._thisDoc,r,e,t,"unterminated string literal(3)");if(ae("0123456789abcdef",s)<0)throw _e(this._thisDoc,r,e,t,"bad string literal hex escape");o=o+s,i=i+1}var a,c=(a="0x"+ie(o,2,10)-0,String.fromCharCode(a));return new ee([n,c])}}function be(e,t,r,n,i){this._str=r.encode("utf-8"),this._str=r,this._i=n,this._why=i,this.lines=t,this._uri=e}function _e(e,t,r,n,i){let o=t+1,s="Line "+o+" of <"+e+">: Bad syntax: "+i+'\nat: "'+r.slice(n,n+30)+'"',a=new SyntaxError(s,e,o);return a.lineNo=o,a.characterInFile=n,a.syntaxProblem=i,a}be.prototype.toString=function(){var e=this._str,t=this._i,r=0;if(t>60){var n="...";r=t-60}else n="";if(ne(e)-t>60)var i="...";else i="";return'Line %i of <%s>: Bad syntax (%s) at ^ in:\n"%s%s^%s%s"'%new ee([this.lines+1,this._uri,this._why,n,e.slice(r,t),e.slice(t,t+60),i])};const Se={...x,supports:{[S.collections]:!0,[S.defaultGraphType]:!1,[S.equalsMethod]:!0,[S.identity]:!1,[S.id]:!0,[S.reversibleId]:!1,[S.variableType]:!0},collection:e=>new f(e),id(e){return(0,u.P3)(e)?`( ${e.elements.map(e=>this.id(e)).join(", ")} )`:(0,u.DZ)(e)?_.toString(e):x.id(e)},termToNQ:e=>e.termType===s.r0?f.toNT(e):x.termToNQ(e)},Ee=Se;function Ae(e,t){return"string"==typeof t?e.rdfFactory.literal(t):Object.prototype.hasOwnProperty.call(t,"@list")?!0===e.rdfFactory.supports.COLLECTIONS?function(e,t){if(!Array.isArray(t))throw new TypeError("Object must be an array");return e.rdfFactory.collection(t.map(t=>Ae(e,t)))}(e,t["@list"]):function(e,t){const r=t["@id"]?Te(e,t):e.rdfFactory.blankNode(),n=t["@list"].map(t=>Ae(e,t)),i=j(e.rdfFactory,r,n);return e.addAll(i),r}(e,t):Object.prototype.hasOwnProperty.call(t,"@id")?Te(e,t):Object.prototype.hasOwnProperty.call(t,"@language")?e.rdfFactory.literal(t["@value"],t["@language"]):Object.prototype.hasOwnProperty.call(t,"@type")?e.rdfFactory.literal(t["@value"],e.rdfFactory.namedNode(t["@type"])):Object.prototype.hasOwnProperty.call(t,"@value")?e.rdfFactory.literal(t["@value"]):e.rdfFactory.literal(t)}async function xe(e,t,n){const i=n&&Object.prototype.hasOwnProperty.call(n,"termType")?n.value:n,o=await Promise.all([r.e(841),r.e(789)]).then(r.t.bind(r,4841,23));return(await o.default.flatten(JSON.parse(e),null,{base:i})).reduce((e,t)=>Fe(e,n,t),t)}function Te(e,t){return t["@id"].startsWith("_:")?e.rdfFactory.blankNode(t["@id"].substring(2)):e.rdfFactory.namedNode(t["@id"])}function Fe(e,t,r){const n=r["@id"]?Te(e,r):e.rdfFactory.blankNode();for(const i of Object.keys(r)){if("@id"===i)continue;if("@graph"==i){const t=n,o=r[i];for(let r=0;r<o.length;r++)e=Fe(e,t,o[r])}const o=r[i];if(Array.isArray(o))for(let r=0;r<o.length;r++)e.addStatement(ke(e,n,i,o[r],t));else e.addStatement(ke(e,n,i,o,t))}return e}function ke(e,t,r,n,i){let o,s;return"@type"===r?(o=e.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),s=e.rdfFactory.namedNode(n)):(o=e.rdfFactory.namedNode(r),s=Ae(e,n)),e.rdfFactory.quad(t,o,s,e.rdfFactory.namedNode(i))}var Ie=r(8287);const Ce="http://www.w3.org/1999/02/22-rdf-syntax-ns#",Ne="http://www.w3.org/2001/XMLSchema#",Re="http://www.w3.org/2000/10/swap/",Pe={xsd:{decimal:`${Ne}decimal`,boolean:`${Ne}boolean`,double:`${Ne}double`,integer:`${Ne}integer`,string:`${Ne}string`},rdf:{type:`${Ce}type`,nil:`${Ce}nil`,first:`${Ce}first`,rest:`${Ce}rest`,langString:`${Ce}langString`},owl:{sameAs:"http://www.w3.org/2002/07/owl#sameAs"},r:{forSome:`${Re}reify#forSome`,forAll:`${Re}reify#forAll`},log:{implies:`${Re}log#implies`,isImpliedBy:`${Re}log#isImpliedBy`}},{xsd:Oe}=Pe,De=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\([^])/g,Ue={"\\":"\\","'":"'",'"':'"',n:"\n",r:"\r",t:"\t",f:"\f",b:"\b",_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},Le=/[\x00-\x20<>\\"\{\}\|\^\`]/,je={_iri:!0,_unescapedIri:!0,_simpleQuotedString:!0,_langcode:!0,_blank:!0,_newline:!0,_comment:!0,_whitespace:!0,_endOfFile:!0},Me=/$0^/;class He{constructor(e){if(this._iri=/^<((?:[^ <>{}\\]|\\[uU])+)>[ \t]*/,this._unescapedIri=/^<([^\x00-\x20<>\\"\{\}\|\^\`]*)>[ \t]*/,this._simpleQuotedString=/^"([^"\\\r\n]*)"(?=[^"])/,this._simpleApostropheString=/^'([^'\\\r\n]*)'(?=[^'])/,this._langcode=/^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9\-])/i,this._prefix=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:(?=[#\s<])/,this._prefixed=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:((?:(?:[0-:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])(?:(?:[\.\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])*(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~]))?)?)(?:[ \t]+|(?=\.?[,;!\^\s#()\[\]\{\}"'<>]))/,this._variable=/^\?(?:(?:[A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?=[.,;!\^\s#()\[\]\{\}"'<>])/,this._blank=/^_:((?:[0-9A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?:[ \t]+|(?=\.?[,;:\s#()\[\]\{\}"'<>]))/,this._number=/^[\-+]?(?:(\d+\.\d*|\.?\d+)[eE][\-+]?|\d*(\.)?)\d+(?=\.?[,;:\s#()\[\]\{\}"'<>])/,this._boolean=/^(?:true|false)(?=[.,;\s#()\[\]\{\}"'<>])/,this._keyword=/^@[a-z]+(?=[\s#<:])/i,this._sparqlKeyword=/^(?:PREFIX|BASE|GRAPH)(?=[\s#<])/i,this._shortPredicates=/^a(?=[\s#()\[\]\{\}"'<>])/,this._newline=/^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/,this._comment=/#([^\n\r]*)/,this._whitespace=/^[ \t]+/,this._endOfFile=/^(?:#[^\n\r]*)?$/,e=e||{},this._isImpliedBy=e.isImpliedBy,this._lineMode=!!e.lineMode){this._n3Mode=!1;for(const e in this)!(e in je)&&this[e]instanceof RegExp&&(this[e]=Me)}else this._n3Mode=!1!==e.n3;this.comments=!!e.comments,this._literalClosingPos=0}_tokenizeToEnd(e,t){let r=this._input,n=r.length;for(;;){let e,s;for(;e=this._newline.exec(r);)this.comments&&(s=this._comment.exec(e[0]))&&i("comment",s[1],"",this._line,e[0].length),r=r.substr(e[0].length,r.length),n=r.length,this._line++;if(!e&&(e=this._whitespace.exec(r))&&(r=r.substr(e[0].length,r.length)),this._endOfFile.test(r))return t&&(this.comments&&(s=this._comment.exec(r))&&i("comment",s[1],"",this._line,r.length),r=null,i("eof","","",this._line,0)),this._input=r;const a=this._line,c=r[0];let u="",l="",h="",d=null,f=0,p=!1;switch(c){case"^":if(r.length<3)break;if("^"!==r[1]){this._n3Mode&&(f=1,u="^");break}if(this._previousMarker="^^",r=r.substr(2),"<"!==r[0]){p=!0;break}case"<":if(d=this._unescapedIri.exec(r))u="IRI",l=d[1];else if(d=this._iri.exec(r)){if(l=this._unescape(d[1]),null===l||Le.test(l))return o(this);u="IRI"}else r.length>1&&"<"===r[1]?(u="<<",f=2):this._n3Mode&&r.length>1&&"="===r[1]&&(f=2,this._isImpliedBy?(u="abbreviation",l="<"):(u="inverse",l=">"));break;case">":r.length>1&&">"===r[1]&&(u=">>",f=2);break;case"_":((d=this._blank.exec(r))||t&&(d=this._blank.exec(`${r} `)))&&(u="blank",h="_",l=d[1]);break;case'"':if(d=this._simpleQuotedString.exec(r))l=d[1];else if(({value:l,matchLength:f}=this._parseLiteral(r)),null===l)return o(this);null===d&&0===f||(u="literal",this._literalClosingPos=0);break;case"'":if(!this._lineMode){if(d=this._simpleApostropheString.exec(r))l=d[1];else if(({value:l,matchLength:f}=this._parseLiteral(r)),null===l)return o(this);null===d&&0===f||(u="literal",this._literalClosingPos=0)}break;case"?":this._n3Mode&&(d=this._variable.exec(r))&&(u="var",l=d[0]);break;case"@":"literal"===this._previousMarker&&(d=this._langcode.exec(r))?(u="langcode",l=d[1]):(d=this._keyword.exec(r))&&(u=d[0]);break;case".":if(1===r.length?t:r[1]<"0"||r[1]>"9"){u=".",f=1;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":(d=this._number.exec(r)||t&&(d=this._number.exec(`${r} `)))&&(u="literal",l=d[0],h="string"==typeof d[1]?Oe.double:"string"==typeof d[2]?Oe.decimal:Oe.integer);break;case"B":case"b":case"p":case"P":case"G":case"g":(d=this._sparqlKeyword.exec(r))?u=d[0].toUpperCase():p=!0;break;case"f":case"t":(d=this._boolean.exec(r))?(u="literal",l=d[0],h=Oe.boolean):p=!0;break;case"a":(d=this._shortPredicates.exec(r))?(u="abbreviation",l="a"):p=!0;break;case"=":this._n3Mode&&r.length>1&&(u="abbreviation",">"!==r[1]?(f=1,l="="):(f=2,l=">"));break;case"!":if(!this._n3Mode)break;case",":case";":case"[":case"]":case"(":case")":case"}":this._lineMode||(f=1,u=c);break;case"{":!this._lineMode&&r.length>=2&&("|"===r[1]?(u="{|",f=2):(u=c,f=1));break;case"|":r.length>=2&&"}"===r[1]&&(u="|}",f=2);break;default:p=!0}if(p&&("@prefix"!==this._previousMarker&&"PREFIX"!==this._previousMarker||!(d=this._prefix.exec(r))?((d=this._prefixed.exec(r))||t&&(d=this._prefixed.exec(`${r} `)))&&(u="prefixed",h=d[1]||"",l=this._unescape(d[2])):(u="prefix",l=d[1]||"")),"^^"===this._previousMarker)switch(u){case"prefixed":u="type";break;case"IRI":u="typeIRI";break;default:u=""}if(!u)return t||!/^'''|^"""/.test(r)&&/\n|\r/.test(r)?o(this):this._input=r;const g=f||d[0].length,y=i(u,l,h,a,g);this.previousToken=y,this._previousMarker=u,r=r.substr(g,r.length)}function i(t,i,o,s,a){const c=r?n-r.length:n,u={type:t,value:i,prefix:o,line:s,start:c,end:c+a};return e(null,u),u}function o(t){e(t._syntaxError(/^\S*/.exec(r)[0]))}}_unescape(e){let t=!1;const r=e.replace(De,(e,r,n,i)=>{if("string"==typeof r)return String.fromCharCode(Number.parseInt(r,16));if("string"==typeof n){let e=Number.parseInt(n,16);return e<=65535?String.fromCharCode(Number.parseInt(n,16)):String.fromCharCode(55296+((e-=65536)>>10),56320+(1023&e))}return i in Ue?Ue[i]:(t=!0,"")});return t?null:r}_parseLiteral(e){if(e.length>=3){const t=e.match(/^(?:"""|"|'''|'|)/)[0],r=t.length;let n=Math.max(this._literalClosingPos,r);for(;(n=e.indexOf(t,n))>0;){let t=0;for(;"\\"===e[n-t-1];)t++;if(t%2==0){const t=e.substring(r,n),i=t.split(/\r\n|\r|\n/).length-1,o=n+r;if(1===r&&0!==i||3===r&&this._lineMode)break;return this._line+=i,{value:this._unescape(t),matchLength:o}}n++}this._literalClosingPos=e.length-r+1}return{value:"",matchLength:0}}_syntaxError(e){this._input=null;const t=new Error(`Unexpected "${e}" on line ${this._line}.`);return t.context={token:void 0,line:this._line,previousToken:this.previousToken},t}_readStartingBom(e){return e.startsWith("\ufeff")?e.substr(1):e}tokenize(e,t){if(this._line=1,"string"==typeof e){if(this._input=this._readStartingBom(e),"function"!=typeof t){const e=[];let t;if(this._tokenizeToEnd((r,n)=>r?t=r:e.push(n),!0),t)throw t;return e}queueMicrotask(()=>this._tokenizeToEnd(t,!0))}else this._pendingBuffer=null,"function"==typeof e.setEncoding&&e.setEncoding("utf8"),e.on("data",e=>{null!==this._input&&0!==e.length&&(this._pendingBuffer&&(e=Ie.hp.concat([this._pendingBuffer,e]),this._pendingBuffer=null),128&e[e.length-1]?this._pendingBuffer=e:(void 0===this._input?this._input=this._readStartingBom("string"==typeof e?e:e.toString()):this._input+=e,this._tokenizeToEnd(t,!1)))}),e.on("end",()=>{"string"==typeof this._input&&this._tokenizeToEnd(t,!0)}),e.on("error",t)}}const{rdf:Be,xsd:qe}=Pe;let Ke,We=0;const Je={namedNode:Ze,blankNode:et,variable:rt,literal:tt,defaultGraph:function(){return Ke},quad:nt,triple:nt,fromTerm:it,fromQuad:ot},Ve=Je;class $e{constructor(e){this.id=e}get value(){return this.id}equals(e){return e instanceof $e?this.id===e.id:!!e&&this.termType===e.termType&&this.value===e.value}hashCode(){return 0}toJSON(){return{termType:this.termType,value:this.value}}}class ze extends $e{get termType(){return"NamedNode"}}class Ge extends $e{get termType(){return"Literal"}get value(){return this.id.substring(1,this.id.lastIndexOf('"'))}get language(){const e=this.id;let t=e.lastIndexOf('"')+1;return t<e.length&&"@"===e[t++]?e.substr(t).toLowerCase():""}get datatype(){return new ze(this.datatypeString)}get datatypeString(){const e=this.id,t=e.lastIndexOf('"')+1,r=t<e.length?e[t]:"";return"^"===r?e.substr(t+2):"@"!==r?qe.string:Be.langString}equals(e){return e instanceof Ge?this.id===e.id:!!e&&!!e.datatype&&this.termType===e.termType&&this.value===e.value&&this.language===e.language&&this.datatype.value===e.datatype.value}toJSON(){return{termType:this.termType,value:this.value,language:this.language,datatype:{termType:"NamedNode",value:this.datatypeString}}}}class Xe extends $e{constructor(e){super(`_:${e}`)}get termType(){return"BlankNode"}get value(){return this.id.substr(2)}}class Ye extends $e{constructor(e){super(`?${e}`)}get termType(){return"Variable"}get value(){return this.id.substr(1)}}Ke=new class extends $e{constructor(){return super(""),Ke||this}get termType(){return"DefaultGraph"}equals(e){return this===e||!!e&&this.termType===e.termType}};class Qe extends $e{constructor(e,t,r,n){super(""),this._subject=e,this._predicate=t,this._object=r,this._graph=n||Ke}get termType(){return"Quad"}get subject(){return this._subject}get predicate(){return this._predicate}get object(){return this._object}get graph(){return this._graph}toJSON(){return{termType:this.termType,subject:this._subject.toJSON(),predicate:this._predicate.toJSON(),object:this._object.toJSON(),graph:this._graph.toJSON()}}equals(e){return!!e&&this._subject.equals(e.subject)&&this._predicate.equals(e.predicate)&&this._object.equals(e.object)&&this._graph.equals(e.graph)}}function Ze(e){return new ze(e)}function et(e){return new Xe(e||"n3-"+We++)}function tt(e,t){if("string"==typeof t)return new Ge(`"${e}"@${t.toLowerCase()}`);let r=t?t.value:"";return""===r&&("boolean"==typeof e?r=qe.boolean:"number"==typeof e&&(Number.isFinite(e)?r=Number.isInteger(e)?qe.integer:qe.double:(r=qe.double,Number.isNaN(e)||(e=e>0?"INF":"-INF")))),""===r||r===qe.string?new Ge(`"${e}"`):new Ge(`"${e}"^^${r}`)}function rt(e){return new Ye(e)}function nt(e,t,r,n){return new Qe(e,t,r,n)}function it(e){if(e instanceof $e)return e;switch(e.termType){case"NamedNode":return Ze(e.value);case"BlankNode":return et(e.value);case"Variable":return rt(e.value);case"DefaultGraph":return Ke;case"Literal":return tt(e.value,e.language||e.datatype);case"Quad":return ot(e);default:throw new Error(`Unexpected termType: ${e.termType}`)}}function ot(e){if(e instanceof Qe)return e;if("Quad"!==e.termType)throw new Error(`Unexpected termType: ${e.termType}`);return nt(it(e.subject),it(e.predicate),it(e.object),it(e.graph))}let st=0;class at{constructor(e){this._contextStack=[],this._graph=null,e=e||{},this._setBase(e.baseIRI),e.factory&&ut(this,e.factory);const t="string"==typeof e.format?e.format.match(/\w*$/)[0].toLowerCase():"",r=/turtle/.test(t),n=/trig/.test(t),i=/triple/.test(t),o=/quad/.test(t),s=this._n3Mode=/n3/.test(t),a=i||o;(this._supportsNamedGraphs=!(r||s))||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(r||n||i||s),this._isImpliedBy=e.isImpliedBy,this._supportsRDFStar=""===t||/star|\*$/.test(t),a&&(this._resolveRelativeIRI=e=>null),this._blankNodePrefix="string"!=typeof e.blankNodePrefix?"":e.blankNodePrefix.replace(/^(?!_:)/,"_:"),this._lexer=e.lexer||new He({lineMode:a,n3:s,isImpliedBy:this._isImpliedBy}),this._explicitQuantifiers=!!e.explicitQuantifiers}static _resetBlankNodePrefix(){st=0}_setBase(e){if(e){const t=e.indexOf("#");t>=0&&(e=e.substr(0,t)),this._base=e,this._basePath=e.indexOf("/")<0?e:e.replace(/[^\/?]*(?:\?.*)?$/,""),e=e.match(/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i),this._baseRoot=e[0],this._baseScheme=e[1]}else this._base="",this._basePath=""}_saveContext(e,t,r,n,i){const o=this._n3Mode;this._contextStack.push({type:e,subject:r,predicate:n,object:i,graph:t,inverse:!!o&&this._inversePredicate,blankPrefix:o?this._prefixes._:"",quantified:o?this._quantified:null}),o&&(this._inversePredicate=!1,this._prefixes._=this._graph?`${this._graph.value}.`:".",this._quantified=Object.create(this._quantified))}_restoreContext(e,t){const r=this._contextStack.pop();if(!r||r.type!==e)return this._error(`Unexpected ${t.type}`,t);this._subject=r.subject,this._predicate=r.predicate,this._object=r.object,this._graph=r.graph,this._n3Mode&&(this._inversePredicate=r.inverse,this._prefixes._=r.blankPrefix,this._quantified=r.quantified)}_readInTopContext(e){switch(e.type){case"eof":return null!==this._graph?this._error("Unclosed graph",e):(delete this._prefixes._,this._callback(null,null,this._prefixes));case"PREFIX":this._sparqlStyle=!0;case"@prefix":return this._readPrefix;case"BASE":this._sparqlStyle=!0;case"@base":return this._readBaseIRI;case"{":if(this._supportsNamedGraphs)return this._graph="",this._subject=null,this._readSubject;case"GRAPH":if(this._supportsNamedGraphs)return this._readNamedGraphLabel;default:return this._readSubject(e)}}_readEntity(e,t){let r;switch(e.type){case"IRI":case"typeIRI":const t=this._resolveIRI(e.value);if(null===t)return this._error("Invalid IRI",e);r=this._factory.namedNode(t);break;case"type":case"prefixed":const n=this._prefixes[e.prefix];if(void 0===n)return this._error(`Undefined prefix "${e.prefix}:"`,e);r=this._factory.namedNode(n+e.value);break;case"blank":r=this._factory.blankNode(this._prefixes[e.prefix]+e.value);break;case"var":r=this._factory.variable(e.value.substr(1));break;default:return this._error(`Expected entity but got ${e.type}`,e)}return!t&&this._n3Mode&&r.id in this._quantified&&(r=this._quantified[r.id]),r}_readSubject(e){switch(this._predicate=null,e.type){case"[":return this._saveContext("blank",this._graph,this._subject=this._factory.blankNode(),null,null),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this.RDF_NIL,null,null),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._graph=this._factory.blankNode(),null,null),this._readSubject):this._error("Unexpected graph",e);case"}":return this._readPunctuation(e);case"@forSome":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORSOME,this._quantifier="blankNode",this._readQuantifierList):this._error('Unexpected "@forSome"',e);case"@forAll":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORALL,this._quantifier="variable",this._readQuantifierList):this._error('Unexpected "@forAll"',e);case"literal":if(!this._n3Mode)return this._error("Unexpected literal",e);if(0===e.prefix.length)return this._literalValue=e.value,this._completeSubjectLiteral;this._subject=this._factory.literal(e.value,this._factory.namedNode(e.prefix));break;case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,null,null,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",e);default:if(void 0===(this._subject=this._readEntity(e)))return;if(this._n3Mode)return this._getPathReader(this._readPredicateOrNamedGraph)}return this._readPredicateOrNamedGraph}_readPredicate(e){const t=e.type;switch(t){case"inverse":this._inversePredicate=!0;case"abbreviation":this._predicate=this.ABBREVIATIONS[e.value];break;case".":case"]":case"}":return null===this._predicate?this._error(`Unexpected ${t}`,e):(this._subject=null,"]"===t?this._readBlankNodeTail(e):this._readPunctuation(e));case";":return null!==this._predicate?this._readPredicate:this._error("Expected predicate but got ;",e);case"[":if(this._n3Mode)return this._saveContext("blank",this._graph,this._subject,this._subject=this._factory.blankNode(),null),this._readBlankNodeHead;case"blank":if(!this._n3Mode)return this._error("Disallowed blank node as predicate",e);default:if(void 0===(this._predicate=this._readEntity(e)))return}return this._readObject}_readObject(e){switch(e.type){case"literal":if(0===e.prefix.length)return this._literalValue=e.value,this._readDataTypeOrLang;this._object=this._factory.literal(e.value,this._factory.namedNode(e.prefix));break;case"[":return this._saveContext("blank",this._graph,this._subject,this._predicate,this._subject=this._factory.blankNode()),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this._subject,this._predicate,this.RDF_NIL),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",e);case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,this._subject,this._predicate,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",e);default:if(void 0===(this._object=this._readEntity(e)))return;if(this._n3Mode)return this._getPathReader(this._getContextEndReader())}return this._getContextEndReader()}_readPredicateOrNamedGraph(e){return"{"===e.type?this._readGraph(e):this._readPredicate(e)}_readGraph(e){return"{"!==e.type?this._error(`Expected graph but got ${e.type}`,e):(this._graph=this._subject,this._subject=null,this._readSubject)}_readBlankNodeHead(e){return"]"===e.type?(this._subject=null,this._readBlankNodeTail(e)):(this._predicate=null,this._readPredicate(e))}_readBlankNodeTail(e){if("]"!==e.type)return this._readBlankNodePunctuation(e);null!==this._subject&&this._emit(this._subject,this._predicate,this._object,this._graph);const t=null===this._predicate;return this._restoreContext("blank",e),null!==this._object?this._getContextEndReader():null!==this._predicate?this._readObject:t?this._readPredicateOrNamedGraph:this._readPredicateAfterBlank}_readPredicateAfterBlank(e){switch(e.type){case".":case"}":return this._subject=null,this._readPunctuation(e);default:return this._readPredicate(e)}}_readListItem(e){let t=null,r=null,n=this._readListItem;const i=this._subject,o=this._contextStack,s=o[o.length-1];switch(e.type){case"[":this._saveContext("blank",this._graph,r=this._factory.blankNode(),this.RDF_FIRST,this._subject=t=this._factory.blankNode()),n=this._readBlankNodeHead;break;case"(":this._saveContext("list",this._graph,r=this._factory.blankNode(),this.RDF_FIRST,this.RDF_NIL),this._subject=null;break;case")":if(this._restoreContext("list",e),0!==o.length&&"list"===o[o.length-1].type&&this._emit(this._subject,this._predicate,this._object,this._graph),null===this._predicate){if(n=this._readPredicate,this._subject===this.RDF_NIL)return n}else if(n=this._getContextEndReader(),this._object===this.RDF_NIL)return n;r=this.RDF_NIL;break;case"literal":0===e.prefix.length?(this._literalValue=e.value,n=this._readListItemDataTypeOrLang):(t=this._factory.literal(e.value,this._factory.namedNode(e.prefix)),n=this._getContextEndReader());break;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",e);default:if(void 0===(t=this._readEntity(e)))return}if(null===r&&(this._subject=r=this._factory.blankNode()),null===i?null===s.predicate?s.subject=r:s.object=r:this._emit(i,this.RDF_REST,r,this._graph),null!==t){if(this._n3Mode&&("IRI"===e.type||"prefixed"===e.type))return this._saveContext("item",this._graph,r,this.RDF_FIRST,t),this._subject=t,this._predicate=null,this._getPathReader(this._readListItem);this._emit(r,this.RDF_FIRST,t,this._graph)}return n}_readDataTypeOrLang(e){return this._completeObjectLiteral(e,!1)}_readListItemDataTypeOrLang(e){return this._completeObjectLiteral(e,!0)}_completeLiteral(e){let t=this._factory.literal(this._literalValue);switch(e.type){case"type":case"typeIRI":const r=this._readEntity(e);if(void 0===r)return;t=this._factory.literal(this._literalValue,r),e=null;break;case"langcode":t=this._factory.literal(this._literalValue,e.value),e=null}return{token:e,literal:t}}_completeSubjectLiteral(e){return this._subject=this._completeLiteral(e).literal,this._readPredicateOrNamedGraph}_completeObjectLiteral(e,t){const r=this._completeLiteral(e);if(r)return this._object=r.literal,t&&this._emit(this._subject,this.RDF_FIRST,this._object,this._graph),null===r.token?this._getContextEndReader():(this._readCallback=this._getContextEndReader(),this._readCallback(r.token))}_readFormulaTail(e){return"}"!==e.type?this._readPunctuation(e):(null!==this._subject&&this._emit(this._subject,this._predicate,this._object,this._graph),this._restoreContext("formula",e),null===this._object?this._readPredicate:this._getContextEndReader())}_readPunctuation(e){let t,r=this._graph;const n=this._subject,i=this._inversePredicate;switch(e.type){case"}":if(null===this._graph)return this._error("Unexpected graph closing",e);if(this._n3Mode)return this._readFormulaTail(e);this._graph=null;case".":this._subject=null,t=this._contextStack.length?this._readSubject:this._readInTopContext,i&&(this._inversePredicate=!1);break;case";":t=this._readPredicate;break;case",":t=this._readObject;break;case"{|":if(!this._supportsRDFStar)return this._error("Unexpected RDF-star syntax",e);const o=this._predicate,s=this._object;this._subject=this._factory.quad(n,o,s,this.DEFAULTGRAPH),t=this._readPredicate;break;case"|}":if("Quad"!==this._subject.termType)return this._error("Unexpected asserted triple closing",e);this._subject=null,t=this._readPunctuation;break;default:if(this._supportsQuads&&null===this._graph&&void 0!==(r=this._readEntity(e))){t=this._readQuadPunctuation;break}return this._error(`Expected punctuation to follow "${this._object.id}"`,e)}if(null!==n){const e=this._predicate,t=this._object;i?this._emit(t,e,n,r):this._emit(n,e,t,r)}return t}_readBlankNodePunctuation(e){let t;switch(e.type){case";":t=this._readPredicate;break;case",":t=this._readObject;break;default:return this._error(`Expected punctuation to follow "${this._object.id}"`,e)}return this._emit(this._subject,this._predicate,this._object,this._graph),t}_readQuadPunctuation(e){return"."!==e.type?this._error("Expected dot to follow quad",e):this._readInTopContext}_readPrefix(e){return"prefix"!==e.type?this._error("Expected prefix to follow @prefix",e):(this._prefix=e.value,this._readPrefixIRI)}_readPrefixIRI(e){if("IRI"!==e.type)return this._error(`Expected IRI to follow prefix "${this._prefix}:"`,e);const t=this._readEntity(e);return this._prefixes[this._prefix]=t.value,this._prefixCallback(this._prefix,t),this._readDeclarationPunctuation}_readBaseIRI(e){const t="IRI"===e.type&&this._resolveIRI(e.value);return t?(this._setBase(t),this._readDeclarationPunctuation):this._error("Expected valid IRI to follow base declaration",e)}_readNamedGraphLabel(e){switch(e.type){case"IRI":case"blank":case"prefixed":return this._readSubject(e),this._readGraph;case"[":return this._readNamedGraphBlankLabel;default:return this._error("Invalid graph label",e)}}_readNamedGraphBlankLabel(e){return"]"!==e.type?this._error("Invalid graph label",e):(this._subject=this._factory.blankNode(),this._readGraph)}_readDeclarationPunctuation(e){return this._sparqlStyle?(this._sparqlStyle=!1,this._readInTopContext(e)):"."!==e.type?this._error("Expected declaration to end with a dot",e):this._readInTopContext}_readQuantifierList(e){let t;switch(e.type){case"IRI":case"prefixed":if(void 0!==(t=this._readEntity(e,!0)))break;default:return this._error(`Unexpected ${e.type}`,e)}return this._explicitQuantifiers?(null===this._subject?this._emit(this._graph||this.DEFAULTGRAPH,this._predicate,this._subject=this._factory.blankNode(),this.QUANTIFIERS_GRAPH):this._emit(this._subject,this.RDF_REST,this._subject=this._factory.blankNode(),this.QUANTIFIERS_GRAPH),this._emit(this._subject,this.RDF_FIRST,t,this.QUANTIFIERS_GRAPH)):this._quantified[t.id]=this._factory[this._quantifier](this._factory.blankNode().value),this._readQuantifierPunctuation}_readQuantifierPunctuation(e){return","===e.type?this._readQuantifierList:(this._explicitQuantifiers&&(this._emit(this._subject,this.RDF_REST,this.RDF_NIL,this.QUANTIFIERS_GRAPH),this._subject=null),this._readCallback=this._getContextEndReader(),this._readCallback(e))}_getPathReader(e){return this._afterPath=e,this._readPath}_readPath(e){switch(e.type){case"!":return this._readForwardPath;case"^":return this._readBackwardPath;default:const t=this._contextStack,r=t.length&&t[t.length-1];if(r&&"item"===r.type){const t=this._subject;this._restoreContext("item",e),this._emit(this._subject,this.RDF_FIRST,t,this._graph)}return this._afterPath(e)}}_readForwardPath(e){let t,r;const n=this._factory.blankNode();if(void 0!==(r=this._readEntity(e)))return null===this._predicate?(t=this._subject,this._subject=n):(t=this._object,this._object=n),this._emit(t,r,n,this._graph),this._readPath}_readBackwardPath(e){const t=this._factory.blankNode();let r,n;if(void 0!==(r=this._readEntity(e)))return null===this._predicate?(n=this._subject,this._subject=t):(n=this._object,this._object=t),this._emit(t,r,n,this._graph),this._readPath}_readRDFStarTailOrGraph(e){return">>"!==e.type?this._supportsQuads&&null===this._graph&&void 0!==(this._graph=this._readEntity(e))?this._readRDFStarTail:this._error(`Expected >> to follow "${this._object.id}"`,e):this._readRDFStarTail(e)}_readRDFStarTail(e){if(">>"!==e.type)return this._error(`Expected >> but got ${e.type}`,e);const t=this._factory.quad(this._subject,this._predicate,this._object,this._graph||this.DEFAULTGRAPH);return this._restoreContext("<<",e),null===this._subject?(this._subject=t,this._readPredicate):(this._object=t,this._getContextEndReader())}_getContextEndReader(){const e=this._contextStack;if(!e.length)return this._readPunctuation;switch(e[e.length-1].type){case"blank":return this._readBlankNodeTail;case"list":return this._readListItem;case"formula":return this._readFormulaTail;case"<<":return this._readRDFStarTailOrGraph}}_emit(e,t,r,n){this._callback(null,this._factory.quad(e,t,r,n||this.DEFAULTGRAPH))}_error(e,t){const r=new Error(`${e} on line ${t.line}.`);r.context={token:t,line:t.line,previousToken:this._lexer.previousToken},this._callback(r),this._callback=ct}_resolveIRI(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)?e:this._resolveRelativeIRI(e)}_resolveRelativeIRI(e){if(!e.length)return this._base;switch(e[0]){case"#":return this._base+e;case"?":return this._base.replace(/(?:\?.*)?$/,e);case"/":return("/"===e[1]?this._baseScheme:this._baseRoot)+this._removeDotSegments(e);default:return/^[^/:]*:/.test(e)?null:this._removeDotSegments(this._basePath+e)}}_removeDotSegments(e){if(!/(^|\/)\.\.?($|[/#?])/.test(e))return e;const t=e.length;let r="",n=-1,i=-1,o=0,s="/";for(;n<t;){switch(s){case":":if(i<0&&"/"===e[++n]&&"/"===e[++n])for(;(i=n+1)<t&&"/"!==e[i];)n=i;break;case"?":case"#":n=t;break;case"/":if("."===e[n+1])switch(s=e[1+ ++n],s){case"/":r+=e.substring(o,n-1),o=n+1;break;case void 0:case"?":case"#":return r+e.substring(o,n)+e.substr(n+1);case".":if(s=e[1+ ++n],void 0===s||"/"===s||"?"===s||"#"===s){if(r+=e.substring(o,n-2),(o=r.lastIndexOf("/"))>=i&&(r=r.substr(0,o)),"/"!==s)return`${r}/${e.substr(n+1)}`;o=n+1}}}s=e[++n]}return r+e.substring(o)}parse(e,t,r){let n,i,o;if(t&&(t.onQuad||t.onPrefix||t.onComment)?(n=t.onQuad,i=t.onPrefix,o=t.onComment):(n=t,i=r),this._readCallback=this._readInTopContext,this._sparqlStyle=!1,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix?this._blankNodePrefix.substr(2):`b${st++}_`,this._prefixCallback=i||ct,this._inversePredicate=!1,this._quantified=Object.create(null),!n){const t=[];let r;if(this._callback=(e,n)=>{e?r=e:n&&t.push(n)},this._lexer.tokenize(e).every(e=>this._readCallback=this._readCallback(e)),r)throw r;return t}let s=(e,t)=>{null!==e?(this._callback(e),this._callback=ct):this._readCallback&&(this._readCallback=this._readCallback(t))};o&&(this._lexer.comments=!0,s=(e,t)=>{null!==e?(this._callback(e),this._callback=ct):this._readCallback&&("comment"===t.type?o(t.value):this._readCallback=this._readCallback(t))}),this._callback=n,this._lexer.tokenize(e,s)}}function ct(){}function ut(e,t){e._factory=t,e.DEFAULTGRAPH=t.defaultGraph(),e.RDF_FIRST=t.namedNode(Pe.rdf.first),e.RDF_REST=t.namedNode(Pe.rdf.rest),e.RDF_NIL=t.namedNode(Pe.rdf.nil),e.N3_FORALL=t.namedNode(Pe.r.forAll),e.N3_FORSOME=t.namedNode(Pe.r.forSome),e.ABBREVIATIONS={a:t.namedNode(Pe.rdf.type),"=":t.namedNode(Pe.owl.sameAs),">":t.namedNode(Pe.log.implies),"<":t.namedNode(Pe.log.isImpliedBy)},e.QUANTIFIERS_GRAPH=t.namedNode("urn:n3:quantifiers")}if(ut(at.prototype,Ve),void 0===lt)var lt={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12};class ht{constructor(e,t){this.options=t||{},this.kb=e,this.target=t.target||{graph:{subjects:{},prefixes:{},terms:{}}},this.blankNodes=[],this.htmlOptions={selfClosing:"br img input area base basefont col colgroup source wbr isindex link meta param hr"},this.theOne="_:"+(new Date).getTime(),this.language=null,this.vocabulary=null,this.blankCounter=0,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"}],this.inXHTMLMode=!1,this.absURIRE=/[\w\_\-]+:\S+/,this.finishedHandlers=[],this.init()}addTriple(e,t,r,n){var i,o,s,a;i=void 0===t?x.namedNode(this.options.base):this.toRDFNodeObject(t),s=this.toRDFNodeObject(r),o=this.toRDFNodeObject(n),a=x.namedNode(this.options.base),this.kb.add(i,s,o,a)}ancestorPath(e){for(var t="";e&&e.nodeType!==lt.DOCUMENT_NODE;)t="/"+e.localName+t,e=e.parentNode;return t}copyMappings(e){var t={};for(var r in e)t[r]=e[r];return t}copyProperties(){}deriveDateTimeType(e){for(var t=0;t<ht.dateTimeTypes.length;t++){var r=ht.dateTimeTypes[t].pattern.exec(e);if(r&&r[0].length===e.length)return ht.dateTimeTypes[t].type}return null}init(){}newBlankNode(){return this.blankCounter++,"_:"+this.blankCounter}newSubjectOrigin(e,t){}parseCURIE(e,t,r){var n,i=e.indexOf(":");if(i>=0){var o=e.substring(0,i);if(""===o)return(n=t[""])?n+e.substring(i+1):null;if("_"===o)return"_:"+e.substring(i+1);if(ht.NCNAME.test(o)&&(n=t[o]))return n+e.substring(i+1)}return null}parseCURIEOrURI(e,t,r){var n=this.parseCURIE(e,t,r);return n||this.resolveAndNormalize(r,e)}parsePredicate(e,t,r,n,i,o){if(""===e)return null;var s=this.parseTermOrCURIEOrAbsURI(e,t,o?null:r,n,i);return s&&0===s.indexOf("_:")?null:s}parsePrefixMappings(e,t){for(var r=this.tokenize(e),n=null,i=0;i<r.length;i++)":"===r[i][r[i].length-1]?n=r[i].substring(0,r[i].length-1):n&&(t[n]=this.options.base?b.join(r[i],this.options.base):r[i],n=null)}static parseRDFaDOM(e,t,r){var n=new ht(t,{base:r});e.baseURI||(e.baseURI=r),n.process(e,{baseURI:r})}parseSafeCURIEOrCURIEOrURI(e,t,r){return"["===(e=this.trim(e)).charAt(0)&&"]"===e.charAt(e.length-1)?0===(e=(e=e.substring(1,e.length-1)).trim(e)).length?null:"_:"===e?this.theOne:this.parseCURIE(e,t,r):this.parseCURIEOrURI(e,t,r)}parseTermOrCURIEOrAbsURI(e,t,r,n,i){e=this.trim(e);var o=this.parseCURIE(e,n,i);if(o)return o;if(r){if(t&&!this.absURIRE.exec(e))return t+e;var s=r[e];if(s)return s;if(s=r[e.toLowerCase()])return s}return this.absURIRE.exec(e)?this.resolveAndNormalize(i,e):null}parseTermOrCURIEOrURI(e,t,r,n,i){e=this.trim(e);var o=this.parseCURIE(e,n,i);if(o)return o;var s=r[e];return s||((s=r[e.toLowerCase()])?s:t&&!this.absURIRE.exec(e)?t+e:this.resolveAndNormalize(i,e))}parseURI(e){return e}process(e,t){var r;t=t||{},e.nodeType===lt.DOCUMENT_NODE?(e.baseURI&&!t.baseURI&&(t.baseURI=e.baseURI),r=e.baseURI,(e=e.documentElement).baseURI||(e.baseURI=r),this.setContext(e)):e.parentNode.nodeType===lt.DOCUMENT_NODE&&this.setContext(e);var n=[],i=function(e){if(!e&&t&&t.baseURI)return t.baseURI;var r=e.indexOf("#");return r>=0&&(e=e.substring(0,r)),t&&t.baseURIMap&&(e=t.baseURIMap(e)),e};for(n.push({current:e,context:this.push(null,i(e.baseURI))});n.length>0;){var o=n.shift();if(o.parent){if(o.context.parent&&o.context.parent.listMapping===o.listMapping)continue;for(let e in o.listMapping){var s=o.listMapping[e];if(0!==s.length){var a=[];for(let e=0;e<s.length;e++)a.push(this.newBlankNode());for(let e=0;e<a.length;e++)this.addTriple(o.parent,a[e],"http://www.w3.org/1999/02/22-rdf-syntax-ns#first",s[e]),this.addTriple(o.parent,a[e],"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",{type:ht.objectURI,value:e+1<a.length?a[e+1]:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"});this.addTriple(o.parent,o.subject,e,{type:ht.objectURI,value:a[0]})}else this.addTriple(o.parent,o.subject,e,{type:ht.objectURI,value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"})}}else{var c=o.current,u=o.context,l=!1,h=null,d=null,f=null,p=u.prefixes,g=!1,y=[],m=u.listMapping,v=!u.parent,w=u.language,_=u.vocabulary;r=this.parseURI(i(c.baseURI)),c.item=null;var S=c.getAttributeNode("vocab");if(S){let e=this.trim(S.value);if(e.length>0){_=e;var E=r.spec;this.addTriple(c,E,"http://www.w3.org/ns/rdfa#usesVocabulary",{type:ht.objectURI,value:_})}else _=this.vocabulary}for(var A=0;A<c.attributes.length;A++){var x=c.attributes[A];if("x"===x.nodeName.charAt(0)&&0===x.nodeName.indexOf("xmlns:")){g||(p=this.copyMappings(p),g=!0);var T=x.nodeName.substring(6),F=ht.trim(x.value);p[T]=this.options.base?b.join(F,this.options.base):F}}var k=c.getAttributeNode("prefix");k&&(g||(p=this.copyMappings(p),g=!0),this.parsePrefixMappings(k.value,p));var I=null;for(let e=0;!I&&e<this.langAttributes.length;e++)I=c.getAttributeNodeNS(this.langAttributes[e].namespaceURI,this.langAttributes[e].localName);if(I){let e=ht.trim(I.value);w=e.length>0?e:null}var C,N,R=c.getAttributeNode("rel"),P=c.getAttributeNode("rev"),O=c.getAttributeNode("typeof"),D=c.getAttributeNode("property"),U=c.getAttributeNode("datatype"),L=this.inHTMLMode?c.getAttributeNode("datetime"):null,j=c.getAttributeNode("content"),M=c.getAttributeNode("about"),H=c.getAttributeNode("src"),B=c.getAttributeNode("resource"),q=c.getAttributeNode("href"),K=c.getAttributeNode("inlist"),W=[];if(R){N=this.tokenize(R.value);for(let e=0;e<N.length;e++)(C=this.parsePredicate(N[e],_,u.terms,p,r,this.inHTMLMode&&null!==D))&&W.push(C)}var J=[];if(P){N=this.tokenize(P.value);for(let e=0;e<N.length;e++)(C=this.parsePredicate(N[e],_,u.terms,p,r,this.inHTMLMode&&D))&&J.push(C)}if(this.inHTMLMode&&(R||P)&&D&&(0===W.length&&(R=null),0===J.length&&(P=null)),R||P?(M&&(h=this.parseSafeCURIEOrCURIEOrURI(M.value,p,r)),O&&(f=h),h||(c.parentNode.nodeType===lt.DOCUMENT_NODE?h=i(c.baseURI):u.parentObject&&(h=i(c.parentNode.baseURI)===u.parentObject?i(c.baseURI):u.parentObject)),B&&(d=this.parseSafeCURIEOrCURIEOrURI(B.value,p,r)),d||(q?d=this.resolveAndNormalize(r,encodeURI(q.value)):H?d=this.resolveAndNormalize(r,encodeURI(H.value)):!O||M||this.inXHTMLMode&&("head"===c.localName||"body"===c.localName)||(d=this.newBlankNode())),!O||M||!this.inXHTMLMode||"head"!==c.localName&&"body"!==c.localName?O&&!M&&(f=d):f=h):!D||j||U?(M&&(h=this.parseSafeCURIEOrCURIEOrURI(M.value,p,r)),!h&&B&&(h=this.parseSafeCURIEOrCURIEOrURI(B.value,p,r)),!h&&q&&(h=this.resolveAndNormalize(r,encodeURI(q.value))),!h&&H&&(h=this.resolveAndNormalize(r,encodeURI(H.value))),h||(c.parentNode.nodeType===lt.DOCUMENT_NODE?h=i(c.baseURI):!this.inXHTMLMode&&!this.inHTMLMode||"head"!==c.localName&&"body"!==c.localName?O?h=this.newBlankNode():u.parentObject&&(h=i(c.parentNode.baseURI)===u.parentObject?i(c.baseURI):u.parentObject,D||(l=!0)):h=i(c.parentNode.baseURI)===u.parentObject?i(c.baseURI):u.parentObject),O&&(f=h)):(M&&(h=this.parseSafeCURIEOrCURIEOrURI(M.value,p,r),O&&(f=h)),h||c.parentNode.nodeType!==lt.DOCUMENT_NODE?!h&&u.parentObject&&(h=i(c.parentNode.baseURI)===u.parentObject?i(c.baseURI):u.parentObject):(h=i(c.baseURI),O&&(f=h)),O&&!f&&(B&&(f=this.parseSafeCURIEOrCURIEOrURI(B.value,p,r)),!f&&q&&(f=this.resolveAndNormalize(r,encodeURI(q.value))),!f&&H&&(f=this.resolveAndNormalize(r,encodeURI(H.value))),f||!this.inXHTMLMode&&!this.inHTMLMode||"head"!==c.localName&&"body"!==c.localName||(f=h),f||(f=this.newBlankNode()),d=f)),h&&(M||B||f)){var V=h;O&&!M&&!B&&d&&(V=d),this.newSubjectOrigin(c,V)}if(f){N=this.tokenize(O.value);for(let e=0;e<N.length;e++){var $=this.parseTermOrCURIEOrAbsURI(N[e],_,u.terms,p,r);$&&this.addTriple(c,f,ht.typeURI,{type:ht.objectURI,value:$})}}if(h&&h!==u.parentObject&&(m={},v=!0),d){if(R&&K)for(let e=0;e<W.length;e++){let t=m[W[e]];t||(t=[],m[W[e]]=t),t.push({type:ht.objectURI,value:d})}else if(R)for(let e=0;e<W.length;e++)this.addTriple(c,h,W[e],{type:ht.objectURI,value:d});if(P)for(let e=0;e<J.length;e++)this.addTriple(c,d,J[e],{type:ht.objectURI,value:h})}else{if(h&&!d&&(R||P)&&(d=this.newBlankNode()),R&&K)for(let e=0;e<W.length;e++){let t=m[W[e]];t||(t=[],m[C]=t),y.push({predicate:W[e],list:t})}else if(R)for(let e=0;e<W.length;e++)y.push({predicate:W[e],forward:!0});if(P)for(let e=0;e<J.length;e++)y.push({predicate:J[e],forward:!1})}if(D){var z=null,G=null;U?(z=""===U.value?ht.PlainLiteralURI:this.parseTermOrCURIEOrAbsURI(U.value,_,u.terms,p,r),G=L&&!j?L.value:z===ht.XMLLiteralURI||z===ht.HTMLLiteralURI?null:j?j.value:c.textContent):j?(z=ht.PlainLiteralURI,G=j.value):L?(G=L.value,(z=ht.deriveDateTimeType(G))||(z=ht.PlainLiteralURI)):R||P||(B&&(G=this.parseSafeCURIEOrCURIEOrURI(B.value,p,r)),!G&&q?G=this.resolveAndNormalize(r,encodeURI(q.value)):!G&&H&&(G=this.resolveAndNormalize(r,encodeURI(H.value))),G&&(z=ht.objectURI)),z||(O&&!M?(z=ht.objectURI,G=f):(G=c.textContent,this.inHTMLMode&&"time"===c.localName&&(z=ht.deriveDateTimeType(G)),z||(z=ht.PlainLiteralURI))),N=this.tokenize(D.value);for(let e=0;e<N.length;e++){let t=this.parsePredicate(N[e],_,u.terms,p,r);if(t)if(K){let e=m[t];e||(e=[],m[t]=e),e.push(z===ht.XMLLiteralURI||z===ht.HTMLLiteralURI?{type:z,value:c.childNodes}:{type:z||ht.PlainLiteralURI,value:G,language:w})}else z===ht.XMLLiteralURI||z===ht.HTMLLiteralURI?this.addTriple(c,h,t,{type:z,value:c.childNodes}):this.addTriple(c,h,t,{type:z||ht.PlainLiteralURI,value:G,language:w})}}if(h&&!l)for(let e=0;e<u.incomplete.length;e++)u.incomplete[e].list?u.incomplete[e].list.push({type:ht.objectURI,value:h}):u.incomplete[e].forward?this.addTriple(c,u.subject,u.incomplete[e].predicate,{type:ht.objectURI,value:h}):this.addTriple(c,h,u.incomplete[e].predicate,{type:ht.objectURI,value:u.subject});var X=null,Y=h;l?((X=this.push(u,u.subject)).parentObject=i(c.parentNode.baseURI)===u.parentObject?i(c.baseURI):u.parentObject,X.incomplete=u.incomplete,X.language=w,X.prefixes=p,X.vocabulary=_):((X=this.push(u,h)).parentObject=d||h||u.subject,X.prefixes=p,X.incomplete=y,d&&(Y=d,m={},v=!0),X.listMapping=m,X.language=w,X.vocabulary=_),v&&n.unshift({parent:c,context:u,subject:Y,listMapping:m});for(var Q=c.lastChild;Q;Q=Q.previousSibling)Q.nodeType===lt.ELEMENT_NODE&&n.unshift({current:Q,context:X})}}this.inHTMLMode&&this.copyProperties();for(let t=0;t<this.finishedHandlers.length;t++)this.finishedHandlers[t](e)}push(e,t){return{parent:e,subject:t||(e?e.subject:null),parentObject:null,incomplete:[],listMapping:e?e.listMapping:{},language:e?e.language:this.language,prefixes:e?e.prefixes:this.target.graph.prefixes,terms:e?e.terms:this.target.graph.terms,vocabulary:e?e.vocabulary:this.vocabulary}}resolveAndNormalize(e,t){return b.join(t,e)}setContext(e){"html"===e.localName&&"XHTML+RDFa 1.1"===e.getAttribute("version")?this.setXHTMLContext():"html"===e.localName||"http://www.w3.org/1999/xhtml"===e.namespaceURI?"undefined"!=typeof document&&document.doctype?"-//W3C//DTD XHTML+RDFa 1.0//EN"===document.doctype.publicId&&"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"===document.doctype.systemId?(console.log("WARNING: RDF 1.0 is not supported. Defaulting to HTML5 mode."),this.setHTMLContext()):"-//W3C//DTD XHTML+RDFa 1.1//EN"===document.doctype.publicId&&"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd"===document.doctype.systemId?this.setXHTMLContext():this.setHTMLContext():this.setHTMLContext():this.setXMLContext()}setHTMLContext(){this.setInitialContext(),this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"},{namespaceURI:null,localName:"lang"}],this.inXHTMLMode=!1,this.inHTMLMode=!0}setInitialContext(){this.vocabulary=null,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"}]}setXHTMLContext(){this.setInitialContext(),this.inXHTMLMode=!0,this.inHTMLMode=!1,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"},{namespaceURI:null,localName:"lang"}],this.target.graph.terms.alternate="http://www.w3.org/1999/xhtml/vocab#alternate",this.target.graph.terms.appendix="http://www.w3.org/1999/xhtml/vocab#appendix",this.target.graph.terms.bookmark="http://www.w3.org/1999/xhtml/vocab#bookmark",this.target.graph.terms.cite="http://www.w3.org/1999/xhtml/vocab#cite",this.target.graph.terms.chapter="http://www.w3.org/1999/xhtml/vocab#chapter",this.target.graph.terms.contents="http://www.w3.org/1999/xhtml/vocab#contents",this.target.graph.terms.copyright="http://www.w3.org/1999/xhtml/vocab#copyright",this.target.graph.terms.first="http://www.w3.org/1999/xhtml/vocab#first",this.target.graph.terms.glossary="http://www.w3.org/1999/xhtml/vocab#glossary",this.target.graph.terms.help="http://www.w3.org/1999/xhtml/vocab#help",this.target.graph.terms.icon="http://www.w3.org/1999/xhtml/vocab#icon",this.target.graph.terms.index="http://www.w3.org/1999/xhtml/vocab#index",this.target.graph.terms.last="http://www.w3.org/1999/xhtml/vocab#last",this.target.graph.terms.license="http://www.w3.org/1999/xhtml/vocab#license",this.target.graph.terms.meta="http://www.w3.org/1999/xhtml/vocab#meta",this.target.graph.terms.next="http://www.w3.org/1999/xhtml/vocab#next",this.target.graph.terms.prev="http://www.w3.org/1999/xhtml/vocab#prev",this.target.graph.terms.previous="http://www.w3.org/1999/xhtml/vocab#previous",this.target.graph.terms.section="http://www.w3.org/1999/xhtml/vocab#section",this.target.graph.terms.stylesheet="http://www.w3.org/1999/xhtml/vocab#stylesheet",this.target.graph.terms.subsection="http://www.w3.org/1999/xhtml/vocab#subsection",this.target.graph.terms.start="http://www.w3.org/1999/xhtml/vocab#start",this.target.graph.terms.top="http://www.w3.org/1999/xhtml/vocab#top",this.target.graph.terms.up="http://www.w3.org/1999/xhtml/vocab#up",this.target.graph.terms.p3pv1="http://www.w3.org/1999/xhtml/vocab#p3pv1",this.target.graph.terms.related="http://www.w3.org/1999/xhtml/vocab#related",this.target.graph.terms.role="http://www.w3.org/1999/xhtml/vocab#role",this.target.graph.terms.transformation="http://www.w3.org/1999/xhtml/vocab#transformation"}setXMLContext(){this.setInitialContext(),this.inXHTMLMode=!1,this.inHTMLMode=!1}tokenize(e){return this.trim(e).split(/\s+/)}static tokenize(e){return this.trim(e).split(/\s+/)}toRDFNodeObject(e){if(void 0!==e){if("string"==typeof e)return"_:"===e.substring(0,2)?(void 0===this.blankNodes[e.substring(2)]&&(this.blankNodes[e.substring(2)]=new a(e.substring(2))),this.blankNodes[e.substring(2)]):x.namedNode(e);switch(e.type){case ht.objectURI:return"_:"===e.value.substring(0,2)?(void 0===this.blankNodes[e.value.substring(2)]&&(this.blankNodes[e.value.substring(2)]=new a(e.value.substring(2))),this.blankNodes[e.value.substring(2)]):x.namedNode(e.value);case ht.PlainLiteralURI:return new h(e.value,e.language||"");case ht.XMLLiteralURI:case ht.HTMLLiteralURI:var t="";return Object.keys(e.value).forEach(r=>{t+=k.domToString(e.value[r],this.htmlOptions)}),new h(t,"",new c.A(e.type));default:return new h(e.value,"",new c.A(e.type))}}}trim(e){return e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}static trim(e){return e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}}ht.XMLLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",ht.HTMLLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML",ht.PlainLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral",ht.objectURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#object",ht.typeURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",ht.nameChar="[-A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ--⁰-Ⰰ-、-豈-﷏ﷰ-�က0-F.0-9·̀-ͯ‿-⁀]",ht.nameStartChar="[A-Za-zÀ-ÖØ-öø-ÿĀ-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁΆΈ-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁҐ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆא-תװ-ײء-غف-يٱ-ڷں-ھۀ-ێې-ۓەۥ-ۦअ-हऽक़-ॡঅ-ঌএ-ঐও-নপ-রলশ-হড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઋઍએ-ઑઓ-નપ-રલ-ળવ-હઽૠଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଶ-ହଽଡ଼-ଢ଼ୟ-ୡஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-வஷ-ஹఅ-ఌఎ-ఐఒ-నప-ళవ-హౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹೞೠ-ೡഅ-ഌഎ-ഐഒ-നപ-ഹൠ-ൡก-ฮะา-ำเ-ๅກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ຮະາ-ຳຽເ-ໄཀ-ཇཉ-ཀྵႠ-Ⴥა-ჶᄀᄂ-ᄃᄅ-ᄇᄉᄋ-ᄌᄎ-ᄒᄼᄾᅀᅌᅎᅐᅔ-ᅕᅙᅟ-ᅡᅣᅥᅧᅩᅭ-ᅮᅲ-ᅳᅵᆞᆨᆫᆮ-ᆯᆷ-ᆸᆺᆼ-ᇂᇫᇰᇹḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼΩK-Å℮ↀ-ↂぁ-ゔァ-ヺㄅ-ㄬ가-힣一-龥〇〡-〩_]",ht.NCNAME=new RegExp("^"+ht.nameStartChar+ht.nameChar+"*$"),ht.dateTimeTypes=[{pattern:/-?P(?:[0-9]+Y)?(?:[0-9]+M)?(?:[0-9]+D)?(?:T(?:[0-9]+H)?(?:[0-9]+M)?(?:[0-9]+(?:\.[0-9]+)?S)?)?/,type:"http://www.w3.org/2001/XMLSchema#duration"},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]-[0-9][0-9]T(?:[0-1][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:"http://www.w3.org/2001/XMLSchema#dateTime"},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]-[0-9][0-9](?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:"http://www.w3.org/2001/XMLSchema#date"},{pattern:/(?:[0-1][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:"http://www.w3.org/2001/XMLSchema#time"},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]/,type:"http://www.w3.org/2001/XMLSchema#gYearMonth"},{pattern:/-?[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9]/,type:"http://www.w3.org/2001/XMLSchema#gYear"}];const dt=ht.parseRDFaDOM;class ft{constructor(e){this.store=e,this.bnodes={},this.why=null,this.reify=!1}frameFactory(e,t,r){return{NODE:1,ARC:2,parent:t,parser:e,store:e.store,element:r,lastChild:0,base:null,lang:null,node:null,nodeType:null,listIndex:1,rdfid:null,datatype:null,collection:!1,terminateFrame:function(){this.collection&&this.node.close()},addSymbol:function(e,t){t=b.join(t,this.base),this.node=this.store.sym(t),this.nodeType=e},loadTriple:function(){if(this.parent.parent.collection?this.parent.parent.node.append(this.node):this.store.add(this.parent.parent.node,this.parent.node,this.node,this.parser.why),null!=this.parent.rdfid){var e=this.store.sym(b.join("#"+this.parent.rdfid,this.base));this.store.add(e,this.store.sym(ft.ns.RDF+"type"),this.store.sym(ft.ns.RDF+"Statement"),this.parser.why),this.store.add(e,this.store.sym(ft.ns.RDF+"subject"),this.parent.parent.node,this.parser.why),this.store.add(e,this.store.sym(ft.ns.RDF+"predicate"),this.parent.node,this.parser.why),this.store.add(e,this.store.sym(ft.ns.RDF+"object"),this.node,this.parser.why)}},isTripleToLoad:function(){return null!=this.parent&&null!=this.parent.parent&&this.nodeType===this.NODE&&this.parent.nodeType===this.ARC&&this.parent.parent.nodeType===this.NODE},addNode:function(e){this.addSymbol(this.NODE,e),this.isTripleToLoad()&&this.loadTriple()},addCollection:function(){this.nodeType=this.NODE,this.node=this.store.collection(),this.collection=!0,this.isTripleToLoad()&&this.loadTriple()},addCollectionArc:function(){this.nodeType=this.ARC},addBNode:function(e){null!=e?null!=this.parser.bnodes[e]?this.node=this.parser.bnodes[e]:this.node=this.parser.bnodes[e]=this.store.bnode():this.node=this.store.bnode(),this.nodeType=this.NODE,this.isTripleToLoad()&&this.loadTriple()},addArc:function(e){e===ft.ns.RDF+"li"&&(e=ft.ns.RDF+"_"+this.parent.listIndex,this.parent.listIndex++),this.addSymbol(this.ARC,e)},addLiteral:function(e){this.parent.datatype&&this.parent.datatype!==ft.ns.RDF+"langString"?this.node=this.store.literal(e,this.store.sym(this.parent.datatype)):this.node=this.store.literal(e,this.lang),this.nodeType=this.NODE,this.isTripleToLoad()&&this.loadTriple()}}}getAttributeNodeNS(e,t,r){var n=null;if(e.getAttributeNodeNS)n=e.getAttributeNodeNS(t,r);else for(var i,o=e.attributes,s=0;s<o.length;++s)if((i=o[s]).namespaceURI===t&&(i.prefix?i.prefix+":"+r:r)===i.nodeName){n=i;break}return n}parse(e,t,r){var n,i=e.childNodes;if(this.cleanParser(),e.nodeType===ft.nodeType.DOCUMENT){for(var o=0;o<i.length;o++)if(i[o].nodeType===ft.nodeType.ELEMENT){n=i[o];break}}else{if(e.nodeType!==ft.nodeType.ELEMENT)throw new Error("RDFParser: can't find root in "+t+". Halting. ");n=e}this.why=r;var s=this.frameFactory(this);return this.base=t,s.base=t,s.lang=null,this.parseDOM(this.buildFrame(s,n)),!0}parseDOM(e){for(var t,r=function(e){var t="";if(null==e.namespaceURI)throw new Error("RDF/XML syntax error: No namespace for "+e.localName+" in "+this.base);return e.namespaceURI&&(t+=e.namespaceURI),e.localName?t+=e.localName:e.nodeName&&(e.nodeName.indexOf(":")>=0?t+=e.nodeName.split(":")[1]:t+=e.nodeName),t}.bind(this),n=!0;e.parent;){var i=e.element,o=i.attributes;if(i.nodeType===ft.nodeType.TEXT||i.nodeType===ft.nodeType.CDATA_SECTION)e.parent.nodeType===e.NODE&&(e.addArc(ft.ns.RDF+"value"),e=this.buildFrame(e)),e.addLiteral(i.nodeValue);else if(r(i)!==ft.ns.RDF+"RDF")if(e.parent&&e.parent.collection&&(e.addCollectionArc(),(e=this.buildFrame(e,e.element)).parent.element=null),e.parent&&e.parent.nodeType&&e.parent.nodeType!==e.ARC){e.addArc(r(i)),this.reify&&(t=this.getAttributeNodeNS(i,ft.ns.RDF,"ID"))&&(e.rdfid=t.nodeValue,i.removeAttributeNode(t));var s=this.getAttributeNodeNS(i,ft.ns.RDF,"parseType"),a=this.getAttributeNodeNS(i,ft.ns.RDF,"datatype");if(a&&(e.datatype=a.nodeValue,i.removeAttributeNode(a)),s){var c=s.nodeValue;"Literal"===c?(e.datatype=ft.ns.RDF+"XMLLiteral",(e=this.buildFrame(e)).addLiteral(i.innerHTML||i.childNodes),n=!1):"Resource"===c?((e=this.buildFrame(e,e.element)).parent.element=null,e.addBNode()):"Collection"===c&&((e=this.buildFrame(e,e.element)).parent.element=null,e.addCollection()),i.removeAttributeNode(s)}if(0!==o.length){var u=this.getAttributeNodeNS(i,ft.ns.RDF,"resource"),l=this.getAttributeNodeNS(i,ft.ns.RDF,"nodeID");e=this.buildFrame(e),u?(e.addNode(u.nodeValue),i.removeAttributeNode(u)):l?(e.addBNode(l.nodeValue),i.removeAttributeNode(l)):e.addBNode();for(var h=o.length-1;h>=0;h--){var d=this.buildFrame(e);d.addArc(r(o[h])),r(o[h])===ft.ns.RDF+"type"?this.buildFrame(d).addNode(o[h].nodeValue):this.buildFrame(d).addLiteral(o[h].nodeValue)}}else 0===i.childNodes.length&&this.buildFrame(e).addLiteral("")}else{var f=this.getAttributeNodeNS(i,ft.ns.RDF,"about");if(t=this.getAttributeNodeNS(i,ft.ns.RDF,"ID"),f&&t)throw new Error("RDFParser: "+i.nodeName+" has both rdf:id and rdf:about. Halting. Only one of these properties may be specified on a node.");if(!f&&t)e.addNode("#"+t.nodeValue),i.removeAttributeNode(t);else if(null==f&&null==t){var p=this.getAttributeNodeNS(i,ft.ns.RDF,"nodeID");p?(e.addBNode(p.nodeValue),i.removeAttributeNode(p)):e.addBNode()}else e.addNode(f.nodeValue),i.removeAttributeNode(f);var g=this.getAttributeNodeNS(i,ft.ns.RDF,"type");ft.ns.RDF+"Description"!==r(i)&&(g={nodeValue:r(i)}),null!=g&&(this.store.add(e.node,this.store.sym(ft.ns.RDF+"type"),this.store.sym(b.join(g.nodeValue,e.base)),this.why),g.nodeName&&i.removeAttributeNode(g));for(var y=o.length-1;y>=0;y--)this.store.add(e.node,this.store.sym(r(o[y])),this.store.literal(o[y].nodeValue,e.lang),this.why)}for(i=e.element;e.parent;){for(var m=e;null==i;)i=(e=e.parent).element;var v=i.childNodes&&i.childNodes[e.lastChild];if(v&&n){if((v.nodeType===ft.nodeType.ELEMENT||v.nodeType===ft.nodeType.TEXT||v.nodeType===ft.nodeType.CDATA_SECTION)&&(v.nodeType!==ft.nodeType.TEXT&&v.nodeType!==ft.nodeType.CDATA_SECTION||1===i.childNodes.length)){e.lastChild++,e=this.buildFrame(m,i.childNodes[e.lastChild-1]);break}e.lastChild++}else{if(e.terminateFrame(),!(e=e.parent))break;i=e.element,n=!0}}}}cleanParser(){this.bnodes={},this.why=null}buildFrame(e,t){var r=this.frameFactory(this,e,t);if(e&&(r.base=e.base,r.lang=e.lang),!t||t.nodeType===ft.nodeType.TEXT||t.nodeType===ft.nodeType.CDATA_SECTION)return r;var n=t.attributes,i=t.getAttributeNode("xml:base");null!=i&&(r.base=i.nodeValue,t.removeAttribute("xml:base"));var o=t.getAttributeNode("xml:lang");null!=o&&(r.lang=o.nodeValue,t.removeAttribute("xml:lang"));for(var s=n.length-1;s>=0;s--)if("xml"===n[s].nodeName.substr(0,3)){if("xmlns:"===n[s].name.slice(0,6)){var a=n[s].nodeValue;this.base&&(a=b.join(a,this.base)),this.store.setPrefixForURI(n[s].name.slice(6),a)}t.removeAttributeNode(n[s])}return r}}function pt(e,t,r){var n,i,o,s=["INSERT","DELETE","WHERE"],a=F("http://www.w3.org/ns/pim/patch#"),c=ve(t,t,r,r,null,null,"",null),u={},l=function(e,t,r,n,i){return"Line "+(t+1)+" of <"+e+">: Bad syntax:\n "+i+'\n at: "'+r.slice(n,n+30)+'"'};n=0;var h=t.sym(r+"#query");for(u.query=h;;){if((i=c.skipSpace(e,n))<0)return u;if(";"===e[i]){if((n=c.skipSpace(e,i+1))<0)return u;i=n}var d=!1;for(o=0;o<s.length;o++){var f=s[o];if(e.slice(i,i+f.length)===f){if((n=c.skipSpace(e,i+f.length))<0)throw l(c._thisDoc,c.lines,e,i+f.length,"found EOF, needed {...} after "+f);if(("INSERT"===f||"DELETE"===f)&&"DATA"===e.slice(n,n+4)){if((i=c.skipSpace(e,n+4))<0)throw l(c._thisDoc,c.lines,e,n+4,"needed {...} after INSERT DATA "+f);n=i}var p=[];if((i=c.node(e,n,p))<0)throw l(c._thisDoc,c.lines,e,n,"bad syntax or EOF in {...} after "+f);u[f.toLowerCase()]=p[0],t.add(h,a(f.toLowerCase()),p[0]),d=!0,n=i}}if(!d&&"@prefix"===e.slice(i,i+7)){if((n=c.directive(e,i))<0)throw l(c._thisDoc,c.lines,e,n,"bad syntax or EOF after @prefix ");n=c.checkDot(e,n),d=!0}if(!d)throw l(c._thisDoc,c.lines,e,i,"Unknown syntax at start of statememt: '"+e.slice(i).slice(0,20)+"'")}}function gt(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"text/turtle",i=arguments.length>4?arguments[4]:void 0;n=n||s.sT,n=n.split(";")[0];try{if(n===s.ny||n===s.sT)ve(t,t,r,r,null,null,"",null).loadBuf(e),a();else if(n===s.JG){new ft(t).parse(k.parseXML(e),r,t.sym(r)),a()}else if(n===s.H)dt(k.parseXML(e,{contentType:s.H}),t,r),a();else if(n===s.lc)dt(k.parseXML(e,{contentType:s.lc}),t,r),a();else if(n===s.K9||n===s.Fn)pt(e,t,r),a();else if(n===s.i2)xe(e,t,r).then(a).catch(c);else{if(n!==s._0&&n!==s.BR)throw void 0===n?new Error("contentType is undefined"):new Error("Don't know how to parse "+n+" yet");var o=new at({factory:Ee});!function(e,r){e&&i(e,t);try{o.parse(r,u)}catch(e){i(e,t)}}(null,e)}}catch(e){c(e)}function a(){i&&i(null,t)}function c(e){if(n!==s.i2||n!==s._0||n!==s.BR){if(!i){let t=new Error(e+" while trying to parse <"+r+"> as "+n);throw t.cause=e,t}i(e,t)}}function u(e,r){r?t.add(r.subject,r.predicate,r.object,r.graph):i(e,t)}gt.handled={"text/n3":!0,"text/turtle":!0,"application/rdf+xml":!0,"application/xhtml+xml":!0,"text/html":!0,"application/sparql-update":!0,"application/sparql-update-single-match":!0,"application/ld+json":!0,"application/nquads":!0,"application/n-quads":!0}}(0,n.A)(ft,"ns",{RDF:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",RDFS:"http://www.w3.org/2000/01/rdf-schema#"}),(0,n.A)(ft,"nodeType",{ELEMENT:1,ATTRIBUTE:2,TEXT:3,CDATA_SECTION:4,ENTITY_REFERENCE:5,ENTITY:6,PROCESSING_INSTRUCTION:7,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,NOTATION:12});var yt=r(4945),mt=r.n(yt),vt=r(2931);const wt={"text/n3":!0,"text/turtle":!0,"application/rdf+xml":!0,"application/xhtml+xml":!0,"text/html":!0,"application/ld+json":!0},bt={rdf:s.JG,owl:s.JG,n3:"text/n3",ttl:"text/turtle",nt:"text/n3",acl:"text/n3",html:"text/html",xml:"text/xml"},_t=e=>({link:F("http://www.w3.org/2007/ont/link#",e),http:F("http://www.w3.org/2007/ont/http#",e),httph:F("http://www.w3.org/2007/ont/httph#",e),rdf:F("http://www.w3.org/1999/02/22-rdf-syntax-ns#",e),rdfs:F("http://www.w3.org/2000/01/rdf-schema#",e),dc:F("http://purl.org/dc/elements/1.1/",e),ldp:F("http://www.w3.org/ns/ldp#",e)}),St=_t();class Et{constructor(e,t){(0,n.A)(this,"response",void 0),(0,n.A)(this,"dom",void 0),this.response=e,this.dom=t}}(0,n.A)(Et,"pattern",void 0);class At extends Et{static toString(){return"RDFXMLHandler"}static register(e){e.mediatypes[s.JG]={q:.9}}parse(e,t,r){let n=e.store;if(this.dom||(this.dom=k.parseXML(t)),"parsererror"===this.dom.documentElement.nodeName)return e.failFetch(r,"Badly formed XML in "+r.resource.value,"parse_error");let i=new ft(n);try{i.parse(this.dom,r.original.value,r.original)}catch(t){return e.failFetch(r,"Syntax error parsing RDF/XML! "+t,"parse_error")}return r.noMeta||n.add(r.original,St.rdf("type"),St.link("RDFDocument"),e.appNode),e.doneFetch(r,this.response)}}At.pattern=new RegExp("application/rdf\\+xml");class xt extends Et{static toString(){return"XHTMLHandler"}static register(e){e.mediatypes[s.H]={q:.8}}parse(e,t,r){let n,i;this.dom||(this.dom=k.parseXML(t));let o=e.store,s=this.dom.getElementsByTagName("title");s.length>0&&o.add(r.resource,St.dc("title"),o.rdfFactory.literal(s[0].textContent),r.resource);let a=this.dom.getElementsByTagName("link");for(let t=a.length-1;t>=0;t--)n=a[t].getAttribute("rel"),i=!1,n||(n=a[t].getAttribute("rev"),i=!0),n&&e.linkData(r.original,n,a[t].getAttribute("href"),r.resource,i);let c=this.dom.getElementsByTagName("script");for(let e=0;e<c.length;e++){let t=c[e].getAttribute("type");wt[t]&&(gt(c[e].textContent,o,r.original.value,t),gt(c[e].textContent,o,r.original.value,t))}if(r.noMeta||o.add(r.resource,St.rdf("type"),St.link("WebPage"),e.appNode),!r.noRDFa&&dt)try{dt(this.dom,o,r.original.value)}catch(t){let n="Error trying to parse "+r.resource+" as RDFa:\n"+t+":\n"+t.stack;return e.failFetch(r,n,"parse_error")}return e.doneFetch(r,this.response)}}xt.pattern=new RegExp("application/xhtml");class Tt extends Et{static toString(){return"XMLHandler"}static register(e){e.mediatypes["text/xml"]={q:.5},e.mediatypes["application/xml"]={q:.5}}static isElement(e){return e.nodeType===Node.ELEMENT_NODE}parse(e,t,r){let n=k.parseXML(t);for(let i=0;i<n.childNodes.length;i++){const o=n.childNodes[i];if(Tt.isElement(o)){let i=o.namespaceURI;if(i&&i===i.rdf){return e.addStatus(r.req,"Has XML root element in the RDF namespace, so assume RDF/XML."),new At(this.response,n).parse(e,t,r)}break}}if(n.doctype&&"html"===n.doctype.name&&n.doctype.publicId.match(/^-\/\/W3C\/\/DTD XHTML/)&&n.doctype.systemId.match(/http:\/\/www.w3.org\/TR\/xhtml/)){return e.addStatus(r.req,"Has XHTML DOCTYPE. Switching to XHTML Handler.\n"),new xt(this.response,n).parse(e,t,r)}let i=n.getElementsByTagName("html")[0];if(i){let o=i.getAttribute("xmlns");if(o&&o.match(/^http:\/\/www.w3.org\/1999\/xhtml/)){return e.addStatus(r.req,"Has a default namespace for XHTML. Switching to XHTMLHandler.\n"),new xt(this.response,n).parse(e,t,r)}}return e.failFetch(r,"Unsupported dialect of XML: not RDF or XHTML namespace, etc.\n"+t.slice(0,80),901)}}Tt.pattern=new RegExp("(text|application)/(.*)xml");class Ft extends Et{static toString(){return"HTMLHandler"}static register(e){e.mediatypes["text/html"]={q:.8}}parse(e,t,r){let n=e.store;if(Rt(t)){return e.addStatus(r.req,"Has an XML declaration. We'll assume it's XHTML as the content-type was text/html.\n"),new xt(this.response).parse(e,t,r)}if(function(e){const t=e.indexOf("<!DOCTYPE html"),r=e.indexOf(">");if(-1===t||-1===r||t>r)return!1;return-1!==e.substr(t,r-t).indexOf("XHTML")}(t)){return e.addStatus(r.req,"Has XHTML DOCTYPE. Switching to XHTMLHandler.\n"),new xt(this.response).parse(e,t,r)}if(function(e){const t=e.match(/[^(<html)]*<html\s+[^<]*xmlns=['"]http:\/\/www.w3.org\/1999\/xhtml["'][^<]*>/);return!!t}(t)){return e.addStatus(r.req,"Has default namespace for XHTML, so switching to XHTMLHandler.\n"),new xt(this.response).parse(e,t,r)}let i=new RegExp("<title>([\\s\\S]+?)</title>","im").exec(t);return i&&n.add(r.resource,St.dc("title"),n.rdfFactory.literal(i[1]),r.resource),n.add(r.resource,St.rdf("type"),St.link("WebPage"),e.appNode),e.addStatus(r.req,"non-XML HTML document, not parsed for data."),e.doneFetch(r,this.response)}}Ft.pattern=new RegExp("text/html");class kt extends Et{static toString(){return"JsonLdHandler"}static register(e){e.mediatypes["application/ld+json"]={q:.9}}async parse(e,t,r,n){const i=e.store;try{return await xe(t,i,r.original.value),e.store.add(r.original,St.rdf("type"),St.link("RDFDocument"),e.appNode),e.doneFetch(r,n)}catch(t){const i="Error trying to parse "+r.resource+" as JSON-LD:\n"+t;return e.failFetch(r,i,"parse_error",n)}}}kt.pattern=/application\/(ld\+json|activity\+json)/;class It extends Et{static toString(){return"TextHandler"}static register(e){e.mediatypes["text/plain"]={q:.5}}parse(e,t,r){if(Rt(t)){return e.addStatus(r.req,"Warning: "+r.resource+" has an XML declaration. We'll assume it's XML but its content-type wasn't XML.\n"),new Tt(this.response).parse(e,t,r)}if(t.slice(0,500).match(/xmlns:/)){return e.addStatus(r.req,"May have an XML namespace. We'll assume it's XML but its content-type wasn't XML.\n"),new Tt(this.response).parse(e,t,r)}return e.addStatus(r.req,"Plain text document, no known RDF semantics."),e.doneFetch(r,this.response)}}It.pattern=new RegExp("text/plain");class Ct extends Et{static toString(){return"N3Handler"}static register(e){e.mediatypes["text/n3"]={},e.mediatypes["text/turtle"]={}}parse(e,t,r,n){let i=e.store,o=ve(i,i,r.original.value,r.original.value,null,null,"",null);try{o.loadBuf(t)}catch(t){let i="Error trying to parse "+r.resource+" as Notation3:\n"+t;return e.failFetch(r,i,"parse_error",n)}return e.addStatus(r.req,"N3 parsed: "+o.statementCount+" triples in "+o.lines+" lines."),e.store.add(r.original,St.rdf("type"),St.link("RDFDocument"),e.appNode),e.doneFetch(r,this.response)}}Ct.pattern=new RegExp("(application|text)/(x-)?(rdf\\+)?(n3|turtle)");const Nt={RDFXMLHandler:At,XHTMLHandler:xt,XMLHandler:Tt,HTMLHandler:Ft,TextHandler:It,N3Handler:Ct,JsonLdHandler:kt};function Rt(e){return!!e.match(/\s*<\?xml\s+version\s*=[^<>]+\?>/)}class Pt{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if((0,n.A)(this,"store",void 0),(0,n.A)(this,"timeout",void 0),(0,n.A)(this,"_fetch",void 0),(0,n.A)(this,"mediatypes",void 0),(0,n.A)(this,"appNode",void 0),(0,n.A)(this,"requested",void 0),(0,n.A)(this,"timeouts",void 0),(0,n.A)(this,"redirectedTo",void 0),(0,n.A)(this,"fetchQueue",void 0),(0,n.A)(this,"fetchCallbacks",void 0),(0,n.A)(this,"nonexistent",void 0),(0,n.A)(this,"lookedUp",void 0),(0,n.A)(this,"handlers",void 0),(0,n.A)(this,"ns",void 0),(0,n.A)(this,"fireCallbacks",void 0),this.store=e||new G,this.ns=_t(this.store.rdfFactory),this.timeout=t.timeout||3e4,this._fetch=t.fetch||void 0!==r.g&&(r.g.solidFetcher||r.g.solidFetch)||"undefined"!=typeof window&&(window.solidFetcher||window.solidFetch)||mt(),!this._fetch)throw new Error("No _fetch function available for Fetcher");this.appNode=this.store.sym("chrome://TheCurrentSession"),this.store.fetcher=this,this.requested={},this.timeouts={},this.redirectedTo={},this.fetchQueue={},this.fetchCallbacks={},this.nonexistent={},this.lookedUp={},this.handlers=[],this.mediatypes={"image/*":{q:.9},"*/*":{q:.1}},k.callbackify(this,["request","fail","refresh","retract","done"]),Object.keys(t.handlers||Nt).map(e=>this.addHandler(Nt[e]))}static crossSiteProxy(e){return Pt.crossSiteProxyTemplate?Pt.crossSiteProxyTemplate.replace("{uri}",encodeURIComponent(e)):void 0}static offlineOverride(e){let t=e;var r;return"undefined"!=typeof window&&window.panes&&(r=window.panes.UI)&&r.preferences&&r.preferences.get("offlineModeUsingLocalhost")&&"http://"===t.slice(0,7)&&"localhost/"!==t.slice(7,17)&&(t="http://localhost/"+t.slice(7),T.A.warn("Localhost kludge for offline use: actually getting <"+t+">")),t}static proxyIfNecessary(e){var t;if("undefined"!=typeof window&&window.panes&&(t=window.panes.UI)&&t.isExtension)return e;if("undefined"!=typeof $SolidTestEnvironment&&$SolidTestEnvironment.localSiteMap){let t=e.split("/").slice(2);const r=(e,t)=>{let n=t[e.shift()];return n?"string"==typeof n?n+e.join("/"):e?r(e,n):null:null},n=r(t,$SolidTestEnvironment.localSiteMap);if(n)return n}return Pt.crossSiteProxyTemplate&&"undefined"!=typeof document&&document.location&&"https:"===(""+document.location).slice(0,6)&&"http:"===e.slice(0,5)?Pt.crossSiteProxyTemplate.replace("{uri}",encodeURIComponent(e)):e}static unsupportedProtocol(e){let t=b.protocol(e);return"tel"===t||"mailto"===t||"urn"===t}static setCredentials(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};void 0===t.credentials&&(void 0!==t.withCredentials?t.credentials=t.withCredentials?"include":"omit":t.credentials="include")}load(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t=Object.assign({},t),e instanceof Array)return Promise.all(e.map(e=>this.load(e,Object.assign({},t))));const r=e;let n=(0,vt.E)(r);n=n.split("#")[0],t=this.initFetchOptions(n,t);const i=this.appNode,o=this.store,s=o.statementsMatching(void 0,this.ns.link("requestedURI"),o.sym(n),i).map(e=>e.subject);for(const e of s){const r=o.any(e,this.ns.link("response"),null,i);if(null!=r){const e=o.statementsMatching(r,this.ns.link("outOfDate"),!0,i);o.remove(e),t.force=!0,t.clearPreviousData=!0}}const a=this.initFetchOptions(n,t);return this.pendingFetchPromise(n,a.baseURI,a)}async pendingFetchPromise(e,t,r){let n;return!r.force&&await this.fetchQueue[t]?n=this.fetchQueue[t]:(n=Promise.race([this.setRequestTimeout(e,r),this.fetchUri(e,r)]),this.fetchQueue[t]=n,this.cleanupFetchRequest(t,void 0,this.timeout)),n.then(t=>(e in this.timeouts&&(this.timeouts[e].forEach(clearTimeout),delete this.timeouts[e]),t))}cleanupFetchRequest(e,t,r){void 0!==t&&console.warn("_options is deprecated"),this.timeouts[e]=(this.timeouts[e]||[]).concat(setTimeout(()=>{this.isPending(e)||delete this.fetchQueue[e]},r))}initFetchOptions(e,t){let r=this.store;!t.method||"GET"===t.method.toUpperCase()||(t.force=!0),t.resource=r.rdfFactory.namedNode(e),t.baseURI=t.baseURI||e,t.original=r.rdfFactory.namedNode(t.baseURI),t.req=r.bnode(),t.headers=t.headers||{},t.contentType&&(t.headers["content-type"]=t.contentType),t.force&&(t.cache="no-cache");let n=this.acceptString();t.headers.accept=n;let i=Pt.offlineOverride(e);t.requestedURI=i,Pt.setCredentials(i,t);let o=Pt.proxyIfNecessary(i);return i!==o&&(t.proxyUsed=!0),t.actualProxyURI=o,t}fetchUri(e,t){if(!e)return Promise.reject(new Error("Cannot fetch an empty uri"));if(Pt.unsupportedProtocol(e))return this.failFetch(t,"fetcher: Unsupported protocol","unsupported_protocol");let r=this.getState(e);if(t.force)delete this.nonexistent[e];else{if("fetched"===r)return Promise.resolve(this.doneFetch(t,{status:200,ok:!0,statusText:"Already loaded into quadstore."}));if("failed"===r&&404===this.requested[e]){let r="Previously failed: "+this.requested[e],n={url:e,status:this.requested[e],statusText:r,responseText:r,headers:new yt.Headers,ok:!1,body:null,bodyUsed:!1,size:0,timeout:0};return this.failFetch(t,r,this.requested[e],n)}}this.fireCallbacks("request",[e]),this.requested[e]=!0,t.noMeta||this.saveRequestMetadata(e,t);let{actualProxyURI:n}=t;return this._fetch(n,t).then(r=>this.handleResponse(r,e,t),r=>{let i={url:n,status:999,statusText:(r.name||"network failure")+": "+(r.errno||r.code||r.type),responseText:r.message,headers:new yt.Headers,ok:!1,body:null,bodyUsed:!1,size:0,timeout:0};return this.handleError(i,e,t)})}nowOrWhenFetched(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const i=(0,vt.E)(e);"function"==typeof t?r=t:void 0===t||((0,u.Y2)(t)?n.referringTerm=t:n=t),this.load(i,n).then(e=>{if(r)if(e)if(e.ok)r(!0,"OK",e);else{let t="HTTP error: Status "+e.status+" ("+e.statusText+")";e.responseText&&(t+=" "+e.responseText),r(!1,t,e)}else{r(!1,"@@ nowOrWhenFetched: no response object!")}},function(e){var t=e.message||e.statusText;t="Failed to load <"+i+"> "+t,e.response&&e.response.status&&(t+=" status: "+e.response.status),r(!1,t,e.response)})}addStatus(e,t){let r=new Date;t="["+r.getHours()+":"+r.getMinutes()+":"+r.getSeconds()+"."+r.getMilliseconds()+"] "+t;let n=this.store;const i=n.the(e,this.ns.link("status"));(0,u.P3)(i)?i.append(n.rdfFactory.literal(t)):T.A.warn("web.js: No list to add to: "+i+","+t)}failFetch(e,t,r,n){this.addStatus(e.req,t),e.noMeta||this.store.add(e.original,this.ns.link("error"),this.store.rdfFactory.literal(t));let i=(e.method||"GET").toUpperCase();("GET"===i||"HEAD"===i)&&(e.resource.equals(e.original),this.requested[b.docpart(e.original.value)]=r,this.fireCallbacks("fail",[e.original.value,t]));var o=new Error("Fetcher: "+t);return o.status=r,o.statusText=t,o.response=n,Promise.reject(o)}linkData(e,t,r,n,i){if(!r)return;let o,s=this.store,a=s.rdfFactory.namedNode(b.join(r,e.value));if("alternate"===t||"seeAlso"===t||"meta"===t||"describedby"===t){if(a.value===e.value)return;o=this.ns.rdfs("seeAlso")}else o="type"===t?s.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"):s.rdfFactory.namedNode(b.join(encodeURIComponent(t),"http://www.iana.org/assignments/link-relations/"));i?s.add(a,o,e,n):s.add(e,o,a,n)}parseLinkHeader(e,t,r){if(!e)return;const n=/[^\(\)<>@,;:"\/\[\]\?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*"))/g,i=e.match(/<[^>]*>\s*(\s*;\s*[^()<>@,;:"/[\]?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*")))*(,|$)/g);if(null!=i)for(let e=0;e<i.length;e++){let o=i[e].split(">"),s=o[0].substring(1),a=o[1].match(n);if(null==a)return;for(let e=0;e<a.length;e++){let n=a[e].split("=")[1].replace(/["']/g,"");this.linkData(t,n,s,r)}}}doneFetch(e,t){return this.addStatus(e.req,"Done."),this.requested[e.original.value]="done",this.fireCallbacks("done",[e.original.value]),t.req=e.req,t}nowKnownAs(e,t){this.lookedUp[e.value]?this.lookedUp[t.value]||this.lookUpThing(t,e):this.lookedUp[t.value]&&(this.lookedUp[e.value]||this.lookUpThing(e,t))}putBack(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=(0,vt.E)(e);let n=new c.A(r).doc();return t.contentType=t["content-type"]||t["Content-Type"]||t.contentType||s.sT,"application/ld+json"===t.contentType?new Promise((r,i)=>{D(n,this.store,n.uri,t.contentType,(n,o)=>{n?i(n):(t.data=o,this.webOperation("PUT",e,t).then(e=>r(e)).catch(e=>i(e)))})}):(t.data=D(n,this.store,n.value,t.contentType),this.webOperation("PUT",r,t))}webCopy(e,t,r){return this.webOperation("GET",e).then(e=>this.webOperation("PUT",t,{data:e.responseText,contentType:r}))}delete(e,t){return this.webOperation("DELETE",e,t).then(t=>(this.requested[e]=404,this.nonexistent[e]=!0,this.unload(this.store.rdfFactory.namedNode(e)),t))}async createIfNotExists(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s.sT,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const n=this;try{var i=await n.load(e)}catch(o){if(404===o.response.status){try{i=await n.webOperation("PUT",e.value,{data:r,contentType:t})}catch(e){throw e}return delete n.requested[e.value],i}throw o}return i}createContainer(e,t,r){let n={"content-type":s.sT,link:this.ns.ldp("BasicContainer")+'; rel="type"'};t&&(n.slug=t);let i={headers:n};return r&&(i.body=r),this.webOperation("POST",e,i)}invalidateCache(e){const t=(0,vt.E)(e),r=this;r.fetchQueue&&r.fetchQueue[t]&&(r.fetchQueue[t].PromiseStatus,delete r.fetchQueue[t]);if(r.requested[t]&&"done"!==r.requested[t]&&"failed"!==r.requested[t]&&404!==r.requested[t]){let e=`Rdflib: fetcher: Destructive operation on <${r.requested[t]}> file being fetched! `+t;console.error(e)}else delete r.requested[t],delete r.nonexistent[t]}webOperation(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=(0,vt.E)(t);r.method=e,r.body=r.data||r.body,r.force=!0;const i=this;if(r.body&&!r.contentType)throw new Error("Web operation sending data must have a defined contentType.");return r.contentType&&(r.headers=r.headers||{},r.headers["content-type"]=r.contentType),Pt.setCredentials(n,r),new Promise(function(t,o){i._fetch(n,r).then(r=>{if(r.ok)"PUT"!==e&&"PATCH"!==e&&"POST"!==e&&"DELETE"!==e||i.invalidateCache(n),r.text?r.text().then(e=>{r.responseText=e,t(r)}):t(r);else{let t="Web error: "+r.status;r.statusText&&(t+=" ("+r.statusText+")"),t+=" on "+e+" of <"+n+">",r.responseText&&(t+=": "+r.responseText);let i=new Error(t);i.response=r,o(i)}},t=>{o(new Error("Fetch error for "+e+" of <"+n+">:"+t))})})}lookUpThing(e,t){let r=this.store.uris(e);return r=r.map(e=>b.docpart(e)),r.forEach(e=>{this.lookedUp[e]=!0}),this.load(r,{referringTerm:t})}getHeader(e,t){const r=this.store,n=e.value,i=r.each(void 0,this.ns.link("requestedURI"),r.rdfFactory.literal(n));for(let e=0;e<i.length;e++){let n=i[e];if(void 0!==n){let e=r.any(n,this.ns.link("response"));if(void 0!==e&&r.anyValue(e,this.ns.http("status"))&&r.anyValue(e,this.ns.http("status")).startsWith("2")){let n=r.each(e,this.ns.httph(t.toLowerCase()));return n.length?n.map(e=>e.value):[]}}}}saveRequestMetadata(e,t){let r=t.req,n=this.store,i=t.referringTerm;this.addStatus(t.req,"Accept: "+t.headers.accept),(0,u.Y2)(i)&&n.add(n.rdfFactory.namedNode(e),this.ns.link("requestedBy"),i,this.appNode),t.original&&t.original.value!==e&&n.add(r,this.ns.link("orginalURI"),n.rdfFactory.literal(t.original.value),this.appNode);const o=new Date,s="["+o.getHours()+":"+o.getMinutes()+":"+o.getSeconds()+"] ";n.add(r,this.ns.rdfs("label"),n.rdfFactory.literal(s+" Request for "+e),this.appNode),n.add(r,this.ns.link("requestedURI"),n.rdfFactory.literal(e),this.appNode),n.add(r,this.ns.link("status"),n.collection(),this.appNode)}saveResponseMetadata(e,t){const r=this.store;let n=r.bnode();return r.add(t.req,this.ns.link("response"),n,this.appNode),r.add(n,this.ns.http("status"),r.rdfFactory.literal(e.status),this.appNode),r.add(n,this.ns.http("statusText"),r.rdfFactory.literal(e.statusText),this.appNode),e.headers.forEach((e,i)=>{r.add(n,this.ns.httph(i),this.store.rdfFactory.literal(e),this.appNode),"content-type"===i&&r.add(t.resource,this.ns.rdf("type"),r.rdfFactory.namedNode(k.mediaTypeClass(e).value),this.appNode)}),n}objectRefresh(e){let t=this.store.uris(e);if(void 0!==t)for(let e=0;e<t.length;e++)this.refresh(this.store.rdfFactory.namedNode(b.docpart(t[e])))}refresh(e,t){this.fireCallbacks("refresh",arguments),this.nowOrWhenFetched(e,{force:!0,clearPreviousData:!0},t)}refreshIfExpired(e,t){let r=this.getHeader(e,"Expires");!r||new Date(r[0]).getTime()<=(new Date).getTime()?this.refresh(e,t):t(!0,"Not expired",{})}retract(e){this.store.removeMany(void 0,void 0,void 0,e),e.value&&delete this.requested[b.docpart(e.value)],this.fireCallbacks("retract",arguments)}getState(e){return void 0===this.requested[e]?"unrequested":!0===this.requested[e]?"requested":"done"===this.requested[e]?"fetched":"redirected"===this.requested[e]?this.getState(this.redirectedTo[e]):"failed"}isPending(e){return!0===this.requested[e]}unload(e){this.store.removeDocument(e),delete this.requested[e.value]}addHandler(e){this.handlers.push(e),e.register(this)}retryNoCredentials(e,t){t.retriedWithNoCredentials=!0,delete this.requested[e],delete this.fetchQueue[e];let r=Object.assign({},t,{credentials:"omit"});return this.addStatus(t.req,"Abort: Will retry with credentials SUPPRESSED to see if that helps"),this.load(e,r)}isCrossSite(e){if("undefined"==typeof document||!document.location)return!1;const t=b.hostpart,r=""+document.location;return(t(r)&&t(e)&&t(r))!==t(e)}handleError(e,t,r){if(this.isCrossSite(t)){if(r.credentials&&"include"===r.credentials&&!r.retriedWithNoCredentials)return this.retryNoCredentials(t,r);let e=Pt.crossSiteProxy(t);if(e&&!r.proxyUsed)return this.redirectToProxy(e,r)}var n;return e instanceof Error?n="Fetch error: "+e.message:(n=e.statusText,e.responseText&&(n+=` ${e.responseText}`)),this.failFetch(r,n,e.status||998,e)}addType(e,t,r,n){let i=t;if(n){var o=r.any(i,this.ns.link("requestedURI"));o&&o.value!==n&&r.add(r.rdfFactory.namedNode(n),this.ns.rdf("type"),e,this.appNode)}for(;;){const t=r.any(i,this.ns.link("requestedURI"));if(t&&t.value&&r.add(r.rdfFactory.namedNode(t.value),this.ns.rdf("type"),e,this.appNode),i=r.any(void 0,r.rdfFactory.namedNode("http://www.w3.org/2007/ont/link#redirectedRequest"),i),!i)break;var s=r.any(i,r.rdfFactory.namedNode("http://www.w3.org/2007/ont/link#response"));if(!s)break;var a=r.any(s,r.rdfFactory.namedNode("http://www.w3.org/2007/ont/http#status"));if(!a)break;if("301"!==a&&"302"!==a)break}}handleResponse(e,t,r){const n=this.store,i=e.headers,o=r.req,s=this.saveResponseMetadata(e,r),a=this.normalizedContentType(r,i)||"";let c=i.get("content-location");if(0===e.status)return this.handleError(e,t,r);if(e.status>=400)return 404===e.status&&(this.nonexistent[r.original.value]=!0,this.nonexistent[t]=!0),this.saveErrorResponse(e,s).then(()=>{let t=r.resource+" "+e.statusText;return this.failFetch(r,t,e.status,e)});var u=null,l=null;if(c&&(l=b.join(c,t))!==t&&(u=l),200===e.status){if(this.addType(this.ns.link("Document"),o,n,t),u&&this.addType(this.ns.link("Document"),o,n,u),r.clearPreviousData){const e=n.statementsMatching(void 0,void 0,void 0,r.resource).slice();for(let t=0;t<e.length;t++)n.removeStatement(e[t])}let e=a.includes("image/")||a.includes("application/pdf");a&&e&&(this.addType(n.rdfFactory.namedNode("http://purl.org/dc/terms/Image"),o,n,t),u&&this.addType(n.rdfFactory.namedNode("http://purl.org/dc/terms/Image"),o,n,u))}if(c){if(!r.force&&u&&"done"===this.requested[l])return this.doneFetch(r,e);this.requested[l]=!0}this.parseLinkHeader(i.get("link"),r.original,o);let h=this.handlerForContentType(a,e);return h?e.text().then(t=>(e.responseText=t,h.parse(this,t,r,e))):(this.addStatus(o,"Fetch over. No data handled."),this.doneFetch(r,e))}saveErrorResponse(e,t){let r=this.store;return e.text().then(e=>{e.length>10&&r.add(t,this.ns.http("content"),r.rdfFactory.literal(e),t)})}handlerForContentType(e,t){if(!e)return null;let r=this.handlers.find(t=>e.match(t.pattern));return r?new r(t):null}guessContentType(e){return bt[e.split(".").pop()]}normalizedContentType(e,t){if(e.forceContentType)return e.forceContentType;let r=t.get("content-type");if(!r||r.includes("application/octet-stream")){let t=this.guessContentType(e.resource.value);if(t)return t}let n=b.protocol(e.resource.value);return!r&&["file","chrome"].includes(n)?"text/xml":r}redirectToProxy(e,t){this.addStatus(t.req,"BLOCKED -> Cross-site Proxy to <"+e+">"),t.proxyUsed=!0;const r=this.store,n=t.req;t.noMeta||(r.add(n,this.ns.link("redirectedTo"),r.rdfFactory.namedNode(e),n),this.addStatus(n,"redirected to new request")),this.requested[t.resource.value]="redirected",this.redirectedTo[t.resource.value]=e;let i=Object.assign({},t);return i.baseURI=t.resource.value,this.fetchUri(e,i).then(e=>(i.noMeta||r.add(n,this.ns.link("redirectedRequest"),i.req,this.appNode),e))}setRequestTimeout(e,t){return new Promise(r=>{this.timeouts[e]=(this.timeouts[e]||[]).concat(setTimeout(()=>{!this.isPending(e)||t.retriedWithNoCredentials||t.proxyUsed||r(this.failFetch(t,`Request to ${e} timed out`,"timeout"))},this.timeout))})}addFetchCallback(e,t){this.fetchCallbacks[e]?this.fetchCallbacks[e].push(t):this.fetchCallbacks[e]=[t]}acceptString(){let e="";for(let t in this.mediatypes){""!==e&&(e+=", "),e+=t;for(let r in this.mediatypes[t])e+=";"+r+"="+this.mediatypes[t][r]}return e}}(0,n.A)(Pt,"HANDLERS",void 0),(0,n.A)(Pt,"CONTENT_TYPE_BY_EXT",void 0),(0,n.A)(Pt,"crossSiteProxyTemplate",void 0),Pt.HANDLERS=Nt,Pt.CONTENT_TYPE_BY_EXT=bt;const Ot={parseJSON:function(e,t,r){var n,i,o,s={},a=r.sym(t);for(var c in e){0===c.indexOf("_:")?s[c]?n=s[c]:(n=r.bnode(c),s[c]=n):n=r.sym(c);var u=e[c];for(var l in u){var h=u[l];for(var d in i=r.sym(l),h){var f=h[d];if("uri"===f.type)o=r.sym(f.value),r.add(n,i,o,a);else if("BlankNode"===f.type)s[f.value]?o=s[f.value]:(o=r.bnode(f.value),s[f.value]=o),r.add(n,i,o,a);else{if("Literal"!==f.type)throw new Error("error: unexpected termtype: "+d.type);o=f.datatype?r.literal(f.value,void 0,r.sym(f.datatype)):f.lang?r.literal(f.value,f.lang):r.literal(f.value),r.add(n,i,o,a)}}}}}};function Dt(e){var t=0;function r(e){var t="",r=e.statements;for(var n in r)T.A.debug("Found statement: "+r),t+=s()+r[n]+"\n";return t}function n(e){var t="";for(var r in e.constraints){var n=e.constraints[r];t+=s()+"FILTER ( "+n.describe(r)+" ) \n"}return t}function i(e){for(var o="",a=0;a<e.optional.length;a++)T.A.debug("Found optional query"),o+=s()+"OPTIONAL { \n",t++,o+=r(e.optional[a]),o+=n(e.optional[a]),o+=i(e.optional[a]),t--,o+=s()+"}\n";return o}function o(e){var o=s()+"WHERE \n{ \n";return t++,o+=r(e),o+=n(e),o+=i(e),t--,o+="}"}function s(){for(var e="",r=0;r<t;r++)e+=" ";return e}return function(e){return function(e){for(var t=s()+"SELECT ",r=0;r<e.vars.length;r++)t+=e.vars[r]+" ";return t+"\n"}(e)+o(e.pat)}(e)}function Ut(e,t,r){var n=[];function i(e){if(n[e])return n[e];var t=r.variable(e);return n[e]=t,t}function o(e){return"string"==typeof e&&e.match(/[^ \n\t]/)}function s(e){return"string"==typeof e&&e.match(/^[\?\$]/)}function a(e){return"string"==typeof e?e.replace(/^</,"<").replace(/>$/,">"):e}function c(e){return"string"==typeof e&&e.match(/^<[^>]*>$/)}function u(e){return"string"==typeof e&&(e.match(/^_:/)||e.match(/^$/))}function l(e){return"string"==typeof e&&e.match(/:$/)}function h(e){return"string"==typeof e&&e.match(/^:|^[^_][^:]*:/)}function d(e){return e.split(":")[0]}function f(e){return e.split(":")[1]}function p(e){return c(e)?e.slice(1,e.length-1):e}function g(e){var t=-1===e.indexOf("'")?null:e.indexOf("'"),n=-1===e.indexOf('"')?null:e.indexOf('"');if(!t&&!n){var i=new Array(1);return i[0]=e,i}var o,s,a=new Array(2);if(!t||n&&n<t)o='"',s=n;else{if(n&&!(t&&t<n))return T.A.error("SQARQL QUERY OOPS!"),a;o="'",s=t}a[0]=e.slice(0,s);var c,u=e.slice(s+1).indexOf(o);return-1===u?(T.A.error("SPARQL parsing error: no matching parentheses in literal "+e),e):(e.slice(u+s+2).match(/^\^\^/)?(c=e.slice(u+s+2).indexOf(" "),a[1]=r.literal(e.slice(s+1,s+1+u),r.sym(p(e.slice(s+4+u,s+2+u+c)))),a=a.concat(g(e.slice(u+s+3+c)))):e.slice(u+s+2).match(/^@/)?(c=e.slice(u+s+2).indexOf(" "),a[1]=r.literal(e.slice(s+1,s+1+u),e.slice(s+3+u,s+2+u+c),null),a=a.concat(g(e.slice(u+s+2+c)))):(a[1]=r.literal(e.slice(s+1,s+1+u)),T.A.info("Literal found: "+a[1]),a=a.concat(g(e.slice(u+s+2)))),a)}function y(e){e=e.replace(/\(/g," ( ").replace(/\)/g," ) ").replace(/</g," <").replace(/>/g,"> ").replace(/{/g," { ").replace(/}/g," } ").replace(/[\t\n\r]/g," ").replace(/; /g," ; ").replace(/\. /g," . ").replace(/, /g," , "),T.A.info("New str into spaceDelimit: \n"+e);var t=[],r=e.split(" ");for(var n in r)o(r[n])&&(t=t.concat(r[n]));return t}function m(e,t){for(var r=0;r<t.length;r++)if("string"==typeof t[r]&&t[r].toLowerCase()===e.toLowerCase())return r;return null}function v(e,t){for(var r=[],n=0;n<t.length;n++)"string"==typeof t[n]&&t[n].toLowerCase()===e.toLowerCase()&&r.push(n);return r}function w(e,t,r){T.A.info("Looking for a close bracket of type "+r+" in "+e);for(var n=0,i=0;i<e.length;i++)if(e[i]===t&&n++,e[i]===r&&n--,n<0)return i;return T.A.error("Statement had no close parenthesis in SPARQL query"),0}function b(e){return this.describe=function(t){return t+" = "+e.toNT()},this.test=function(t){return e.equals(t)},this}function _(e){this.describe=function(t){return"REGEXP( '"+e+"' , "+t+" )"},this.test=function(t){var r=new RegExp(e);return!!t.value&&r.test(t.value)}}function S(e,t){3!==e.length||"Variable"!==e[0].termType||"NamedNode"!==e[2].termType&&"Literal"!==e[2].termType?6===e.length&&"string"==typeof e[0]&&"regexp"===e[0].toLowerCase()&&"("===e[1]&&")"===e[5]&&","===e[3]&&"Variable"===e[4].termType&&"Literal"===e[2].termType&&(T.A.debug("Constraint added: "+e),t.constraints[e[4]]=new _(e[2].value)):"="===e[1]||">"===e[1]||"<"===e[1]?(T.A.debug("Constraint added: "+e),t.constraints[e[0]]=new b(e[2])):T.A.warn("I don't know how to handle the constraint: "+e)}function E(e,t){T.A.debug("Optional query: "+e+" not yet implemented.");var n=r.formula();A(e,n),t.optional.push(n)}function A(e,t){var n,o,l=function(e){for(var t=[],n=0;n<e.length;n++)"string"==typeof e[n]?(e[n]=a(e[n]),s(e[n])?t[n]=i(e[n].slice(1)):u(e[n])?(T.A.info(e[n]+" was identified as a bnode."),t[n]=r.bnode()):c(e[n])?(T.A.info(e[n]+" was identified as a symbol."),t[n]=r.sym(p(e[n]))):h(e[n])?(T.A.info(e[n]+" was identified as a prefixed symbol"),k[d(e[n])]?t[n]=r.sym(e[n]=k[d(e[n])]+f(e[n])):(T.A.error("SPARQL error: "+e[n]+" with prefix "+d(e[n])+" does not have a correct prefix entry."),t[n]=e[n])):t[n]=e[n]):t[n]=e[n];return t}(e);for(T.A.debug("WHERE: "+l);m("OPTIONAL",l);)o=m("OPTIONAL",l),T.A.debug("OPT: "+o+" "+l[o]+" in "+l),"{"!==l[o+1]&&T.A.warn("Bad optional opening bracket in word "+o),-1===(n=w(l.slice(o+2),"{","}"))?T.A.error("No matching bracket in word "+o):(E(l.slice(o+2,o+2+n),t),o=m("OPTIONAL",l),n=w(l.slice(o+2),"{","}"),l.splice(o,n+3));for(T.A.debug("WHERE after optionals: "+l);m("FILTER",l);){var g=m("FILTER",l);"("!==l[g+1]&&T.A.warn("Bad filter opening bracket in word "+g),-1===(n=w(l.slice(g+2),"(",")"))?T.A.error("No matching bracket in word "+g):(S(l.slice(g+2,g+2+n),t),g=m("FILTER",l),n=w(l.slice(g+2),"(",")"),l.splice(g,n+3))}T.A.debug("WHERE after filters and optionals: "+l),function(e,t){var r=new Array(1);r[0]=-1;for(var n=r.concat(v(".",e)),i=[],o=0;o<n.length-1;o++)i[o]=e.slice(n[o]+1,n[o+1]);for(o in i){T.A.info("s+p+o "+o+" = "+i[o]);var s=i[o][0];i[o].splice(0,1);var a=r.concat(v(";",i[o]));a.push(i[o].length);for(var c=[],u=0;u<a.length-1;u++)c[u]=i[o].slice(a[u]+1,a[u+1]);for(o in c){T.A.info("p+o "+o+" = "+i[o]);var l=c[o][0];c[o].splice(0,1);var h=r.concat(v(",",c[o]));h.push(c[o].length);var d=[];for(u=0;u<h.length-1;u++)d[u]=c[o].slice(h[u]+1,h[u+1]);for(o in d){var f=d[o][0];T.A.info("Subj="+s+" Pred="+l+" Obj="+f),t.add(s,l,f)}}}}(l,t)}T.A.info("SPARQL input: \n"+e);var x=new K,F=function(e){var t=g(e),r=[];for(var n in t)r="string"==typeof t[n]?r.concat(y(t[n])):r.concat(t[n]);return r=function(e){for(var t=e,r=0;r<t.length;r++)if("a"===t[r]&&(t[r]="<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>"),"is"===t[r]&&"of"===t[r+2]){t.splice(r,1),t.splice(r+1,1);var n=t[r-1];t[r-1]=t[r+1],t[r+1]=n}return t}(r),T.A.info("SPARQL Tokens: "+r),r}(e),k=function(e){var t=v("PREFIX",e),r=[];for(var n in t){var i=e[t[n]+1],o=e[t[n]+2];if(l(i))if(c(o)){T.A.info("Prefix found: "+i+" -> "+o);var s=d(i),a=p(o);r[s]=a}else T.A.error("Invalid SPARQL symbol: "+o);else T.A.error("Invalid SPARQL prefix: "+i)}return r}(F);k.rdf||(k.rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"),k.rdfs||(k.rdfs="http://www.w3.org/2000/01/rdf-schema#");var I=m("SELECT",F),C=m("WHERE",F);if(I<0||C<0||I>C)return T.A.error("Invalid or nonexistent SELECT and WHERE tags in SPARQL query"),!1;if(function(e,t){for(var r in T.A.info("SPARQL vars: "+e),e)if(s(e[r])){T.A.info("Added "+e[r]+" to query variables from SPARQL");var n=i(e[r].slice(1));t.vars.push(n),n.label=e[r].slice(1)}else T.A.warn("Incorrect SPARQL variable in SELECT: "+e[r])}(F.slice(I+1,C),x),A(F.slice(C+2,F.length-1),x.pat),t)return x;for(var N in x.pat.statements){var R=x.pat.statements[N];"NamedNode"===R.subject.termType&&r.fetcher&&r.fetcher.lookUpThing(R.subject,"sparql:"+R.subject),"NamedNode"===R.object.termType&&r.fetcher&&r.fetcher.lookUpThing(R.object,"sparql:"+R.object)}return x}class Lt{constructor(e){if((0,n.A)(this,"store",void 0),(0,n.A)(this,"ifps",void 0),(0,n.A)(this,"fps",void 0),(0,n.A)(this,"patchControl",void 0),(0,n.A)(this,"ns",void 0),(e=e||new G).updater)throw new Error("You can't have two UpdateManagers for the same store");e.fetcher||(e.fetcher=new Pt(e)),this.store=e,e.updater=this,this.ifps={},this.fps={},this.ns={},this.ns.link=F("http://www.w3.org/2007/ont/link#"),this.ns.http=F("http://www.w3.org/2007/ont/http#"),this.ns.httph=F("http://www.w3.org/2007/ont/httph#"),this.ns.ldp=F("http://www.w3.org/ns/ldp#"),this.ns.rdf=F("http://www.w3.org/1999/02/22-rdf-syntax-ns#"),this.ns.rdfs=F("http://www.w3.org/2000/01/rdf-schema#"),this.ns.rdf=F("http://www.w3.org/1999/02/22-rdf-syntax-ns#"),this.ns.owl=F("http://www.w3.org/2002/07/owl#"),this.patchControl=[]}patchControlFor(e){return this.patchControl[e.value]||(this.patchControl[e.value]=[]),this.patchControl[e.value]}isHttpUri(e){return"http"===e.slice(0,4)}flagAuthorizationMetadata(e){e||(e=this.store);const t=e.fetcher?.appNode,r=e.statementsMatching(void 0,this.ns.link("requestedURI"),void 0,t).map(e=>e.subject);for(const n of r){const r=e.any(n,this.ns.link("response"),null,t);null!=r&&e.add(r,this.ns.link("outOfDate"),!0,t)}}async checkEditable(e,t){if(!e)return!1;t||(t=this.store);const r=this.editable(e,t);if(void 0!==r)return r;await(t.fetcher?.load(e));return this.editable(e,t)}editable(e,t){if(!e)return!1;if(t||(t=this.store),e=(0,vt.E)(e),!this.isHttpUri(e)&&t.holds(t.rdfFactory.namedNode(e),t.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),t.rdfFactory.namedNode("http://www.w3.org/2007/ont/link#MachineEditableDocument")))return"LOCALFILE";var r,n=!1;const i=t.fetcher?.appNode;for(var o,s=t.each(void 0,this.ns.link("requestedURI"),(0,b.docpart)(e),i),a=0;a<s.length;a++)if(void 0!==(r=s[a])){const s=t.any(r,this.ns.link("response"),null,i);if(void 0!==s){if(t.anyJS(s,this.ns.link("outOfDate"),null,i))continue;var c=t.anyValue(s,this.ns.httph("wac-allow"));if(c)for(var u of c.split(",")){var l=u.split("=");if(l[0].includes("user")&&!l[1].includes("write")&&!l[1].includes("append"))return!1}var h=t.each(s,this.ns.httph("accept-patch"));if(h.length)for(let e=0;e<h.length;e++){if((o=h[e].value.trim()).indexOf("application/sparql-update")>=0)return"SPARQL";if(o.indexOf("application/sparql-update-single-match")>=0)return"SPARQL";if(o.indexOf("text/n3")>=0)return"N3PATCH"}var d=t.each(s,this.ns.httph("ms-author-via"));if(d.length)for(let e=0;e<d.length;e++){if((o=d[e].value.trim()).indexOf("SPARQL")>=0)return"SPARQL";if(o.indexOf("DAV")>=0)return"DAV"}if(!this.isHttpUri(e))return!!c&&"LOCALFILE";var f=t.each(s,this.ns.http("status"));if(f.length)for(let e=0;e<f.length;e++)200!==f[e]&&404!==f[e]||(n=!0)}}if(0===s.length);else if(n)return!1}anonymize(e){return"_:"===e.toNT().substr(0,2)&&this.mentioned(e)?"?"+e.toNT().substr(2):e.toNT()}anonymizeNT(e){return this.anonymize(e.subject)+" "+this.anonymize(e.predicate)+" "+this.anonymize(e.object)+" ."}nTriples(e){return`${e.subject.toNT()} ${e.predicate.toNT()} ${e.object.toNT()} .`}statementBnodes(e){return[e.subject,e.predicate,e.object].filter(function(e){return(0,u.jt)(e)})}statementArrayBnodes(e){var t=[];for(let r=0;r<e.length;r++)t=t.concat(this.statementBnodes(e[r]));t.sort();var r=[];for(let e=0;e<t.length;e++)0!==e&&t[e].equals(t[e-1])||r.push(t[e]);return r}cacheIfps(){this.ifps={};var e=this.store.each(void 0,this.ns.rdf("type"),this.ns.owl("InverseFunctionalProperty"));for(let t=0;t<e.length;t++)this.ifps[e[t].value]=!0;this.fps={},e=this.store.each(void 0,this.ns.rdf("type"),this.ns.owl("FunctionalProperty"));for(let t=0;t<e.length;t++)this.fps[e[t].value]=!0}bnodeContext2(e,t,r){var n,i,o=this.store.statementsMatching(void 0,void 0,e,t);for(let e=0;e<o.length;e++)if(this.fps[o[e].predicate.value]){if(!(n=o[e].subject).isBlank)return[o[e]];if(r&&(i=this.bnodeContext2(n,t,r-1)))return i.concat([o[e]])}o=this.store.statementsMatching(e,void 0,void 0,t);for(let e=0;e<o.length;e++)if(this.ifps[o[e].predicate.value]){if(!(n=o[e].object).isBlank)return[o[e]];if(r&&(i=this.bnodeContext2(n,t,r-1)))return i.concat([o[e]])}return null}bnodeContext1(e,t){for(var r=0;r<3;r++){var n=this.bnodeContext2(e,t,r);if(null!==n)return n}return this.store.connectedStatements(e,t)}mentioned(e){return 0!==this.store.statementsMatching(e,null,null,null).length||0!==this.store.statementsMatching(null,e).length||0!==this.store.statementsMatching(null,null,e).length}bnodeContext(e,t){var r=[];if(e.length){this.cacheIfps();for(let i=0;i<e.length;i++){var n=e[i];this.mentioned(n)&&(r=r.concat(this.bnodeContext1(n,t)))}}return r}statementContext(e){var t=this.statementBnodes(e);return this.bnodeContext(t,e.graph)}contextWhere(e){var t=this;return e&&0!==e.length?"WHERE { "+e.map(function(e){return t.anonymizeNT(e)}).join("\n")+" }\n":""}fire(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Promise.resolve().then(()=>{if(!e)throw new Error("No URI given for remote editing operation: "+t);return n.noMeta=!0,n.contentType=n.contentType||"application/sparql-update",n.body=t,this.store.fetcher.webOperation("PATCH",e,n)}).then(n=>{if(!n.ok){let r="UpdateManager: update failed for <"+e+"> status="+n.status+", "+n.statusText+"\n for query: "+t;throw new Error(r)}r(e,n.ok,n.responseText,n)}).catch(t=>{r(e,!1,t.message,t)})}update_statement(e){if(!e||e.graph){var t=this,r=this.statementContext(e);return{statement:e?[e.subject,e.predicate,e.object,e.graph]:void 0,statementNT:e?this.anonymizeNT(e):void 0,where:t.contextWhere(r),set_object:function(e,r){var n=this.where;n+="DELETE DATA { "+this.statementNT+" } ;\n",n+="INSERT DATA { "+this.anonymize(this.statement[0])+" "+this.anonymize(this.statement[1])+" "+this.anonymize(e)+" . }\n",t.fire(this.statement[3].value,n,r)}}}}insert_statement(e,t){var r=e instanceof Array?e[0]:e,n=this.contextWhere(this.statementContext(r));if(e instanceof Array){var i="";for(let t=0;t<e.length;t++)i+=e[t]+"\n";n+="INSERT DATA { "+i+" }\n"}else n+="INSERT DATA { "+this.anonymize(e.subject)+" "+this.anonymize(e.predicate)+" "+this.anonymize(e.object)+" . }\n";this.fire(r.graph.value,n,t)}delete_statement(e,t){var r=e instanceof Array?e[0]:e,n=this.contextWhere(this.statementContext(r));if(e instanceof Array){var i="";for(let t=0;t<e.length;t++)i+=e[t]+"\n";n+="DELETE DATA { "+i+" }\n"}else n+="DELETE DATA { "+this.anonymize(e.subject)+" "+this.anonymize(e.predicate)+" "+this.anonymize(e.object)+" . }\n";this.fire(r.graph.value,n,t)}requestDownstreamAction(e,t){var r=this.patchControlFor(e);if(r.pendingUpstream)if(r.downstreamAction){if(""+r.downstreamAction!=""+t)throw new Error("Can't wait for > 1 different downstream actions")}else r.downstreamAction=t;else t(e)}clearUpstreamCount(e){this.patchControlFor(e).upstreamCount=0}getUpdatesVia(e){var t=this.store.fetcher.getHeader(e,"updates-via");return t&&t.length?t[0].trim():null}addDownstreamChangeListener(e,t){var r=this.patchControlFor(e);r.downstreamChangeListeners||(r.downstreamChangeListeners=[]),r.downstreamChangeListeners.push(t),this.setRefreshHandler(e,e=>{this.reloadAndSync(e)})}reloadAndSync(e){var t=this.patchControlFor(e),r=this;if(t.reloading)t.outOfDate=!0;else{t.reloading=!0;var n=1e3,i=function(){r.reload(r.store,e,function(e,r,o){if(e){if(t.downstreamChangeListeners)for(let e=0;e<t.downstreamChangeListeners.length;e++)t.downstreamChangeListeners[e]();t.reloading=!1,t.outOfDate&&(t.outOfDate=!1,i())}else t.reloading=!1,o&&0===o.status&&(t.reloading=!0,n*=2,setTimeout(i,n))})};i()}}setRefreshHandler(e,t){let r=this.getUpdatesVia(e);var n=t,i=this,o=this,s=1500,a=0;if(!r)return!1;r=(0,b.join)(r,e.value);const c=r.replace(/^http:/,"ws:").replace(/^https:/,"wss:");var u=function(){var t;if("undefined"!=typeof WebSocket)t=new WebSocket(c);else{if("undefined"==typeof window||!window.WebSocket)return;t=window.WebSocket(c)}t.onopen=function(){s=1500,this.send("sub "+e.value),a&&o.requestDownstreamAction(e,n)};var r=i.patchControlFor(e);r.upstreamCount=0,t.onerror=function(e){},t.onclose=function(e){s*=2,a+=1,setTimeout(function(){u()},s)},t.onmessage=function(t){if(t.data&&"pub"===t.data.slice(0,3)){if("upstreamCount"in r&&(r.upstreamCount-=1,r.upstreamCount>=0))return;r.upstreamCount=0,i.requestDownstreamAction(e,n)}}};return u(),!0}updateMany(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const r=e.concat(t).map(e=>e.why),n=this,i=[];r.forEach(e=>{i.find(t=>t.equals(e))||i.push(e)});const o=i.map(r=>n.update(e.filter(e=>e.why.equals(r)),t.filter(e=>e.why.equals(r))));return o.length,Promise.all(o)}constructSparqlUpdateQuery(e,t,r){var n=this.contextWhere(r),i="";if(n.length){if(e.length){i+="DELETE { ";for(let t=0;t<e.length;t++)i+=this.anonymizeNT(e[t])+"\n";i+=" }\n"}if(t.length){i+="INSERT { ";for(let e=0;e<t.length;e++)i+=this.anonymizeNT(t[e])+"\n";i+=" }\n"}i+=n}else{if(e.length){i+="DELETE DATA { ";for(let t=0;t<e.length;t++)i+=this.anonymizeNT(e[t])+"\n";i+=" } \n"}if(t.length){e.length&&(i+=" ; "),i+="INSERT DATA { ";for(let e=0;e<t.length;e++)i+=this.nTriples(t[e])+"\n";i+=" }\n"}}return i}constructN3PatchQuery(e,t,r){var n="\n@prefix solid: <http://www.w3.org/ns/solid/terms#>.\n@prefix ex: <http://www.example.org/terms#>.\n\n_:patch\n";return r&&r.length>0&&(n+=`\n solid:where {\n ${r.map(e=>this.anonymizeNT(e)).join("\n ")}\n };`),e.length>0&&(n+=`\n solid:deletes {\n ${e.map(e=>this.anonymizeNT(e)).join("\n ")}\n };`),t.length>0&&(n+=`\n solid:inserts {\n ${t.map(e=>this.anonymizeNT(e)).join("\n ")}\n };`),n+=" a solid:InsertDeletePatch .\n"}update(e,t,r,n){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(!r){var o=this;return new Promise(function(r,s){o.update(e,t,function(e,t,n){t?r():s(new Error(n))},n,i)})}try{var s=this.store,a=e?(0,u.ok)(e)?e.statements:e instanceof Array?e:[e]:[],c=t?(0,u.ok)(t)?t.statements:t instanceof Array?t:[t]:[];if(!(a instanceof Array))throw new Error("Type Error "+typeof a+": "+a);if(!(c instanceof Array))throw new Error("Type Error "+typeof c+": "+c);if(0===a.length&&0===c.length)return r(null,!0);var l=a.length?a[0].graph:c[0].graph;if(!l){let e="Error patching: statement does not specify which document to patch:"+a[0]+", "+c[0];throw new Error(e)}if("NamedNode"!==l.termType){let e="Error patching: document not a NamedNode:"+a[0]+", "+c[0];throw new Error(e)}var h=this.patchControlFor(l),d=Date.now(),f=["subject","predicate","object","why"],p={delete:a,insert:c};["insert","delete"].map(function(e){p[e].map(function(e){if(!l.equals(e.graph))throw new Error("update: destination "+l+" inconsistent with delete quad "+e.graph);f.map(function(t){if(void 0===e[t])throw new Error("update: undefined "+t+" of statement.")})})});var g=this.editable(l.value,s);if(!1===g)throw new Error("Update: Can't make changes in uneditable "+l);if(void 0===g){if(n)throw new Error("Update: Loaded "+l+"but still can't figure out what editing protocol it supports.");return void this.store.fetcher.load(l).then(n=>{this.update(e,t,r,!0,i)},n=>{if(404!==n.response.status)throw new Error(`Update: Can't get updatability status ${l} before patching: ${n}`);this.update(e,t,r,!0,i)})}if(g.indexOf("SPARQL")>=0||g.indexOf("N3PATCH")>=0){var y=g.indexOf("SPARQL")>=0,m=[];a.length&&(m=this.statementArrayBnodes(a)),c.length&&(m=m.concat(this.statementArrayBnodes(c)));var v=this.bnodeContext(m,l),w=y?this.constructSparqlUpdateQuery(a,c,v):this.constructN3PatchQuery(a,c,v);i.contentType=y?"application/sparql-update":"text/n3",h.pendingUpstream=h.pendingUpstream?h.pendingUpstream+1:1,"upstreamCount"in h&&(h.upstreamCount+=1),this.fire(l.value,w,(e,t,n,i)=>{if(i.elapsedTimeMs=Date.now()-d,t){try{s.remove(a)}catch(e){t=!1,n="Remote Ok BUT error deleting "+a.length+" from store!!! "+e}for(let e=0;e<c.length;e++)s.add(c[e].subject,c[e].predicate,c[e].object,l)}if(r(e,t,n,i),h.pendingUpstream-=1,0===h.pendingUpstream&&h.downstreamAction){var o=h.downstreamAction;delete h.downstreamAction,o(l)}},i)}else if(g.indexOf("DAV")>=0)this.updateDav(l,a,c,r,i);else{if(!(g.indexOf("LOCALFILE")>=0))throw new Error("Unhandled edit method: '"+g+"' for "+l);try{this.updateLocalFile(l,a,c,r,i)}catch(e){r(l.value,!1,"Exception trying to write back file <"+l.value+">\n")}}}catch(e){r(void 0,!1,"Exception in update: "+e+"\n"+k.stackString(e))}}updateDav(e,t,r,n){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=this.store;var s=o.any(e,this.ns.link("request"));if(!s)throw new Error("No record of our HTTP GET request for document: "+e);var a=o.any(s,this.ns.link("response"));if(!a)return null;var c=o.the(a,this.ns.httph("content-type")).value;let u=o.statementsMatching(void 0,void 0,void 0,e).slice();for(let e=0;e<t.length;e++)k.RDFArrayRemove(u,t[e]);for(let e=0;e<r.length;e++)u.push(r[e]);const l=this.serialize(e.value,u,c);var h,d=o.the(a,this.ns.httph("content-location"));return d&&(h=(0,b.join)(d.value,h)),i.contentType=c,i.noMeta=!0,i.body=l,o.fetcher.webOperation("PUT",h,i).then(i=>{if(!i.ok)throw new Error(i.error);for(let e=0;e<t.length;e++)o.remove(t[e]);for(let t=0;t<r.length;t++)o.add(r[t].subject,r[t].predicate,r[t].object,e);n(e.value,i.ok,i.responseText,i)}).catch(t=>{n(e.value,!1,t.message,t)})}updateLocalFile(e,t,r,n){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const o=this.store;let s=o.statementsMatching(void 0,void 0,void 0,e).slice();for(let e=0;e<t.length;e++)k.RDFArrayRemove(s,t[e]);for(let e=0;e<r.length;e++)s.push(r[e]);var a=e.value.lastIndexOf(".");if(a<1)throw new Error("Rewriting file: No filename extension: "+e.value);var c=e.value.slice(a+1);let u=Pt.CONTENT_TYPE_BY_EXT[c];if(!u)throw new Error("File extension ."+c+" not supported for data write");i.body=this.serialize(e.value,s,u),i.contentType=u,o.fetcher.webOperation("PUT",e.value,i).then(i=>{if(!i.ok)return n(e.value,!1,i.error);for(let e=0;e<t.length;e++)o.remove(t[e]);for(let t=0;t<r.length;t++)o.add(r[t].subject,r[t].predicate,r[t].object,e);n(e.value,!0,"")})}serialize(e,t,r){const n=this.store;let i;if("string"==typeof t)return t;var o=P(n);switch(o.suggestNamespaces(n.namespaces),o.setBase(e),r){case"text/xml":case"application/rdf+xml":i=o.statementsToXML(t);break;case"text/n3":case"text/turtle":case"application/x-turtle":case"application/n3":i=o.statementsToN3(t);break;default:throw new Error("Content-type "+r+" not supported for data serialization")}return i}put(e,t,r,n){const i=this.store;let o;return Promise.resolve().then(()=>(o=this.serialize(e.value,t,r),i.fetcher.webOperation("PUT",e.value,{contentType:r,body:o}))).then(r=>{if(!r.ok)return n(e.value,r.ok,r.error,r);delete i.fetcher.nonexistent[e.value],delete i.fetcher.requested[e.value],"string"!=typeof t&&t.map(e=>{i.addStatement(e)}),n(e.value,r.ok,"",r)}).catch(t=>{n(e.value,!1,t.message)})}reload(e,t,r){var n=Date.now();e.fetcher.nowOrWhenFetched(t.value,{force:!0,noMeta:!0,clearPreviousData:!0},function(e,i,o){if(e)if(o.onErrorWasCalled||200!==o.status)r(!1,"Non-HTTP error reloading data: "+i,o);else{var s=Date.now()-n;t.reloadTimeTotal||(t.reloadTimeTotal=0),t.reloadTimeCount||(t.reloadTimeCount=0),t.reloadTimeTotal+=s,t.reloadTimeCount+=1,r(!0)}else r(!1,"Error reloading data: "+i,o)})}}const jt={...Ee,fetcher:(e,t)=>new Pt(e,t),graph(){return new G(arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0)||{rdfFactory:Ee})},lit(e,t,r){return this.literal(""+e,t||r)},st(e,t,r,n){return this.quad(e,t,r,n)}},Mt=jt;class Ht{constructor(e,t){this.parent=e,this.via=t,this.connected=!1,this.pending={},this.subscribed={},this.socket={};try{this.socket=new WebSocket(t),this.socket.onopen=this.onOpen,this.socket.onclose=this.onClose,this.socket.onmessage=this.onMessage,this.socket.onerror=this.onError}catch(e){this.onError(e)}}_decode(e){var t,r,n,i,o,s,a;for(r in i={},o=function(){var r,n,i,o;for(o=[],r=0,n=(i=e.split("&")).length;r<n;r++)t=i[r],o.push(t.split("="));return o}())t=o[r],a=(s=[decodeURIComponent(t[0]),decodeURIComponent(t[1])])[1],null==i[n=s[0]]&&(i[n]=[]),i[n].push(a);return i}_send(e,t,r){var n,i;return i=[e,t,r].join(" "),"function"==typeof(n=this.socket).send?n.send(i):void 0}_subscribe(e){return this._send("sub",e,""),this.subscribed[e]=!0,this.subscribed[e]}onClose(e){var t;for(t in this.connected=!1,this.subscribed)this.pending[t]=!0;return this.subscribed={},this.subscribed}onError(e){throw new Error("onError"+e)}onMessage(e){var t,r;return"ping"===(r=e.data.split(" "))[0]?"function"==typeof(t=this.socket).send?t.send("pong "+r.slice(1).join(" ")):void 0:"pub"===r[0]?this.parent.onUpdate(r[1],this._decode(r[2])):void 0}onOpen(e){var t,r;for(r in this.connected=!0,t=[],this.pending)delete this.pending[r],t.push(this._subscribe(r));return t}subscribe(e){return this.connected?this._subscribe(e):(this.pending[e]=!0,this.pending[e])}}class Bt{constructor(e){this.fetcher=e,this.graph={},this.via={},this.fetcher.addCallback("headers",this.onHeaders)}onHeaders(e){var t,r,n;return null==e.headers||"undefined"==typeof WebSocket||null===WebSocket||(t=e.headers.etag,n=e.headers["updates-via"],r=e.uri,t&&n&&(this.graph[r]={etag:t,via:n},this.register(n,r))),!0}onUpdate(e,t){return this.fetcher.refresh(Mt.namedNode(e))}register(e,t){return null==this.via[e]&&(this.via[e]=new Ht(this,e)),this.via[e].subscribe(t)}}const qt={};for(const e in Mt)"function"==typeof Mt[e]&&(qt[e]=Mt[e].bind(Mt));const{fetcher:Kt,graph:Wt,lit:Jt,st:Vt,namedNode:$t,variable:zt,blankNode:Gt,defaultGraph:Xt,literal:Yt,quad:Qt,triple:Zt}=qt,er=new H,tr=e=>er.fromNT(e),rr=B.fromValue,nr=a.nextId;class ir extends G{constructor(e){super(e),(0,n.A)(this,"fetcher",void 0),this.fetcher=new Pt(this,{})}}class or extends ir{constructor(e){super(e),(0,n.A)(this,"updater",void 0),this.updater=new Lt(this)}}},4299:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateV7State=void 0;const n=r(2291),i=r(6011),o={};function s(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,0===e.seq&&e.msecs++),e}function a(e,t,r,n,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(n){if(i<0||i+16>n.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`)}else n=new Uint8Array(16),i=0;return t??=Date.now(),r??=127*e[6]<<24|e[7]<<16|e[8]<<8|e[9],n[i++]=t/1099511627776&255,n[i++]=t/4294967296&255,n[i++]=t/16777216&255,n[i++]=t/65536&255,n[i++]=t/256&255,n[i++]=255&t,n[i++]=112|r>>>28&15,n[i++]=r>>>20&255,n[i++]=128|r>>>14&63,n[i++]=r>>>6&255,n[i++]=r<<2&255|3&e[10],n[i++]=e[11],n[i++]=e[12],n[i++]=e[13],n[i++]=e[14],n[i++]=e[15],n}t.updateV7State=s,t.default=function(e,t,r){let c;if(e)c=a(e.random??e.rng?.()??(0,n.default)(),e.msecs,e.seq,t,r);else{const e=Date.now(),i=(0,n.default)();s(o,e,i),c=a(i,o.msecs,o.seq,t,r)}return t??(0,i.unsafeStringify)(c)}},4353:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSuggestedIssuers=function(){const e=[...r],{host:t,origin:n}=new URL(location.href),i=e.map(({uri:e})=>new URL(e).host);i.includes(t)||i.some(e=>function(e,t){const r=e.length-t.length-1;return r>0&&"."===e[r]&&e.endsWith(t)}(t,e))||e.unshift({name:t,uri:n});return e};const r=[{name:"Solid Community",uri:"https://solidcommunity.net"},{name:"Solid Web",uri:"https://solidweb.org"},{name:"Solid Web ME",uri:"https://solidweb.me"},{name:"Inrupt.com",uri:"https://login.inrupt.com"}]},4466:(e,t,r)=>{var n=r(4582).NAMESPACE,i=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,o=new RegExp("[\\-\\.0-9"+i.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),s=new RegExp("^"+i.source+o.source+"*(?::"+i.source+o.source+"*)?$");function a(e,t){this.message=e,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,a)}function c(){}function u(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function l(e,t,r,i,o,s){function a(e,t,n){r.attributeNames.hasOwnProperty(e)&&s.fatalError("Attribute "+e+" redefined"),r.addValue(e,t.replace(/[\t\n\r]/g," ").replace(/&#?\w+;/g,o),n)}for(var c,u=++t,l=0;;){var h=e.charAt(u);switch(h){case"=":if(1===l)c=e.slice(t,u),l=3;else{if(2!==l)throw new Error("attribute equal must after attrName");l=3}break;case"'":case'"':if(3===l||1===l){if(1===l&&(s.warning('attribute value must after "="'),c=e.slice(t,u)),t=u+1,!((u=e.indexOf(h,t))>0))throw new Error("attribute value no end '"+h+"' match");a(c,d=e.slice(t,u),t-1),l=5}else{if(4!=l)throw new Error('attribute value must after "="');a(c,d=e.slice(t,u),t),s.warning('attribute "'+c+'" missed start quot('+h+")!!"),t=u+1,l=5}break;case"/":switch(l){case 0:r.setTagName(e.slice(t,u));case 5:case 6:case 7:l=7,r.closed=!0;case 4:case 1:break;case 2:r.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return s.error("unexpected end of input"),0==l&&r.setTagName(e.slice(t,u)),u;case">":switch(l){case 0:r.setTagName(e.slice(t,u));case 5:case 6:case 7:break;case 4:case 1:"/"===(d=e.slice(t,u)).slice(-1)&&(r.closed=!0,d=d.slice(0,-1));case 2:2===l&&(d=c),4==l?(s.warning('attribute "'+d+'" missed quot(")!'),a(c,d,t)):(n.isHTML(i[""])&&d.match(/^(?:disabled|checked|selected)$/i)||s.warning('attribute "'+d+'" missed value!! "'+d+'" instead!!'),a(d,d,t));break;case 3:throw new Error("attribute value missed!!")}return u;case"":h=" ";default:if(h<=" ")switch(l){case 0:r.setTagName(e.slice(t,u)),l=6;break;case 1:c=e.slice(t,u),l=2;break;case 4:var d=e.slice(t,u);s.warning('attribute "'+d+'" missed quot(")!!'),a(c,d,t);case 5:l=6}else switch(l){case 2:r.tagName;n.isHTML(i[""])&&c.match(/^(?:disabled|checked|selected)$/i)||s.warning('attribute "'+c+'" missed value!! "'+c+'" instead2!!'),a(c,c,t),t=u,l=1;break;case 5:s.warning('attribute space is required"'+c+'"!!');case 6:l=1,t=u;break;case 3:l=4,t=u;break;case 7:throw new Error("elements closed character '/' and '>' must be connected to")}}u++}}function h(e,t,r){for(var i=e.tagName,o=null,s=e.length;s--;){var a=e[s],c=a.qName,u=a.value;if((f=c.indexOf(":"))>0)var l=a.prefix=c.slice(0,f),h=c.slice(f+1),d="xmlns"===l&&h;else h=c,l=null,d="xmlns"===c&&"";a.localName=h,!1!==d&&(null==o&&(o={},p(r,r={})),r[d]=o[d]=u,a.uri=n.XMLNS,t.startPrefixMapping(d,u))}for(s=e.length;s--;){(l=(a=e[s]).prefix)&&("xml"===l&&(a.uri=n.XML),"xmlns"!==l&&(a.uri=r[l||""]))}var f;(f=i.indexOf(":"))>0?(l=e.prefix=i.slice(0,f),h=e.localName=i.slice(f+1)):(l=null,h=e.localName=i);var g=e.uri=r[l||""];if(t.startElement(g,h,i,e),!e.closed)return e.currentNSMap=r,e.localNSMap=o,!0;if(t.endElement(g,h,i),o)for(l in o)Object.prototype.hasOwnProperty.call(o,l)&&t.endPrefixMapping(l)}function d(e,t,r,n,i){if(/^(?:script|textarea)$/i.test(r)){var o=e.indexOf("</"+r+">",t),s=e.substring(t+1,o);if(/[&<]/.test(s))return/^script$/i.test(r)?(i.characters(s,0,s.length),o):(s=s.replace(/&#?\w+;/g,n),i.characters(s,0,s.length),o)}return t+1}function f(e,t,r,n){var i=n[r];return null==i&&((i=e.lastIndexOf("</"+r+">"))<t&&(i=e.lastIndexOf("</"+r)),n[r]=i),i<t}function p(e,t){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}function g(e,t,r,n){if("-"===e.charAt(t+2))return"-"===e.charAt(t+3)?(i=e.indexOf("--\x3e",t+4))>t?(r.comment(e,t+4,i-t-4),i+3):(n.error("Unclosed comment"),-1):-1;if("CDATA["==e.substr(t+3,6)){var i=e.indexOf("]]>",t+9);return r.startCDATA(),r.characters(e,t+9,i-t-9),r.endCDATA(),i+3}var o=function(e,t){var r,n=[],i=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;i.lastIndex=t,i.exec(e);for(;r=i.exec(e);)if(n.push(r),r[1])return n}(e,t),s=o.length;if(s>1&&/!doctype/i.test(o[0][0])){var a=o[1][0],c=!1,u=!1;s>3&&(/^public$/i.test(o[2][0])?(c=o[3][0],u=s>4&&o[4][0]):/^system$/i.test(o[2][0])&&(u=o[3][0]));var l=o[s-1];return r.startDTD(a,c,u),r.endDTD(),l.index+l[0].length}return-1}function y(e,t,r){var n=e.indexOf("?>",t);if(n){var i=e.substring(t,n).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(i){i[0].length;return r.processingInstruction(i[1],i[2]),n+2}return-1}return-1}function m(){this.attributeNames={}}a.prototype=new Error,a.prototype.name=a.name,c.prototype={parse:function(e,t,r){var i=this.domBuilder;i.startDocument(),p(t,t={}),function(e,t,r,i,o){function s(e){if(e>65535){var t=55296+((e-=65536)>>10),r=56320+(1023&e);return String.fromCharCode(t,r)}return String.fromCharCode(e)}function c(e){var t=e.slice(1,-1);return Object.hasOwnProperty.call(r,t)?r[t]:"#"===t.charAt(0)?s(parseInt(t.substr(1).replace("x","0x"))):(o.error("entity not found:"+e),e)}function p(t){if(t>x){var r=e.substring(x,t).replace(/&#?\w+;/g,c);S&&v(x),i.characters(r,0,t-x),x=t}}function v(t,r){for(;t>=b&&(r=_.exec(e));)w=r.index,b=w+r[0].length,S.lineNumber++;S.columnNumber=t-w+1}var w=0,b=0,_=/.*(?:\r\n?|\n)|.*$/g,S=i.locator,E=[{currentNSMap:t}],A={},x=0;for(;;){try{var T=e.indexOf("<",x);if(T<0){if(!e.substr(x).match(/^\s*$/)){var F=i.doc,k=F.createTextNode(e.substr(x));F.appendChild(k),i.currentElement=k}return}switch(T>x&&p(T),e.charAt(T+1)){case"/":var I=e.indexOf(">",T+3),C=e.substring(T+2,I).replace(/[ \t\n\r]+$/g,""),N=E.pop();I<0?(C=e.substring(T+2).replace(/[\s<].*/,""),o.error("end tag name: "+C+" is not complete:"+N.tagName),I=T+1+C.length):C.match(/\s</)&&(C=C.replace(/[\s<].*/,""),o.error("end tag name: "+C+" maybe not complete"),I=T+1+C.length);var R=N.localNSMap,P=N.tagName==C;if(P||N.tagName&&N.tagName.toLowerCase()==C.toLowerCase()){if(i.endElement(N.uri,N.localName,C),R)for(var O in R)Object.prototype.hasOwnProperty.call(R,O)&&i.endPrefixMapping(O);P||o.fatalError("end tag name: "+C+" is not match the current start tagName:"+N.tagName)}else E.push(N);I++;break;case"?":S&&v(T),I=y(e,T,i);break;case"!":S&&v(T),I=g(e,T,i,o);break;default:S&&v(T);var D=new m,U=E[E.length-1].currentNSMap,L=(I=l(e,T,D,U,c,o),D.length);if(!D.closed&&f(e,I,D.tagName,A)&&(D.closed=!0,r.nbsp||o.warning("unclosed xml attribute")),S&&L){for(var j=u(S,{}),M=0;M<L;M++){var H=D[M];v(H.offset),H.locator=u(S,{})}i.locator=j,h(D,i,U)&&E.push(D),i.locator=S}else h(D,i,U)&&E.push(D);n.isHTML(D.uri)&&!D.closed?I=d(e,I,D.tagName,c,i):I++}}catch(e){if(e instanceof a)throw e;o.error("element parse error: "+e),I=-1}I>x?x=I:p(Math.max(T,x)+1)}}(e,t,r,i,this.errorHandler),i.endDocument()}},m.prototype={setTagName:function(e){if(!s.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,r){if(!s.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:r}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},t.XMLReader=c,t.ParseError=a},4495:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});const n=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){const{modulusLength:r}=t.algorithm;if("number"!=typeof r||r<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}}},4557:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.URL=t.DNS=void 0;const n=r(2829),i=r(2988);var o=r(2988);function s(e,t,r,o){return(0,i.default)(80,n.default,e,t,r,o)}Object.defineProperty(t,"DNS",{enumerable:!0,get:function(){return o.DNS}}),Object.defineProperty(t,"URL",{enumerable:!0,get:function(){return o.URL}}),s.DNS=i.DNS,s.URL=i.URL,t.default=s},4582:(e,t)=>{"use strict";function r(e,t){return void 0===t&&(t=Object),t&&"function"==typeof t.freeze?t.freeze(e):e}var n=r({HTML:"text/html",isHTML:function(e){return e===n.HTML},XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),i=r({HTML:"http://www.w3.org/1999/xhtml",isHTML:function(e){return e===i.HTML},SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});t.assign=function(e,t){if(null===e||"object"!=typeof e)throw new TypeError("target is not an object");for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},t.find=function(e,t,r){if(void 0===r&&(r=Array.prototype),e&&"function"==typeof r.find)return r.find.call(e,t);for(var n=0;n<e.length;n++)if(Object.prototype.hasOwnProperty.call(e,n)){var i=e[n];if(t.call(void 0,i,n,e))return i}},t.freeze=r,t.MIME_TYPE=n,t.NAMESPACE=i},4618:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});const n=(e,t)=>{if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw new TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)}},4667:(e,t,r)=>{"use strict";var n=r(3121),i=r(182);const o=["ES256","RS256"],s={ERROR:"error",LOGIN:"login",LOGOUT:"logout",NEW_REFRESH_TOKEN:"newRefreshToken",NEW_TOKENS:"newTokens",AUTHORIZATION_REQUEST:"authorizationRequest",SESSION_EXPIRED:"sessionExpired",SESSION_EXTENDED:"sessionExtended",SESSION_RESTORED:"sessionRestore",TIMEOUT_SET:"timeoutSet"},a=["openid","offline_access","webid"];class c{sessionInfoManager;constructor(e){this.sessionInfoManager=e,this.sessionInfoManager=e}async canHandle(){return!0}async handle(e){await this.sessionInfoManager.clear(e)}}class u{redirector;constructor(e){this.redirector=e,this.redirector=e}async canHandle(e,t){return"idp"===t?.logoutType}async handle(e,t){if("idp"!==t?.logoutType)throw new Error("Attempting to call idp logout handler to perform app logout");if(void 0===t.toLogoutUrl)throw new Error("Cannot perform IDP logout. Did you log in using the OIDC authentication flow?");this.redirector.redirect(t.toLogoutUrl(t),{handleRedirect:t.handleRedirect})}}async function l(e,t){await Promise.all([t.deleteAllUserData(e,{secure:!1}),t.deleteAllUserData(e,{secure:!0})])}function h({endSessionEndpoint:e,idTokenHint:t,postLogoutRedirectUri:r,state:n}){const i=new URL(e);return void 0!==t&&i.searchParams.append("id_token_hint",t),void 0!==r&&(i.searchParams.append("post_logout_redirect_uri",r),void 0!==n&&i.searchParams.append("state",n)),i.toString()}function d(e){try{return new URL(e),!0}catch{return!1}}const f=(e,t)=>fetch(e,t);class p{secureStorage;insecureStorage;constructor(e,t){this.secureStorage=e,this.insecureStorage=t,this.secureStorage=e,this.insecureStorage=t}getKey(e){return`solidClientAuthenticationUser:${e}`}async getUserData(e,t){const r=await(t?this.secureStorage:this.insecureStorage).get(this.getKey(e));if(void 0===r)return{};try{return JSON.parse(r)}catch(n){throw new Error(`Data for user [${e}] in [${t?"secure":"unsecure"}] storage is corrupted - expected valid JSON, but got: ${r}`)}}async setUserData(e,t,r){await(r?this.secureStorage:this.insecureStorage).set(this.getKey(e),JSON.stringify(t))}async get(e,t){const r=await(t?.secure?this.secureStorage:this.insecureStorage).get(e);if(void 0===r&&t?.errorIfNull)throw new Error(`[${e}] is not stored`);return r}async set(e,t,r){return(r?.secure?this.secureStorage:this.insecureStorage).set(e,t)}async delete(e,t){return(t?.secure?this.secureStorage:this.insecureStorage).delete(e)}async getForUser(e,t,r){const n=await this.getUserData(e,r?.secure);let i;if(n&&n[t]||(i=void 0),i=n[t],void 0===i&&r?.errorIfNull)throw new Error(`Field [${t}] for user [${e}] is not stored`);return i||void 0}async setForUser(e,t,r){let n;try{n=await this.getUserData(e,r?.secure)}catch{n={}}await this.setUserData(e,{...n,...t},r?.secure)}async deleteForUser(e,t,r){const n=await this.getUserData(e,r?.secure);delete n[t],await this.setUserData(e,n,r?.secure)}async deleteAllUserData(e,t){await(t?.secure?this.secureStorage:this.insecureStorage).delete(this.getKey(e))}}class g extends Error{constructor(e){super(e)}}class y extends Error{constructor(e){super(`[${e}] is not implemented`)}}class m extends Error{missingFields;constructor(e){super(`Invalid response from OIDC provider: missing fields ${e}`),this.missingFields=e}}class v extends Error{error;errorDescription;constructor(e,t,r){super(e),this.error=t,this.errorDescription=r}}function w(e){const t=new URL(e);return new URL(t.pathname,t.origin).toString()}async function b(e,t,r){return new n.SignJWT({htu:w(e),htm:t.toUpperCase(),jti:i.v4()}).setProtectedHeader({alg:o[0],jwk:r.publicKey,typ:"dpop+jwt"}).setIssuedAt().sign(r.privateKey,{})}async function _(e,t,r,n){if(void 0!==r)return async function(e,t,r,n){const i=new Headers(n?.headers);return i.set("Authorization",`DPoP ${t}`),i.set("DPoP",await b(e,n?.method??"get",r)),{...n,headers:i}}(e,t,r,n);const i=new Headers(n?.headers);return i.set("Authorization",`Bearer ${t}`),{...n,headers:i}}async function S(e,t,r,n,i=fetch){return i(t,await _(t.toString(),e,n,r))}const E=e=>void 0!==e?e-5>0?e-5:e:600;const A="getResponse",x={get:async(e,t)=>A,set:async(e,t)=>{},delete:async e=>{},getForUser:async(e,t,r)=>A,setForUser:async(e,t,r)=>{},deleteForUser:async(e,t,r)=>{},deleteAllUserData:async(e,t)=>{}},T=e=>{const t=e;return{get:async e=>{if(void 0!==t[e])return"string"==typeof t[e]?t[e]:JSON.stringify(t[e])},set:async(e,r)=>{t[e]=r},delete:async e=>{delete t[e]}}};t.AggregateHandler=class{handleables;constructor(e){this.handleables=e,this.handleables=e}async getProperHandler(e){const t=await Promise.all(this.handleables.map(t=>t.canHandle(...e)));for(let e=0;e<t.length;e+=1)if(t[e])return this.handleables[e];return null}async canHandle(...e){return null!==await this.getProperHandler(e)}async handle(...e){const t=await this.getProperHandler(e);if(t)return t.handle(...e);throw new Error(`[${this.constructor.name}] cannot find a suitable handler for: ${e.map(e=>{try{return JSON.stringify(e)}catch(t){return e.toString()}}).join(", ")}`)}},t.AuthorizationCodeWithPkceOidcHandlerBase=class{storageUtility;redirector;constructor(e,t){this.storageUtility=e,this.redirector=t,this.storageUtility=e,this.redirector=t}parametersGuard=e=>void 0!==e.issuerConfiguration.grantTypesSupported&&e.issuerConfiguration.grantTypesSupported.indexOf("authorization_code")>-1&&void 0!==e.redirectUrl;async canHandle(e){return this.parametersGuard(e)}async setupRedirectHandler({oidcLoginOptions:e,state:t,codeVerifier:r,targetUrl:n}){if(!this.parametersGuard(e))throw new Error("The authorization code grant requires a redirectUrl.");var i,o;await Promise.all([this.storageUtility.setForUser(t,{sessionId:e.sessionId}),this.storageUtility.setForUser(e.sessionId,{codeVerifier:r,issuer:e.issuer.toString(),redirectUrl:e.redirectUrl,dpop:Boolean(e.dpop).toString(),keepAlive:(i=e.keepAlive,o=!0,"boolean"==typeof i?Boolean(i):Boolean(o)).toString()})]),this.redirector.redirect(n,{handleRedirect:e.handleRedirect})}},t.ClientAuthentication=class{loginHandler;redirectHandler;logoutHandler;sessionInfoManager;issuerConfigFetcher;boundLogout;constructor(e,t,r,n,i){this.loginHandler=e,this.redirectHandler=t,this.logoutHandler=r,this.sessionInfoManager=n,this.issuerConfigFetcher=i,this.loginHandler=e,this.redirectHandler=t,this.logoutHandler=r,this.sessionInfoManager=n,this.issuerConfigFetcher=i}fetch=f;logout=async(e,t)=>{await this.logoutHandler.handle(e,"idp"===t?.logoutType?{...t,toLogoutUrl:this.boundLogout}:t),this.fetch=f,delete this.boundLogout};getSessionInfo=async e=>this.sessionInfoManager.get(e);getAllSessionInfo=async()=>this.sessionInfoManager.getAll()},t.ConfigurationError=g,t.DEFAULT_SCOPES=a,t.EVENTS=s,t.GeneralLogoutHandler=c,t.IRpLogoutHandler=u,t.IWaterfallLogoutHandler=class{handlers;constructor(e,t){this.handlers=[new c(e),new u(t)]}async canHandle(){return!0}async handle(e,t){for(const r of this.handlers)await r.canHandle(e,t)&&await r.handle(e,t)}},t.InMemoryStorage=class{map={};async get(e){return this.map[e]||void 0}async set(e,t){this.map[e]=t}async delete(e){delete this.map[e]}},t.InvalidResponseError=m,t.NotImplementedError=y,t.OidcProviderError=v,t.PREFERRED_SIGNING_ALG=o,t.REFRESH_BEFORE_EXPIRATION_SECONDS=5,t.SOLID_CLIENT_AUTHN_KEY_PREFIX="solidClientAuthn:",t.SessionInfoManagerBase=class{storageUtility;constructor(e){this.storageUtility=e,this.storageUtility=e}update(e,t){throw new Error("Not Implemented")}set(e,t){throw new Error("Not Implemented")}get(e){throw new Error("Not implemented")}async getAll(){throw new Error("Not implemented")}async clear(e){return l(e,this.storageUtility)}async register(e){throw new Error("Not implemented")}async getRegisteredSessionIdAll(){throw new Error("Not implemented")}async clearAll(){throw new Error("Not implemented")}async setOidcContext(e,t){throw new Error("Not implemented")}},t.StorageUtility=p,t.StorageUtilityGetResponse=A,t.StorageUtilityMock=x,t.USER_SESSION_PREFIX="solidClientAuthenticationUser",t.buildAuthenticatedFetch=function(e,t){let r,n=e;const i=t?.refreshOptions;if(void 0!==i){const e=async()=>{try{const{accessToken:o,refreshToken:a,expiresIn:c}=await async function(e,t,r){const n=await e.tokenRefresher.refresh(e.sessionId,e.refreshToken,t);return r?.emit(s.SESSION_EXTENDED,n.expiresIn??600),{accessToken:n.accessToken,refreshToken:n.refreshToken,expiresIn:n.expiresIn}}(i,t.dpopKey,t.eventEmitter);n=o,void 0!==a&&(i.refreshToken=a),clearTimeout(r),r=setTimeout(e,1e3*E(c)),t.eventEmitter?.emit(s.TIMEOUT_SET,r)}catch(e){e instanceof v&&(t?.eventEmitter?.emit(s.ERROR,e.error,e.errorDescription),t?.eventEmitter?.emit(s.SESSION_EXPIRED)),e instanceof m&&e.missingFields.includes("access_token")&&t?.eventEmitter?.emit(s.SESSION_EXPIRED)}};r=setTimeout(e,1e3*E(t.expiresIn)),t.eventEmitter?.emit(s.TIMEOUT_SET,r)}else if(void 0!==t&&void 0!==t.eventEmitter){const e=setTimeout(()=>{t.eventEmitter.emit(s.SESSION_EXPIRED)},1e3*E(t.expiresIn));t.eventEmitter.emit(s.TIMEOUT_SET,e)}return async(e,r)=>{let i=await S(n,e,r,t?.dpopKey,t?.fetch);const o=!i.ok&&(s=i.status,![401,403].includes(s));var s;if(i.ok||o)return i;return i.url!==e&&void 0!==t?.dpopKey&&(i=await S(n,i.url,r,t.dpopKey,t.fetch)),i}},t.clear=l,t.createDpopHeader=b,t.determineSigningAlg=function(e,t){return t.find(t=>e.includes(t))??null},t.generateDpopKeyPair=async function(){const{privateKey:e,publicKey:t}=await n.generateKeyPair(o[0]),r={privateKey:e,publicKey:await n.exportJWK(t)};return[r.publicKey.alg]=o,r},t.getEndSessionUrl=h,t.getSessionIdFromOauthState=async function(e,t){return e.getForUser(t,"sessionId")},t.getUnauthenticatedSession=function(){return{isLoggedIn:!1,sessionId:i.v4(),fetch:(...e)=>fetch(...e)}},t.getWebidFromTokenPayload=async function(e,t,r,i){let o,s;try{const{payload:s}=await n.jwtVerify(e,n.createRemoteJWKSet(new URL(t)),{issuer:r,audience:i});o=s}catch(e){throw new Error(`Token verification failed: ${e.stack}`)}if("string"==typeof o.azp&&(s=o.azp),"string"==typeof o.webid)return{webId:o.webid,clientId:s};if("string"!=typeof o.sub)throw new Error(`The token ${JSON.stringify(o)} is invalid: it has no 'webid' claim and no 'sub' claim.`);try{return new URL(o.sub),{webId:o.sub,clientId:s}}catch(e){throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${o.sub}] is invalid as a URL - error [${e}].`)}},t.handleRegistration=async function(e,t,r,n){let i;if(function(e,t){return t.scopesSupported.includes("webid")&&void 0!==e.clientId&&d(e.clientId)}(e,t))i={clientId:e.clientId,clientName:e.clientName,clientType:"solid-oidc"};else{if(!function(e){return void 0!==e.clientId&&!d(e.clientId)}(e))return n.getClient({sessionId:e.sessionId,clientName:e.clientName,redirectUrl:e.redirectUrl},t);i={clientId:e.clientId,clientSecret:e.clientSecret,clientName:e.clientName,clientType:"static"}}const o={clientId:i.clientId,clientType:i.clientType};return"static"===i.clientType&&(o.clientSecret=i.clientSecret),i.clientName&&(o.clientName=i.clientName),await r.setForUser(e.sessionId,o),i},t.isKnownClientType=function(e){return"string"==typeof e&&["dynamic","static","solid-oidc"].includes(e)},t.isSupportedTokenType=function(e){return"string"==typeof e&&["DPoP","Bearer"].includes(e)},t.isValidRedirectUrl=function(e){try{const t=new URL(e),r=!t.searchParams.has("code")&&!t.searchParams.has("state"),n=""===t.hash;return r&&n}catch(e){return!1}},t.loadOidcContextFromStorage=async function(e,t,r){try{const[n,i,o,s,a]=await Promise.all([t.getForUser(e,"issuer",{errorIfNull:!0}),t.getForUser(e,"codeVerifier"),t.getForUser(e,"redirectUrl"),t.getForUser(e,"dpop",{errorIfNull:!0}),t.getForUser(e,"keepAlive")]);await t.deleteForUser(e,"codeVerifier");return{codeVerifier:i,redirectUrl:o,issuerConfig:await r.fetchConfig(n),dpop:"true"===s,keepAlive:"string"!=typeof a||"true"===a}}catch(t){throw new Error(`Failed to retrieve OIDC context from storage associated with session [${e}]: ${t}`)}},t.maybeBuildRpInitiatedLogout=function({endSessionEndpoint:e,idTokenHint:t}){if(void 0!==e)return function({state:r,postLogoutUrl:n}){return h({endSessionEndpoint:e,idTokenHint:t,state:r,postLogoutRedirectUri:n})}},t.mockStorage=T,t.mockStorageUtility=(e,t=!1)=>t?new p(T(e),T({})):new p(T({}),T(e)),t.normalizeScopes=function(e){return Array.isArray(e)?Array.from(new Set([...a,...e.filter(e=>"string"==typeof e&&!e.includes(" "))])):a},t.removeOpenIdParams=function(e){const t=new URL(e);return t.searchParams.delete("state"),t.searchParams.delete("code"),t.searchParams.delete("error"),t.searchParams.delete("error_description"),t.searchParams.delete("iss"),t},t.saveSessionInfoToStorage=async function(e,t,r,i,o,s,a,c){void 0!==s&&await e.setForUser(t,{refreshToken:s},{secure:a}),void 0!==r&&await e.setForUser(t,{webId:r},{secure:a}),void 0!==i&&await e.setForUser(t,{clientId:i},{secure:a}),void 0!==o&&await e.setForUser(t,{isLoggedIn:o},{secure:a}),void 0!==c&&await e.setForUser(t,{publicKey:JSON.stringify(c.publicKey),privateKey:JSON.stringify(await n.exportJWK(c.privateKey))},{secure:a})}},4705:(e,t,r)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function i(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}function o(e,t,r){return(t=i(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.d(t,{A:()=>o})},4722:(e,t,r)=>{var n=r(4582),i=n.find,o=n.NAMESPACE;function s(e){return""!==e}function a(e,t){return e.hasOwnProperty(t)||(e[t]=!0),e}function c(e){if(!e)return[];var t=function(e){return e?e.split(/[\t\n\f\r ]+/).filter(s):[]}(e);return Object.keys(t.reduce(a,{}))}function u(e,t){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}function l(e,t){var r=e.prototype;if(!(r instanceof t)){function n(){}n.prototype=t.prototype,u(r,n=new n),e.prototype=r=n}r.constructor!=e&&("function"!=typeof e&&console.error("unknown Class:"+e),r.constructor=e)}var h={},d=h.ELEMENT_NODE=1,f=h.ATTRIBUTE_NODE=2,p=h.TEXT_NODE=3,g=h.CDATA_SECTION_NODE=4,y=h.ENTITY_REFERENCE_NODE=5,m=h.ENTITY_NODE=6,v=h.PROCESSING_INSTRUCTION_NODE=7,w=h.COMMENT_NODE=8,b=h.DOCUMENT_NODE=9,_=h.DOCUMENT_TYPE_NODE=10,S=h.DOCUMENT_FRAGMENT_NODE=11,E=h.NOTATION_NODE=12,A={},x={},T=(A.INDEX_SIZE_ERR=(x[1]="Index size error",1),A.DOMSTRING_SIZE_ERR=(x[2]="DOMString size error",2),A.HIERARCHY_REQUEST_ERR=(x[3]="Hierarchy request error",3)),F=(A.WRONG_DOCUMENT_ERR=(x[4]="Wrong document",4),A.INVALID_CHARACTER_ERR=(x[5]="Invalid character",5),A.NO_DATA_ALLOWED_ERR=(x[6]="No data allowed",6),A.NO_MODIFICATION_ALLOWED_ERR=(x[7]="No modification allowed",7),A.NOT_FOUND_ERR=(x[8]="Not found",8)),k=(A.NOT_SUPPORTED_ERR=(x[9]="Not supported",9),A.INUSE_ATTRIBUTE_ERR=(x[10]="Attribute in use",10));A.INVALID_STATE_ERR=(x[11]="Invalid state",11),A.SYNTAX_ERR=(x[12]="Syntax error",12),A.INVALID_MODIFICATION_ERR=(x[13]="Invalid modification",13),A.NAMESPACE_ERR=(x[14]="Invalid namespace",14),A.INVALID_ACCESS_ERR=(x[15]="Invalid access",15);function I(e,t){if(t instanceof Error)var r=t;else r=this,Error.call(this,x[e]),this.message=x[e],Error.captureStackTrace&&Error.captureStackTrace(this,I);return r.code=e,t&&(this.message=this.message+": "+t),r}function C(){}function N(e,t){this._node=e,this._refresh=t,R(this)}function R(e){var t=e._node._inc||e._node.ownerDocument._inc;if(e._inc!==t){var r=e._refresh(e._node);if(be(e,"length",r.length),!e.$$length||r.length<e.$$length)for(var n=r.length;n in e;n++)Object.prototype.hasOwnProperty.call(e,n)&&delete e[n];u(r,e),e._inc=t}}function P(){}function O(e,t){for(var r=e.length;r--;)if(e[r]===t)return r}function D(e,t,r,n){if(n?t[O(t,n)]=r:t[t.length++]=r,e){r.ownerElement=e;var i=e.ownerDocument;i&&(n&&q(i,e,n),function(e,t,r){e&&e._inc++;var n=r.namespaceURI;n===o.XMLNS&&(t._nsMap[r.prefix?r.localName:""]=r.value)}(i,e,r))}}function U(e,t,r){var n=O(t,r);if(!(n>=0))throw new I(F,new Error(e.tagName+"@"+r));for(var i=t.length-1;n<i;)t[n]=t[++n];if(t.length=i,e){var o=e.ownerDocument;o&&(q(o,e,r),r.ownerElement=null)}}function L(){}function j(){}function M(e){return("<"==e?"<":">"==e&&">")||"&"==e&&"&"||'"'==e&&"""||"&#"+e.charCodeAt()+";"}function H(e,t){if(t(e))return!0;if(e=e.firstChild)do{if(H(e,t))return!0}while(e=e.nextSibling)}function B(){this.ownerDocument=this}function q(e,t,r,n){e&&e._inc++,r.namespaceURI===o.XMLNS&&delete t._nsMap[r.prefix?r.localName:""]}function K(e,t,r){if(e&&e._inc){e._inc++;var n=t.childNodes;if(r)n[n.length++]=r;else{for(var i=t.firstChild,o=0;i;)n[o++]=i,i=i.nextSibling;n.length=o,delete n[n.length]}}}function W(e,t){var r=t.previousSibling,n=t.nextSibling;return r?r.nextSibling=n:e.firstChild=n,n?n.previousSibling=r:e.lastChild=r,t.parentNode=null,t.previousSibling=null,t.nextSibling=null,K(e.ownerDocument,e),t}function J(e){return e&&e.nodeType===j.DOCUMENT_TYPE_NODE}function V(e){return e&&e.nodeType===j.ELEMENT_NODE}function $(e){return e&&e.nodeType===j.TEXT_NODE}function z(e,t){var r=e.childNodes||[];if(i(r,V)||J(t))return!1;var n=i(r,J);return!(t&&n&&r.indexOf(n)>r.indexOf(t))}function G(e,t){var r=e.childNodes||[];if(i(r,function(e){return V(e)&&e!==t}))return!1;var n=i(r,J);return!(t&&n&&r.indexOf(n)>r.indexOf(t))}function X(e,t,r){if(!function(e){return e&&(e.nodeType===j.DOCUMENT_NODE||e.nodeType===j.DOCUMENT_FRAGMENT_NODE||e.nodeType===j.ELEMENT_NODE)}(e))throw new I(T,"Unexpected parent node type "+e.nodeType);if(r&&r.parentNode!==e)throw new I(F,"child not in parent");if(!function(e){return e&&(V(e)||$(e)||J(e)||e.nodeType===j.DOCUMENT_FRAGMENT_NODE||e.nodeType===j.COMMENT_NODE||e.nodeType===j.PROCESSING_INSTRUCTION_NODE)}(t)||J(t)&&e.nodeType!==j.DOCUMENT_NODE)throw new I(T,"Unexpected node type "+t.nodeType+" for parent node type "+e.nodeType)}function Y(e,t,r){var n=e.childNodes||[],o=t.childNodes||[];if(t.nodeType===j.DOCUMENT_FRAGMENT_NODE){var s=o.filter(V);if(s.length>1||i(o,$))throw new I(T,"More than one element or text in fragment");if(1===s.length&&!z(e,r))throw new I(T,"Element in fragment can not be inserted before doctype")}if(V(t)&&!z(e,r))throw new I(T,"Only one element can be added and only after doctype");if(J(t)){if(i(n,J))throw new I(T,"Only one doctype is allowed");var a=i(n,V);if(r&&n.indexOf(a)<n.indexOf(r))throw new I(T,"Doctype can only be inserted before an element");if(!r&&a)throw new I(T,"Doctype can not be appended since element is present")}}function Q(e,t,r){var n=e.childNodes||[],o=t.childNodes||[];if(t.nodeType===j.DOCUMENT_FRAGMENT_NODE){var s=o.filter(V);if(s.length>1||i(o,$))throw new I(T,"More than one element or text in fragment");if(1===s.length&&!G(e,r))throw new I(T,"Element in fragment can not be inserted before doctype")}if(V(t)&&!G(e,r))throw new I(T,"Only one element can be added and only after doctype");if(J(t)){if(i(n,function(e){return J(e)&&e!==r}))throw new I(T,"Only one doctype is allowed");var a=i(n,V);if(r&&n.indexOf(a)<n.indexOf(r))throw new I(T,"Doctype can only be inserted before an element")}}function Z(e,t,r,n){X(e,t,r),e.nodeType===j.DOCUMENT_NODE&&(n||Y)(e,t,r);var i=t.parentNode;if(i&&i.removeChild(t),t.nodeType===S){var o=t.firstChild;if(null==o)return t;var s=t.lastChild}else o=s=t;var a=r?r.previousSibling:e.lastChild;o.previousSibling=a,s.nextSibling=r,a?a.nextSibling=o:e.firstChild=o,null==r?e.lastChild=s:r.previousSibling=s;do{o.parentNode=e,ee(o,e.ownerDocument||e)}while(o!==s&&(o=o.nextSibling));return K(e.ownerDocument||e,e),t.nodeType==S&&(t.firstChild=t.lastChild=null),t}function ee(e,t){if(e.ownerDocument!==t){if(e.ownerDocument=t,e.nodeType===d&&e.attributes)for(var r=0;r<e.attributes.length;r++){var n=e.attributes.item(r);n&&(n.ownerDocument=t)}for(var i=e.firstChild;i;)ee(i,t),i=i.nextSibling}}function te(){this._nsMap={}}function re(){}function ne(){}function ie(){}function oe(){}function se(){}function ae(){}function ce(){}function ue(){}function le(){}function he(){}function de(){}function fe(){}function pe(e,t){var r=[],n=9==this.nodeType&&this.documentElement||this,i=n.prefix,o=n.namespaceURI;if(o&&null==i&&null==(i=n.lookupPrefix(o)))var s=[{namespace:o,prefix:null}];return me(this,r,e,t,s),r.join("")}function ge(e,t,r){var n=e.prefix||"",i=e.namespaceURI;if(!i)return!1;if("xml"===n&&i===o.XML||i===o.XMLNS)return!1;for(var s=r.length;s--;){var a=r[s];if(a.prefix===n)return a.namespace!==i}return!0}function ye(e,t,r){e.push(" ",t,'="',r.replace(/[<>&"\t\n\r]/g,M),'"')}function me(e,t,r,n,i){if(i||(i=[]),n){if(!(e=n(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case d:var s=e.attributes,a=s.length,c=e.firstChild,u=e.tagName,l=u;if(!(r=o.isHTML(e.namespaceURI)||r)&&!e.prefix&&e.namespaceURI){for(var h,m=0;m<s.length;m++)if("xmlns"===s.item(m).name){h=s.item(m).value;break}if(!h)for(var E=i.length-1;E>=0;E--){if(""===(A=i[E]).prefix&&A.namespace===e.namespaceURI){h=A.namespace;break}}if(h!==e.namespaceURI)for(E=i.length-1;E>=0;E--){var A;if((A=i[E]).namespace===e.namespaceURI){A.prefix&&(l=A.prefix+":"+u);break}}}t.push("<",l);for(var x=0;x<a;x++){"xmlns"==(T=s.item(x)).prefix?i.push({prefix:T.localName,namespace:T.value}):"xmlns"==T.nodeName&&i.push({prefix:"",namespace:T.value})}for(x=0;x<a;x++){var T,F,k;if(ge(T=s.item(x),0,i))ye(t,(F=T.prefix||"")?"xmlns:"+F:"xmlns",k=T.namespaceURI),i.push({prefix:F,namespace:k});me(T,t,r,n,i)}if(u===l&&ge(e,0,i))ye(t,(F=e.prefix||"")?"xmlns:"+F:"xmlns",k=e.namespaceURI),i.push({prefix:F,namespace:k});if(c||r&&!/^(?:meta|link|img|br|hr|input)$/i.test(u)){if(t.push(">"),r&&/^script$/i.test(u))for(;c;)c.data?t.push(c.data):me(c,t,r,n,i.slice()),c=c.nextSibling;else for(;c;)me(c,t,r,n,i.slice()),c=c.nextSibling;t.push("</",l,">")}else t.push("/>");return;case b:case S:for(c=e.firstChild;c;)me(c,t,r,n,i.slice()),c=c.nextSibling;return;case f:return ye(t,e.name,e.value);case p:return t.push(e.data.replace(/[<&>]/g,M));case g:return t.push("<![CDATA[",e.data,"]]>");case w:return t.push("\x3c!--",e.data,"--\x3e");case _:var I=e.publicId,C=e.systemId;if(t.push("<!DOCTYPE ",e.name),I)t.push(" PUBLIC ",I),C&&"."!=C&&t.push(" ",C),t.push(">");else if(C&&"."!=C)t.push(" SYSTEM ",C,">");else{var N=e.internalSubset;N&&t.push(" [",N,"]"),t.push(">")}return;case v:return t.push("<?",e.target," ",e.data,"?>");case y:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function ve(e,t,r){var n;switch(t.nodeType){case d:(n=t.cloneNode(!1)).ownerDocument=e;case S:break;case f:r=!0}if(n||(n=t.cloneNode(!1)),n.ownerDocument=e,n.parentNode=null,r)for(var i=t.firstChild;i;)n.appendChild(ve(e,i,r)),i=i.nextSibling;return n}function we(e,t,r){var n=new t.constructor;for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var o=t[i];"object"!=typeof o&&o!=n[i]&&(n[i]=o)}switch(t.childNodes&&(n.childNodes=new C),n.ownerDocument=e,n.nodeType){case d:var s=t.attributes,a=n.attributes=new P,c=s.length;a._ownerElement=n;for(var u=0;u<c;u++)n.setAttributeNode(we(e,s.item(u),!0));break;case f:r=!0}if(r)for(var l=t.firstChild;l;)n.appendChild(we(e,l,r)),l=l.nextSibling;return n}function be(e,t,r){e[t]=r}I.prototype=Error.prototype,u(A,I),C.prototype={length:0,item:function(e){return e>=0&&e<this.length?this[e]:null},toString:function(e,t){for(var r=[],n=0;n<this.length;n++)me(this[n],r,e,t);return r.join("")},filter:function(e){return Array.prototype.filter.call(this,e)},indexOf:function(e){return Array.prototype.indexOf.call(this,e)}},N.prototype.item=function(e){return R(this),this[e]||null},l(N,C),P.prototype={length:0,item:C.prototype.item,getNamedItem:function(e){for(var t=this.length;t--;){var r=this[t];if(r.nodeName==e)return r}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new I(k);var r=this.getNamedItem(e.nodeName);return D(this._ownerElement,this,e,r),r},setNamedItemNS:function(e){var t,r=e.ownerElement;if(r&&r!=this._ownerElement)throw new I(k);return t=this.getNamedItemNS(e.namespaceURI,e.localName),D(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return U(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var r=this.getNamedItemNS(e,t);return U(this._ownerElement,this,r),r},getNamedItemNS:function(e,t){for(var r=this.length;r--;){var n=this[r];if(n.localName==t&&n.namespaceURI==e)return n}return null}},L.prototype={hasFeature:function(e,t){return!0},createDocument:function(e,t,r){var n=new B;if(n.implementation=this,n.childNodes=new C,n.doctype=r||null,r&&n.appendChild(r),t){var i=n.createElementNS(e,t);n.appendChild(i)}return n},createDocumentType:function(e,t,r){var n=new ae;return n.name=e,n.nodeName=e,n.publicId=t||"",n.systemId=r||"",n}},j.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return Z(this,e,t)},replaceChild:function(e,t){Z(this,e,t,Q),t&&this.removeChild(t)},removeChild:function(e){return W(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(e){return we(this.ownerDocument||this,this,e)},normalize:function(){for(var e=this.firstChild;e;){var t=e.nextSibling;t&&t.nodeType==p&&e.nodeType==p?(this.removeChild(t),e.appendData(t.data)):(e.normalize(),e=t)}},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(e){for(var t=this;t;){var r=t._nsMap;if(r)for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n)&&r[n]===e)return n;t=t.nodeType==f?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var r=t._nsMap;if(r&&Object.prototype.hasOwnProperty.call(r,e))return r[e];t=t.nodeType==f?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},u(h,j),u(h,j.prototype),B.prototype={nodeName:"#document",nodeType:b,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==S){for(var r=e.firstChild;r;){var n=r.nextSibling;this.insertBefore(r,t),r=n}return e}return Z(this,e,t),ee(e,this),null===this.documentElement&&e.nodeType===d&&(this.documentElement=e),e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),W(this,e)},replaceChild:function(e,t){Z(this,e,t,Q),ee(e,this),t&&this.removeChild(t),V(e)&&(this.documentElement=e)},importNode:function(e,t){return ve(this,e,t)},getElementById:function(e){var t=null;return H(this.documentElement,function(r){if(r.nodeType==d&&r.getAttribute("id")==e)return t=r,!0}),t},getElementsByClassName:function(e){var t=c(e);return new N(this,function(r){var n=[];return t.length>0&&H(r.documentElement,function(i){if(i!==r&&i.nodeType===d){var o=i.getAttribute("class");if(o){var s=e===o;if(!s){var a=c(o);s=t.every((u=a,function(e){return u&&-1!==u.indexOf(e)}))}s&&n.push(i)}}var u}),n})},createElement:function(e){var t=new te;return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.localName=e,t.childNodes=new C,(t.attributes=new P)._ownerElement=t,t},createDocumentFragment:function(){var e=new he;return e.ownerDocument=this,e.childNodes=new C,e},createTextNode:function(e){var t=new ie;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new oe;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new se;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var r=new de;return r.ownerDocument=this,r.tagName=r.nodeName=r.target=e,r.nodeValue=r.data=t,r},createAttribute:function(e){var t=new re;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new le;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var r=new te,n=t.split(":"),i=r.attributes=new P;return r.childNodes=new C,r.ownerDocument=this,r.nodeName=t,r.tagName=t,r.namespaceURI=e,2==n.length?(r.prefix=n[0],r.localName=n[1]):r.localName=t,i._ownerElement=r,r},createAttributeNS:function(e,t){var r=new re,n=t.split(":");return r.ownerDocument=this,r.nodeName=t,r.name=t,r.namespaceURI=e,r.specified=!0,2==n.length?(r.prefix=n[0],r.localName=n[1]):r.localName=t,r}},l(B,j),te.prototype={nodeType:d,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var r=this.ownerDocument.createAttribute(e);r.value=r.nodeValue=""+t,this.setAttributeNode(r)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===S?this.insertBefore(e,null):function(e,t){return t.parentNode&&t.parentNode.removeChild(t),t.parentNode=e,t.previousSibling=e.lastChild,t.nextSibling=null,t.previousSibling?t.previousSibling.nextSibling=t:e.firstChild=t,e.lastChild=t,K(e.ownerDocument,e,t),ee(t,e.ownerDocument||e),t}(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var r=this.getAttributeNodeNS(e,t);r&&this.removeAttributeNode(r)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var r=this.getAttributeNodeNS(e,t);return r&&r.value||""},setAttributeNS:function(e,t,r){var n=this.ownerDocument.createAttributeNS(e,t);n.value=n.nodeValue=""+r,this.setAttributeNode(n)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new N(this,function(t){var r=[];return H(t,function(n){n===t||n.nodeType!=d||"*"!==e&&n.tagName!=e||r.push(n)}),r})},getElementsByTagNameNS:function(e,t){return new N(this,function(r){var n=[];return H(r,function(i){i===r||i.nodeType!==d||"*"!==e&&i.namespaceURI!==e||"*"!==t&&i.localName!=t||n.push(i)}),n})}},B.prototype.getElementsByTagName=te.prototype.getElementsByTagName,B.prototype.getElementsByTagNameNS=te.prototype.getElementsByTagNameNS,l(te,j),re.prototype.nodeType=f,l(re,j),ne.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(x[T])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,r){r=this.data.substring(0,e)+r+this.data.substring(e+t),this.nodeValue=this.data=r,this.length=r.length}},l(ne,j),ie.prototype={nodeName:"#text",nodeType:p,splitText:function(e){var t=this.data,r=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var n=this.ownerDocument.createTextNode(r);return this.parentNode&&this.parentNode.insertBefore(n,this.nextSibling),n}},l(ie,ne),oe.prototype={nodeName:"#comment",nodeType:w},l(oe,ne),se.prototype={nodeName:"#cdata-section",nodeType:g},l(se,ne),ae.prototype.nodeType=_,l(ae,j),ce.prototype.nodeType=E,l(ce,j),ue.prototype.nodeType=m,l(ue,j),le.prototype.nodeType=y,l(le,j),he.prototype.nodeName="#document-fragment",he.prototype.nodeType=S,l(he,j),de.prototype.nodeType=v,l(de,j),fe.prototype.serializeToString=function(e,t,r){return pe.call(e,t,r)},j.prototype.toString=pe;try{if(Object.defineProperty){function _e(e){switch(e.nodeType){case d:case S:var t=[];for(e=e.firstChild;e;)7!==e.nodeType&&8!==e.nodeType&&t.push(_e(e)),e=e.nextSibling;return t.join("");default:return e.nodeValue}}Object.defineProperty(N.prototype,"length",{get:function(){return R(this),this.$$length}}),Object.defineProperty(j.prototype,"textContent",{get:function(){return _e(this)},set:function(e){switch(this.nodeType){case d:case S:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),be=function(e,t,r){e["$$"+t]=r}}}catch(Se){}t.DocumentType=ae,t.DOMException=I,t.DOMImplementation=L,t.Element=te,t.Node=j,t.NodeList=C,t.XMLSerializer=fe},4746:function(e,t,r){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.SolidAuthnLogic=void 0;const a=r(4090),c=r(2233),u=s(r(9378)),l=r(2452);t.SolidAuthnLogic=class{session;constructor(e){this.session=e}get authSession(){return this.session}currentUser(){const e=(0,c.appContext)();return e.viewingNoAuthPage?(0,a.sym)(e.webId):this&&this.session&&this.session.info&&this.session.info.webId&&this.session.info.isLoggedIn?(0,a.sym)(this.session.info.webId):(0,c.offlineTestID)()}async checkUser(e){const t=new URL(window.location.href).hash;t&&window.localStorage.setItem("preLoginRedirectHash",t),this.session.events.on(l.EVENTS.SESSION_RESTORED,e=>{u.log(`Session restored to ${e}`),document.location.toString()!==e&&history.replaceState(null,"",e)});const r=new URL(window.location.href);r.hash="",await this.session.handleIncomingRedirect({restorePreviousSession:!0,url:r.href});const n=window.localStorage.getItem("preLoginRedirectHash");if(n){const e=new URL(window.location.href);e.hash!==n&&(history.pushState?history.pushState(null,document.title,n):location.hash=n,e.hash=n),window.localStorage.setItem("preLoginRedirectHash","")}let i=(0,c.offlineTestID)();if(i)return Promise.resolve(e?e(i):i);const o=this.webIdFromSession(this.session.info);return o&&(i=this.saveUser(o)),i&&u.log(`(Logged in as ${i} by authentication)`),Promise.resolve(e?e(i):i)}saveUser(e,t){let r;if(e){r="string"==typeof e?e:e.uri;const n=(0,a.namedNode)(r);return t&&(t.me=n),n}return null}webIdFromSession(e){return e?.webId&&e.isLoggedIn?e.webId:null}}},4940:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});const n={debug(e){},warn(e){},info(e){},error(e){},success(e){},msg(e){}}},4945:(e,t,r)=>{var n="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==r.g&&r.g,i=function(){function e(){this.fetch=!1,this.DOMException=n.DOMException}return e.prototype=n,new e}();!function(e){!function(t){var n=void 0!==e&&e||"undefined"!=typeof self&&self||void 0!==r.g&&r.g||{},i="URLSearchParams"in n,o="Symbol"in n&&"iterator"in Symbol,s="FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(e){return!1}}(),a="FormData"in n,c="ArrayBuffer"in n;if(c)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],l=ArrayBuffer.isView||function(e){return e&&u.indexOf(Object.prototype.toString.call(e))>-1};function h(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function d(e){return"string"!=typeof e&&(e=String(e)),e}function f(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return o&&(t[Symbol.iterator]=function(){return t}),t}function p(e){this.map={},e instanceof p?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){if(2!=e.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function g(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function y(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function m(e){var t=new FileReader,r=y(t);return t.readAsArrayBuffer(e),r}function v(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function w(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:s&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:a&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:i&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():c&&s&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=v(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c&&(ArrayBuffer.prototype.isPrototypeOf(e)||l(e))?this._bodyArrayBuffer=v(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):i&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s&&(this.blob=function(){var e=g(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=g(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(s)return this.blob().then(m);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,r,n,i,o=g(this);if(o)return o;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=y(t),n=/charset=([A-Za-z0-9_-]+)/.exec(e.type),i=n?n[1]:"utf-8",t.readAsText(e,i),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a&&(this.formData=function(){return this.text().then(S)}),this.json=function(){return this.text().then(JSON.parse)},this}p.prototype.append=function(e,t){e=h(e),t=d(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},p.prototype.delete=function(e){delete this.map[h(e)]},p.prototype.get=function(e){return e=h(e),this.has(e)?this.map[e]:null},p.prototype.has=function(e){return this.map.hasOwnProperty(h(e))},p.prototype.set=function(e,t){this.map[h(e)]=d(t)},p.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},p.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),f(e)},p.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),f(e)},p.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),f(e)},o&&(p.prototype[Symbol.iterator]=p.prototype.entries);var b=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function _(e,t){if(!(this instanceof _))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,i,o=(t=t||{}).body;if(e instanceof _){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new p(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,o||null==e._bodyInit||(o=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new p(t.headers)),this.method=(r=t.method||this.method||"GET",i=r.toUpperCase(),b.indexOf(i)>-1?i:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal||function(){if("AbortController"in n)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(o),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var s=/([?&])_=[^&]*/;if(s.test(this.url))this.url=this.url.replace(s,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function S(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function E(e,t){if(!(this instanceof E))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new p(t.headers),this.url=t.url||"",this._initBody(e)}_.prototype.clone=function(){return new _(this,{body:this._bodyInit})},w.call(_.prototype),w.call(E.prototype),E.prototype.clone=function(){return new E(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},E.error=function(){var e=new E(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var A=[301,302,303,307,308];E.redirect=function(e,t){if(-1===A.indexOf(t))throw new RangeError("Invalid status code");return new E(null,{status:t,headers:{location:e}})},t.DOMException=n.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function x(e,r){return new Promise(function(i,o){var a=new _(e,r);if(a.signal&&a.signal.aborted)return o(new t.DOMException("Aborted","AbortError"));var u=new XMLHttpRequest;function l(){u.abort()}if(u.onload=function(){var e,t,r={statusText:u.statusText,headers:(e=u.getAllResponseHeaders()||"",t=new p,e.replace(/\r?\n[\t ]+/g," ").split("\r").map(function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e}).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();try{t.append(n,i)}catch(e){console.warn("Response "+e.message)}}}),t)};0===a.url.indexOf("file://")&&(u.status<200||u.status>599)?r.status=200:r.status=u.status,r.url="responseURL"in u?u.responseURL:r.headers.get("X-Request-URL");var n="response"in u?u.response:u.responseText;setTimeout(function(){i(new E(n,r))},0)},u.onerror=function(){setTimeout(function(){o(new TypeError("Network request failed"))},0)},u.ontimeout=function(){setTimeout(function(){o(new TypeError("Network request timed out"))},0)},u.onabort=function(){setTimeout(function(){o(new t.DOMException("Aborted","AbortError"))},0)},u.open(a.method,function(e){try{return""===e&&n.location.href?n.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?u.withCredentials=!0:"omit"===a.credentials&&(u.withCredentials=!1),"responseType"in u&&(s?u.responseType="blob":c&&(u.responseType="arraybuffer")),r&&"object"==typeof r.headers&&!(r.headers instanceof p||n.Headers&&r.headers instanceof n.Headers)){var f=[];Object.getOwnPropertyNames(r.headers).forEach(function(e){f.push(h(e)),u.setRequestHeader(e,d(r.headers[e]))}),a.headers.forEach(function(e,t){-1===f.indexOf(t)&&u.setRequestHeader(t,e)})}else a.headers.forEach(function(e,t){u.setRequestHeader(t,e)});a.signal&&(a.signal.addEventListener("abort",l),u.onreadystatechange=function(){4===u.readyState&&a.signal.removeEventListener("abort",l)}),u.send(void 0===a._bodyInit?null:a._bodyInit)})}x.polyfill=!0,n.fetch||(n.fetch=x,n.Headers=p,n.Request=_,n.Response=E),t.Headers=p,t.Request=_,t.Response=E,t.fetch=x,Object.defineProperty(t,"__esModule",{value:!0})}({})}(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var o=n.fetch?n:i;(t=o.fetch).default=o.fetch,t.fetch=o.fetch,t.Headers=o.Headers,t.Request=o.Request,t.Response=o.Response,e.exports=t},5108:(e,t,r)=>{"use strict";r.d(t,{A:()=>u});var n=r(4705),i=r(1059),o=r(8936),s=r(9403),a=r(2931),c=r(2915);class u extends o.A{constructor(e){if(super((0,a.E)(e)),(0,n.A)(this,"termType",s.Kk),(0,n.A)(this,"classOrder",i.A.NamedNode),!this.value)throw new Error("Missing IRI for NamedNode");if(!this.value.includes(":"))throw new Error('NamedNode IRI "'+e+'" must be absolute.');if(this.value.includes(" "))throw new Error('Error: NamedNode IRI "'+e+'" must not contain unencoded spaces.')}dir(){var e=this.value.split("#")[0],t=e.slice(0,-1).lastIndexOf("/"),r=e.indexOf("//");return r>=0&&t<r+2||t<0?null:new u(e.slice(0,t+1))}site(){var e=this.value.split("#")[0],t=e.indexOf("//");if(t<0)throw new Error("This URI does not have a web site part (origin)");var r=e.indexOf("/",t+2);return new u(r<0?e.slice(0)+"/":e.slice(0,r+1))}doc(){return this.value.indexOf("#")<0?this:new u(this.value.split("#")[0])}toString(){return"<"+this.value+">"}id(){return this.value.split("#")[1]}get uri(){return this.value}set uri(e){this.value=e}static fromValue(e){return null==e||(0,c.D0)(e)?e:new u(e)}}},5130:(e,t,r)=>{"use strict";r.d(t,{JU:()=>h,Yp:()=>l,Y5:()=>u});var n=r(5141),i=r(7991),o=r(1575),s=r(1436),a=r(5994);const c=async e=>{if(e instanceof Uint8Array)return{kty:"oct",k:(0,s.lF)(e)};if(!(0,i.R)(e))throw new TypeError((0,o.A)(e,...a.g,"Uint8Array"));if(!e.extractable)throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");const{ext:t,key_ops:r,alg:n,use:c,...u}=await i.A.subtle.exportKey("jwk",e);return u};async function u(e){return(0,n.Nj)(e)}async function l(e){return(0,n.Jq)(e)}async function h(e){return c(e)}},5141:(e,t,r)=>{"use strict";r.d(t,{IG:()=>g,sc:()=>y,zp:()=>b,Jq:()=>h,Nj:()=>l});var n=r(7991),i=r(1575),o=r(1436);const s=(e,t)=>`-----BEGIN ${t}-----\n${(e.match(/.{1,64}/g)||[]).join("\n")}\n-----END ${t}-----`;var a=r(7493),c=r(5994);const u=async(e,t,r)=>{if(!(0,n.R)(r))throw new TypeError((0,i.A)(r,...c.g));if(!r.extractable)throw new TypeError("CryptoKey is not extractable");if(r.type!==e)throw new TypeError(`key is not a ${e} key`);return s((0,o.WG)(new Uint8Array(await n.A.subtle.exportKey(t,r))),`${e.toUpperCase()} KEY`)},l=e=>u("public","spki",e),h=e=>u("private","pkcs8",e),d=(e,t,r=0)=>{0===r&&(t.unshift(t.length),t.unshift(6));const n=e.indexOf(t[0],r);if(-1===n)return!1;const i=e.subarray(n,n+t.length);return i.length===t.length&&(i.every((e,r)=>e===t[r])||d(e,t,n+1))},f=e=>{switch(!0){case d(e,[42,134,72,206,61,3,1,7]):return"P-256";case d(e,[43,129,4,0,34]):return"P-384";case d(e,[43,129,4,0,35]):return"P-521";case d(e,[43,101,110]):return"X25519";case d(e,[43,101,111]):return"X448";case d(e,[43,101,112]):return"Ed25519";case d(e,[43,101,113]):return"Ed448";default:throw new a.JOSENotSupported("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},p=async(e,t,r,i,o)=>{let s,c;const u=new Uint8Array(atob(r.replace(e,"")).split("").map(e=>e.charCodeAt(0))),l="spki"===t;switch(i){case"PS256":case"PS384":case"PS512":s={name:"RSA-PSS",hash:`SHA-${i.slice(-3)}`},c=l?["verify"]:["sign"];break;case"RS256":case"RS384":case"RS512":s={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${i.slice(-3)}`},c=l?["verify"]:["sign"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":s={name:"RSA-OAEP",hash:`SHA-${parseInt(i.slice(-3),10)||1}`},c=l?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":s={name:"ECDSA",namedCurve:"P-256"},c=l?["verify"]:["sign"];break;case"ES384":s={name:"ECDSA",namedCurve:"P-384"},c=l?["verify"]:["sign"];break;case"ES512":s={name:"ECDSA",namedCurve:"P-521"},c=l?["verify"]:["sign"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{const e=f(u);s=e.startsWith("P-")?{name:"ECDH",namedCurve:e}:{name:e},c=l?[]:["deriveBits"];break}case"Ed25519":s={name:"Ed25519"},c=l?["verify"]:["sign"];break;case"EdDSA":s={name:f(u)},c=l?["verify"]:["sign"];break;default:throw new a.JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value')}return n.A.subtle.importKey(t,u,s,o?.extractable??!1,c)},g=(e,t,r)=>p(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,"pkcs8",e,t,r),y=(e,t,r)=>p(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g,"spki",e,t,r);function m(e){const t=[];let r=0;for(;r<e.length;){const n=v(e.subarray(r));t.push(n),r+=n.byteLength}return t}function v(e){let t=0,r=31&e[0];if(t++,31===r){for(r=0;e[t]>=128;)r=128*r+e[t]-128,t++;r=128*r+e[t]-128,t++}let n=0;if(e[t]<128)n=e[t],t++;else{if(128===n){for(n=0;0!==e[t+n]||0!==e[t+n+1];){if(n>e.byteLength)throw new TypeError("invalid indefinite form length");n++}const r=t+n+2;return{byteLength:r,contents:e.subarray(t,t+n),raw:e.subarray(0,r)}}{const r=127&e[t];t++,n=0;for(let i=0;i<r;i++)n=256*n+e[t],t++}}const i=t+n;return{byteLength:i,contents:e.subarray(t,i),raw:e.subarray(0,i)}}function w(e){const t=e.replace(/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g,""),r=(0,o.y4)(t);return s(function(e){const t=m(m(v(e).contents)[0].contents);return(0,o.WG)(t[160===t[0].raw[0]?6:5].raw)}(r),"PUBLIC KEY")}const b=(e,t,r)=>{let n;try{n=w(e)}catch(e){throw new TypeError("Failed to parse the X.509 certificate",{cause:e})}return y(n,t,r)}},5306:function(e,t){var r,n,i;n=[],void 0===(i="function"==typeof(r=function(){"use strict";function e(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}function t(e,r,n,i){this.message=e,this.expected=r,this.found=n,this.location=i,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}function r(e,r){r=void 0!==r?r:{};var n,i={},o={turtleDoc:Yr},s=Yr,a=function(e){var t=ei.toJSON();return t["@graph"]=[],e.filter(e=>Array.isArray(e)).forEach(e=>{e.forEach(e=>{t["@graph"].push(e)})}),1===t["@graph"].length&&(Object.assign(t,t["@graph"][0]),delete t["@graph"]),t},c="\ufeff",u=Kr("\ufeff",!1),l=".",h=Kr(".",!1),d=function(e){return e},f="#",p=Kr("#",!1),g=/^[^\n]/,y=Wr(["\n"],!0,!1),m="\n",v=Kr("\n",!1),w=function(e){return e.join("")},b="@prefix",_=Kr("@prefix",!1),S=function(e,t){return ei.addPrefix(""===e?"0":e,t),{}},E="@base",A=Kr("@base",!1),x=function(e){return ei.addBase(e),{}},T=/^[Bb]/,F=Wr(["B","b"],!1,!1),k=/^[Aa]/,I=Wr(["A","a"],!1,!1),C=/^[Ss]/,N=Wr(["S","s"],!1,!1),R=/^[Ee]/,P=Wr(["E","e"],!1,!1),O=/^[Pp]/,D=Wr(["P","p"],!1,!1),U=/^[Rr]/,L=Wr(["R","r"],!1,!1),j=/^[Ff]/,M=Wr(["F","f"],!1,!1),H=/^[Ii]/,B=Wr(["I","i"],!1,!1),q=/^[Xx]/,K=Wr(["X","x"],!1,!1),W=function(e,t){var r={};return"string"==typeof e&&"[]"!==e?r["@id"]=e:"object"==typeof e&&Object.assign(r,e),t&&Object.assign(r,t),[r]},J=function(e,t){var r={};return e&&Object.assign(r,e),t&&Object.assign(r,t),[r]},V=";",$=Kr(";",!1),z=function(e,t,r,n){var i={};return i[r]=n,i},G=function(e,t,r){return r},X=function(e,t,r){var n={};return r.unshift(Zn(e,t)),r.forEach(e=>{e&&Object.keys(e).forEach(t=>{e[t].forEach(e=>{"@type"===t&&void 0!==e["@id"]&&(e=e["@id"]),void 0===n[t]?n[t]=e:Array.isArray(n[t])?n[t].push(e):n[t]=[n[t],e]})})}),n},Y=",",Q=Kr(",",!1),Z=function(e,t){return t},ee=function(e,t){return t.unshift(e),t},te="a",re=Kr("a",!1),ne=function(){return"@type"},ie=function(e){return ti(e,!0)},oe=function(e){return ti(e,!1)},se=function(e){return"[]"===e?{}:{"@id":e}},ae=function(e){return{"@id":e}},ce="[",ue=Kr("[",!1),le="]",he=Kr("]",!1),de="(",fe=Kr("(",!1),pe=")",ge=Kr(")",!1),ye=function(e){return{"@list":e}},me=function(e,t){return{"@value":e,"@language":t}},ve="^^",we=Kr("^^",!1),be=function(e,t){if("http://www.w3.org/2001/XMLSchema#boolean"===t&&"true"===e)return!0;if("http://www.w3.org/2001/XMLSchema#boolean"===t&&"false"===e)return!1;if("http://www.w3.org/2001/XMLSchema#integer"===t)return parseInt(e);if("http://www.w3.org/2001/XMLSchema#double"===t)return parseFloat(e);const r=ei.resolve(t,!0);if(r){const n=t.split(":")[0];if("http://www.w3.org/2001/XMLSchema#boolean"===r&&"true"===e)return ei.decrement(n),!0;if("http://www.w3.org/2001/XMLSchema#boolean"===r&&"false"===e)return ei.decrement(n),!1;if("http://www.w3.org/2001/XMLSchema#integer"===r)return ei.decrement(n),parseInt(e);if("http://www.w3.org/2001/XMLSchema#double"===r)return ei.decrement(n),parseFloat(e)}return{"@value":e,"@type":t}},_e="true",Se=Kr("true",!1),Ee=function(){return!0},Ae="false",xe=Kr("false",!1),Te=function(){return!1},Fe=function(e){return e+":"},ke="<",Ie=Kr("<",!1),Ce=/^[^\0- <>"{}|\^`\\]/,Ne=Wr([["\0"," "],"<",">",'"',"{","}","|","^","`","\\"],!0,!1),Re=">",Pe=Kr(">",!1),Oe=function(e){const t=e.map(e=>65536<=e.codePointAt(0)&&e.codePointAt(0)<=983039?"a":1===e.length?e:6===e.length?String.fromCharCode("0x"+e.substring(2)):10===e.length?String.fromCodePoint("0x"+e.substring(2)):e).join("");if(t.match(/^[^\u0000-\u0020<>"{}|^`\\]*$/)){var r=e.join("");try{return ei.resolve(r)}catch(e){qr("Invalid IRIREF "+r)}}else qr("Invalid IRIREF "+e.join("")+" / "+t)},De=":",Ue=Kr(":",!1),Le=function(e){return e=e||"0",!1===ei.hasPrefix(e)&&qr("undefined prefix "+e),e},je=function(e){return e||""},Me=function(e,t){return ei.increment(e),ei.resolve(e+":"+t)},He="_:",Be=Kr("_:",!1),qe=/^[0-9]/,Ke=Wr([["0","9"]],!1,!1),We="@",Je=Kr("@",!1),Ve=/^[a-zA-Z]/,$e=Wr([["a","z"],["A","Z"]],!1,!1),ze="-",Ge=Kr("-",!1),Xe=/^[a-zA-Z0-9]/,Ye=Wr([["a","z"],["A","Z"],["0","9"]],!1,!1),Qe=function(e,t){return"-"+t.join("")},Ze=function(e,t){return e.join("")+t.join("")},et=/^[+\-]/,tt=Wr(["+","-"],!1,!1),rt=function(e){return e.match(/^[0+][0-9]+$/)?{"@value":e,"@type":"http://www.w3.org/2001/XMLSchema#integer"}:parseInt(e)},nt=function(e){return{"@value":e,"@type":"http://www.w3.org/2001/XMLSchema#decimal"}},it=function(e){return{"@value":e,"@type":"http://www.w3.org/2001/XMLSchema#double"}},ot=/^[eE]/,st=Wr(["e","E"],!1,!1),at='"',ct=Kr('"',!1),ut=/^[^"\\\n\r]/,lt=Wr(['"',"\\","\n","\r"],!0,!1),ht="'",dt=Kr("'",!1),ft=/^[^'\\\n\r]/,pt=Wr(["'","\\","\n","\r"],!0,!1),gt="'''",yt=Kr("'''",!1),mt=/^[^'\\]/,vt=Wr(["'","\\"],!0,!1),wt="''",bt=Kr("''",!1),_t=function(e,t){return"''"+t.join("")},St=function(e,t){return"'"+t.join("")},Et=function(e,t){return e.join("")+t.join("")},At='"""',xt=Kr('"""',!1),Tt=/^[^"\\]/,Ft=Wr(['"',"\\"],!0,!1),kt='""',It=Kr('""',!1),Ct=function(e,t){return'""'+t.join("")},Nt=function(e,t){return'"'+t.join("")},Rt="\\U",Pt=Kr("\\U",!1),Ot=function(e){return String.fromCodePoint(parseInt(e.join(""),16))},Dt="\\u",Ut=Kr("\\u",!1),Lt=function(e){return String.fromCharCode(parseInt(e.join(""),16))},jt="\\t",Mt=Kr("\\t",!1),Ht=function(){return"\t"},Bt="\\b",qt=Kr("\\b",!1),Kt=function(){return"\b"},Wt="\\n",Jt=Kr("\\n",!1),Vt=function(){return"\n"},$t="\\r",zt=Kr("\\r",!1),Gt=function(){return"\r"},Xt="\\f",Yt=Kr("\\f",!1),Qt=function(){return"\f"},Zt='\\"',er=Kr('\\"',!1),tr=function(){return'"'},rr="\\'",nr=Kr("\\'",!1),ir=function(){return"'"},or="\\\\",sr=Kr("\\\\",!1),ar=function(){return"\\"},cr=/^[ \t\r\n]/,ur=Wr([" ","\t","\r","\n"],!1,!1),lr=function(){return"[]"},hr=/^[\uD800-\uDBFF]/,dr=Wr([["\ud800","\udbff"]],!1,!1),fr=/^[\uDC00-\uDFFF]/,pr=Wr([["\udc00","\udfff"]],!1,!1),gr=function(e,t){return e+t},yr=/^[A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,mr=Wr([["A","Z"],["a","z"],["À","Ö"],["Ø","ö"],["ø","˿"],["Ͱ","ͽ"],["Ϳ",""],["",""],["⁰",""],["Ⰰ",""],["、",""],["豈","﷏"],["ﷰ","�"]],!1,!1),vr="_",wr=Kr("_",!1),br="·",_r=Kr("·",!1),Sr=/^[\u0300-\u036F]/,Er=Wr([["̀","ͯ"]],!1,!1),Ar=/^[\u203F-\u2040]/,xr=Wr([["‿","⁀"]],!1,!1),Tr=function(e,t,r,n){return r.join("")+n.join("")},Fr=function(e,t,r){return e+t.join("")+r.join("")},kr="%",Ir=Kr("%",!1),Cr=/^[0-9A-Fa-f]/,Nr=Wr([["0","9"],["A","F"],["a","f"]],!1,!1),Rr="\\",Pr=Kr("\\",!1),Or=/^[_~.!$&'()*+,;=\/?#@%\-]/,Dr=Wr(["_","~",".","!","$","&","'","(",")","*","+",",",";","=","/","?","#","@","%","-"],!1,!1),Ur=0,Lr=0,jr=[{line:1,column:1}],Mr=0,Hr=[],Br=0;if("startRule"in r){if(!(r.startRule in o))throw new Error("Can't start parsing from rule \""+r.startRule+'".');s=o[r.startRule]}function qr(e,t){throw Gr(e,t=void 0!==t?t:$r(Lr,Ur))}function Kr(e,t){return{type:"literal",text:e,ignoreCase:t}}function Wr(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function Jr(){return{type:"end"}}function Vr(t){var r,n=jr[t];if(n)return n;for(r=t-1;!jr[r];)r--;for(n={line:(n=jr[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return jr[t]=n,n}function $r(e,t){var r=Vr(e),n=Vr(t);return{start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:n.line,column:n.column}}}function zr(e){Ur<Mr||(Ur>Mr&&(Mr=Ur,Hr=[]),Hr.push(e))}function Gr(e,r){return new t(e,null,null,r)}function Xr(e,r,n){return new t(t.buildMessage(e,r),e,r,n)}function Yr(){var e,t,r,n,o;for(e=Ur,t=[],r=Qr();r!==i;)t.push(r),r=Qr();if(t!==i){for(r=[],n=Zr();n!==i;)r.push(n),n=Zr();if(r!==i){for(n=[],o=tn();o!==i;)n.push(o),o=tn();n!==i?(Lr=e,e=t=a(r)):(Ur=e,e=i)}else Ur=e,e=i}else Ur=e,e=i;return e}function Qr(){var t;return 65279===e.charCodeAt(Ur)?(t=c,Ur++):(t=i,0===Br&&zr(u)),t}function Zr(){var t,r,n,o;if((t=rn())===i)if(t=Ur,(r=cn())!==i){for(n=[],o=tn();o!==i;)n.push(o),o=tn();n!==i?(46===e.charCodeAt(Ur)?(o=l,Ur++):(o=i,0===Br&&zr(h)),o!==i?(Lr=t,t=r=d(r)):(Ur=t,t=i)):(Ur=t,t=i)}else Ur=t,t=i;return t}function en(){var t,r,n,o;if(t=Ur,35===e.charCodeAt(Ur)?(r=f,Ur++):(r=i,0===Br&&zr(p)),r!==i){for(n=[],g.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(y));o!==i;)n.push(o),g.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(y));n!==i?(10===e.charCodeAt(Ur)?(o=m,Ur++):(o=i,0===Br&&zr(v)),o!==i?(Lr=t,t=r=w(n)):(Ur=t,t=i)):(Ur=t,t=i)}else Ur=t,t=i;return t}function tn(){var e;return(e=Bn())===i&&(e=en()),e}function rn(){var e;return(e=nn())===i&&(e=on())===i&&(e=an())===i&&(e=sn()),e}function nn(){var t,r,n,o,s,a,c,u,d;for(t=Ur,r=[],n=tn();n!==i;)r.push(n),n=tn();if(r!==i)if(e.substr(Ur,7)===b?(n=b,Ur+=7):(n=i,0===Br&&zr(_)),n!==i){for(o=[],s=tn();s!==i;)o.push(s),s=tn();if(o!==i)if((s=Fn())!==i){for(a=[],c=tn();c!==i;)a.push(c),c=tn();if(a!==i)if((c=xn())!==i){for(u=[],d=tn();d!==i;)u.push(d),d=tn();u!==i?(46===e.charCodeAt(Ur)?(d=l,Ur++):(d=i,0===Br&&zr(h)),d!==i?(Lr=t,t=r=S(s,c)):(Ur=t,t=i)):(Ur=t,t=i)}else Ur=t,t=i;else Ur=t,t=i}else Ur=t,t=i;else Ur=t,t=i}else Ur=t,t=i;else Ur=t,t=i;return t}function on(){var t,r,n,o,s,a,c;for(t=Ur,r=[],n=tn();n!==i;)r.push(n),n=tn();if(r!==i)if(e.substr(Ur,5)===E?(n=E,Ur+=5):(n=i,0===Br&&zr(A)),n!==i){for(o=[],s=tn();s!==i;)o.push(s),s=tn();if(o!==i)if((s=xn())!==i){for(a=[],c=tn();c!==i;)a.push(c),c=tn();a!==i?(46===e.charCodeAt(Ur)?(c=l,Ur++):(c=i,0===Br&&zr(h)),c!==i?(Lr=t,t=r=x(s)):(Ur=t,t=i)):(Ur=t,t=i)}else Ur=t,t=i;else Ur=t,t=i}else Ur=t,t=i;else Ur=t,t=i;return t}function sn(){var t,r,n,o,s,a,c,u;for(t=Ur,r=[],n=tn();n!==i;)r.push(n),n=tn();if(r!==i)if(T.test(e.charAt(Ur))?(n=e.charAt(Ur),Ur++):(n=i,0===Br&&zr(F)),n!==i)if(k.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(I)),o!==i)if(C.test(e.charAt(Ur))?(s=e.charAt(Ur),Ur++):(s=i,0===Br&&zr(N)),s!==i)if(R.test(e.charAt(Ur))?(a=e.charAt(Ur),Ur++):(a=i,0===Br&&zr(P)),a!==i){for(c=[],u=tn();u!==i;)c.push(u),u=tn();c!==i&&(u=xn())!==i?(Lr=t,t=r=x(u)):(Ur=t,t=i)}else Ur=t,t=i;else Ur=t,t=i;else Ur=t,t=i;else Ur=t,t=i;else Ur=t,t=i;return t}function an(){var t,r,n,o,s,a,c,u,l,h,d,f;for(t=Ur,r=[],n=tn();n!==i;)r.push(n),n=tn();if(r!==i)if(O.test(e.charAt(Ur))?(n=e.charAt(Ur),Ur++):(n=i,0===Br&&zr(D)),n!==i)if(U.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(L)),o!==i)if(R.test(e.charAt(Ur))?(s=e.charAt(Ur),Ur++):(s=i,0===Br&&zr(P)),s!==i)if(j.test(e.charAt(Ur))?(a=e.charAt(Ur),Ur++):(a=i,0===Br&&zr(M)),a!==i)if(H.test(e.charAt(Ur))?(c=e.charAt(Ur),Ur++):(c=i,0===Br&&zr(B)),c!==i)if(q.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(K)),u!==i){for(l=[],h=tn();h!==i;)l.push(h),h=tn();if(l!==i)if((h=Fn())!==i){for(d=[],f=tn();f!==i;)d.push(f),f=tn();d!==i&&(f=xn())!==i?(Lr=t,t=r=S(h,f)):(Ur=t,t=i)}else Ur=t,t=i;else Ur=t,t=i}else Ur=t,t=i;else Ur=t,t=i;else Ur=t,t=i;else Ur=t,t=i;else Ur=t,t=i;else Ur=t,t=i;else Ur=t,t=i;return t}function cn(){var e,t,r;return e=Ur,(t=dn())!==i&&(r=un())!==i?(Lr=e,e=t=W(t,r)):(Ur=e,e=i),e===i&&(e=Ur,(t=yn())!==i?((r=un())===i&&(r=null),r!==i?(Lr=e,e=t=J(t,r)):(Ur=e,e=i)):(Ur=e,e=i)),e}function un(){var t,r,n,o,s,a,c,u,l,h;if(t=Ur,(r=hn())!==i)if((n=ln())!==i){for(o=[],s=Ur,a=[],c=tn();c!==i;)a.push(c),c=tn();for(a!==i?(59===e.charCodeAt(Ur)?(c=V,Ur++):(c=i,0===Br&&zr($)),c!==i?(u=Ur,(l=hn())!==i&&(h=ln())!==i?(Lr=u,u=l=z(r,n,l,h)):(Ur=u,u=i),u===i&&(u=null),u!==i?(Lr=s,s=a=G(r,n,u)):(Ur=s,s=i)):(Ur=s,s=i)):(Ur=s,s=i);s!==i;){for(o.push(s),s=Ur,a=[],c=tn();c!==i;)a.push(c),c=tn();a!==i?(59===e.charCodeAt(Ur)?(c=V,Ur++):(c=i,0===Br&&zr($)),c!==i?(u=Ur,(l=hn())!==i&&(h=ln())!==i?(Lr=u,u=l=z(r,n,l,h)):(Ur=u,u=i),u===i&&(u=null),u!==i?(Lr=s,s=a=G(r,n,u)):(Ur=s,s=i)):(Ur=s,s=i)):(Ur=s,s=i)}o!==i?(Lr=t,t=r=X(r,n,o)):(Ur=t,t=i)}else Ur=t,t=i;else Ur=t,t=i;return t}function ln(){var t,r,n,o,s,a,c;if(t=Ur,(r=pn())!==i){for(n=[],o=Ur,s=[],a=tn();a!==i;)s.push(a),a=tn();for(s!==i?(44===e.charCodeAt(Ur)?(a=Y,Ur++):(a=i,0===Br&&zr(Q)),a!==i&&(c=pn())!==i?(Lr=o,o=s=Z(r,c)):(Ur=o,o=i)):(Ur=o,o=i);o!==i;){for(n.push(o),o=Ur,s=[],a=tn();a!==i;)s.push(a),a=tn();s!==i?(44===e.charCodeAt(Ur)?(a=Y,Ur++):(a=i,0===Br&&zr(Q)),a!==i&&(c=pn())!==i?(Lr=o,o=s=Z(r,c)):(Ur=o,o=i)):(Ur=o,o=i)}n!==i?(Lr=t,t=r=ee(r,n)):(Ur=t,t=i)}else Ur=t,t=i;return t}function hn(){var t,r,n;if(t=Ur,(r=fn())!==i&&(Lr=t,r=d(r)),(t=r)===i){for(t=Ur,r=[],n=tn();n!==i;)r.push(n),n=tn();r!==i?(97===e.charCodeAt(Ur)?(n=te,Ur++):(n=i,0===Br&&zr(re)),n!==i?(Lr=t,t=r=ne()):(Ur=t,t=i)):(Ur=t,t=i)}return t}function dn(){var e,t;return e=Ur,(t=mn())!==i&&(Lr=e,t=ie(t)),(e=t)===i&&(e=An())===i&&(e=Sn()),e}function fn(){var e,t,r;for(e=Ur,t=[],r=tn();r!==i;)t.push(r),r=tn();return t!==i&&(r=Sn())!==i?(Lr=e,e=t=d(r)):(Ur=e,e=i),e}function pn(){var e,t;return(e=gn())===i&&(e=Ur,(t=mn())!==i&&(Lr=e,t=oe(t)),(e=t)===i&&(e=Ur,(t=An())!==i&&(Lr=e,t=se(t)),(e=t)===i&&(e=Ur,(t=yn())!==i&&(Lr=e,t=d(t)),(e=t)===i&&(e=Ur,(t=Sn())!==i&&(Lr=e,t=ae(t)),e=t)))),e}function gn(){var e;return(e=wn())===i&&(e=vn())===i&&(e=bn()),e}function yn(){var t,r,n,o,s,a;for(t=Ur,r=[],n=tn();n!==i;)r.push(n),n=tn();if(r!==i)if(91===e.charCodeAt(Ur)?(n=ce,Ur++):(n=i,0===Br&&zr(ue)),n!==i)if((o=un())!==i){for(s=[],a=tn();a!==i;)s.push(a),a=tn();s!==i?(93===e.charCodeAt(Ur)?(a=le,Ur++):(a=i,0===Br&&zr(he)),a!==i?(Lr=t,t=r=d(o)):(Ur=t,t=i)):(Ur=t,t=i)}else Ur=t,t=i;else Ur=t,t=i;else Ur=t,t=i;return t}function mn(){var t,r,n,o,s,a;for(t=Ur,r=[],n=tn();n!==i;)r.push(n),n=tn();if(r!==i)if(40===e.charCodeAt(Ur)?(n=de,Ur++):(n=i,0===Br&&zr(fe)),n!==i){for(o=[],s=pn();s!==i;)o.push(s),s=pn();if(o!==i){for(s=[],a=tn();a!==i;)s.push(a),a=tn();s!==i?(41===e.charCodeAt(Ur)?(a=pe,Ur++):(a=i,0===Br&&zr(ge)),a!==i?(Lr=t,t=r=ye(o)):(Ur=t,t=i)):(Ur=t,t=i)}else Ur=t,t=i}else Ur=t,t=i;else Ur=t,t=i;return t}function vn(){var e,t,r;for(e=Ur,t=[],r=tn();r!==i;)t.push(r),r=tn();return t!==i?((r=Pn())===i&&(r=Rn())===i&&(r=Nn()),r!==i?(Lr=e,e=t=d(r)):(Ur=e,e=i)):(Ur=e,e=i),e}function wn(){var t,r,n,o,s,a,c;for(t=Ur,r=[],n=tn();n!==i;)r.push(n),n=tn();if(r!==i)if((n=_n())!==i){for(o=[],s=tn();s!==i;)o.push(s),s=tn();o!==i&&(s=Cn())!==i?(Lr=t,t=r=me(n,s)):(Ur=t,t=i)}else Ur=t,t=i;else Ur=t,t=i;if(t===i){for(t=Ur,r=[],n=tn();n!==i;)r.push(n),n=tn();if(r!==i)if((n=_n())!==i){for(o=[],s=tn();s!==i;)o.push(s),s=tn();if(o!==i)if(e.substr(Ur,2)===ve?(s=ve,Ur+=2):(s=i,0===Br&&zr(we)),s!==i){for(a=[],c=tn();c!==i;)a.push(c),c=tn();a!==i&&(c=Sn())!==i?(Lr=t,t=r=be(n,c)):(Ur=t,t=i)}else Ur=t,t=i;else Ur=t,t=i}else Ur=t,t=i;else Ur=t,t=i;if(t===i){for(t=Ur,r=[],n=tn();n!==i;)r.push(n),n=tn();r!==i&&(n=_n())!==i?(Lr=t,t=r=d(n)):(Ur=t,t=i)}}return t}function bn(){var t,r,n;for(t=Ur,r=[],n=tn();n!==i;)r.push(n),n=tn();if(r!==i?(e.substr(Ur,4)===_e?(n=_e,Ur+=4):(n=i,0===Br&&zr(Se)),n!==i?(Lr=t,t=r=Ee()):(Ur=t,t=i)):(Ur=t,t=i),t===i){for(t=Ur,r=[],n=tn();n!==i;)r.push(n),n=tn();r!==i?(e.substr(Ur,5)===Ae?(n=Ae,Ur+=5):(n=i,0===Br&&zr(xe)),n!==i?(Lr=t,t=r=Te()):(Ur=t,t=i)):(Ur=t,t=i)}return t}function _n(){var e,t,r;for(e=Ur,t=[],r=tn();r!==i;)t.push(r),r=tn();return t!==i?((r=Ln())===i&&(r=jn())===i&&(r=Un())===i&&(r=Dn()),r!==i?(Lr=e,e=t=d(r)):(Ur=e,e=i)):(Ur=e,e=i),e}function Sn(){var e,t,r;for(e=Ur,t=[],r=tn();r!==i;)t.push(r),r=tn();if(t!==i&&(r=xn())!==i?(Lr=e,e=t=d(r)):(Ur=e,e=i),e===i){for(e=Ur,t=[],r=tn();r!==i;)t.push(r),r=tn();t!==i&&(r=En())!==i?(Lr=e,e=t=d(r)):(Ur=e,e=i)}return e}function En(){var e,t;return(e=kn())===i&&(e=Ur,(t=Tn())!==i&&(Lr=e,t=Fe(t)),e=t),e}function An(){var e,t,r;for(e=Ur,t=[],r=tn();r!==i;)t.push(r),r=tn();if(t!==i&&(r=In())!==i?(Lr=e,e=t=d(r)):(Ur=e,e=i),e===i){for(e=Ur,t=[],r=tn();r!==i;)t.push(r),r=tn();t!==i&&(r=qn())!==i?(Lr=e,e=t=d(r)):(Ur=e,e=i)}return e}function xn(){var t,r,n,o;if(t=Ur,60===e.charCodeAt(Ur)?(r=ke,Ur++):(r=i,0===Br&&zr(Ie)),r!==i){for(n=[],Ce.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(Ne)),o===i&&(o=Mn());o!==i;)n.push(o),Ce.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(Ne)),o===i&&(o=Mn());n!==i?(62===e.charCodeAt(Ur)?(o=Re,Ur++):(o=i,0===Br&&zr(Pe)),o!==i?(Lr=t,t=r=Oe(n)):(Ur=t,t=i)):(Ur=t,t=i)}else Ur=t,t=i;return t}function Tn(){var t,r,n;return t=Ur,(r=Vn())===i&&(r=null),r!==i?(58===e.charCodeAt(Ur)?(n=De,Ur++):(n=i,0===Br&&zr(Ue)),n!==i?(Lr=t,t=r=Le(r)):(Ur=t,t=i)):(Ur=t,t=i),t}function Fn(){var t,r,n;return t=Ur,(r=Vn())===i&&(r=null),r!==i?(58===e.charCodeAt(Ur)?(n=De,Ur++):(n=i,0===Br&&zr(Ue)),n!==i?(Lr=t,t=r=je(r)):(Ur=t,t=i)):(Ur=t,t=i),t}function kn(){var e,t,r;return e=Ur,(t=Tn())!==i&&(r=$n())!==i?(Lr=e,e=t=Me(t,r)):(Ur=e,e=i),e}function In(){var t,r,n,o,s,a,c,u,d,f;if(t=Ur,r=Ur,e.substr(Ur,2)===He?(n=He,Ur+=2):(n=i,0===Br&&zr(Be)),n!==i)if((o=Wn())===i&&(qe.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(Ke))),o!==i){for(s=[],a=Jn();a!==i;)s.push(a),a=Jn();if(s!==i){if(a=[],c=Ur,u=[],46===e.charCodeAt(Ur)?(d=l,Ur++):(d=i,0===Br&&zr(h)),d!==i)for(;d!==i;)u.push(d),46===e.charCodeAt(Ur)?(d=l,Ur++):(d=i,0===Br&&zr(h));else u=i;if(u!==i){if(d=[],(f=Jn())!==i)for(;f!==i;)d.push(f),f=Jn();else d=i;d!==i?c=u=[u,d]:(Ur=c,c=i)}else Ur=c,c=i;for(;c!==i;){if(a.push(c),c=Ur,u=[],46===e.charCodeAt(Ur)?(d=l,Ur++):(d=i,0===Br&&zr(h)),d!==i)for(;d!==i;)u.push(d),46===e.charCodeAt(Ur)?(d=l,Ur++):(d=i,0===Br&&zr(h));else u=i;if(u!==i){if(d=[],(f=Jn())!==i)for(;f!==i;)d.push(f),f=Jn();else d=i;d!==i?c=u=[u,d]:(Ur=c,c=i)}else Ur=c,c=i}a!==i?r=n=[n,o,s,a]:(Ur=r,r=i)}else Ur=r,r=i}else Ur=r,r=i;else Ur=r,r=i;return t=r!==i?e.substring(t,Ur):r}function Cn(){var t,r,n,o,s,a,c,u;if(t=Ur,64===e.charCodeAt(Ur)?(r=We,Ur++):(r=i,0===Br&&zr(Je)),r!==i){if(n=[],Ve.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr($e)),o!==i)for(;o!==i;)n.push(o),Ve.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr($e));else n=i;if(n!==i){if(o=[],s=Ur,45===e.charCodeAt(Ur)?(a=ze,Ur++):(a=i,0===Br&&zr(Ge)),a!==i){if(c=[],Xe.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ye)),u!==i)for(;u!==i;)c.push(u),Xe.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ye));else c=i;c!==i?(Lr=s,s=a=Qe(n,c)):(Ur=s,s=i)}else Ur=s,s=i;for(;s!==i;)if(o.push(s),s=Ur,45===e.charCodeAt(Ur)?(a=ze,Ur++):(a=i,0===Br&&zr(Ge)),a!==i){if(c=[],Xe.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ye)),u!==i)for(;u!==i;)c.push(u),Xe.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ye));else c=i;c!==i?(Lr=s,s=a=Qe(n,c)):(Ur=s,s=i)}else Ur=s,s=i;o!==i?(Lr=t,t=r=Ze(n,o)):(Ur=t,t=i)}else Ur=t,t=i}else Ur=t,t=i;return t}function Nn(){var t,r,n,o,s,a;if(t=Ur,r=Ur,n=Ur,et.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(tt)),o===i&&(o=null),o!==i){if(s=[],qe.test(e.charAt(Ur))?(a=e.charAt(Ur),Ur++):(a=i,0===Br&&zr(Ke)),a!==i)for(;a!==i;)s.push(a),qe.test(e.charAt(Ur))?(a=e.charAt(Ur),Ur++):(a=i,0===Br&&zr(Ke));else s=i;s!==i?n=o=[o,s]:(Ur=n,n=i)}else Ur=n,n=i;return(r=n!==i?e.substring(r,Ur):n)!==i&&(Lr=t,r=rt(r)),t=r}function Rn(){var t,r,n,o,s,a,c,u;if(t=Ur,r=Ur,n=Ur,et.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(tt)),o===i&&(o=null),o!==i){for(s=[],qe.test(e.charAt(Ur))?(a=e.charAt(Ur),Ur++):(a=i,0===Br&&zr(Ke));a!==i;)s.push(a),qe.test(e.charAt(Ur))?(a=e.charAt(Ur),Ur++):(a=i,0===Br&&zr(Ke));if(s!==i)if(46===e.charCodeAt(Ur)?(a=l,Ur++):(a=i,0===Br&&zr(h)),a!==i){if(c=[],qe.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ke)),u!==i)for(;u!==i;)c.push(u),qe.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ke));else c=i;c!==i?n=o=[o,s,a,c]:(Ur=n,n=i)}else Ur=n,n=i;else Ur=n,n=i}else Ur=n,n=i;return(r=n!==i?e.substring(r,Ur):n)!==i&&(Lr=t,r=nt(r)),t=r}function Pn(){var t,r,n,o,s,a,c,u,d;if(t=Ur,r=Ur,n=Ur,et.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(tt)),o===i&&(o=null),o!==i){if(s=Ur,a=[],qe.test(e.charAt(Ur))?(c=e.charAt(Ur),Ur++):(c=i,0===Br&&zr(Ke)),c!==i)for(;c!==i;)a.push(c),qe.test(e.charAt(Ur))?(c=e.charAt(Ur),Ur++):(c=i,0===Br&&zr(Ke));else a=i;if(a!==i)if(46===e.charCodeAt(Ur)?(c=l,Ur++):(c=i,0===Br&&zr(h)),c!==i){for(u=[],qe.test(e.charAt(Ur))?(d=e.charAt(Ur),Ur++):(d=i,0===Br&&zr(Ke));d!==i;)u.push(d),qe.test(e.charAt(Ur))?(d=e.charAt(Ur),Ur++):(d=i,0===Br&&zr(Ke));u!==i&&(d=On())!==i?s=a=[a,c,u,d]:(Ur=s,s=i)}else Ur=s,s=i;else Ur=s,s=i;if(s===i){if(s=Ur,46===e.charCodeAt(Ur)?(a=l,Ur++):(a=i,0===Br&&zr(h)),a!==i){if(c=[],qe.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ke)),u!==i)for(;u!==i;)c.push(u),qe.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ke));else c=i;c!==i&&(u=On())!==i?s=a=[a,c,u]:(Ur=s,s=i)}else Ur=s,s=i;if(s===i){if(s=Ur,a=[],qe.test(e.charAt(Ur))?(c=e.charAt(Ur),Ur++):(c=i,0===Br&&zr(Ke)),c!==i)for(;c!==i;)a.push(c),qe.test(e.charAt(Ur))?(c=e.charAt(Ur),Ur++):(c=i,0===Br&&zr(Ke));else a=i;a!==i&&(c=On())!==i?s=a=[a,c]:(Ur=s,s=i)}}s!==i?n=o=[o,s]:(Ur=n,n=i)}else Ur=n,n=i;return(r=n!==i?e.substring(r,Ur):n)!==i&&(Lr=t,r=it(r)),t=r}function On(){var t,r,n,o,s,a;if(t=Ur,r=Ur,ot.test(e.charAt(Ur))?(n=e.charAt(Ur),Ur++):(n=i,0===Br&&zr(st)),n!==i)if(et.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(tt)),o===i&&(o=null),o!==i){if(s=[],qe.test(e.charAt(Ur))?(a=e.charAt(Ur),Ur++):(a=i,0===Br&&zr(Ke)),a!==i)for(;a!==i;)s.push(a),qe.test(e.charAt(Ur))?(a=e.charAt(Ur),Ur++):(a=i,0===Br&&zr(Ke));else s=i;s!==i?r=n=[n,o,s]:(Ur=r,r=i)}else Ur=r,r=i;else Ur=r,r=i;return t=r!==i?e.substring(t,Ur):r}function Dn(){var t,r,n,o;if(t=Ur,34===e.charCodeAt(Ur)?(r=at,Ur++):(r=i,0===Br&&zr(ct)),r!==i){for(n=[],ut.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(lt)),o===i&&(o=Hn())===i&&(o=Mn());o!==i;)n.push(o),ut.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(lt)),o===i&&(o=Hn())===i&&(o=Mn());n!==i?(34===e.charCodeAt(Ur)?(o=at,Ur++):(o=i,0===Br&&zr(ct)),o!==i?(Lr=t,t=r=w(n)):(Ur=t,t=i)):(Ur=t,t=i)}else Ur=t,t=i;return t}function Un(){var t,r,n,o;if(t=Ur,39===e.charCodeAt(Ur)?(r=ht,Ur++):(r=i,0===Br&&zr(dt)),r!==i){for(n=[],ft.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(pt)),o===i&&(o=Hn())===i&&(o=Mn());o!==i;)n.push(o),ft.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(pt)),o===i&&(o=Hn())===i&&(o=Mn());n!==i?(39===e.charCodeAt(Ur)?(o=ht,Ur++):(o=i,0===Br&&zr(dt)),o!==i?(Lr=t,t=r=w(n)):(Ur=t,t=i)):(Ur=t,t=i)}else Ur=t,t=i;return t}function Ln(){var t,r,n,o,s,a,c,u;if(t=Ur,e.substr(Ur,3)===gt?(r=gt,Ur+=3):(r=i,0===Br&&zr(yt)),r!==i){for(n=[],mt.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(vt)),o===i&&(o=Hn())===i&&(o=Mn());o!==i;)n.push(o),mt.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(vt)),o===i&&(o=Hn())===i&&(o=Mn());if(n!==i){if(o=[],s=Ur,e.substr(Ur,2)===wt?(a=wt,Ur+=2):(a=i,0===Br&&zr(bt)),a!==i){if(c=[],mt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(vt)),u===i&&(u=Hn())===i&&(u=Mn()),u!==i)for(;u!==i;)c.push(u),mt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(vt)),u===i&&(u=Hn())===i&&(u=Mn());else c=i;c!==i?(Lr=s,s=a=_t(n,c)):(Ur=s,s=i)}else Ur=s,s=i;if(s===i)if(s=Ur,39===e.charCodeAt(Ur)?(a=ht,Ur++):(a=i,0===Br&&zr(dt)),a!==i){if(c=[],mt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(vt)),u===i&&(u=Hn())===i&&(u=Mn()),u!==i)for(;u!==i;)c.push(u),mt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(vt)),u===i&&(u=Hn())===i&&(u=Mn());else c=i;c!==i?(Lr=s,s=a=St(n,c)):(Ur=s,s=i)}else Ur=s,s=i;for(;s!==i;){if(o.push(s),s=Ur,e.substr(Ur,2)===wt?(a=wt,Ur+=2):(a=i,0===Br&&zr(bt)),a!==i){if(c=[],mt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(vt)),u===i&&(u=Hn())===i&&(u=Mn()),u!==i)for(;u!==i;)c.push(u),mt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(vt)),u===i&&(u=Hn())===i&&(u=Mn());else c=i;c!==i?(Lr=s,s=a=_t(n,c)):(Ur=s,s=i)}else Ur=s,s=i;if(s===i)if(s=Ur,39===e.charCodeAt(Ur)?(a=ht,Ur++):(a=i,0===Br&&zr(dt)),a!==i){if(c=[],mt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(vt)),u===i&&(u=Hn())===i&&(u=Mn()),u!==i)for(;u!==i;)c.push(u),mt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(vt)),u===i&&(u=Hn())===i&&(u=Mn());else c=i;c!==i?(Lr=s,s=a=St(n,c)):(Ur=s,s=i)}else Ur=s,s=i}o!==i?(e.substr(Ur,3)===gt?(s=gt,Ur+=3):(s=i,0===Br&&zr(yt)),s!==i?(Lr=t,t=r=Et(n,o)):(Ur=t,t=i)):(Ur=t,t=i)}else Ur=t,t=i}else Ur=t,t=i;return t}function jn(){var t,r,n,o,s,a,c,u;if(t=Ur,e.substr(Ur,3)===At?(r=At,Ur+=3):(r=i,0===Br&&zr(xt)),r!==i){for(n=[],Tt.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(Ft)),o===i&&(o=Hn())===i&&(o=Mn());o!==i;)n.push(o),Tt.test(e.charAt(Ur))?(o=e.charAt(Ur),Ur++):(o=i,0===Br&&zr(Ft)),o===i&&(o=Hn())===i&&(o=Mn());if(n!==i){if(o=[],s=Ur,e.substr(Ur,2)===kt?(a=kt,Ur+=2):(a=i,0===Br&&zr(It)),a!==i){if(c=[],Tt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ft)),u===i&&(u=Hn())===i&&(u=Mn()),u!==i)for(;u!==i;)c.push(u),Tt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ft)),u===i&&(u=Hn())===i&&(u=Mn());else c=i;c!==i?(Lr=s,s=a=Ct(n,c)):(Ur=s,s=i)}else Ur=s,s=i;if(s===i)if(s=Ur,34===e.charCodeAt(Ur)?(a=at,Ur++):(a=i,0===Br&&zr(ct)),a!==i){if(c=[],Tt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ft)),u===i&&(u=Hn())===i&&(u=Mn()),u!==i)for(;u!==i;)c.push(u),Tt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ft)),u===i&&(u=Hn())===i&&(u=Mn());else c=i;c!==i?(Lr=s,s=a=Nt(n,c)):(Ur=s,s=i)}else Ur=s,s=i;for(;s!==i;){if(o.push(s),s=Ur,e.substr(Ur,2)===kt?(a=kt,Ur+=2):(a=i,0===Br&&zr(It)),a!==i){if(c=[],Tt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ft)),u===i&&(u=Hn())===i&&(u=Mn()),u!==i)for(;u!==i;)c.push(u),Tt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ft)),u===i&&(u=Hn())===i&&(u=Mn());else c=i;c!==i?(Lr=s,s=a=Ct(n,c)):(Ur=s,s=i)}else Ur=s,s=i;if(s===i)if(s=Ur,34===e.charCodeAt(Ur)?(a=at,Ur++):(a=i,0===Br&&zr(ct)),a!==i){if(c=[],Tt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ft)),u===i&&(u=Hn())===i&&(u=Mn()),u!==i)for(;u!==i;)c.push(u),Tt.test(e.charAt(Ur))?(u=e.charAt(Ur),Ur++):(u=i,0===Br&&zr(Ft)),u===i&&(u=Hn())===i&&(u=Mn());else c=i;c!==i?(Lr=s,s=a=Nt(n,c)):(Ur=s,s=i)}else Ur=s,s=i}o!==i?(e.substr(Ur,3)===At?(s=At,Ur+=3):(s=i,0===Br&&zr(xt)),s!==i?(Lr=t,t=r=Et(n,o)):(Ur=t,t=i)):(Ur=t,t=i)}else Ur=t,t=i}else Ur=t,t=i;return t}function Mn(){var t,r,n,o,s,a,c,u,l,h,d;return t=Ur,e.substr(Ur,2)===Rt?(r=Rt,Ur+=2):(r=i,0===Br&&zr(Pt)),r!==i?(n=Ur,(o=Xn())!==i&&(s=Xn())!==i&&(a=Xn())!==i&&(c=Xn())!==i&&(u=Xn())!==i&&(l=Xn())!==i&&(h=Xn())!==i&&(d=Xn())!==i?n=o=[o,s,a,c,u,l,h,d]:(Ur=n,n=i),n!==i?(Lr=t,t=r=Ot(n)):(Ur=t,t=i)):(Ur=t,t=i),t===i&&(t=Ur,e.substr(Ur,2)===Dt?(r=Dt,Ur+=2):(r=i,0===Br&&zr(Ut)),r!==i?(n=Ur,(o=Xn())!==i&&(s=Xn())!==i&&(a=Xn())!==i&&(c=Xn())!==i?n=o=[o,s,a,c]:(Ur=n,n=i),n!==i?(Lr=t,t=r=Lt(n)):(Ur=t,t=i)):(Ur=t,t=i)),t}function Hn(){var t,r;return t=Ur,e.substr(Ur,2)===jt?(r=jt,Ur+=2):(r=i,0===Br&&zr(Mt)),r!==i&&(Lr=t,r=Ht()),(t=r)===i&&(t=Ur,e.substr(Ur,2)===Bt?(r=Bt,Ur+=2):(r=i,0===Br&&zr(qt)),r!==i&&(Lr=t,r=Kt()),(t=r)===i&&(t=Ur,e.substr(Ur,2)===Wt?(r=Wt,Ur+=2):(r=i,0===Br&&zr(Jt)),r!==i&&(Lr=t,r=Vt()),(t=r)===i&&(t=Ur,e.substr(Ur,2)===$t?(r=$t,Ur+=2):(r=i,0===Br&&zr(zt)),r!==i&&(Lr=t,r=Gt()),(t=r)===i&&(t=Ur,e.substr(Ur,2)===Xt?(r=Xt,Ur+=2):(r=i,0===Br&&zr(Yt)),r!==i&&(Lr=t,r=Qt()),(t=r)===i&&(t=Ur,e.substr(Ur,2)===Zt?(r=Zt,Ur+=2):(r=i,0===Br&&zr(er)),r!==i&&(Lr=t,r=tr()),(t=r)===i&&(t=Ur,e.substr(Ur,2)===rr?(r=rr,Ur+=2):(r=i,0===Br&&zr(nr)),r!==i&&(Lr=t,r=ir()),(t=r)===i&&(t=Ur,e.substr(Ur,2)===or?(r=or,Ur+=2):(r=i,0===Br&&zr(sr)),r!==i&&(Lr=t,r=ar()),t=r))))))),t}function Bn(){var t;return cr.test(e.charAt(Ur))?(t=e.charAt(Ur),Ur++):(t=i,0===Br&&zr(ur)),t}function qn(){var t,r,n,o;if(t=Ur,91===e.charCodeAt(Ur)?(r=ce,Ur++):(r=i,0===Br&&zr(ue)),r!==i){for(n=[],o=tn();o!==i;)n.push(o),o=tn();n!==i?(93===e.charCodeAt(Ur)?(o=le,Ur++):(o=i,0===Br&&zr(he)),o!==i?(Lr=t,t=r=lr()):(Ur=t,t=i)):(Ur=t,t=i)}else Ur=t,t=i;return t}function Kn(){var t,r,n;return t=Ur,hr.test(e.charAt(Ur))?(r=e.charAt(Ur),Ur++):(r=i,0===Br&&zr(dr)),r!==i?(fr.test(e.charAt(Ur))?(n=e.charAt(Ur),Ur++):(n=i,0===Br&&zr(pr)),n!==i?(Lr=t,t=r=gr(r,n)):(Ur=t,t=i)):(Ur=t,t=i),t===i&&(yr.test(e.charAt(Ur))?(t=e.charAt(Ur),Ur++):(t=i,0===Br&&zr(mr))),t}function Wn(){var t;return(t=Kn())===i&&(95===e.charCodeAt(Ur)?(t=vr,Ur++):(t=i,0===Br&&zr(wr))),t}function Jn(){var t;return(t=Wn())===i&&(45===e.charCodeAt(Ur)?(t=ze,Ur++):(t=i,0===Br&&zr(Ge)),t===i&&(qe.test(e.charAt(Ur))?(t=e.charAt(Ur),Ur++):(t=i,0===Br&&zr(Ke)),t===i&&(183===e.charCodeAt(Ur)?(t=br,Ur++):(t=i,0===Br&&zr(_r)),t===i&&(Sr.test(e.charAt(Ur))?(t=e.charAt(Ur),Ur++):(t=i,0===Br&&zr(Er)),t===i&&(Ar.test(e.charAt(Ur))?(t=e.charAt(Ur),Ur++):(t=i,0===Br&&zr(xr))))))),t}function Vn(){var t,r,n,o,s,a,c,u,d;if(t=Ur,r=Ur,(n=Kn())!==i){for(o=[],s=Jn();s!==i;)o.push(s),s=Jn();if(o!==i){if(s=[],a=Ur,c=[],46===e.charCodeAt(Ur)?(u=l,Ur++):(u=i,0===Br&&zr(h)),u!==i)for(;u!==i;)c.push(u),46===e.charCodeAt(Ur)?(u=l,Ur++):(u=i,0===Br&&zr(h));else c=i;if(c!==i){if(u=[],(d=Jn())!==i)for(;d!==i;)u.push(d),d=Jn();else u=i;u!==i?a=c=[c,u]:(Ur=a,a=i)}else Ur=a,a=i;for(;a!==i;){if(s.push(a),a=Ur,c=[],46===e.charCodeAt(Ur)?(u=l,Ur++):(u=i,0===Br&&zr(h)),u!==i)for(;u!==i;)c.push(u),46===e.charCodeAt(Ur)?(u=l,Ur++):(u=i,0===Br&&zr(h));else c=i;if(c!==i){if(u=[],(d=Jn())!==i)for(;d!==i;)u.push(d),d=Jn();else u=i;u!==i?a=c=[c,u]:(Ur=a,a=i)}else Ur=a,a=i}s!==i?r=n=[n,o,s]:(Ur=r,r=i)}else Ur=r,r=i}else Ur=r,r=i;return t=r!==i?e.substring(t,Ur):r}function $n(){var t,r,n,o,s,a,c,u;if(t=Ur,(r=Wn())===i&&(58===e.charCodeAt(Ur)?(r=De,Ur++):(r=i,0===Br&&zr(Ue)),r===i&&(qe.test(e.charAt(Ur))?(r=e.charAt(Ur),Ur++):(r=i,0===Br&&zr(Ke)),r===i&&(r=zn()))),r!==i){for(n=[],(o=Jn())===i&&(58===e.charCodeAt(Ur)?(o=De,Ur++):(o=i,0===Br&&zr(Ue)),o===i&&(o=zn()));o!==i;)n.push(o),(o=Jn())===i&&(58===e.charCodeAt(Ur)?(o=De,Ur++):(o=i,0===Br&&zr(Ue)),o===i&&(o=zn()));if(n!==i){if(o=[],s=Ur,a=[],46===e.charCodeAt(Ur)?(c=l,Ur++):(c=i,0===Br&&zr(h)),c!==i)for(;c!==i;)a.push(c),46===e.charCodeAt(Ur)?(c=l,Ur++):(c=i,0===Br&&zr(h));else a=i;if(a!==i){if(c=[],(u=Jn())===i&&(58===e.charCodeAt(Ur)?(u=De,Ur++):(u=i,0===Br&&zr(Ue)),u===i&&(u=zn())),u!==i)for(;u!==i;)c.push(u),(u=Jn())===i&&(58===e.charCodeAt(Ur)?(u=De,Ur++):(u=i,0===Br&&zr(Ue)),u===i&&(u=zn()));else c=i;c!==i?(Lr=s,s=a=Tr(r,n,a,c)):(Ur=s,s=i)}else Ur=s,s=i;for(;s!==i;){if(o.push(s),s=Ur,a=[],46===e.charCodeAt(Ur)?(c=l,Ur++):(c=i,0===Br&&zr(h)),c!==i)for(;c!==i;)a.push(c),46===e.charCodeAt(Ur)?(c=l,Ur++):(c=i,0===Br&&zr(h));else a=i;if(a!==i){if(c=[],(u=Jn())===i&&(58===e.charCodeAt(Ur)?(u=De,Ur++):(u=i,0===Br&&zr(Ue)),u===i&&(u=zn())),u!==i)for(;u!==i;)c.push(u),(u=Jn())===i&&(58===e.charCodeAt(Ur)?(u=De,Ur++):(u=i,0===Br&&zr(Ue)),u===i&&(u=zn()));else c=i;c!==i?(Lr=s,s=a=Tr(r,n,a,c)):(Ur=s,s=i)}else Ur=s,s=i}o!==i?(Lr=t,t=r=Fr(r,n,o)):(Ur=t,t=i)}else Ur=t,t=i}else Ur=t,t=i;return t}function zn(){var e;return(e=Gn())===i&&(e=Yn()),e}function Gn(){var t,r,n,o,s;return t=Ur,r=Ur,37===e.charCodeAt(Ur)?(n=kr,Ur++):(n=i,0===Br&&zr(Ir)),n!==i&&(o=Xn())!==i&&(s=Xn())!==i?r=n=[n,o,s]:(Ur=r,r=i),t=r!==i?e.substring(t,Ur):r}function Xn(){var t;return Cr.test(e.charAt(Ur))?(t=e.charAt(Ur),Ur++):(t=i,0===Br&&zr(Nr)),t}function Yn(){var t,r,n;return t=Ur,92===e.charCodeAt(Ur)?(r=Rr,Ur++):(r=i,0===Br&&zr(Pr)),r!==i?(Or.test(e.charAt(Ur))?(n=e.charAt(Ur),Ur++):(n=i,0===Br&&zr(Dr)),n!==i?(Lr=t,t=r=d(n)):(Ur=t,t=i)):(Ur=t,t=i),t}var Qn=function(e){return e.match(/^[a-z](.*?):(.+?)/g)};function Zn(e,t){var r={};return r[e]=t,r}var ei={base:[],data:{},addBase:function(e){if(0===ei.base.length)return void ei.base.push(e);const t=ei.base[ei.base.length-1];t!==e&&ei.base.push(new URL(e,t).toString())},addPrefix:function(e,t){const r=ei.data[e];void 0===r?ei.data[e]=[{uri:t,count:0}]:r[r.length-1].uri!==t&&r.push({uri:t,count:0})},hasPrefix:function(e){return void 0!==this.data[e]},resolve:function(e,t){const n=Object.keys(ei.data).find(t=>0===e.indexOf(t+":"));if(void 0!==n){const r=ei.data[n];if(1===r.length&&!0!==t&&Qn(r[0].uri))return e;const i=r[r.length-1].uri;return e.replace(n+":",i)}var i=0===ei.base.length?r.baseIRI:ei.base[ei.base.length-1];return!i||e.match(/^(http:|https:|urn:|file:)/)?e:0===e.indexOf("//")&&i?i.split("//")[0]+e:new URL(e,i).toString()},increment:function(e){const t=ei.data[e];void 0!==t&&t[t.length-1].count++},decrement:function(e){const t=ei.data[e];void 0!==t&&t[t.length-1].count--},toJSON:function(){const e={};return ei.base.length>0&&(void 0===e["@context"]&&(e["@context"]={}),e["@context"]["@base"]=ei.base[0]),Object.keys(ei.data).forEach(t=>{const r=ei.data[t][0];"http://www.w3.org/2001/XMLSchema#"===r.uri&&r.count<1||Qn(r.uri)&&(void 0===e["@context"]&&(e["@context"]={}),e["@context"][t]=r.uri)}),e}};function ti(e,t){if(void 0===e["@list"])return e;if(!t&&!e["@list"].find(e=>void 0!==e["@list"]))return e;if(0===e["@list"].length)return{"@id":"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"};var r={},n=null;return e["@list"].forEach(e=>{null===n?n=r:(n["http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"]={},n=n["http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"]),n["http://www.w3.org/1999/02/22-rdf-syntax-ns#first"]=ti(e,!0),n["http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"]={"@id":"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"}}),r}if((n=s())!==i&&Ur===e.length)return n;throw n!==i&&Ur<e.length&&zr(Jr()),Xr(Hr,Mr<e.length?e.charAt(Mr):null,Mr<e.length?$r(Mr,Mr+1):$r(Mr,Mr))}return e(t,Error),t.buildMessage=function(e,t){var r={literal:function(e){return'"'+i(e.text)+'"'},class:function(e){var t,r="";for(t=0;t<e.parts.length;t++)r+=e.parts[t]instanceof Array?o(e.parts[t][0])+"-"+o(e.parts[t][1]):o(e.parts[t]);return"["+(e.inverted?"^":"")+r+"]"},any:function(e){return"any character"},end:function(e){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function i(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+n(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+n(e)})}function o(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+n(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+n(e)})}function s(e){return r[e.type](e)}function a(e){var t,r,n=new Array(e.length);for(t=0;t<e.length;t++)n[t]=s(e[t]);if(n.sort(),n.length>0){for(t=1,r=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}function c(e){return e?'"'+i(e)+'"':"end of input"}return"Expected "+a(e)+" but "+c(t)+" found."},{SyntaxError:t,parse:r}})?r.apply(t,n):r)||(e.exports=i)},5386:e=>{const t={acl:"http://www.w3.org/ns/auth/acl#",arg:"http://www.w3.org/ns/pim/arg#",as:"https://www.w3.org/ns/activitystreams#",bookmark:"http://www.w3.org/2002/01/bookmark#",cal:"http://www.w3.org/2002/12/cal/ical#",cco:"http://www.ontologyrepository.com/CommonCoreOntologies/",cert:"http://www.w3.org/ns/auth/cert#",contact:"http://www.w3.org/2000/10/swap/pim/contact#",dc:"http://purl.org/dc/elements/1.1/",dct:"http://purl.org/dc/terms/",doap:"http://usefulinc.com/ns/doap#",foaf:"http://xmlns.com/foaf/0.1/",geo:"http://www.w3.org/2003/01/geo/wgs84_pos#",gpx:"http://www.w3.org/ns/pim/gpx#",gr:"http://purl.org/goodrelations/v1#",http:"http://www.w3.org/2007/ont/http#",httph:"http://www.w3.org/2007/ont/httph#",icalTZ:"http://www.w3.org/2002/12/cal/icaltzd#",ldp:"http://www.w3.org/ns/ldp#",link:"http://www.w3.org/2007/ont/link#",log:"http://www.w3.org/2000/10/swap/log#",meeting:"http://www.w3.org/ns/pim/meeting#",mo:"http://purl.org/ontology/mo/",org:"http://www.w3.org/ns/org#",owl:"http://www.w3.org/2002/07/owl#",pad:"http://www.w3.org/ns/pim/pad#",patch:"http://www.w3.org/ns/pim/patch#",prov:"http://www.w3.org/ns/prov#",pto:"http://www.productontology.org/id/",qu:"http://www.w3.org/2000/10/swap/pim/qif#",trip:"http://www.w3.org/ns/pim/trip#",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",rss:"http://purl.org/rss/1.0/",sched:"http://www.w3.org/ns/pim/schedule#",schema:"http://schema.org/",sioc:"http://rdfs.org/sioc/ns#",skos:"http://www.w3.org/2004/02/skos/core#",solid:"http://www.w3.org/ns/solid/terms#",space:"http://www.w3.org/ns/pim/space#",stat:"http://www.w3.org/ns/posix/stat#",tab:"http://www.w3.org/2007/ont/link#",tabont:"http://www.w3.org/2007/ont/link#",ui:"http://www.w3.org/ns/ui#",vann:"http://purl.org/vocab/vann/",vcard:"http://www.w3.org/2006/vcard/ns#",wf:"http://www.w3.org/2005/01/wf/flow#",xsd:"http://www.w3.org/2001/XMLSchema#"};e.exports=function(e={namedNode:e=>e}){const r={};for(const n in t){const i=t[n];r[n]=function(t=""){return e.namedNode(i+t)}}return r}},5500:(e,t,r)=>{"use strict";r.d(t,{M3:()=>s,W2:()=>o,ll:()=>i,t9:()=>a});var n=r(149);function i(e){return(0,n.A)(e)&&"string"==typeof e.kty}function o(e){return"oct"!==e.kty&&"string"==typeof e.d}function s(e){return"oct"!==e.kty&&void 0===e.d}function a(e){return i(e)&&"oct"===e.kty&&"string"==typeof e.k}},5550:(e,t,r)=>{"use strict";r.d(t,{n:()=>p});var n=r(1436),i=r(1020),o=r(7991),s=r(4495),a=r(676);const c=async(e,t,r)=>{const n=await(0,a.A)(e,t,"sign");(0,s.A)(e,n);const c=await o.A.subtle.sign((0,i.A)(e,n.algorithm),n,r);return new Uint8Array(c)};var u=r(9874),l=r(7493),h=r(1476),d=r(8858),f=r(2168);class p{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=e}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}async sign(e,t){if(!this._protectedHeader&&!this._unprotectedHeader)throw new l.JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!(0,u.A)(this._protectedHeader,this._unprotectedHeader))throw new l.JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const r={...this._protectedHeader,...this._unprotectedHeader};let i=!0;if((0,f.A)(l.JWSInvalid,new Map([["b64",!0]]),t?.crit,this._protectedHeader,r).has("b64")&&(i=this._protectedHeader.b64,"boolean"!=typeof i))throw new l.JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:o}=r;if("string"!=typeof o||!o)throw new l.JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');(0,d.I)(o,e,"sign");let s,a=this._payload;i&&(a=h.Rd.encode((0,n.lF)(a))),s=this._protectedHeader?h.Rd.encode((0,n.lF)(JSON.stringify(this._protectedHeader))):h.Rd.encode("");const p=(0,h.xW)(s,h.Rd.encode("."),a),g=await c(o,e,p),y={signature:(0,n.lF)(g),payload:""};return i&&(y.payload=h.D0.decode(a)),this._unprotectedHeader&&(y.header=this._unprotectedHeader),this._protectedHeader&&(y.protected=h.D0.decode(s)),y}}},5609:(e,t,r)=>{"use strict";r.d(t,{B:()=>s});var n=r(6711),i=r(7493),o=r(1476);async function s(e,t,r){if(e instanceof Uint8Array&&(e=o.D0.decode(e)),"string"!=typeof e)throw new i.JWSInvalid("Compact JWS must be a string or Uint8Array");const{0:s,1:a,2:c,length:u}=e.split(".");if(3!==u)throw new i.JWSInvalid("Invalid Compact JWS");const l=await(0,n.Z)({payload:a,protected:s,signature:c},t,r),h={payload:l.payload,protectedHeader:l.protectedHeader};return"function"==typeof t?{...h,key:l.key}:h}},5752:(e,t,r)=>{var n=r(4582),i=r(4722),o=r(6559),s=r(4466),a=i.DOMImplementation,c=n.NAMESPACE,u=s.ParseError,l=s.XMLReader;function h(e){return e.replace(/\r[\n\u0085]/g,"\n").replace(/[\r\u0085\u2028]/g,"\n")}function d(e){this.options=e||{locator:{}}}function f(){this.cdata=!1}function p(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function g(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function y(e,t,r){return"string"==typeof e?e.substr(t,r):e.length>=t+r||t?new java.lang.String(e,t,r)+"":e}function m(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}d.prototype.parseFromString=function(e,t){var r=this.options,n=new l,i=r.domBuilder||new f,s=r.errorHandler,a=r.locator,u=r.xmlns||{},d=/\/x?html?$/.test(t),p=d?o.HTML_ENTITIES:o.XML_ENTITIES;a&&i.setDocumentLocator(a),n.errorHandler=function(e,t,r){if(!e){if(t instanceof f)return t;e=t}var n={},i=e instanceof Function;function o(t){var o=e[t];!o&&i&&(o=2==e.length?function(r){e(t,r)}:e),n[t]=o&&function(e){o("[xmldom "+t+"]\t"+e+g(r))}||function(){}}return r=r||{},o("warning"),o("error"),o("fatalError"),n}(s,i,a),n.domBuilder=r.domBuilder||i,d&&(u[""]=c.HTML),u.xml=u.xml||c.XML;var y=r.normalizeLineEndings||h;return e&&"string"==typeof e?n.parse(y(e),u,p):n.errorHandler.error("invalid doc source"),i.doc},f.prototype={startDocument:function(){this.doc=(new a).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,r,n){var i=this.doc,o=i.createElementNS(e,r||t),s=n.length;m(this,o),this.currentElement=o,this.locator&&p(this.locator,o);for(var a=0;a<s;a++){e=n.getURI(a);var c=n.getValue(a),u=(r=n.getQName(a),i.createAttributeNS(e,r));this.locator&&p(n.getLocator(a),u),u.value=u.nodeValue=c,o.setAttributeNode(u)}},endElement:function(e,t,r){var n=this.currentElement;n.tagName;this.currentElement=n.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var r=this.doc.createProcessingInstruction(e,t);this.locator&&p(this.locator,r),m(this,r)},ignorableWhitespace:function(e,t,r){},characters:function(e,t,r){if(e=y.apply(this,arguments)){if(this.cdata)var n=this.doc.createCDATASection(e);else n=this.doc.createTextNode(e);this.currentElement?this.currentElement.appendChild(n):/^\s*$/.test(e)&&this.doc.appendChild(n),this.locator&&p(this.locator,n)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,r){e=y.apply(this,arguments);var n=this.doc.createComment(e);this.locator&&p(this.locator,n),m(this,n)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,r){var n=this.doc.implementation;if(n&&n.createDocumentType){var i=n.createDocumentType(e,t,r);this.locator&&p(this.locator,i),m(this,i),this.doc.doctype=i}},warning:function(e){console.warn("[xmldom warning]\t"+e,g(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,g(this.locator))},fatalError:function(e){throw new u(e,this.locator)}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(e){f.prototype[e]=function(){return null}}),t.DOMParser=d},5994:(e,t,r)=>{"use strict";r.d(t,{A:()=>i,g:()=>o});var n=r(7991);const i=e=>!!(0,n.R)(e)||"KeyObject"===e?.[Symbol.toStringTag],o=["CryptoKey"]},6011:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unsafeStringify=void 0;const n=r(9746),i=[];for(let e=0;e<256;++e)i.push((e+256).toString(16).slice(1));function o(e,t=0){return(i[e[t+0]]+i[e[t+1]]+i[e[t+2]]+i[e[t+3]]+"-"+i[e[t+4]]+i[e[t+5]]+"-"+i[e[t+6]]+i[e[t+7]]+"-"+i[e[t+8]]+i[e[t+9]]+"-"+i[e[t+10]]+i[e[t+11]]+i[e[t+12]]+i[e[t+13]]+i[e[t+14]]+i[e[t+15]]).toLowerCase()}t.unsafeStringify=o,t.default=function(e,t=0){const r=o(e,t);if(!(0,n.default)(r))throw TypeError("Stringified UUID is invalid");return r}},6118:function(e,t,r){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ns=void 0;const c=a(r(5386)),u=s(r(4090));t.ns=(0,c.default)(u)},6356:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6011),i=r(1425),o=r(6568);t.default=function(e,t,r){e??={},r??=0;let s=(0,i.default)({...e,_v6:!0},new Uint8Array(16));if(s=(0,o.default)(s),t){for(let e=0;e<16;e++)t[r+e]=s[e];return t}return(0,n.unsafeStringify)(s)}},6516:function(e){var t;t=function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=22)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i={debug:function(){},info:function(){},warn:function(){},error:function(){}},o=void 0,s=void 0;(t.Log=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.reset=function(){s=3,o=i},e.debug=function(){if(s>=4){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];o.debug.apply(o,Array.from(t))}},e.info=function(){if(s>=3){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];o.info.apply(o,Array.from(t))}},e.warn=function(){if(s>=2){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];o.warn.apply(o,Array.from(t))}},e.error=function(){if(s>=1){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];o.error.apply(o,Array.from(t))}},n(e,null,[{key:"NONE",get:function(){return 0}},{key:"ERROR",get:function(){return 1}},{key:"WARN",get:function(){return 2}},{key:"INFO",get:function(){return 3}},{key:"DEBUG",get:function(){return 4}},{key:"level",get:function(){return s},set:function(e){if(!(0<=e&&e<=4))throw new Error("Invalid log level");s=e}},{key:"logger",get:function(){return o},set:function(e){if(!e.debug&&e.info&&(e.debug=e.info),!(e.debug&&e.info&&e.warn&&e.error))throw new Error("Invalid logger");o=e}}]),e}()).reset()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i={setInterval:function(e){function t(t,r){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e,t){return setInterval(e,t)}),clearInterval:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){return clearInterval(e)})},o=!1,s=null;t.Global=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e._testing=function(){o=!0},e.setXMLHttpRequest=function(e){s=e},n(e,null,[{key:"location",get:function(){if(!o)return location}},{key:"localStorage",get:function(){if(!o&&"undefined"!=typeof window)return localStorage}},{key:"sessionStorage",get:function(){if(!o&&"undefined"!=typeof window)return sessionStorage}},{key:"XMLHttpRequest",get:function(){if(!o&&"undefined"!=typeof window)return s||XMLHttpRequest}},{key:"timer",get:function(){if(!o)return i}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataService=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=r(7),s=".well-known/openid-configuration";t.MetadataService=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.JsonService;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw i.Log.error("MetadataService: No settings passed to MetadataService"),new Error("settings");this._settings=t,this._jsonService=new r(["application/jwk-set+json"])}return e.prototype.resetSigningKeys=function(){this._settings=this._settings||{},this._settings.signingKeys=void 0},e.prototype.getMetadata=function(){var e=this;return this._settings.metadata?(i.Log.debug("MetadataService.getMetadata: Returning metadata from settings"),Promise.resolve(this._settings.metadata)):this.metadataUrl?(i.Log.debug("MetadataService.getMetadata: getting metadata from",this.metadataUrl),this._jsonService.getJson(this.metadataUrl).then(function(t){i.Log.debug("MetadataService.getMetadata: json received");var r=e._settings.metadataSeed||{};return e._settings.metadata=Object.assign({},r,t),e._settings.metadata})):(i.Log.error("MetadataService.getMetadata: No authority or metadataUrl configured on settings"),Promise.reject(new Error("No authority or metadataUrl configured on settings")))},e.prototype.getIssuer=function(){return this._getMetadataProperty("issuer")},e.prototype.getAuthorizationEndpoint=function(){return this._getMetadataProperty("authorization_endpoint")},e.prototype.getUserInfoEndpoint=function(){return this._getMetadataProperty("userinfo_endpoint")},e.prototype.getTokenEndpoint=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._getMetadataProperty("token_endpoint",e)},e.prototype.getCheckSessionIframe=function(){return this._getMetadataProperty("check_session_iframe",!0)},e.prototype.getEndSessionEndpoint=function(){return this._getMetadataProperty("end_session_endpoint",!0)},e.prototype.getRevocationEndpoint=function(){return this._getMetadataProperty("revocation_endpoint",!0)},e.prototype.getKeysEndpoint=function(){return this._getMetadataProperty("jwks_uri",!0)},e.prototype._getMetadataProperty=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return i.Log.debug("MetadataService.getMetadataProperty for: "+e),this.getMetadata().then(function(r){if(i.Log.debug("MetadataService.getMetadataProperty: metadata recieved"),void 0===r[e]){if(!0===t)return void i.Log.warn("MetadataService.getMetadataProperty: Metadata does not contain optional property "+e);throw i.Log.error("MetadataService.getMetadataProperty: Metadata does not contain property "+e),new Error("Metadata does not contain property "+e)}return r[e]})},e.prototype.getSigningKeys=function(){var e=this;return this._settings.signingKeys?(i.Log.debug("MetadataService.getSigningKeys: Returning signingKeys from settings"),Promise.resolve(this._settings.signingKeys)):this._getMetadataProperty("jwks_uri").then(function(t){return i.Log.debug("MetadataService.getSigningKeys: jwks_uri received",t),e._jsonService.getJson(t).then(function(t){if(i.Log.debug("MetadataService.getSigningKeys: key set received",t),!t.keys)throw i.Log.error("MetadataService.getSigningKeys: Missing keys on keyset"),new Error("Missing keys on keyset");return e._settings.signingKeys=t.keys,e._settings.signingKeys})})},n(e,[{key:"metadataUrl",get:function(){return this._metadataUrl||(this._settings.metadataUrl?this._metadataUrl=this._settings.metadataUrl:(this._metadataUrl=this._settings.authority,this._metadataUrl&&this._metadataUrl.indexOf(s)<0&&("/"!==this._metadataUrl[this._metadataUrl.length-1]&&(this._metadataUrl+="/"),this._metadataUrl+=s))),this._metadataUrl}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UrlUtility=void 0;var n=r(0),i=r(1);t.UrlUtility=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.addQueryParam=function(e,t,r){return e.indexOf("?")<0&&(e+="?"),"?"!==e[e.length-1]&&(e+="&"),e+=encodeURIComponent(t),(e+="=")+encodeURIComponent(r)},e.parseUrlFragment=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i.Global;"string"!=typeof e&&(e=r.location.href);var o=e.lastIndexOf(t);o>=0&&(e=e.substr(o+1)),"?"===t&&(o=e.indexOf("#"))>=0&&(e=e.substr(0,o));for(var s,a={},c=/([^&=]+)=([^&]*)/g,u=0;s=c.exec(e);)if(a[decodeURIComponent(s[1])]=decodeURIComponent(s[2].replace(/\+/g," ")),u++>50)return n.Log.error("UrlUtility.parseUrlFragment: response exceeded expected number of parameters",e),{error:"Response exceeded expected number of parameters"};for(var l in a)return a;return{}},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JoseUtil=void 0;var n=r(26),i=function(e){return e&&e.__esModule?e:{default:e}}(r(33));t.JoseUtil=(0,i.default)({jws:n.jws,KeyUtil:n.KeyUtil,X509:n.X509,crypto:n.crypto,hextob64u:n.hextob64u,b64tohex:n.b64tohex,AllowedSigningAlgs:n.AllowedSigningAlgs})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OidcClientSettings=void 0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(0),s=r(23),a=r(6),c=r(24),u=r(2),l=".well-known/openid-configuration";t.OidcClientSettings=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.authority,i=t.metadataUrl,o=t.metadata,l=t.signingKeys,h=t.metadataSeed,d=t.client_id,f=t.client_secret,p=t.response_type,g=void 0===p?"id_token":p,y=t.scope,m=void 0===y?"openid":y,v=t.redirect_uri,w=t.post_logout_redirect_uri,b=t.client_authentication,_=void 0===b?"client_secret_post":b,S=t.prompt,E=t.display,A=t.max_age,x=t.ui_locales,T=t.acr_values,F=t.resource,k=t.response_mode,I=t.filterProtocolClaims,C=void 0===I||I,N=t.loadUserInfo,R=void 0===N||N,P=t.staleStateAge,O=void 0===P?900:P,D=t.clockSkew,U=void 0===D?300:D,L=t.clockService,j=void 0===L?new s.ClockService:L,M=t.userInfoJwtIssuer,H=void 0===M?"OP":M,B=t.mergeClaims,q=void 0!==B&&B,K=t.stateStore,W=void 0===K?new a.WebStorageStateStore:K,J=t.ResponseValidatorCtor,V=void 0===J?c.ResponseValidator:J,$=t.MetadataServiceCtor,z=void 0===$?u.MetadataService:$,G=t.extraQueryParams,X=void 0===G?{}:G,Y=t.extraTokenParams,Q=void 0===Y?{}:Y;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this._authority=r,this._metadataUrl=i,this._metadata=o,this._metadataSeed=h,this._signingKeys=l,this._client_id=d,this._client_secret=f,this._response_type=g,this._scope=m,this._redirect_uri=v,this._post_logout_redirect_uri=w,this._client_authentication=_,this._prompt=S,this._display=E,this._max_age=A,this._ui_locales=x,this._acr_values=T,this._resource=F,this._response_mode=k,this._filterProtocolClaims=!!C,this._loadUserInfo=!!R,this._staleStateAge=O,this._clockSkew=U,this._clockService=j,this._userInfoJwtIssuer=H,this._mergeClaims=!!q,this._stateStore=W,this._validator=new V(this),this._metadataService=new z(this),this._extraQueryParams="object"===(void 0===X?"undefined":n(X))?X:{},this._extraTokenParams="object"===(void 0===Q?"undefined":n(Q))?Q:{}}return e.prototype.getEpochTime=function(){return this._clockService.getEpochTime()},i(e,[{key:"client_id",get:function(){return this._client_id},set:function(e){if(this._client_id)throw o.Log.error("OidcClientSettings.set_client_id: client_id has already been assigned."),new Error("client_id has already been assigned.");this._client_id=e}},{key:"client_secret",get:function(){return this._client_secret}},{key:"response_type",get:function(){return this._response_type}},{key:"scope",get:function(){return this._scope}},{key:"redirect_uri",get:function(){return this._redirect_uri}},{key:"post_logout_redirect_uri",get:function(){return this._post_logout_redirect_uri}},{key:"client_authentication",get:function(){return this._client_authentication}},{key:"prompt",get:function(){return this._prompt}},{key:"display",get:function(){return this._display}},{key:"max_age",get:function(){return this._max_age}},{key:"ui_locales",get:function(){return this._ui_locales}},{key:"acr_values",get:function(){return this._acr_values}},{key:"resource",get:function(){return this._resource}},{key:"response_mode",get:function(){return this._response_mode}},{key:"authority",get:function(){return this._authority},set:function(e){if(this._authority)throw o.Log.error("OidcClientSettings.set_authority: authority has already been assigned."),new Error("authority has already been assigned.");this._authority=e}},{key:"metadataUrl",get:function(){return this._metadataUrl||(this._metadataUrl=this.authority,this._metadataUrl&&this._metadataUrl.indexOf(l)<0&&("/"!==this._metadataUrl[this._metadataUrl.length-1]&&(this._metadataUrl+="/"),this._metadataUrl+=l)),this._metadataUrl}},{key:"metadata",get:function(){return this._metadata},set:function(e){this._metadata=e}},{key:"metadataSeed",get:function(){return this._metadataSeed},set:function(e){this._metadataSeed=e}},{key:"signingKeys",get:function(){return this._signingKeys},set:function(e){this._signingKeys=e}},{key:"filterProtocolClaims",get:function(){return this._filterProtocolClaims}},{key:"loadUserInfo",get:function(){return this._loadUserInfo}},{key:"staleStateAge",get:function(){return this._staleStateAge}},{key:"clockSkew",get:function(){return this._clockSkew}},{key:"userInfoJwtIssuer",get:function(){return this._userInfoJwtIssuer}},{key:"mergeClaims",get:function(){return this._mergeClaims}},{key:"stateStore",get:function(){return this._stateStore}},{key:"validator",get:function(){return this._validator}},{key:"metadataService",get:function(){return this._metadataService}},{key:"extraQueryParams",get:function(){return this._extraQueryParams},set:function(e){"object"===(void 0===e?"undefined":n(e))?this._extraQueryParams=e:this._extraQueryParams={}}},{key:"extraTokenParams",get:function(){return this._extraTokenParams},set:function(e){"object"===(void 0===e?"undefined":n(e))?this._extraTokenParams=e:this._extraTokenParams={}}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebStorageStateStore=void 0;var n=r(0),i=r(1);t.WebStorageStateStore=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.prefix,n=void 0===r?"oidc.":r,o=t.store,s=void 0===o?i.Global.localStorage:o;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this._store=s,this._prefix=n}return e.prototype.set=function(e,t){return n.Log.debug("WebStorageStateStore.set",e),e=this._prefix+e,this._store.setItem(e,t),Promise.resolve()},e.prototype.get=function(e){n.Log.debug("WebStorageStateStore.get",e),e=this._prefix+e;var t=this._store.getItem(e);return Promise.resolve(t)},e.prototype.remove=function(e){n.Log.debug("WebStorageStateStore.remove",e),e=this._prefix+e;var t=this._store.getItem(e);return this._store.removeItem(e),Promise.resolve(t)},e.prototype.getAllKeys=function(){n.Log.debug("WebStorageStateStore.getAllKeys");for(var e=[],t=0;t<this._store.length;t++){var r=this._store.key(t);0===r.indexOf(this._prefix)&&e.push(r.substr(this._prefix.length))}return Promise.resolve(e)},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JsonService=void 0;var n=r(0),i=r(1);t.JsonService=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.Global.XMLHttpRequest,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),t&&Array.isArray(t)?this._contentTypes=t.slice():this._contentTypes=[],this._contentTypes.push("application/json"),n&&this._contentTypes.push("application/jwt"),this._XMLHttpRequest=r,this._jwtHandler=n}return e.prototype.getJson=function(e,t){var r=this;if(!e)throw n.Log.error("JsonService.getJson: No url passed"),new Error("url");return n.Log.debug("JsonService.getJson, url: ",e),new Promise(function(i,o){var s=new r._XMLHttpRequest;s.open("GET",e);var a=r._contentTypes,c=r._jwtHandler;s.onload=function(){if(n.Log.debug("JsonService.getJson: HTTP response received, status",s.status),200===s.status){var t=s.getResponseHeader("Content-Type");if(t){var r=a.find(function(e){if(t.startsWith(e))return!0});if("application/jwt"==r)return void c(s).then(i,o);if(r)try{return void i(JSON.parse(s.responseText))}catch(e){return n.Log.error("JsonService.getJson: Error parsing JSON response",e.message),void o(e)}}o(Error("Invalid response Content-Type: "+t+", from URL: "+e))}else o(Error(s.statusText+" ("+s.status+")"))},s.onerror=function(){n.Log.error("JsonService.getJson: network error"),o(Error("Network Error"))},t&&(n.Log.debug("JsonService.getJson: token passed, setting Authorization header"),s.setRequestHeader("Authorization","Bearer "+t)),s.send()})},e.prototype.postForm=function(e,t,r){var i=this;if(!e)throw n.Log.error("JsonService.postForm: No url passed"),new Error("url");return n.Log.debug("JsonService.postForm, url: ",e),new Promise(function(o,s){var a=new i._XMLHttpRequest;a.open("POST",e);var c=i._contentTypes;a.onload=function(){if(n.Log.debug("JsonService.postForm: HTTP response received, status",a.status),200!==a.status){if(400===a.status&&(r=a.getResponseHeader("Content-Type"))&&c.find(function(e){if(r.startsWith(e))return!0}))try{var t=JSON.parse(a.responseText);if(t&&t.error)return n.Log.error("JsonService.postForm: Error from server: ",t.error),void s(new Error(t.error))}catch(e){return n.Log.error("JsonService.postForm: Error parsing JSON response",e.message),void s(e)}s(Error(a.statusText+" ("+a.status+")"))}else{var r;if((r=a.getResponseHeader("Content-Type"))&&c.find(function(e){if(r.startsWith(e))return!0}))try{return void o(JSON.parse(a.responseText))}catch(e){return n.Log.error("JsonService.postForm: Error parsing JSON response",e.message),void s(e)}s(Error("Invalid response Content-Type: "+r+", from URL: "+e))}},a.onerror=function(){n.Log.error("JsonService.postForm: network error"),s(Error("Network Error"))};var u="";for(var l in t){var h=t[l];h&&(u.length>0&&(u+="&"),u+=encodeURIComponent(l),u+="=",u+=encodeURIComponent(h))}a.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),void 0!==r&&a.setRequestHeader("Authorization","Basic "+btoa(r)),a.send(u)})},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SigninRequest=void 0;var n=r(0),i=r(3),o=r(13);t.SigninRequest=function(){function e(t){var r=t.url,s=t.client_id,a=t.redirect_uri,c=t.response_type,u=t.scope,l=t.authority,h=t.data,d=t.prompt,f=t.display,p=t.max_age,g=t.ui_locales,y=t.id_token_hint,m=t.login_hint,v=t.acr_values,w=t.resource,b=t.response_mode,_=t.request,S=t.request_uri,E=t.extraQueryParams,A=t.request_type,x=t.client_secret,T=t.extraTokenParams,F=t.skipUserInfo;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!r)throw n.Log.error("SigninRequest.ctor: No url passed"),new Error("url");if(!s)throw n.Log.error("SigninRequest.ctor: No client_id passed"),new Error("client_id");if(!a)throw n.Log.error("SigninRequest.ctor: No redirect_uri passed"),new Error("redirect_uri");if(!c)throw n.Log.error("SigninRequest.ctor: No response_type passed"),new Error("response_type");if(!u)throw n.Log.error("SigninRequest.ctor: No scope passed"),new Error("scope");if(!l)throw n.Log.error("SigninRequest.ctor: No authority passed"),new Error("authority");var k=e.isOidc(c),I=e.isCode(c);b||(b=e.isCode(c)?"query":null),this.state=new o.SigninState({nonce:k,data:h,client_id:s,authority:l,redirect_uri:a,code_verifier:I,request_type:A,response_mode:b,client_secret:x,scope:u,extraTokenParams:T,skipUserInfo:F}),r=i.UrlUtility.addQueryParam(r,"client_id",s),r=i.UrlUtility.addQueryParam(r,"redirect_uri",a),r=i.UrlUtility.addQueryParam(r,"response_type",c),r=i.UrlUtility.addQueryParam(r,"scope",u),r=i.UrlUtility.addQueryParam(r,"state",this.state.id),k&&(r=i.UrlUtility.addQueryParam(r,"nonce",this.state.nonce)),I&&(r=i.UrlUtility.addQueryParam(r,"code_challenge",this.state.code_challenge),r=i.UrlUtility.addQueryParam(r,"code_challenge_method","S256"));var C={prompt:d,display:f,max_age:p,ui_locales:g,id_token_hint:y,login_hint:m,acr_values:v,resource:w,request:_,request_uri:S,response_mode:b};for(var N in C)C[N]&&(r=i.UrlUtility.addQueryParam(r,N,C[N]));for(var R in E)r=i.UrlUtility.addQueryParam(r,R,E[R]);this.url=r}return e.isOidc=function(e){return!!e.split(/\s+/g).filter(function(e){return"id_token"===e})[0]},e.isOAuth=function(e){return!!e.split(/\s+/g).filter(function(e){return"token"===e})[0]},e.isCode=function(e){return!!e.split(/\s+/g).filter(function(e){return"code"===e})[0]},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.State=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(r(14));t.State=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.id,n=t.data,i=t.created,s=t.request_type;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this._id=r||(0,o.default)(),this._data=n,this._created="number"==typeof i&&i>0?i:parseInt(Date.now()/1e3),this._request_type=s}return e.prototype.toStorageString=function(){return i.Log.debug("State.toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type})},e.fromStorageString=function(t){return i.Log.debug("State.fromStorageString"),new e(JSON.parse(t))},e.clearStaleState=function(t,r){var n=Date.now()/1e3-r;return t.getAllKeys().then(function(r){i.Log.debug("State.clearStaleState: got keys",r);for(var o=[],s=function(s){var a=r[s];c=t.get(a).then(function(r){var o=!1;if(r)try{var s=e.fromStorageString(r);i.Log.debug("State.clearStaleState: got item from key: ",a,s.created),s.created<=n&&(o=!0)}catch(e){i.Log.error("State.clearStaleState: Error parsing state for key",a,e.message),o=!0}else i.Log.debug("State.clearStaleState: no item in storage for key: ",a),o=!0;if(o)return i.Log.debug("State.clearStaleState: removed item for key: ",a),t.remove(a)}),o.push(c)},a=0;a<r.length;a++){var c;s(a)}return i.Log.debug("State.clearStaleState: waiting on promise count:",o.length),Promise.all(o)})},n(e,[{key:"id",get:function(){return this._id}},{key:"data",get:function(){return this._data}},{key:"created",get:function(){return this._created}},{key:"request_type",get:function(){return this._request_type}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OidcClient=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=r(5),s=r(12),a=r(8),c=r(34),u=r(35),l=r(36),h=r(13),d=r(9);t.OidcClient=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),t instanceof o.OidcClientSettings?this._settings=t:this._settings=new o.OidcClientSettings(t)}return e.prototype.createSigninRequest=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.response_type,n=t.scope,o=t.redirect_uri,s=t.data,c=t.state,u=t.prompt,l=t.display,h=t.max_age,d=t.ui_locales,f=t.id_token_hint,p=t.login_hint,g=t.acr_values,y=t.resource,m=t.request,v=t.request_uri,w=t.response_mode,b=t.extraQueryParams,_=t.extraTokenParams,S=t.request_type,E=t.skipUserInfo,A=arguments[1];i.Log.debug("OidcClient.createSigninRequest");var x=this._settings.client_id;r=r||this._settings.response_type,n=n||this._settings.scope,o=o||this._settings.redirect_uri,u=u||this._settings.prompt,l=l||this._settings.display,h=h||this._settings.max_age,d=d||this._settings.ui_locales,g=g||this._settings.acr_values,y=y||this._settings.resource,w=w||this._settings.response_mode,b=b||this._settings.extraQueryParams,_=_||this._settings.extraTokenParams;var T=this._settings.authority;return a.SigninRequest.isCode(r)&&"code"!==r?Promise.reject(new Error("OpenID Connect hybrid flow is not supported")):this._metadataService.getAuthorizationEndpoint().then(function(t){i.Log.debug("OidcClient.createSigninRequest: Received authorization endpoint",t);var F=new a.SigninRequest({url:t,client_id:x,redirect_uri:o,response_type:r,scope:n,data:s||c,authority:T,prompt:u,display:l,max_age:h,ui_locales:d,id_token_hint:f,login_hint:p,acr_values:g,resource:y,request:m,request_uri:v,extraQueryParams:b,extraTokenParams:_,request_type:S,response_mode:w,client_secret:e._settings.client_secret,skipUserInfo:E}),k=F.state;return(A=A||e._stateStore).set(k.id,k.toStorageString()).then(function(){return F})})},e.prototype.readSigninResponseState=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];i.Log.debug("OidcClient.readSigninResponseState");var n="query"===this._settings.response_mode||!this._settings.response_mode&&a.SigninRequest.isCode(this._settings.response_type)?"?":"#",o=new c.SigninResponse(e,n);return o.state?(t=t||this._stateStore,(r?t.remove.bind(t):t.get.bind(t))(o.state).then(function(e){if(!e)throw i.Log.error("OidcClient.readSigninResponseState: No matching state found in storage"),new Error("No matching state found in storage");return{state:h.SigninState.fromStorageString(e),response:o}})):(i.Log.error("OidcClient.readSigninResponseState: No state in response"),Promise.reject(new Error("No state in response")))},e.prototype.processSigninResponse=function(e,t){var r=this;return i.Log.debug("OidcClient.processSigninResponse"),this.readSigninResponseState(e,t,!0).then(function(e){var t=e.state,n=e.response;return i.Log.debug("OidcClient.processSigninResponse: Received state from storage; validating response"),r._validator.validateSigninResponse(t,n)})},e.prototype.createSignoutRequest=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.id_token_hint,n=t.data,o=t.state,s=t.post_logout_redirect_uri,a=t.extraQueryParams,c=t.request_type,l=arguments[1];return i.Log.debug("OidcClient.createSignoutRequest"),s=s||this._settings.post_logout_redirect_uri,a=a||this._settings.extraQueryParams,this._metadataService.getEndSessionEndpoint().then(function(t){if(!t)throw i.Log.error("OidcClient.createSignoutRequest: No end session endpoint url returned"),new Error("no end session endpoint");i.Log.debug("OidcClient.createSignoutRequest: Received end session endpoint",t);var h=new u.SignoutRequest({url:t,id_token_hint:r,post_logout_redirect_uri:s,data:n||o,extraQueryParams:a,request_type:c}),d=h.state;return d&&(i.Log.debug("OidcClient.createSignoutRequest: Signout request has state to persist"),(l=l||e._stateStore).set(d.id,d.toStorageString())),h})},e.prototype.readSignoutResponseState=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];i.Log.debug("OidcClient.readSignoutResponseState");var n=new l.SignoutResponse(e);if(!n.state)return i.Log.debug("OidcClient.readSignoutResponseState: No state in response"),n.error?(i.Log.warn("OidcClient.readSignoutResponseState: Response was error: ",n.error),Promise.reject(new s.ErrorResponse(n))):Promise.resolve({state:void 0,response:n});var o=n.state;return t=t||this._stateStore,(r?t.remove.bind(t):t.get.bind(t))(o).then(function(e){if(!e)throw i.Log.error("OidcClient.readSignoutResponseState: No matching state found in storage"),new Error("No matching state found in storage");return{state:d.State.fromStorageString(e),response:n}})},e.prototype.processSignoutResponse=function(e,t){var r=this;return i.Log.debug("OidcClient.processSignoutResponse"),this.readSignoutResponseState(e,t,!0).then(function(e){var t=e.state,n=e.response;return t?(i.Log.debug("OidcClient.processSignoutResponse: Received state from storage; validating response"),r._validator.validateSignoutResponse(t,n)):(i.Log.debug("OidcClient.processSignoutResponse: No state from storage; skipping validating response"),n)})},e.prototype.clearStaleState=function(e){return i.Log.debug("OidcClient.clearStaleState"),e=e||this._stateStore,d.State.clearStaleState(e,this.settings.staleStateAge)},n(e,[{key:"_stateStore",get:function(){return this.settings.stateStore}},{key:"_validator",get:function(){return this.settings.validator}},{key:"_metadataService",get:function(){return this.settings.metadataService}},{key:"settings",get:function(){return this._settings}},{key:"metadataService",get:function(){return this._metadataService}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TokenClient=void 0;var n=r(7),i=r(2),o=r(0);t.TokenClient=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.JsonService,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i.MetadataService;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw o.Log.error("TokenClient.ctor: No settings passed"),new Error("settings");this._settings=t,this._jsonService=new r,this._metadataService=new s(this._settings)}return e.prototype.exchangeCode=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(t=Object.assign({},t)).grant_type=t.grant_type||"authorization_code",t.client_id=t.client_id||this._settings.client_id,t.client_secret=t.client_secret||this._settings.client_secret,t.redirect_uri=t.redirect_uri||this._settings.redirect_uri;var r=void 0,n=t._client_authentication||this._settings._client_authentication;return delete t._client_authentication,t.code?t.redirect_uri?t.code_verifier?t.client_id?t.client_secret||"client_secret_basic"!=n?("client_secret_basic"==n&&(r=t.client_id+":"+t.client_secret,delete t.client_id,delete t.client_secret),this._metadataService.getTokenEndpoint(!1).then(function(n){return o.Log.debug("TokenClient.exchangeCode: Received token endpoint"),e._jsonService.postForm(n,t,r).then(function(e){return o.Log.debug("TokenClient.exchangeCode: response received"),e})})):(o.Log.error("TokenClient.exchangeCode: No client_secret passed"),Promise.reject(new Error("A client_secret is required"))):(o.Log.error("TokenClient.exchangeCode: No client_id passed"),Promise.reject(new Error("A client_id is required"))):(o.Log.error("TokenClient.exchangeCode: No code_verifier passed"),Promise.reject(new Error("A code_verifier is required"))):(o.Log.error("TokenClient.exchangeCode: No redirect_uri passed"),Promise.reject(new Error("A redirect_uri is required"))):(o.Log.error("TokenClient.exchangeCode: No code passed"),Promise.reject(new Error("A code is required")))},e.prototype.exchangeRefreshToken=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(t=Object.assign({},t)).grant_type=t.grant_type||"refresh_token",t.client_id=t.client_id||this._settings.client_id,t.client_secret=t.client_secret||this._settings.client_secret;var r=void 0,n=t._client_authentication||this._settings._client_authentication;return delete t._client_authentication,t.refresh_token?t.client_id?("client_secret_basic"==n&&(r=t.client_id+":"+t.client_secret,delete t.client_id,delete t.client_secret),this._metadataService.getTokenEndpoint(!1).then(function(n){return o.Log.debug("TokenClient.exchangeRefreshToken: Received token endpoint"),e._jsonService.postForm(n,t,r).then(function(e){return o.Log.debug("TokenClient.exchangeRefreshToken: response received"),e})})):(o.Log.error("TokenClient.exchangeRefreshToken: No client_id passed"),Promise.reject(new Error("A client_id is required"))):(o.Log.error("TokenClient.exchangeRefreshToken: No refresh_token passed"),Promise.reject(new Error("A refresh_token is required")))},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorResponse=void 0;var n=r(0);t.ErrorResponse=function(e){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=r.error,o=r.error_description,s=r.error_uri,a=r.state,c=r.session_state;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),!i)throw n.Log.error("No error passed to ErrorResponse"),new Error("error");var u=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,o||i));return u.name="ErrorResponse",u.error=i,u.error_description=o,u.error_uri=s,u.state=a,u.session_state=c,u}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t}(Error)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SigninState=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=r(9),s=r(4),a=function(e){return e&&e.__esModule?e:{default:e}}(r(14));t.SigninState=function(e){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r.nonce,i=r.authority,o=r.client_id,c=r.redirect_uri,u=r.code_verifier,l=r.response_mode,h=r.client_secret,d=r.scope,f=r.extraTokenParams,p=r.skipUserInfo;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var g=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,arguments[0]));if(!0===n?g._nonce=(0,a.default)():n&&(g._nonce=n),!0===u?g._code_verifier=(0,a.default)()+(0,a.default)()+(0,a.default)():u&&(g._code_verifier=u),g.code_verifier){var y=s.JoseUtil.hashString(g.code_verifier,"SHA256");g._code_challenge=s.JoseUtil.hexToBase64Url(y)}return g._redirect_uri=c,g._authority=i,g._client_id=o,g._response_mode=l,g._client_secret=h,g._scope=d,g._extraTokenParams=f,g._skipUserInfo=p,g}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.toStorageString=function(){return i.Log.debug("SigninState.toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,nonce:this.nonce,code_verifier:this.code_verifier,redirect_uri:this.redirect_uri,authority:this.authority,client_id:this.client_id,response_mode:this.response_mode,client_secret:this.client_secret,scope:this.scope,extraTokenParams:this.extraTokenParams,skipUserInfo:this.skipUserInfo})},t.fromStorageString=function(e){return i.Log.debug("SigninState.fromStorageString"),new t(JSON.parse(e))},n(t,[{key:"nonce",get:function(){return this._nonce}},{key:"authority",get:function(){return this._authority}},{key:"client_id",get:function(){return this._client_id}},{key:"redirect_uri",get:function(){return this._redirect_uri}},{key:"code_verifier",get:function(){return this._code_verifier}},{key:"code_challenge",get:function(){return this._code_challenge}},{key:"response_mode",get:function(){return this._response_mode}},{key:"client_secret",get:function(){return this._client_secret}},{key:"scope",get:function(){return this._scope}},{key:"extraTokenParams",get:function(){return this._extraTokenParams}},{key:"skipUserInfo",get:function(){return this._skipUserInfo}}]),t}(o.State)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){return("undefined"!=n&&null!==n&&void 0!==n.getRandomValues?i:o)().replace(/-/g,"")};var n="undefined"!=typeof window?window.crypto||window.msCrypto:null;function i(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,function(e){return(e^n.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)})}function o(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,function(e){return(e^16*Math.random()>>e/4).toString(16)})}e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.User=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0);t.User=function(){function e(t){var r=t.id_token,n=t.session_state,i=t.access_token,o=t.refresh_token,s=t.token_type,a=t.scope,c=t.profile,u=t.expires_at,l=t.state;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.id_token=r,this.session_state=n,this.access_token=i,this.refresh_token=o,this.token_type=s,this.scope=a,this.profile=c,this.expires_at=u,this.state=l}return e.prototype.toStorageString=function(){return i.Log.debug("User.toStorageString"),JSON.stringify({id_token:this.id_token,session_state:this.session_state,access_token:this.access_token,refresh_token:this.refresh_token,token_type:this.token_type,scope:this.scope,profile:this.profile,expires_at:this.expires_at})},e.fromStorageString=function(t){return i.Log.debug("User.fromStorageString"),new e(JSON.parse(t))},n(e,[{key:"expires_in",get:function(){if(this.expires_at){var e=parseInt(Date.now()/1e3);return this.expires_at-e}},set:function(e){var t=parseInt(e);if("number"==typeof t&&t>0){var r=parseInt(Date.now()/1e3);this.expires_at=r+t}}},{key:"expired",get:function(){var e=this.expires_in;if(void 0!==e)return e<=0}},{key:"scopes",get:function(){return(this.scope||"").split(" ")}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AccessTokenEvents=void 0;var n=r(0),i=r(46);t.AccessTokenEvents=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.accessTokenExpiringNotificationTime,n=void 0===r?60:r,o=t.accessTokenExpiringTimer,s=void 0===o?new i.Timer("Access token expiring"):o,a=t.accessTokenExpiredTimer,c=void 0===a?new i.Timer("Access token expired"):a;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this._accessTokenExpiringNotificationTime=n,this._accessTokenExpiring=s,this._accessTokenExpired=c}return e.prototype.load=function(e){if(e.access_token&&void 0!==e.expires_in){var t=e.expires_in;if(n.Log.debug("AccessTokenEvents.load: access token present, remaining duration:",t),t>0){var r=t-this._accessTokenExpiringNotificationTime;r<=0&&(r=1),n.Log.debug("AccessTokenEvents.load: registering expiring timer in:",r),this._accessTokenExpiring.init(r)}else n.Log.debug("AccessTokenEvents.load: canceling existing expiring timer becase we're past expiration."),this._accessTokenExpiring.cancel();var i=t+1;n.Log.debug("AccessTokenEvents.load: registering expired timer in:",i),this._accessTokenExpired.init(i)}else this._accessTokenExpiring.cancel(),this._accessTokenExpired.cancel()},e.prototype.unload=function(){n.Log.debug("AccessTokenEvents.unload: canceling existing access token timers"),this._accessTokenExpiring.cancel(),this._accessTokenExpired.cancel()},e.prototype.addAccessTokenExpiring=function(e){this._accessTokenExpiring.addHandler(e)},e.prototype.removeAccessTokenExpiring=function(e){this._accessTokenExpiring.removeHandler(e)},e.prototype.addAccessTokenExpired=function(e){this._accessTokenExpired.addHandler(e)},e.prototype.removeAccessTokenExpired=function(e){this._accessTokenExpired.removeHandler(e)},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Event=void 0;var n=r(0);t.Event=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._name=t,this._callbacks=[]}return e.prototype.addHandler=function(e){this._callbacks.push(e)},e.prototype.removeHandler=function(e){var t=this._callbacks.findIndex(function(t){return t===e});t>=0&&this._callbacks.splice(t,1)},e.prototype.raise=function(){n.Log.debug("Event: Raising event: "+this._name);for(var e=0;e<this._callbacks.length;e++){var t;(t=this._callbacks)[e].apply(t,arguments)}},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SessionMonitor=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=r(19),s=r(1);t.SessionMonitor=function(){function e(t){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.CheckSessionIFrame,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:s.Global.timer;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw i.Log.error("SessionMonitor.ctor: No user manager passed to SessionMonitor"),new Error("userManager");this._userManager=t,this._CheckSessionIFrameCtor=n,this._timer=a,this._userManager.events.addUserLoaded(this._start.bind(this)),this._userManager.events.addUserUnloaded(this._stop.bind(this)),Promise.resolve(this._userManager.getUser().then(function(e){e?r._start(e):r._settings.monitorAnonymousSession&&r._userManager.querySessionStatus().then(function(e){var t={session_state:e.session_state};e.sub&&e.sid&&(t.profile={sub:e.sub,sid:e.sid}),r._start(t)}).catch(function(e){i.Log.error("SessionMonitor ctor: error from querySessionStatus:",e.message)})}).catch(function(e){i.Log.error("SessionMonitor ctor: error from getUser:",e.message)}))}return e.prototype._start=function(e){var t=this,r=e.session_state;r&&(e.profile?(this._sub=e.profile.sub,this._sid=e.profile.sid,i.Log.debug("SessionMonitor._start: session_state:",r,", sub:",this._sub)):(this._sub=void 0,this._sid=void 0,i.Log.debug("SessionMonitor._start: session_state:",r,", anonymous user")),this._checkSessionIFrame?this._checkSessionIFrame.start(r):this._metadataService.getCheckSessionIframe().then(function(e){if(e){i.Log.debug("SessionMonitor._start: Initializing check session iframe");var n=t._client_id,o=t._checkSessionInterval,s=t._stopCheckSessionOnError;t._checkSessionIFrame=new t._CheckSessionIFrameCtor(t._callback.bind(t),n,e,o,s),t._checkSessionIFrame.load().then(function(){t._checkSessionIFrame.start(r)})}else i.Log.warn("SessionMonitor._start: No check session iframe found in the metadata")}).catch(function(e){i.Log.error("SessionMonitor._start: Error from getCheckSessionIframe:",e.message)}))},e.prototype._stop=function(){var e=this;if(this._sub=void 0,this._sid=void 0,this._checkSessionIFrame&&(i.Log.debug("SessionMonitor._stop"),this._checkSessionIFrame.stop()),this._settings.monitorAnonymousSession)var t=this._timer.setInterval(function(){e._timer.clearInterval(t),e._userManager.querySessionStatus().then(function(t){var r={session_state:t.session_state};t.sub&&t.sid&&(r.profile={sub:t.sub,sid:t.sid}),e._start(r)}).catch(function(e){i.Log.error("SessionMonitor: error from querySessionStatus:",e.message)})},1e3)},e.prototype._callback=function(){var e=this;this._userManager.querySessionStatus().then(function(t){var r=!0;t?t.sub===e._sub?(r=!1,e._checkSessionIFrame.start(t.session_state),t.sid===e._sid?i.Log.debug("SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:",t.session_state):(i.Log.debug("SessionMonitor._callback: Same sub still logged in at OP, session state has changed, restarting check session iframe; session_state:",t.session_state),e._userManager.events._raiseUserSessionChanged())):i.Log.debug("SessionMonitor._callback: Different subject signed into OP:",t.sub):i.Log.debug("SessionMonitor._callback: Subject no longer signed into OP"),r&&(e._sub?(i.Log.debug("SessionMonitor._callback: SessionMonitor._callback; raising signed out event"),e._userManager.events._raiseUserSignedOut()):(i.Log.debug("SessionMonitor._callback: SessionMonitor._callback; raising signed in event"),e._userManager.events._raiseUserSignedIn()))}).catch(function(t){e._sub&&(i.Log.debug("SessionMonitor._callback: Error calling queryCurrentSigninSession; raising signed out event",t.message),e._userManager.events._raiseUserSignedOut())})},n(e,[{key:"_settings",get:function(){return this._userManager.settings}},{key:"_metadataService",get:function(){return this._userManager.metadataService}},{key:"_client_id",get:function(){return this._settings.client_id}},{key:"_checkSessionInterval",get:function(){return this._settings.checkSessionInterval}},{key:"_stopCheckSessionOnError",get:function(){return this._settings.stopCheckSessionOnError}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CheckSessionIFrame=void 0;var n=r(0);t.CheckSessionIFrame=function(){function e(t,r,n,i){var o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this._callback=t,this._client_id=r,this._url=n,this._interval=i||2e3,this._stopOnError=o;var s=n.indexOf("/",n.indexOf("//")+2);this._frame_origin=n.substr(0,s),this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="absolute",this._frame.style.display="none",this._frame.width=0,this._frame.height=0,this._frame.src=n}return e.prototype.load=function(){var e=this;return new Promise(function(t){e._frame.onload=function(){t()},window.document.body.appendChild(e._frame),e._boundMessageEvent=e._message.bind(e),window.addEventListener("message",e._boundMessageEvent,!1)})},e.prototype._message=function(e){e.origin===this._frame_origin&&e.source===this._frame.contentWindow&&("error"===e.data?(n.Log.error("CheckSessionIFrame: error message from check session op iframe"),this._stopOnError&&this.stop()):"changed"===e.data?(n.Log.debug("CheckSessionIFrame: changed message from check session op iframe"),this.stop(),this._callback()):n.Log.debug("CheckSessionIFrame: "+e.data+" message from check session op iframe"))},e.prototype.start=function(e){var t=this;if(this._session_state!==e){n.Log.debug("CheckSessionIFrame.start"),this.stop(),this._session_state=e;var r=function(){t._frame.contentWindow.postMessage(t._client_id+" "+t._session_state,t._frame_origin)};r(),this._timer=window.setInterval(r,this._interval)}},e.prototype.stop=function(){this._session_state=null,this._timer&&(n.Log.debug("CheckSessionIFrame.stop"),window.clearInterval(this._timer),this._timer=null)},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TokenRevocationClient=void 0;var n=r(0),i=r(2),o=r(1);t.TokenRevocationClient=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.Global.XMLHttpRequest,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i.MetadataService;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw n.Log.error("TokenRevocationClient.ctor: No settings provided"),new Error("No settings provided.");this._settings=t,this._XMLHttpRequestCtor=r,this._metadataService=new s(this._settings)}return e.prototype.revoke=function(e,t){var r=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"access_token";if(!e)throw n.Log.error("TokenRevocationClient.revoke: No token provided"),new Error("No token provided.");if("access_token"!==i&&"refresh_token"!=i)throw n.Log.error("TokenRevocationClient.revoke: Invalid token type"),new Error("Invalid token type.");return this._metadataService.getRevocationEndpoint().then(function(o){if(o){n.Log.debug("TokenRevocationClient.revoke: Revoking "+i);var s=r._settings.client_id,a=r._settings.client_secret;return r._revoke(o,s,a,e,i)}if(t)throw n.Log.error("TokenRevocationClient.revoke: Revocation not supported"),new Error("Revocation not supported")})},e.prototype._revoke=function(e,t,r,i,o){var s=this;return new Promise(function(a,c){var u=new s._XMLHttpRequestCtor;u.open("POST",e),u.onload=function(){n.Log.debug("TokenRevocationClient.revoke: HTTP response received, status",u.status),200===u.status?a():c(Error(u.statusText+" ("+u.status+")"))},u.onerror=function(){n.Log.debug("TokenRevocationClient.revoke: Network Error."),c("Network Error")};var l="client_id="+encodeURIComponent(t);r&&(l+="&client_secret="+encodeURIComponent(r)),l+="&token_type_hint="+encodeURIComponent(o),l+="&token="+encodeURIComponent(i),u.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),u.send(l)})},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CordovaPopupWindow=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0);t.CordovaPopupWindow=function(){function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._promise=new Promise(function(e,t){r._resolve=e,r._reject=t}),this.features=t.popupWindowFeatures||"location=no,toolbar=no,zoom=no",this.target=t.popupWindowTarget||"_blank",this.redirect_uri=t.startUrl,i.Log.debug("CordovaPopupWindow.ctor: redirect_uri: "+this.redirect_uri)}return e.prototype._isInAppBrowserInstalled=function(e){return["cordova-plugin-inappbrowser","cordova-plugin-inappbrowser.inappbrowser","org.apache.cordova.inappbrowser"].some(function(t){return e.hasOwnProperty(t)})},e.prototype.navigate=function(e){if(e&&e.url){if(!window.cordova)return this._error("cordova is undefined");var t=window.cordova.require("cordova/plugin_list").metadata;if(!1===this._isInAppBrowserInstalled(t))return this._error("InAppBrowser plugin not found");this._popup=cordova.InAppBrowser.open(e.url,this.target,this.features),this._popup?(i.Log.debug("CordovaPopupWindow.navigate: popup successfully created"),this._exitCallbackEvent=this._exitCallback.bind(this),this._loadStartCallbackEvent=this._loadStartCallback.bind(this),this._popup.addEventListener("exit",this._exitCallbackEvent,!1),this._popup.addEventListener("loadstart",this._loadStartCallbackEvent,!1)):this._error("Error opening popup window")}else this._error("No url provided");return this.promise},e.prototype._loadStartCallback=function(e){0===e.url.indexOf(this.redirect_uri)&&this._success({url:e.url})},e.prototype._exitCallback=function(e){this._error(e)},e.prototype._success=function(e){this._cleanup(),i.Log.debug("CordovaPopupWindow: Successful response from cordova popup window"),this._resolve(e)},e.prototype._error=function(e){this._cleanup(),i.Log.error(e),this._reject(new Error(e))},e.prototype.close=function(){this._cleanup()},e.prototype._cleanup=function(){this._popup&&(i.Log.debug("CordovaPopupWindow: cleaning up popup"),this._popup.removeEventListener("exit",this._exitCallbackEvent,!1),this._popup.removeEventListener("loadstart",this._loadStartCallbackEvent,!1),this._popup.close()),this._popup=null},n(e,[{key:"promise",get:function(){return this._promise}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),i=r(10),o=r(5),s=r(6),a=r(37),c=r(38),u=r(16),l=r(2),h=r(48),d=r(49),f=r(19),p=r(20),g=r(18),y=r(1),m=r(15),v=r(50);t.default={Version:v.Version,Log:n.Log,OidcClient:i.OidcClient,OidcClientSettings:o.OidcClientSettings,WebStorageStateStore:s.WebStorageStateStore,InMemoryWebStorage:a.InMemoryWebStorage,UserManager:c.UserManager,AccessTokenEvents:u.AccessTokenEvents,MetadataService:l.MetadataService,CordovaPopupNavigator:h.CordovaPopupNavigator,CordovaIFrameNavigator:d.CordovaIFrameNavigator,CheckSessionIFrame:f.CheckSessionIFrame,TokenRevocationClient:p.TokenRevocationClient,SessionMonitor:g.SessionMonitor,Global:y.Global,User:m.User},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ClockService=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.prototype.getEpochTime=function(){return Promise.resolve(Date.now()/1e3|0)},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ResponseValidator=void 0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(0),o=r(2),s=r(25),a=r(11),c=r(12),u=r(4),l=["nonce","at_hash","iat","nbf","exp","aud","iss","c_hash"];t.ResponseValidator=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.MetadataService,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:s.UserInfoService,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:u.JoseUtil,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:a.TokenClient;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw i.Log.error("ResponseValidator.ctor: No settings passed to ResponseValidator"),new Error("settings");this._settings=t,this._metadataService=new r(this._settings),this._userInfoService=new n(this._settings),this._joseUtil=c,this._tokenClient=new l(this._settings)}return e.prototype.validateSigninResponse=function(e,t){var r=this;return i.Log.debug("ResponseValidator.validateSigninResponse"),this._processSigninParams(e,t).then(function(t){return i.Log.debug("ResponseValidator.validateSigninResponse: state processed"),r._validateTokens(e,t).then(function(t){return i.Log.debug("ResponseValidator.validateSigninResponse: tokens validated"),r._processClaims(e,t).then(function(e){return i.Log.debug("ResponseValidator.validateSigninResponse: claims processed"),e})})})},e.prototype.validateSignoutResponse=function(e,t){return e.id!==t.state?(i.Log.error("ResponseValidator.validateSignoutResponse: State does not match"),Promise.reject(new Error("State does not match"))):(i.Log.debug("ResponseValidator.validateSignoutResponse: state validated"),t.state=e.data,t.error?(i.Log.warn("ResponseValidator.validateSignoutResponse: Response was error",t.error),Promise.reject(new c.ErrorResponse(t))):Promise.resolve(t))},e.prototype._processSigninParams=function(e,t){if(e.id!==t.state)return i.Log.error("ResponseValidator._processSigninParams: State does not match"),Promise.reject(new Error("State does not match"));if(!e.client_id)return i.Log.error("ResponseValidator._processSigninParams: No client_id on state"),Promise.reject(new Error("No client_id on state"));if(!e.authority)return i.Log.error("ResponseValidator._processSigninParams: No authority on state"),Promise.reject(new Error("No authority on state"));if(this._settings.authority){if(this._settings.authority&&this._settings.authority!==e.authority)return i.Log.error("ResponseValidator._processSigninParams: authority mismatch on settings vs. signin state"),Promise.reject(new Error("authority mismatch on settings vs. signin state"))}else this._settings.authority=e.authority;if(this._settings.client_id){if(this._settings.client_id&&this._settings.client_id!==e.client_id)return i.Log.error("ResponseValidator._processSigninParams: client_id mismatch on settings vs. signin state"),Promise.reject(new Error("client_id mismatch on settings vs. signin state"))}else this._settings.client_id=e.client_id;return i.Log.debug("ResponseValidator._processSigninParams: state validated"),t.state=e.data,t.error?(i.Log.warn("ResponseValidator._processSigninParams: Response was error",t.error),Promise.reject(new c.ErrorResponse(t))):e.nonce&&!t.id_token?(i.Log.error("ResponseValidator._processSigninParams: Expecting id_token in response"),Promise.reject(new Error("No id_token in response"))):!e.nonce&&t.id_token?(i.Log.error("ResponseValidator._processSigninParams: Not expecting id_token in response"),Promise.reject(new Error("Unexpected id_token in response"))):e.code_verifier&&!t.code?(i.Log.error("ResponseValidator._processSigninParams: Expecting code in response"),Promise.reject(new Error("No code in response"))):!e.code_verifier&&t.code?(i.Log.error("ResponseValidator._processSigninParams: Not expecting code in response"),Promise.reject(new Error("Unexpected code in response"))):(t.scope||(t.scope=e.scope),Promise.resolve(t))},e.prototype._processClaims=function(e,t){var r=this;if(t.isOpenIdConnect){if(i.Log.debug("ResponseValidator._processClaims: response is OIDC, processing claims"),t.profile=this._filterProtocolClaims(t.profile),!0!==e.skipUserInfo&&this._settings.loadUserInfo&&t.access_token)return i.Log.debug("ResponseValidator._processClaims: loading user info"),this._userInfoService.getClaims(t.access_token).then(function(e){return i.Log.debug("ResponseValidator._processClaims: user info claims received from user info endpoint"),e.sub!==t.profile.sub?(i.Log.error("ResponseValidator._processClaims: sub from user info endpoint does not match sub in id_token"),Promise.reject(new Error("sub from user info endpoint does not match sub in id_token"))):(t.profile=r._mergeClaims(t.profile,e),i.Log.debug("ResponseValidator._processClaims: user info claims received, updated profile:",t.profile),t)});i.Log.debug("ResponseValidator._processClaims: not loading user info")}else i.Log.debug("ResponseValidator._processClaims: response is not OIDC, not processing claims");return Promise.resolve(t)},e.prototype._mergeClaims=function(e,t){var r=Object.assign({},e);for(var i in t){var o=t[i];Array.isArray(o)||(o=[o]);for(var s=0;s<o.length;s++){var a=o[s];r[i]?Array.isArray(r[i])?r[i].indexOf(a)<0&&r[i].push(a):r[i]!==a&&("object"===(void 0===a?"undefined":n(a))&&this._settings.mergeClaims?r[i]=this._mergeClaims(r[i],a):r[i]=[r[i],a]):r[i]=a}}return r},e.prototype._filterProtocolClaims=function(e){i.Log.debug("ResponseValidator._filterProtocolClaims, incoming claims:",e);var t=Object.assign({},e);return this._settings._filterProtocolClaims?(l.forEach(function(e){delete t[e]}),i.Log.debug("ResponseValidator._filterProtocolClaims: protocol claims filtered",t)):i.Log.debug("ResponseValidator._filterProtocolClaims: protocol claims not filtered"),t},e.prototype._validateTokens=function(e,t){return t.code?(i.Log.debug("ResponseValidator._validateTokens: Validating code"),this._processCode(e,t)):t.id_token?t.access_token?(i.Log.debug("ResponseValidator._validateTokens: Validating id_token and access_token"),this._validateIdTokenAndAccessToken(e,t)):(i.Log.debug("ResponseValidator._validateTokens: Validating id_token"),this._validateIdToken(e,t)):(i.Log.debug("ResponseValidator._validateTokens: No code to process or id_token to validate"),Promise.resolve(t))},e.prototype._processCode=function(e,t){var r=this,o={client_id:e.client_id,client_secret:e.client_secret,code:t.code,redirect_uri:e.redirect_uri,code_verifier:e.code_verifier};return e.extraTokenParams&&"object"===n(e.extraTokenParams)&&Object.assign(o,e.extraTokenParams),this._tokenClient.exchangeCode(o).then(function(n){for(var o in n)t[o]=n[o];return t.id_token?(i.Log.debug("ResponseValidator._processCode: token response successful, processing id_token"),r._validateIdTokenAttributes(e,t)):(i.Log.debug("ResponseValidator._processCode: token response successful, returning response"),t)})},e.prototype._validateIdTokenAttributes=function(e,t){var r=this;return this._metadataService.getIssuer().then(function(n){var o=e.client_id,s=r._settings.clockSkew;return i.Log.debug("ResponseValidator._validateIdTokenAttributes: Validaing JWT attributes; using clock skew (in seconds) of: ",s),r._settings.getEpochTime().then(function(a){return r._joseUtil.validateJwtAttributes(t.id_token,n,o,s,a).then(function(r){return e.nonce&&e.nonce!==r.nonce?(i.Log.error("ResponseValidator._validateIdTokenAttributes: Invalid nonce in id_token"),Promise.reject(new Error("Invalid nonce in id_token"))):r.sub?(t.profile=r,t):(i.Log.error("ResponseValidator._validateIdTokenAttributes: No sub present in id_token"),Promise.reject(new Error("No sub present in id_token")))})})})},e.prototype._validateIdTokenAndAccessToken=function(e,t){var r=this;return this._validateIdToken(e,t).then(function(e){return r._validateAccessToken(e)})},e.prototype._getSigningKeyForJwt=function(e){var t=this;return this._metadataService.getSigningKeys().then(function(r){var n=e.header.kid;if(!r)return i.Log.error("ResponseValidator._validateIdToken: No signing keys from metadata"),Promise.reject(new Error("No signing keys from metadata"));i.Log.debug("ResponseValidator._validateIdToken: Received signing keys");var o=void 0;if(n)o=r.filter(function(e){return e.kid===n})[0];else{if((r=t._filterByAlg(r,e.header.alg)).length>1)return i.Log.error("ResponseValidator._validateIdToken: No kid found in id_token and more than one key found in metadata"),Promise.reject(new Error("No kid found in id_token and more than one key found in metadata"));o=r[0]}return Promise.resolve(o)})},e.prototype._getSigningKeyForJwtWithSingleRetry=function(e){var t=this;return this._getSigningKeyForJwt(e).then(function(r){return r?Promise.resolve(r):(t._metadataService.resetSigningKeys(),t._getSigningKeyForJwt(e))})},e.prototype._validateIdToken=function(e,t){var r=this;if(!e.nonce)return i.Log.error("ResponseValidator._validateIdToken: No nonce on state"),Promise.reject(new Error("No nonce on state"));var n=this._joseUtil.parseJwt(t.id_token);return n&&n.header&&n.payload?e.nonce!==n.payload.nonce?(i.Log.error("ResponseValidator._validateIdToken: Invalid nonce in id_token"),Promise.reject(new Error("Invalid nonce in id_token"))):this._metadataService.getIssuer().then(function(o){return i.Log.debug("ResponseValidator._validateIdToken: Received issuer"),r._getSigningKeyForJwtWithSingleRetry(n).then(function(s){if(!s)return i.Log.error("ResponseValidator._validateIdToken: No key matching kid or alg found in signing keys"),Promise.reject(new Error("No key matching kid or alg found in signing keys"));var a=e.client_id,c=r._settings.clockSkew;return i.Log.debug("ResponseValidator._validateIdToken: Validaing JWT; using clock skew (in seconds) of: ",c),r._joseUtil.validateJwt(t.id_token,s,o,a,c).then(function(){return i.Log.debug("ResponseValidator._validateIdToken: JWT validation successful"),n.payload.sub?(t.profile=n.payload,t):(i.Log.error("ResponseValidator._validateIdToken: No sub present in id_token"),Promise.reject(new Error("No sub present in id_token")))})})}):(i.Log.error("ResponseValidator._validateIdToken: Failed to parse id_token",n),Promise.reject(new Error("Failed to parse id_token")))},e.prototype._filterByAlg=function(e,t){var r=null;if(t.startsWith("RS"))r="RSA";else if(t.startsWith("PS"))r="PS";else{if(!t.startsWith("ES"))return i.Log.debug("ResponseValidator._filterByAlg: alg not supported: ",t),[];r="EC"}return i.Log.debug("ResponseValidator._filterByAlg: Looking for keys that match kty: ",r),e=e.filter(function(e){return e.kty===r}),i.Log.debug("ResponseValidator._filterByAlg: Number of keys that match kty: ",r,e.length),e},e.prototype._validateAccessToken=function(e){if(!e.profile)return i.Log.error("ResponseValidator._validateAccessToken: No profile loaded from id_token"),Promise.reject(new Error("No profile loaded from id_token"));if(!e.profile.at_hash)return i.Log.error("ResponseValidator._validateAccessToken: No at_hash in id_token"),Promise.reject(new Error("No at_hash in id_token"));if(!e.id_token)return i.Log.error("ResponseValidator._validateAccessToken: No id_token"),Promise.reject(new Error("No id_token"));var t=this._joseUtil.parseJwt(e.id_token);if(!t||!t.header)return i.Log.error("ResponseValidator._validateAccessToken: Failed to parse id_token",t),Promise.reject(new Error("Failed to parse id_token"));var r=t.header.alg;if(!r||5!==r.length)return i.Log.error("ResponseValidator._validateAccessToken: Unsupported alg:",r),Promise.reject(new Error("Unsupported alg: "+r));var n=r.substr(2,3);if(!n)return i.Log.error("ResponseValidator._validateAccessToken: Unsupported alg:",r,n),Promise.reject(new Error("Unsupported alg: "+r));if(256!==(n=parseInt(n))&&384!==n&&512!==n)return i.Log.error("ResponseValidator._validateAccessToken: Unsupported alg:",r,n),Promise.reject(new Error("Unsupported alg: "+r));var o="sha"+n,s=this._joseUtil.hashString(e.access_token,o);if(!s)return i.Log.error("ResponseValidator._validateAccessToken: access_token hash failed:",o),Promise.reject(new Error("Failed to validate at_hash"));var a=s.substr(0,s.length/2),c=this._joseUtil.hexToBase64Url(a);return c!==e.profile.at_hash?(i.Log.error("ResponseValidator._validateAccessToken: Failed to validate at_hash",c,e.profile.at_hash),Promise.reject(new Error("Failed to validate at_hash"))):(i.Log.debug("ResponseValidator._validateAccessToken: success"),Promise.resolve(e))},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserInfoService=void 0;var n=r(7),i=r(2),o=r(0),s=r(4);t.UserInfoService=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.JsonService,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i.MetadataService,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.JoseUtil;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw o.Log.error("UserInfoService.ctor: No settings passed"),new Error("settings");this._settings=t,this._jsonService=new r(void 0,void 0,this._getClaimsFromJwt.bind(this)),this._metadataService=new a(this._settings),this._joseUtil=c}return e.prototype.getClaims=function(e){var t=this;return e?this._metadataService.getUserInfoEndpoint().then(function(r){return o.Log.debug("UserInfoService.getClaims: received userinfo url",r),t._jsonService.getJson(r,e).then(function(e){return o.Log.debug("UserInfoService.getClaims: claims received",e),e})}):(o.Log.error("UserInfoService.getClaims: No token passed"),Promise.reject(new Error("A token is required")))},e.prototype._getClaimsFromJwt=function e(t){var r=this;try{var n=this._joseUtil.parseJwt(t.responseText);if(!n||!n.header||!n.payload)return o.Log.error("UserInfoService._getClaimsFromJwt: Failed to parse JWT",n),Promise.reject(new Error("Failed to parse id_token"));var i=n.header.kid,s=void 0;switch(this._settings.userInfoJwtIssuer){case"OP":s=this._metadataService.getIssuer();break;case"ANY":s=Promise.resolve(n.payload.iss);break;default:s=Promise.resolve(this._settings.userInfoJwtIssuer)}return s.then(function(e){return o.Log.debug("UserInfoService._getClaimsFromJwt: Received issuer:"+e),r._metadataService.getSigningKeys().then(function(s){if(!s)return o.Log.error("UserInfoService._getClaimsFromJwt: No signing keys from metadata"),Promise.reject(new Error("No signing keys from metadata"));o.Log.debug("UserInfoService._getClaimsFromJwt: Received signing keys");var a=void 0;if(i)a=s.filter(function(e){return e.kid===i})[0];else{if((s=r._filterByAlg(s,n.header.alg)).length>1)return o.Log.error("UserInfoService._getClaimsFromJwt: No kid found in id_token and more than one key found in metadata"),Promise.reject(new Error("No kid found in id_token and more than one key found in metadata"));a=s[0]}if(!a)return o.Log.error("UserInfoService._getClaimsFromJwt: No key matching kid or alg found in signing keys"),Promise.reject(new Error("No key matching kid or alg found in signing keys"));var c=r._settings.client_id,u=r._settings.clockSkew;return o.Log.debug("UserInfoService._getClaimsFromJwt: Validaing JWT; using clock skew (in seconds) of: ",u),r._joseUtil.validateJwt(t.responseText,a,e,c,u,void 0,!0).then(function(){return o.Log.debug("UserInfoService._getClaimsFromJwt: JWT validation successful"),n.payload})})})}catch(e){return o.Log.error("UserInfoService._getClaimsFromJwt: Error parsing JWT response",e.message),void reject(e)}},e.prototype._filterByAlg=function(e,t){var r=null;if(t.startsWith("RS"))r="RSA";else if(t.startsWith("PS"))r="PS";else{if(!t.startsWith("ES"))return o.Log.debug("UserInfoService._filterByAlg: alg not supported: ",t),[];r="EC"}return o.Log.debug("UserInfoService._filterByAlg: Looking for keys that match kty: ",r),e=e.filter(function(e){return e.kty===r}),o.Log.debug("UserInfoService._filterByAlg: Number of keys that match kty: ",r,e.length),e},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AllowedSigningAlgs=t.b64tohex=t.hextob64u=t.crypto=t.X509=t.KeyUtil=t.jws=void 0;var n=r(27);t.jws=n.jws,t.KeyUtil=n.KEYUTIL,t.X509=n.X509,t.crypto=n.crypto,t.hextob64u=n.hextob64u,t.b64tohex=n.b64tohex,t.AllowedSigningAlgs=["RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"]},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});var r,n,i,o,s,a,c,u,l,h,d,f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p={userAgent:!1},g={},y=y||(r=Math,i=(n={}).lib={},o=i.Base=function(){function e(){}return{extend:function(t){e.prototype=this;var r=new e;return t&&r.mixIn(t),r.hasOwnProperty("init")||(r.init=function(){r.$super.init.apply(this,arguments)}),r.init.prototype=r,r.$super=this,r},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),s=i.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<i;o++){var s=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=s<<24-(n+o)%4*8}else for(o=0;o<i;o+=4)t[n+o>>>2]=r[o>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=r.ceil(t/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(4294967296*r.random()|0);return new s.init(t,e)}}),a=n.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new s.init(r,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new s.init(r,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},h=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,n=t.words,i=t.sigBytes,o=this.blockSize,a=i/(4*o),c=(a=e?r.ceil(a):r.max((0|a)-this._minBufferSize,0))*o,u=r.min(4*c,i);if(c){for(var l=0;l<c;l+=o)this._doProcessBlock(n,l);var h=n.splice(0,c);t.sigBytes-=u}return new s.init(h,u)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),i.Hasher=h.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new d.HMAC.init(e,r).finalize(t)}}}),d=n.algo={},n);!function(){var e,t=(e=y).lib,r=t.Base,n=t.WordArray;(e=e.x64={}).Word=r.extend({init:function(e,t){this.high=e,this.low=t}}),e.WordArray=r.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:8*e.length},toX32:function(){for(var e=this.words,t=e.length,r=[],i=0;i<t;i++){var o=e[i];r.push(o.high),r.push(o.low)}return n.create(r,this.sigBytes)},clone:function(){for(var e=r.clone.call(this),t=e.words=this.words.slice(0),n=t.length,i=0;i<n;i++)t[i]=t[i].clone();return e}})}(),function(){var e=y,t=e.lib.WordArray;e.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp(),e=[];for(var i=0;i<r;i+=3)for(var o=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;4>s&&i+.75*s<r;s++)e.push(n.charAt(o>>>6*(3-s)&63));if(t=n.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var r=e.length,n=this._map;(i=n.charAt(64))&&-1!=(i=e.indexOf(i))&&(r=i);for(var i=[],o=0,s=0;s<r;s++)if(s%4){var a=n.indexOf(e.charAt(s-1))<<s%4*2,c=n.indexOf(e.charAt(s))>>>6-s%4*2;i[o>>>2]|=(a|c)<<24-o%4*8,o++}return t.create(i,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(e){for(var t=y,r=(i=t.lib).WordArray,n=i.Hasher,i=t.algo,o=[],s=[],a=function(e){return 4294967296*(e-(0|e))|0},c=2,u=0;64>u;){var l;e:{l=c;for(var h=e.sqrt(l),d=2;d<=h;d++)if(!(l%d)){l=!1;break e}l=!0}l&&(8>u&&(o[u]=a(e.pow(c,.5))),s[u]=a(e.pow(c,1/3)),u++),c++}var f=[];i=i.SHA256=n.extend({_doReset:function(){this._hash=new r.init(o.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],c=r[4],u=r[5],l=r[6],h=r[7],d=0;64>d;d++){if(16>d)f[d]=0|e[t+d];else{var p=f[d-15],g=f[d-2];f[d]=((p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3)+f[d-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+f[d-16]}p=h+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&u^~c&l)+s[d]+f[d],g=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&i^n&o^i&o),h=l,l=u,u=c,c=a+p|0,a=o,o=i,i=n,n=p+g|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0,r[5]=r[5]+u|0,r[6]=r[6]+l|0,r[7]=r[7]+h|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}}),t.SHA256=n._createHelper(i),t.HmacSHA256=n._createHmacHelper(i)}(Math),function(){function e(){return n.create.apply(n,arguments)}for(var t=y,r=t.lib.Hasher,n=(o=t.x64).Word,i=o.WordArray,o=t.algo,s=[e(1116352408,3609767458),e(1899447441,602891725),e(3049323471,3964484399),e(3921009573,2173295548),e(961987163,4081628472),e(1508970993,3053834265),e(2453635748,2937671579),e(2870763221,3664609560),e(3624381080,2734883394),e(310598401,1164996542),e(607225278,1323610764),e(1426881987,3590304994),e(1925078388,4068182383),e(2162078206,991336113),e(2614888103,633803317),e(3248222580,3479774868),e(3835390401,2666613458),e(4022224774,944711139),e(264347078,2341262773),e(604807628,2007800933),e(770255983,1495990901),e(1249150122,1856431235),e(1555081692,3175218132),e(1996064986,2198950837),e(2554220882,3999719339),e(2821834349,766784016),e(2952996808,2566594879),e(3210313671,3203337956),e(3336571891,1034457026),e(3584528711,2466948901),e(113926993,3758326383),e(338241895,168717936),e(666307205,1188179964),e(773529912,1546045734),e(1294757372,1522805485),e(1396182291,2643833823),e(1695183700,2343527390),e(1986661051,1014477480),e(2177026350,1206759142),e(2456956037,344077627),e(2730485921,1290863460),e(2820302411,3158454273),e(3259730800,3505952657),e(3345764771,106217008),e(3516065817,3606008344),e(3600352804,1432725776),e(4094571909,1467031594),e(275423344,851169720),e(430227734,3100823752),e(506948616,1363258195),e(659060556,3750685593),e(883997877,3785050280),e(958139571,3318307427),e(1322822218,3812723403),e(1537002063,2003034995),e(1747873779,3602036899),e(1955562222,1575990012),e(2024104815,1125592928),e(2227730452,2716904306),e(2361852424,442776044),e(2428436474,593698344),e(2756734187,3733110249),e(3204031479,2999351573),e(3329325298,3815920427),e(3391569614,3928383900),e(3515267271,566280711),e(3940187606,3454069534),e(4118630271,4000239992),e(116418474,1914138554),e(174292421,2731055270),e(289380356,3203993006),e(460393269,320620315),e(685471733,587496836),e(852142971,1086792851),e(1017036298,365543100),e(1126000580,2618297676),e(1288033470,3409855158),e(1501505948,4234509866),e(1607167915,987167468),e(1816402316,1246189591)],a=[],c=0;80>c;c++)a[c]=e();o=o.SHA512=r.extend({_doReset:function(){this._hash=new i.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var r=(h=this._hash.words)[0],n=h[1],i=h[2],o=h[3],c=h[4],u=h[5],l=h[6],h=h[7],d=r.high,f=r.low,p=n.high,g=n.low,y=i.high,m=i.low,v=o.high,w=o.low,b=c.high,_=c.low,S=u.high,E=u.low,A=l.high,x=l.low,T=h.high,F=h.low,k=d,I=f,C=p,N=g,R=y,P=m,O=v,D=w,U=b,L=_,j=S,M=E,H=A,B=x,q=T,K=F,W=0;80>W;W++){var J=a[W];if(16>W)var V=J.high=0|e[t+2*W],$=J.low=0|e[t+2*W+1];else{V=(($=(V=a[W-15]).high)>>>1|(z=V.low)<<31)^($>>>8|z<<24)^$>>>7;var z=(z>>>1|$<<31)^(z>>>8|$<<24)^(z>>>7|$<<25),G=(($=(G=a[W-2]).high)>>>19|(X=G.low)<<13)^($<<3|X>>>29)^$>>>6,X=(X>>>19|$<<13)^(X<<3|$>>>29)^(X>>>6|$<<26),Y=($=a[W-7]).high,Q=(Z=a[W-16]).high,Z=Z.low;V=(V=(V=V+Y+(($=z+$.low)>>>0<z>>>0?1:0))+G+(($+=X)>>>0<X>>>0?1:0))+Q+(($+=Z)>>>0<Z>>>0?1:0),J.high=V,J.low=$}Y=U&j^~U&H,Z=L&M^~L&B,J=k&C^k&R^C&R;var ee=I&N^I&P^N&P,te=(z=(k>>>28|I<<4)^(k<<30|I>>>2)^(k<<25|I>>>7),G=(I>>>28|k<<4)^(I<<30|k>>>2)^(I<<25|k>>>7),(X=s[W]).high),re=X.low;Q=q+((U>>>14|L<<18)^(U>>>18|L<<14)^(U<<23|L>>>9))+((X=K+((L>>>14|U<<18)^(L>>>18|U<<14)^(L<<23|U>>>9)))>>>0<K>>>0?1:0),q=H,K=B,H=j,B=M,j=U,M=L,U=O+(Q=(Q=(Q=Q+Y+((X+=Z)>>>0<Z>>>0?1:0))+te+((X+=re)>>>0<re>>>0?1:0))+V+((X+=$)>>>0<$>>>0?1:0))+((L=D+X|0)>>>0<D>>>0?1:0)|0,O=R,D=P,R=C,P=N,C=k,N=I,k=Q+(J=z+J+(($=G+ee)>>>0<G>>>0?1:0))+((I=X+$|0)>>>0<X>>>0?1:0)|0}f=r.low=f+I,r.high=d+k+(f>>>0<I>>>0?1:0),g=n.low=g+N,n.high=p+C+(g>>>0<N>>>0?1:0),m=i.low=m+P,i.high=y+R+(m>>>0<P>>>0?1:0),w=o.low=w+D,o.high=v+O+(w>>>0<D>>>0?1:0),_=c.low=_+L,c.high=b+U+(_>>>0<L>>>0?1:0),E=u.low=E+M,u.high=S+j+(E>>>0<M>>>0?1:0),x=l.low=x+B,l.high=A+H+(x>>>0<B>>>0?1:0),F=h.low=F+K,h.high=T+q+(F>>>0<K>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),t[31+(n+128>>>10<<5)]=r,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32}),t.SHA512=r._createHelper(o),t.HmacSHA512=r._createHmacHelper(o)}(),function(){var e=y,t=(i=e.x64).Word,r=i.WordArray,n=(i=e.algo).SHA512,i=i.SHA384=n.extend({_doReset:function(){this._hash=new r.init([new t.init(3418070365,3238371032),new t.init(1654270250,914150663),new t.init(2438529370,812702999),new t.init(355462360,4144912697),new t.init(1731405415,4290775857),new t.init(2394180231,1750603025),new t.init(3675008525,1694076839),new t.init(1203062813,3204075428)])},_doFinalize:function(){var e=n._doFinalize.call(this);return e.sigBytes-=16,e}});e.SHA384=n._createHelper(i),e.HmacSHA384=n._createHmacHelper(i)}();
|
|
4
|
-
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
5
|
-
*/
|
|
6
|
-
var m,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function w(e){var t,r,n="";for(t=0;t+3<=e.length;t+=3)r=parseInt(e.substring(t,t+3),16),n+=v.charAt(r>>6)+v.charAt(63&r);for(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=v.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=v.charAt(r>>2)+v.charAt((3&r)<<4));(3&n.length)>0;)n+="=";return n}function b(e){var t,r,n,i="",o=0;for(t=0;t<e.length&&"="!=e.charAt(t);++t)(n=v.indexOf(e.charAt(t)))<0||(0==o?(i+=F(n>>2),r=3&n,o=1):1==o?(i+=F(r<<2|n>>4),r=15&n,o=2):2==o?(i+=F(r),i+=F(n>>2),r=3&n,o=3):(i+=F(r<<2|n>>4),i+=F(15&n),o=0));return 1==o&&(i+=F(r<<2)),i}function _(e){var t,r=b(e),n=new Array;for(t=0;2*t<r.length;++t)n[t]=parseInt(r.substring(2*t,2*t+2),16);return n}function S(e,t,r){null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function E(){return new S(null)}"Microsoft Internet Explorer"==p.appName?(S.prototype.am=function(e,t,r,n,i,o){for(var s=32767&t,a=t>>15;--o>=0;){var c=32767&this[e],u=this[e++]>>15,l=a*c+u*s;i=((c=s*c+((32767&l)<<15)+r[n]+(1073741823&i))>>>30)+(l>>>15)+a*u+(i>>>30),r[n++]=1073741823&c}return i},m=30):"Netscape"!=p.appName?(S.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var s=t*this[e++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},m=26):(S.prototype.am=function(e,t,r,n,i,o){for(var s=16383&t,a=t>>14;--o>=0;){var c=16383&this[e],u=this[e++]>>14,l=a*c+u*s;i=((c=s*c+((16383&l)<<14)+r[n]+i)>>28)+(l>>14)+a*u,r[n++]=268435455&c}return i},m=28),S.prototype.DB=m,S.prototype.DM=(1<<m)-1,S.prototype.DV=1<<m,S.prototype.FV=Math.pow(2,52),S.prototype.F1=52-m,S.prototype.F2=2*m-52;var A,x,T=new Array;for(A="0".charCodeAt(0),x=0;x<=9;++x)T[A++]=x;for(A="a".charCodeAt(0),x=10;x<36;++x)T[A++]=x;for(A="A".charCodeAt(0),x=10;x<36;++x)T[A++]=x;function F(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function k(e,t){var r=T[e.charCodeAt(t)];return null==r?-1:r}function I(e){var t=E();return t.fromInt(e),t}function C(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function N(e){this.m=e}function R(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function P(e,t){return e&t}function O(e,t){return e|t}function D(e,t){return e^t}function U(e,t){return e&~t}function L(e){if(0==e)return-1;var t=0;return!(65535&e)&&(e>>=16,t+=16),!(255&e)&&(e>>=8,t+=8),!(15&e)&&(e>>=4,t+=4),!(3&e)&&(e>>=2,t+=2),!(1&e)&&++t,t}function j(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function M(){}function H(e){return e}function B(e){this.r2=E(),this.q3=E(),S.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}N.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},N.prototype.revert=function(e){return e},N.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},N.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},N.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},R.prototype.convert=function(e){var t=E();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(S.ZERO)>0&&this.m.subTo(t,t),t},R.prototype.revert=function(e){var t=E();return e.copyTo(t),this.reduce(t),t},R.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e[t],n=r*this.mpl+((r*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},R.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},R.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},S.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},S.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},S.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,o=0;--n>=0;){var s=8==r?255&e[n]:k(e,n);s<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<<this.DB-o)-1)<<o,this[this.t++]=s>>this.DB-o):this[this.t-1]|=s<<o,(o+=r)>=this.DB&&(o-=this.DB))}8==r&&!!(128&e[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),i&&S.ZERO.subTo(this,this)},S.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t},S.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},S.prototype.drShiftTo=function(e,t){for(var r=e;r<this.t;++r)t[r-e]=this[r];t.t=Math.max(this.t-e,0),t.s=this.s},S.prototype.lShiftTo=function(e,t){var r,n=e%this.DB,i=this.DB-n,o=(1<<i)-1,s=Math.floor(e/this.DB),a=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t[r+s+1]=this[r]>>i|a,a=(this[r]&o)<<n;for(r=s-1;r>=0;--r)t[r]=0;t[s]=a,t.t=this.t+s+1,t.s=this.s,t.clamp()},S.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,o=(1<<n)-1;t[0]=this[r]>>n;for(var s=r+1;s<this.t;++s)t[s-r-1]|=(this[s]&o)<<i,t[s-r]=this[s]>>n;n>0&&(t[this.t-r-1]|=(this.s&o)<<i),t.t=this.t-r,t.clamp()}},S.prototype.subTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this[r]-e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e[r],t[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()},S.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t[i]=0;for(i=0;i<n.t;++i)t[i+r.t]=r.am(0,n[i],t,i,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&S.ZERO.subTo(t,t)},S.prototype.squareTo=function(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t[r],e,2*r,0,1);(e[r+t.t]+=t.am(r+1,2*t[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},S.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=E());var o=E(),s=this.s,a=e.s,c=this.DB-C(n[n.t-1]);c>0?(n.lShiftTo(c,o),i.lShiftTo(c,r)):(n.copyTo(o),i.copyTo(r));var u=o.t,l=o[u-1];if(0!=l){var h=l*(1<<this.F1)+(u>1?o[u-2]>>this.F2:0),d=this.FV/h,f=(1<<this.F1)/h,p=1<<this.F2,g=r.t,y=g-u,m=null==t?E():t;for(o.dlShiftTo(y,m),r.compareTo(m)>=0&&(r[r.t++]=1,r.subTo(m,r)),S.ONE.dlShiftTo(u,m),m.subTo(o,o);o.t<u;)o[o.t++]=0;for(;--y>=0;){var v=r[--g]==l?this.DM:Math.floor(r[g]*d+(r[g-1]+p)*f);if((r[g]+=o.am(0,v,r,y,0,u))<v)for(o.dlShiftTo(y,m),r.subTo(m,r);r[g]<--v;)r.subTo(m,r)}null!=t&&(r.drShiftTo(u,t),s!=a&&S.ZERO.subTo(t,t)),r.t=u,r.clamp(),c>0&&r.rShiftTo(c,r),s<0&&S.ZERO.subTo(r,r)}}},S.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},S.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},S.prototype.exp=function(e,t){if(e>4294967295||e<1)return S.ONE;var r=E(),n=E(),i=t.convert(this),o=C(e)-1;for(i.copyTo(r);--o>=0;)if(t.sqrTo(r,n),(e&1<<o)>0)t.mulTo(n,i,r);else{var s=r;r=n,n=s}return t.revert(r)},S.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,i=!1,o="",s=this.t,a=this.DB-s*this.DB%t;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(i=!0,o=F(r));s>=0;)a<t?(r=(this[s]&(1<<a)-1)<<t-a,r|=this[--s]>>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=F(r));return i?o:"0"},S.prototype.negate=function(){var e=E();return S.ZERO.subTo(this,e),e},S.prototype.abs=function(){return this.s<0?this.negate():this},S.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0},S.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+C(this[this.t-1]^this.s&this.DM)},S.prototype.mod=function(e){var t=E();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(S.ZERO)>0&&e.subTo(t,t),t},S.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new N(t):new R(t),this.exp(e,r)},S.ZERO=I(0),S.ONE=I(1),M.prototype.convert=H,M.prototype.revert=H,M.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},M.prototype.sqrTo=function(e,t){e.squareTo(t)},B.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=E();return e.copyTo(t),this.reduce(t),t},B.prototype.revert=function(e){return e},B.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},B.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},B.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var q,K,W,J=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],V=(1<<26)/J[J.length-1];
|
|
7
|
-
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
8
|
-
*/function $(){this.i=0,this.j=0,this.S=new Array}
|
|
9
|
-
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
10
|
-
*/
|
|
11
|
-
function z(){!function(e){K[W++]^=255&e,K[W++]^=e>>8&255,K[W++]^=e>>16&255,K[W++]^=e>>24&255,W>=256&&(W-=256)}((new Date).getTime())}if(S.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},S.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=I(r),i=E(),o=E(),s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(e).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(e)+s},S.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,o=0,s=0,a=0;a<e.length;++a){var c=k(e,a);c<0?"-"==e.charAt(a)&&0==this.signum()&&(i=!0):(s=t*s+c,++o>=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(s,0)),i&&S.ZERO.subTo(this,this)},S.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(S.ONE.shiftLeft(e-1),O,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(S.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}},S.prototype.bitwiseTo=function(e,t,r){var n,i,o=Math.min(e.t,this.t);for(n=0;n<o;++n)r[n]=t(this[n],e[n]);if(e.t<this.t){for(i=e.s&this.DM,n=o;n<this.t;++n)r[n]=t(this[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=o;n<e.t;++n)r[n]=t(i,e[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()},S.prototype.changeBit=function(e,t){var r=S.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r},S.prototype.addTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this[r]+e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e[r],t[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()},S.prototype.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},S.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},S.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i<n;++i)r[i+this.t]=this.am(0,e[i],r,i,0,this.t);for(n=Math.min(e.t,t);i<n;++i)this.am(0,e[i],r,i,0,t-i);r.clamp()},S.prototype.multiplyUpperTo=function(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r[this.t+n-t]=this.am(t-n,e[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)},S.prototype.modInt=function(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r},S.prototype.millerRabin=function(e){var t=this.subtract(S.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var n=t.shiftRight(r);(e=e+1>>1)>J.length&&(e=J.length);for(var i=E(),o=0;o<e;++o){i.fromInt(J[Math.floor(Math.random()*J.length)]);var s=i.modPow(n,this);if(0!=s.compareTo(S.ONE)&&0!=s.compareTo(t)){for(var a=1;a++<r&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo(S.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0},S.prototype.clone=
|
|
12
|
-
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
13
|
-
*/
|
|
14
|
-
function(){var e=E();return this.copyTo(e),e},S.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},S.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},S.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},S.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},S.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n<this.DB&&(r=this[e]>>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this[e]&(1<<n)-1)<<8-n,r|=this[--e]>>(n+=this.DB-8)):(r=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),!!(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},S.prototype.equals=function(e){return 0==this.compareTo(e)},S.prototype.min=function(e){return this.compareTo(e)<0?this:e},S.prototype.max=function(e){return this.compareTo(e)>0?this:e},S.prototype.and=function(e){var t=E();return this.bitwiseTo(e,P,t),t},S.prototype.or=function(e){var t=E();return this.bitwiseTo(e,O,t),t},S.prototype.xor=function(e){var t=E();return this.bitwiseTo(e,D,t),t},S.prototype.andNot=function(e){var t=E();return this.bitwiseTo(e,U,t),t},S.prototype.not=function(){for(var e=E(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e},S.prototype.shiftLeft=function(e){var t=E();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},S.prototype.shiftRight=function(e){var t=E();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},S.prototype.getLowestSetBit=function(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+L(this[e]);return this.s<0?this.t*this.DB:-1},S.prototype.bitCount=function(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=j(this[r]^t);return e},S.prototype.testBit=function(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this[t]&1<<e%this.DB)},S.prototype.setBit=function(e){return this.changeBit(e,O)},S.prototype.clearBit=function(e){return this.changeBit(e,U)},S.prototype.flipBit=function(e){return this.changeBit(e,D)},S.prototype.add=function(e){var t=E();return this.addTo(e,t),t},S.prototype.subtract=function(e){var t=E();return this.subTo(e,t),t},S.prototype.multiply=function(e){var t=E();return this.multiplyTo(e,t),t},S.prototype.divide=function(e){var t=E();return this.divRemTo(e,t,null),t},S.prototype.remainder=function(e){var t=E();return this.divRemTo(e,null,t),t},S.prototype.divideAndRemainder=function(e){var t=E(),r=E();return this.divRemTo(e,t,r),new Array(t,r)},S.prototype.modPow=function(e,t){var r,n,i=e.bitLength(),o=I(1);if(i<=0)return o;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new N(t):t.isEven()?new B(t):new R(t);var s=new Array,a=3,c=r-1,u=(1<<r)-1;if(s[1]=n.convert(this),r>1){var l=E();for(n.sqrTo(s[1],l);a<=u;)s[a]=E(),n.mulTo(l,s[a-2],s[a]),a+=2}var h,d,f=e.t-1,p=!0,g=E();for(i=C(e[f])-1;f>=0;){for(i>=c?h=e[f]>>i-c&u:(h=(e[f]&(1<<i+1)-1)<<c-i,f>0&&(h|=e[f-1]>>this.DB+i-c)),a=r;!(1&h);)h>>=1,--a;if((i-=a)<0&&(i+=this.DB,--f),p)s[h].copyTo(o),p=!1;else{for(;a>1;)n.sqrTo(o,g),n.sqrTo(g,o),a-=2;a>0?n.sqrTo(o,g):(d=o,o=g,g=d),n.mulTo(g,s[h],o)}for(;f>=0&&!(e[f]&1<<i);)n.sqrTo(o,g),d=o,o=g,g=d,--i<0&&(i=this.DB-1,--f)}return n.revert(o)},S.prototype.modInverse=function(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return S.ZERO;for(var r=e.clone(),n=this.clone(),i=I(1),o=I(0),s=I(0),a=I(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(i.isEven()&&o.isEven()||(i.addTo(this,i),o.subTo(e,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),t?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(e,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),t&&s.subTo(i,s),a.subTo(o,a))}return 0!=n.compareTo(S.ONE)?S.ZERO:a.compareTo(e)>=0?a.subtract(e):a.signum()<0?(a.addTo(e,a),a.signum()<0?a.add(e):a):a},S.prototype.pow=function(e){return this.exp(e,new M)},S.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return t;for(i<o&&(o=i),o>0&&(t.rShiftTo(o,t),r.rShiftTo(o,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},S.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r[0]<=J[J.length-1]){for(t=0;t<J.length;++t)if(r[0]==J[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<J.length;){for(var n=J[t],i=t+1;i<J.length&&n<V;)n*=J[i++];for(n=r.modInt(n);t<i;)if(n%J[t++]==0)return!1}return r.millerRabin(e)},S.prototype.square=function(){var e=E();return this.squareTo(e),e},$.prototype.init=function(e){var t,r,n;for(t=0;t<256;++t)this.S[t]=t;for(r=0,t=0;t<256;++t)r=r+this.S[t]+e[t%e.length]&255,n=this.S[t],this.S[t]=this.S[r],this.S[r]=n;this.i=0,this.j=0},$.prototype.next=function(){var e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]},null==K){var G;if(K=new Array,W=0,void 0!==g&&(void 0!==g.crypto||void 0!==g.msCrypto)){var X=g.crypto||g.msCrypto;if(X.getRandomValues){var Y=new Uint8Array(32);for(X.getRandomValues(Y),G=0;G<32;++G)K[W++]=Y[G]}else if("Netscape"==p.appName&&p.appVersion<"5"){var Q=g.crypto.random(32);for(G=0;G<Q.length;++G)K[W++]=255&Q.charCodeAt(G)}}for(;W<256;)G=Math.floor(65536*Math.random()),K[W++]=G>>>8,K[W++]=255&G;W=0,z()}function Z(){if(null==q){for(z(),(q=new $).init(K),W=0;W<K.length;++W)K[W]=0;W=0}return q.next()}function ee(){}
|
|
15
|
-
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
16
|
-
*/function te(e,t){return new S(e,t)}function re(e,t,r){for(var n="",i=0;n.length<t;)n+=r(String.fromCharCode.apply(String,e.concat([(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i]))),i+=1;return n}function ne(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}
|
|
17
|
-
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
18
|
-
*/function ie(e,t){this.x=t,this.q=e}function oe(e,t,r,n){this.curve=e,this.x=t,this.y=r,this.z=null==n?S.ONE:n,this.zinv=null}function se(e,t,r){this.q=e,this.a=this.fromBigInteger(t),this.b=this.fromBigInteger(r),this.infinity=new oe(this,null,null)}ee.prototype.nextBytes=function(e){var t;for(t=0;t<e.length;++t)e[t]=Z()},ne.prototype.doPublic=function(e){return e.modPowInt(this.e,this.n)},ne.prototype.setPublic=function(e,t){if(this.isPublic=!0,this.isPrivate=!1,"string"!=typeof e)this.n=e,this.e=t;else{if(!(null!=e&&null!=t&&e.length>0&&t.length>0))throw"Invalid RSA public key";this.n=te(e,16),this.e=parseInt(t,16)}},ne.prototype.encrypt=function(e){var t=function(e,t){if(t<e.length+11)throw"Message too long for RSA";for(var r=new Array,n=e.length-1;n>=0&&t>0;){var i=e.charCodeAt(n--);i<128?r[--t]=i:i>127&&i<2048?(r[--t]=63&i|128,r[--t]=i>>6|192):(r[--t]=63&i|128,r[--t]=i>>6&63|128,r[--t]=i>>12|224)}r[--t]=0;for(var o=new ee,s=new Array;t>2;){for(s[0]=0;0==s[0];)o.nextBytes(s);r[--t]=s[0]}return r[--t]=2,r[--t]=0,new S(r)}(e,this.n.bitLength()+7>>3);if(null==t)return null;var r=this.doPublic(t);if(null==r)return null;var n=r.toString(16);return 1&n.length?"0"+n:n},ne.prototype.encryptOAEP=function(e,t,r){var n=function(e,t,r,n){var i=ce.crypto.MessageDigest,o=ce.crypto.Util,s=null;if(r||(r="sha1"),"string"==typeof r&&(s=i.getCanonicalAlgName(r),n=i.getHashLength(s),r=function(e){return Se(o.hashHex(Ee(e),s))}),e.length+2*n+2>t)throw"Message too long for RSA";var a,c="";for(a=0;a<t-e.length-2*n-2;a+=1)c+="\0";var u=r("")+c+""+e,l=new Array(n);(new ee).nextBytes(l);var h=re(l,u.length,r),d=[];for(a=0;a<u.length;a+=1)d[a]=u.charCodeAt(a)^h.charCodeAt(a);var f=re(d,l.length,r),p=[0];for(a=0;a<l.length;a+=1)p[a+1]=l[a]^f.charCodeAt(a);return new S(p.concat(d))}(e,this.n.bitLength()+7>>3,t,r);if(null==n)return null;var i=this.doPublic(n);if(null==i)return null;var o=i.toString(16);return 1&o.length?"0"+o:o},ne.prototype.type="RSA",ie.prototype.equals=function(e){return e==this||this.q.equals(e.q)&&this.x.equals(e.x)},ie.prototype.toBigInteger=function(){return this.x},ie.prototype.negate=function(){return new ie(this.q,this.x.negate().mod(this.q))},ie.prototype.add=function(e){return new ie(this.q,this.x.add(e.toBigInteger()).mod(this.q))},ie.prototype.subtract=function(e){return new ie(this.q,this.x.subtract(e.toBigInteger()).mod(this.q))},ie.prototype.multiply=function(e){return new ie(this.q,this.x.multiply(e.toBigInteger()).mod(this.q))},ie.prototype.square=function(){return new ie(this.q,this.x.square().mod(this.q))},ie.prototype.divide=function(e){return new ie(this.q,this.x.multiply(e.toBigInteger().modInverse(this.q)).mod(this.q))},oe.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},oe.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},oe.prototype.equals=function(e){return e==this||(this.isInfinity()?e.isInfinity():e.isInfinity()?this.isInfinity():!!e.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(e.z)).mod(this.curve.q).equals(S.ZERO)&&e.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(e.z)).mod(this.curve.q).equals(S.ZERO))},oe.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(S.ZERO)&&!this.y.toBigInteger().equals(S.ZERO)},oe.prototype.negate=function(){return new oe(this.curve,this.x,this.y.negate(),this.z)},oe.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(e.z)).mod(this.curve.q),r=e.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(e.z)).mod(this.curve.q);if(S.ZERO.equals(r))return S.ZERO.equals(t)?this.twice():this.curve.getInfinity();var n=new S("3"),i=this.x.toBigInteger(),o=this.y.toBigInteger(),s=(e.x.toBigInteger(),e.y.toBigInteger(),r.square()),a=s.multiply(r),c=i.multiply(s),u=t.square().multiply(this.z),l=u.subtract(c.shiftLeft(1)).multiply(e.z).subtract(a).multiply(r).mod(this.curve.q),h=c.multiply(n).multiply(t).subtract(o.multiply(a)).subtract(u.multiply(t)).multiply(e.z).add(t.multiply(a)).mod(this.curve.q),d=a.multiply(this.z).multiply(e.z).mod(this.curve.q);return new oe(this.curve,this.curve.fromBigInteger(l),this.curve.fromBigInteger(h),d)},oe.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var e=new S("3"),t=this.x.toBigInteger(),r=this.y.toBigInteger(),n=r.multiply(this.z),i=n.multiply(r).mod(this.curve.q),o=this.curve.a.toBigInteger(),s=t.square().multiply(e);S.ZERO.equals(o)||(s=s.add(this.z.square().multiply(o)));var a=(s=s.mod(this.curve.q)).square().subtract(t.shiftLeft(3).multiply(i)).shiftLeft(1).multiply(n).mod(this.curve.q),c=s.multiply(e).multiply(t).subtract(i.shiftLeft(1)).shiftLeft(2).multiply(i).subtract(s.square().multiply(s)).mod(this.curve.q),u=n.square().multiply(n).shiftLeft(3).mod(this.curve.q);return new oe(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(c),u)},oe.prototype.multiply=function(e){if(this.isInfinity())return this;if(0==e.signum())return this.curve.getInfinity();var t,r=e,n=r.multiply(new S("3")),i=this.negate(),o=this,s=this.curve.q.subtract(e),a=s.multiply(new S("3")),c=new oe(this.curve,this.x,this.y),u=c.negate();for(t=n.bitLength()-2;t>0;--t){o=o.twice();var l=n.testBit(t);l!=r.testBit(t)&&(o=o.add(l?this:i))}for(t=a.bitLength()-2;t>0;--t){c=c.twice();var h=a.testBit(t);h!=s.testBit(t)&&(c=c.add(h?c:u))}return o},oe.prototype.multiplyTwo=function(e,t,r){var n;n=e.bitLength()>r.bitLength()?e.bitLength()-1:r.bitLength()-1;for(var i=this.curve.getInfinity(),o=this.add(t);n>=0;)i=i.twice(),e.testBit(n)?i=r.testBit(n)?i.add(o):i.add(this):r.testBit(n)&&(i=i.add(t)),--n;return i},se.prototype.getQ=function(){return this.q},se.prototype.getA=function(){return this.a},se.prototype.getB=function(){return this.b},se.prototype.equals=function(e){return e==this||this.q.equals(e.q)&&this.a.equals(e.a)&&this.b.equals(e.b)},se.prototype.getInfinity=function(){return this.infinity},se.prototype.fromBigInteger=function(e){return new ie(this.q,e)},se.prototype.decodePointHex=function(e){switch(parseInt(e.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:default:return null;case 4:case 6:case 7:var t=(e.length-2)/2,r=e.substr(2,t),n=e.substr(t+2,t);return new oe(this,this.fromBigInteger(new S(r,16)),this.fromBigInteger(new S(n,16)))}},
|
|
19
|
-
/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib
|
|
20
|
-
*/
|
|
21
|
-
ie.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},oe.prototype.getEncoded=function(e){var t=function(e,t){var r=e.toByteArrayUnsigned();if(t<r.length)r=r.slice(r.length-t);else for(;t>r.length;)r.unshift(0);return r},r=this.getX().toBigInteger(),n=this.getY().toBigInteger(),i=t(r,32);return e?n.isEven()?i.unshift(2):i.unshift(3):(i.unshift(4),i=i.concat(t(n,32))),i},oe.decodeFrom=function(e,t){t[0];var r=t.length-1,n=t.slice(1,1+r/2),i=t.slice(1+r/2,1+r);n.unshift(0),i.unshift(0);var o=new S(n),s=new S(i);return new oe(e,e.fromBigInteger(o),e.fromBigInteger(s))},oe.decodeFromHex=function(e,t){t.substr(0,2);var r=t.length-2,n=t.substr(2,r/2),i=t.substr(2+r/2,r/2),o=new S(n,16),s=new S(i,16);return new oe(e,e.fromBigInteger(o),e.fromBigInteger(s))},oe.prototype.add2D=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;if(this.x.equals(e.x))return this.y.equals(e.y)?this.twice():this.curve.getInfinity();var t=e.x.subtract(this.x),r=e.y.subtract(this.y).divide(t),n=r.square().subtract(this.x).subtract(e.x),i=r.multiply(this.x.subtract(n)).subtract(this.y);return new oe(this.curve,n,i)},oe.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var e=this.curve.fromBigInteger(S.valueOf(2)),t=this.curve.fromBigInteger(S.valueOf(3)),r=this.x.square().multiply(t).add(this.curve.a).divide(this.y.multiply(e)),n=r.square().subtract(this.x.multiply(e)),i=r.multiply(this.x.subtract(n)).subtract(this.y);return new oe(this.curve,n,i)},oe.prototype.multiply2D=function(e){if(this.isInfinity())return this;if(0==e.signum())return this.curve.getInfinity();var t,r=e,n=r.multiply(new S("3")),i=this.negate(),o=this;for(t=n.bitLength()-2;t>0;--t){o=o.twice();var s=n.testBit(t);s!=r.testBit(t)&&(o=o.add2D(s?this:i))}return o},oe.prototype.isOnCurve=function(){var e=this.getX().toBigInteger(),t=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),i=this.curve.getQ(),o=t.multiply(t).mod(i),s=e.multiply(e).multiply(e).add(r.multiply(e)).add(n).mod(i);return o.equals(s)},oe.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},oe.prototype.validate=function(){var e=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var t=this.getX().toBigInteger(),r=this.getY().toBigInteger();if(t.compareTo(S.ONE)<0||t.compareTo(e.subtract(S.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(S.ONE)<0||r.compareTo(e.subtract(S.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(e).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};
|
|
22
|
-
/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval
|
|
23
|
-
*/
|
|
24
|
-
var ae=function(){var e=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),t=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),r={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(e,t,n){return t?r[t]:String.fromCharCode(parseInt(n,16))}var i=new String(""),o=Object.hasOwnProperty;return function(r,s){var a,c,u=r.match(e),l=u[0],h=!1;"{"===l?a={}:"["===l?a=[]:(a=[],h=!0);for(var d=[a],p=1-h,g=u.length;p<g;++p){var y;switch((l=u[p]).charCodeAt(0)){default:(y=d[0])[c||y.length]=+l,c=void 0;break;case 34:if(-1!==(l=l.substring(1,l.length-1)).indexOf("\\")&&(l=l.replace(t,n)),y=d[0],!c){if(!(y instanceof Array)){c=l||i;break}c=y.length}y[c]=l,c=void 0;break;case 91:y=d[0],d.unshift(y[c||y.length]=[]),c=void 0;break;case 93:case 125:d.shift();break;case 102:(y=d[0])[c||y.length]=!1,c=void 0;break;case 110:(y=d[0])[c||y.length]=null,c=void 0;break;case 116:(y=d[0])[c||y.length]=!0,c=void 0;break;case 123:y=d[0],d.unshift(y[c||y.length]={}),c=void 0}}if(h){if(1!==d.length)throw new Error;a=a[0]}else if(d.length)throw new Error;return s&&(a=function e(t,r){var n=t[r];if(n&&"object"===(void 0===n?"undefined":f(n))){var i=null;for(var a in n)if(o.call(n,a)&&n!==t){var c=e(n,a);void 0!==c?n[a]=c:(i||(i=[]),i.push(a))}if(i)for(var u=i.length;--u>=0;)delete n[i[u]]}return s.call(t,r,n)}({"":a},"")),a}}();void 0!==ce&&ce||(t.KJUR=ce={}),void 0!==ce.asn1&&ce.asn1||(ce.asn1={}),ce.asn1.ASN1Util=new function(){this.integerToByteHex=function(e){var t=e.toString(16);return t.length%2==1&&(t="0"+t),t},this.bigIntToMinTwosComplementsHex=function(e){var t=e.toString(16);if("-"!=t.substr(0,1))t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t);else{var r=t.substr(1).length;r%2==1?r+=1:t.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i<r;i++)n+="f";t=new S(n,16).xor(e).add(S.ONE).toString(16).replace(/^-/,"")}return t},this.getPEMStringFromHex=function(e,t){return Fe(e,t)},this.newObject=function(e){var t=ce.asn1,r=t.ASN1Object,n=t.DERBoolean,i=t.DERInteger,o=t.DERBitString,s=t.DEROctetString,a=t.DERNull,c=t.DERObjectIdentifier,u=t.DEREnumerated,l=t.DERUTF8String,h=t.DERNumericString,d=t.DERPrintableString,f=t.DERTeletexString,p=t.DERIA5String,g=t.DERUTCTime,y=t.DERGeneralizedTime,m=t.DERVisibleString,v=t.DERBMPString,w=t.DERSequence,b=t.DERSet,_=t.DERTaggedObject,S=t.ASN1Util.newObject;if(e instanceof t.ASN1Object)return e;var E=Object.keys(e);if(1!=E.length)throw new Error("key of param shall be only one.");var A=E[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+A+":"))throw new Error("undefined key: "+A);if("bool"==A)return new n(e[A]);if("int"==A)return new i(e[A]);if("bitstr"==A)return new o(e[A]);if("octstr"==A)return new s(e[A]);if("null"==A)return new a(e[A]);if("oid"==A)return new c(e[A]);if("enum"==A)return new u(e[A]);if("utf8str"==A)return new l(e[A]);if("numstr"==A)return new h(e[A]);if("prnstr"==A)return new d(e[A]);if("telstr"==A)return new f(e[A]);if("ia5str"==A)return new p(e[A]);if("utctime"==A)return new g(e[A]);if("gentime"==A)return new y(e[A]);if("visstr"==A)return new m(e[A]);if("bmpstr"==A)return new v(e[A]);if("asn1"==A)return new r(e[A]);if("seq"==A){for(var x=e[A],T=[],F=0;F<x.length;F++){var k=S(x[F]);T.push(k)}return new w({array:T})}if("set"==A){for(x=e[A],T=[],F=0;F<x.length;F++)k=S(x[F]),T.push(k);return new b({array:T})}if("tag"==A){var I=e[A];if("[object Array]"===Object.prototype.toString.call(I)&&3==I.length){var C=S(I[2]);return new _({tag:I[0],explicit:I[1],obj:C})}return new _(I)}},this.jsonToASN1HEX=function(e){return this.newObject(e).getEncodedHex()}},ce.asn1.ASN1Util.oidHexToInt=function(e){for(var t="",r=parseInt(e.substr(0,2),16),n=(t=Math.floor(r/40)+"."+r%40,""),i=2;i<e.length;i+=2){var o=("00000000"+parseInt(e.substr(i,2),16).toString(2)).slice(-8);n+=o.substr(1,7),"0"==o.substr(0,1)&&(t=t+"."+new S(n,2).toString(10),n="")}return t},ce.asn1.ASN1Util.oidIntToHex=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},r=function(e){var r="",n=new S(e,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var o="",s=0;s<i;s++)o+="0";for(n=o+n,s=0;s<n.length-1;s+=7){var a=n.substr(s,7);s!=n.length-7&&(a="1"+a),r+=t(parseInt(a,2))}return r};if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var n="",i=e.split("."),o=40*parseInt(i[0])+parseInt(i[1]);n+=t(o),i.splice(0,2);for(var s=0;s<i.length;s++)n+=r(i[s]);return n},ce.asn1.ASN1Object=function(e){this.params=null,this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n=0,v="+this.hV);var e=this.hV.length/2,t=e.toString(16);if(t.length%2==1&&(t="0"+t),e<128)return t;var r=t.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);return(128+r).toString(16)+t},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(e){this.params=e},null!=e&&null!=e.tlv&&(this.hTLV=e.tlv,this.isModified=!1)},ce.asn1.DERAbstractString=function(e){ce.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=be(this.s).toLowerCase()},this.setStringHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e?this.setString(e):void 0!==e.str?this.setString(e.str):void 0!==e.hex&&this.setStringHex(e.hex))},Be(ce.asn1.DERAbstractString,ce.asn1.ASN1Object),ce.asn1.DERAbstractTime=function(e){ce.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(e){var t=e.getTime()+6e4*e.getTimezoneOffset();return new Date(t)},this.formatDate=function(e,t,r){var n=this.zeroPadding,i=this.localDateToUTC(e),o=String(i.getFullYear());"utc"==t&&(o=o.substr(2,2));var s=o+n(String(i.getMonth()+1),2)+n(String(i.getDate()),2)+n(String(i.getHours()),2)+n(String(i.getMinutes()),2)+n(String(i.getSeconds()),2);if(!0===r){var a=i.getMilliseconds();if(0!=a){var c=n(String(a),3);s=s+"."+(c=c.replace(/[0]+$/,""))}}return s+"Z"},this.zeroPadding=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=ge(e)},this.setByDateValue=function(e,t,r,n,i,o){var s=new Date(Date.UTC(e,t-1,r,n,i,o,0));this.setByDate(s)},this.getFreshValueHex=function(){return this.hV}},Be(ce.asn1.DERAbstractTime,ce.asn1.ASN1Object),ce.asn1.DERAbstractStructured=function(e){ce.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array=e},this.appendASN1Object=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array.push(e)},this.asn1Array=new Array,void 0!==e&&void 0!==e.array&&(this.asn1Array=e.array)},Be(ce.asn1.DERAbstractStructured,ce.asn1.ASN1Object),ce.asn1.DERBoolean=function(e){ce.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==e?"010100":"0101ff"},Be(ce.asn1.DERBoolean,ce.asn1.ASN1Object),ce.asn1.DERInteger=function(e){ce.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=ce.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new S(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.bigint?this.setByBigInteger(e.bigint):void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},Be(ce.asn1.DERInteger,ce.asn1.ASN1Object),ce.asn1.DERBitString=function(e){if(void 0!==e&&void 0!==e.obj){var t=ce.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.getEncodedHex()}ce.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(e){this.hTLV=null,this.isModified=!0,this.hV=e},this.setUnusedBitsAndHexValue=function(e,t){if(e<0||7<e)throw"unused bits shall be from 0 to 7: u = "+e;var r="0"+e;this.hTLV=null,this.isModified=!0,this.hV=r+t},this.setByBinaryString=function(e){var t=8-(e=e.replace(/0+$/,"")).length%8;8==t&&(t=0);for(var r=0;r<=t;r++)e+="0";var n="";for(r=0;r<e.length-1;r+=8){var i=e.substr(r,8),o=parseInt(i,2).toString(16);1==o.length&&(o="0"+o),n+=o}this.hTLV=null,this.isModified=!0,this.hV="0"+t+n},this.setByBooleanArray=function(e){for(var t="",r=0;r<e.length;r++)1==e[r]?t+="1":t+="0";this.setByBinaryString(t)},this.newFalseArray=function(e){for(var t=new Array(e),r=0;r<e;r++)t[r]=!1;return t},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e&&e.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(e):void 0!==e.hex?this.setHexValueIncludingUnusedBits(e.hex):void 0!==e.bin?this.setByBinaryString(e.bin):void 0!==e.array&&this.setByBooleanArray(e.array))},Be(ce.asn1.DERBitString,ce.asn1.ASN1Object),ce.asn1.DEROctetString=function(e){if(void 0!==e&&void 0!==e.obj){var t=ce.asn1.ASN1Util.newObject(e.obj);e.hex=t.getEncodedHex()}ce.asn1.DEROctetString.superclass.constructor.call(this,e),this.hT="04"},Be(ce.asn1.DEROctetString,ce.asn1.DERAbstractString),ce.asn1.DERNull=function(){ce.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Be(ce.asn1.DERNull,ce.asn1.ASN1Object),ce.asn1.DERObjectIdentifier=function(e){ce.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueOidString=function(e){var t=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},r=function(e){var r="",n=parseInt(e,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var o="",s=0;s<i;s++)o+="0";for(n=o+n,s=0;s<n.length-1;s+=7){var a=n.substr(s,7);s!=n.length-7&&(a="1"+a),r+=t(parseInt(a,2))}return r};try{if(!e.match(/^[0-9.]+$/))return null;var n="",i=e.split("."),o=40*parseInt(i[0],10)+parseInt(i[1],10);n+=t(o),i.splice(0,2);for(var s=0;s<i.length;s++)n+=r(i[s]);return n}catch(e){return null}}(e);if(null==t)throw new Error("malformed oid string: "+e);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueName=function(e){var t=ce.asn1.x509.OID.name2oid(e);if(""===t)throw new Error("DERObjectIdentifier oidName undefined: "+e);this.setValueOidString(t)},this.setValueNameOrOid=function(e){e.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(e):this.setValueName(e)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(e){"string"==typeof e?this.setValueNameOrOid(e):void 0!==e.oid?this.setValueNameOrOid(e.oid):void 0!==e.name?this.setValueNameOrOid(e.name):void 0!==e.hex&&this.setValueHex(e.hex)},void 0!==e&&this.setByParam(e)},Be(ce.asn1.DERObjectIdentifier,ce.asn1.ASN1Object),ce.asn1.DEREnumerated=function(e){ce.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=ce.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new S(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},Be(ce.asn1.DEREnumerated,ce.asn1.ASN1Object),ce.asn1.DERUTF8String=function(e){ce.asn1.DERUTF8String.superclass.constructor.call(this,e),this.hT="0c"},Be(ce.asn1.DERUTF8String,ce.asn1.DERAbstractString),ce.asn1.DERNumericString=function(e){ce.asn1.DERNumericString.superclass.constructor.call(this,e),this.hT="12"},Be(ce.asn1.DERNumericString,ce.asn1.DERAbstractString),ce.asn1.DERPrintableString=function(e){ce.asn1.DERPrintableString.superclass.constructor.call(this,e),this.hT="13"},Be(ce.asn1.DERPrintableString,ce.asn1.DERAbstractString),ce.asn1.DERTeletexString=function(e){ce.asn1.DERTeletexString.superclass.constructor.call(this,e),this.hT="14"},Be(ce.asn1.DERTeletexString,ce.asn1.DERAbstractString),ce.asn1.DERIA5String=function(e){ce.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="16"},Be(ce.asn1.DERIA5String,ce.asn1.DERAbstractString),ce.asn1.DERVisibleString=function(e){ce.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="1a"},Be(ce.asn1.DERVisibleString,ce.asn1.DERAbstractString),ce.asn1.DERBMPString=function(e){ce.asn1.DERBMPString.superclass.constructor.call(this,e),this.hT="1e"},Be(ce.asn1.DERBMPString,ce.asn1.DERAbstractString),ce.asn1.DERUTCTime=function(e){ce.asn1.DERUTCTime.superclass.constructor.call(this,e),this.hT="17",this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"utc"),this.hV=ge(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=ge(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{12}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date))},Be(ce.asn1.DERUTCTime,ce.asn1.DERAbstractTime),ce.asn1.DERGeneralizedTime=function(e){ce.asn1.DERGeneralizedTime.superclass.constructor.call(this,e),this.hT="18",this.withMillis=!1,this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=ge(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=ge(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{14}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date),!0===e.millis&&(this.withMillis=!0))},Be(ce.asn1.DERGeneralizedTime,ce.asn1.DERAbstractTime),ce.asn1.DERSequence=function(e){ce.asn1.DERSequence.superclass.constructor.call(this,e),this.hT="30",this.getFreshValueHex=function(){for(var e="",t=0;t<this.asn1Array.length;t++)e+=this.asn1Array[t].getEncodedHex();return this.hV=e,this.hV}},Be(ce.asn1.DERSequence,ce.asn1.DERAbstractStructured),ce.asn1.DERSet=function(e){ce.asn1.DERSet.superclass.constructor.call(this,e),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var e=new Array,t=0;t<this.asn1Array.length;t++){var r=this.asn1Array[t];e.push(r.getEncodedHex())}return 1==this.sortFlag&&e.sort(),this.hV=e.join(""),this.hV},void 0!==e&&void 0!==e.sortflag&&0==e.sortflag&&(this.sortFlag=!1)},Be(ce.asn1.DERSet,ce.asn1.DERAbstractStructured),ce.asn1.DERTaggedObject=function(e){ce.asn1.DERTaggedObject.superclass.constructor.call(this);var t=ce.asn1;this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(e,t,r){this.hT=t,this.isExplicit=e,this.asn1Object=r,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=r.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,t),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(e){null!=e.tag&&(this.hT=e.tag),null!=e.explicit&&(this.isExplicit=e.explicit),null!=e.tage&&(this.hT=e.tage,this.isExplicit=!0),null!=e.tagi&&(this.hT=e.tagi,this.isExplicit=!1),null!=e.obj&&(e.obj instanceof t.ASN1Object?(this.asn1Object=e.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)):"object"==f(e.obj)&&(this.asn1Object=t.ASN1Util.newObject(e.obj),this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},null!=e&&this.setByParam(e)},Be(ce.asn1.DERTaggedObject,ce.asn1.ASN1Object);var ce,ue,le,he=new function(){};function de(e){for(var t=new Array,r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function fe(e){for(var t="",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}function pe(e){for(var t="",r=0;r<e.length;r++){var n=e[r].toString(16);1==n.length&&(n="0"+n),t+=n}return t}function ge(e){return pe(de(e))}function ye(e){return(e=(e=e.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}function me(e){return e.length%4==2?e+="==":e.length%4==3&&(e+="="),(e=e.replace(/-/g,"+")).replace(/_/g,"/")}function ve(e){return e.length%2==1&&(e="0"+e),ye(w(e))}function we(e){return b(me(e))}function be(e){return Ne(Le(e))}function _e(e){return decodeURIComponent(Re(e))}function Se(e){for(var t="",r=0;r<e.length-1;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t}function Ee(e){for(var t="",r=0;r<e.length;r++)t+=("0"+e.charCodeAt(r).toString(16)).slice(-2);return t}function Ae(e){return w(e)}function xe(e){var t=Ae(e).replace(/(.{64})/g,"$1\r\n");return t.replace(/\r\n$/,"")}function Te(e){return b(e.replace(/[^0-9A-Za-z\/+=]*/g,""))}function Fe(e,t){return"-----BEGIN "+t+"-----\r\n"+xe(e)+"\r\n-----END "+t+"-----\r\n"}function ke(e,t){if(-1==e.indexOf("-----BEGIN "))throw"can't find PEM header: "+t;return Te(e=void 0!==t?(e=e.replace(new RegExp("^[^]*-----BEGIN "+t+"-----"),"")).replace(new RegExp("-----END "+t+"-----[^]*$"),""):(e=e.replace(/^[^]*-----BEGIN [^-]+-----/,"")).replace(/-----END [^-]+-----[^]*$/,""))}function Ie(e){var t,r,n,i,o,s,a,c,u,l,h;if(h=e.match(/^(\d{2}|\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/))return c=h[1],t=parseInt(c),2===c.length&&(50<=t&&t<100?t=1900+t:0<=t&&t<50&&(t=2e3+t)),r=parseInt(h[2])-1,n=parseInt(h[3]),i=parseInt(h[4]),o=parseInt(h[5]),s=parseInt(h[6]),a=0,""!==(u=h[7])&&(l=(u.substr(1)+"00").substr(0,3),a=parseInt(l)),Date.UTC(t,r,n,i,o,s,a);throw"unsupported zulu format: "+e}function Ce(e){return~~(Ie(e)/1e3)}function Ne(e){return e.replace(/%/g,"")}function Re(e){return e.replace(/(..)/g,"%$1")}function Pe(e){var t="malformed IPv6 address";if(!e.match(/^[0-9A-Fa-f:]+$/))throw t;var r=(e=e.toLowerCase()).split(":").length-1;if(r<2)throw t;var n=":".repeat(7-r+2),i=(e=e.replace("::",n)).split(":");if(8!=i.length)throw t;for(var o=0;o<8;o++)i[o]=("0000"+i[o]).slice(-4);return i.join("")}function Oe(e){if(!e.match(/^[0-9A-Fa-f]{32}$/))throw"malformed IPv6 address octet";for(var t=(e=e.toLowerCase()).match(/.{1,4}/g),r=0;r<8;r++)t[r]=t[r].replace(/^0+/,""),""==t[r]&&(t[r]="0");var n=(e=":"+t.join(":")+":").match(/:(0:){2,}/g);if(null===n)return e.slice(1,-1);var i="";for(r=0;r<n.length;r++)n[r].length>i.length&&(i=n[r]);return(e=e.replace(i,"::")).slice(1,-1)}function De(e){var t="malformed hex value";if(!e.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw t;if(8!=e.length)return 32==e.length?Oe(e):e;try{return parseInt(e.substr(0,2),16)+"."+parseInt(e.substr(2,2),16)+"."+parseInt(e.substr(4,2),16)+"."+parseInt(e.substr(6,2),16)}catch(e){throw t}}function Ue(e){return e.match(/.{4}/g).map(function(e){var t=parseInt(e.substr(0,2),16),r=parseInt(e.substr(2),16);if(0==t&r<128)return String.fromCharCode(r);if(t<8){var n=128|63&r;return _e((192|(7&t)<<3|(192&r)>>6).toString(16)+n.toString(16))}n=128|(15&t)<<2|(192&r)>>6;var i=128|63&r;return _e((224|(240&t)>>4).toString(16)+n.toString(16)+i.toString(16))}).join("")}function Le(e){for(var t=encodeURIComponent(e),r="",n=0;n<t.length;n++)"%"==t[n]?(r+=t.substr(n,3),n+=2):r=r+"%"+ge(t[n]);return r}function je(e){return!(e.length%2!=0||!e.match(/^[0-9a-f]+$/)&&!e.match(/^[0-9A-F]+$/))}function Me(e){return e.length%2==1?"0"+e:e.substr(0,1)>"7"?"00"+e:e}he.getLblen=function(e,t){if("8"!=e.substr(t+2,1))return 1;var r=parseInt(e.substr(t+3,1));return 0==r?-1:0<r&&r<10?r+1:-2},he.getL=function(e,t){var r=he.getLblen(e,t);return r<1?"":e.substr(t+2,2*r)},he.getVblen=function(e,t){var r;return""==(r=he.getL(e,t))?-1:("8"===r.substr(0,1)?new S(r.substr(2),16):new S(r,16)).intValue()},he.getVidx=function(e,t){var r=he.getLblen(e,t);return r<0?r:t+2*(r+1)},he.getV=function(e,t){var r=he.getVidx(e,t),n=he.getVblen(e,t);return e.substr(r,2*n)},he.getTLV=function(e,t){return e.substr(t,2)+he.getL(e,t)+he.getV(e,t)},he.getTLVblen=function(e,t){return 2+2*he.getLblen(e,t)+2*he.getVblen(e,t)},he.getNextSiblingIdx=function(e,t){return he.getVidx(e,t)+2*he.getVblen(e,t)},he.getChildIdx=function(e,t){var r,n,i,o=he,s=[];r=o.getVidx(e,t),n=2*o.getVblen(e,t),"03"==e.substr(t,2)&&(r+=2,n-=2),i=0;for(var a=r;i<=n;){var c=o.getTLVblen(e,a);if((i+=c)<=n&&s.push(a),a+=c,i>=n)break}return s},he.getNthChildIdx=function(e,t,r){return he.getChildIdx(e,t)[r]},he.getIdxbyList=function(e,t,r,n){var i,o,s=he;return 0==r.length?void 0!==n&&e.substr(t,2)!==n?-1:t:(i=r.shift())>=(o=s.getChildIdx(e,t)).length?-1:s.getIdxbyList(e,o[i],r,n)},he.getIdxbyListEx=function(e,t,r,n){var i,o,s=he;if(0==r.length)return void 0!==n&&e.substr(t,2)!==n?-1:t;i=r.shift(),o=s.getChildIdx(e,t);for(var a=0,c=0;c<o.length;c++){var u=e.substr(o[c],2);if("number"==typeof i&&!s.isContextTag(u)&&a==i||"string"==typeof i&&s.isContextTag(u,i))return s.getIdxbyListEx(e,o[c],r,n);s.isContextTag(u)||a++}return-1},he.getTLVbyList=function(e,t,r,n){var i=he,o=i.getIdxbyList(e,t,r,n);return-1==o||o>=e.length?null:i.getTLV(e,o)},he.getTLVbyListEx=function(e,t,r,n){var i=he,o=i.getIdxbyListEx(e,t,r,n);return-1==o?null:i.getTLV(e,o)},he.getVbyList=function(e,t,r,n,i){var o,s,a=he;return-1==(o=a.getIdxbyList(e,t,r,n))||o>=e.length?null:(s=a.getV(e,o),!0===i&&(s=s.substr(2)),s)},he.getVbyListEx=function(e,t,r,n,i){var o,s,a=he;return-1==(o=a.getIdxbyListEx(e,t,r,n))?null:(s=a.getV(e,o),"03"==e.substr(o,2)&&!1!==i&&(s=s.substr(2)),s)},he.getInt=function(e,t,r){null==r&&(r=-1);try{var n=e.substr(t,2);if("02"!=n&&"03"!=n)return r;var i=he.getV(e,t);return"02"==n?parseInt(i,16):function(e){try{var t=e.substr(0,2);if("00"==t)return parseInt(e.substr(2),16);var r=parseInt(t,16),n=e.substr(2),i=parseInt(n,16).toString(2);return"0"==i&&(i="00000000"),i=i.slice(0,0-r),parseInt(i,2)}catch(e){return-1}}(i)}catch(e){return r}},he.getOID=function(e,t,r){null==r&&(r=null);try{return"06"!=e.substr(t,2)?r:function(e){if(!je(e))return null;try{var t=[],r=e.substr(0,2),n=parseInt(r,16);t[0]=new String(Math.floor(n/40)),t[1]=new String(n%40);for(var i=e.substr(2),o=[],s=0;s<i.length/2;s++)o.push(parseInt(i.substr(2*s,2),16));var a=[],c="";for(s=0;s<o.length;s++)128&o[s]?c+=He((127&o[s]).toString(2),7):(c+=He((127&o[s]).toString(2),7),a.push(new String(parseInt(c,2))),c="");var u=t.join(".");return a.length>0&&(u=u+"."+a.join(".")),u}catch(e){return null}}(he.getV(e,t))}catch(e){return r}},he.getOIDName=function(e,t,r){null==r&&(r=null);try{var n=he.getOID(e,t,r);if(n==r)return r;var i=ce.asn1.x509.OID.oid2name(n);return""==i?n:i}catch(e){return r}},he.getString=function(e,t,r){null==r&&(r=null);try{return Se(he.getV(e,t))}catch(e){return r}},he.hextooidstr=function(e){var t=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},r=[],n=e.substr(0,2),i=parseInt(n,16);r[0]=new String(Math.floor(i/40)),r[1]=new String(i%40);for(var o=e.substr(2),s=[],a=0;a<o.length/2;a++)s.push(parseInt(o.substr(2*a,2),16));var c=[],u="";for(a=0;a<s.length;a++)128&s[a]?u+=t((127&s[a]).toString(2),7):(u+=t((127&s[a]).toString(2),7),c.push(new String(parseInt(u,2))),u="");var l=r.join(".");return c.length>0&&(l=l+"."+c.join(".")),l},he.dump=function(e,t,r,n){var i=he,o=i.getV,s=i.dump,a=i.getChildIdx,c=e;e instanceof ce.asn1.ASN1Object&&(c=e.getEncodedHex());var u=function(e,t){return e.length<=2*t?e:e.substr(0,t)+"..(total "+e.length/2+"bytes).."+e.substr(e.length-t,t)};void 0===t&&(t={ommit_long_octet:32}),void 0===r&&(r=0),void 0===n&&(n="");var l,h=t.ommit_long_octet;if("01"==(l=c.substr(r,2)))return"00"==(d=o(c,r))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==l)return n+"INTEGER "+u(d=o(c,r),h)+"\n";if("03"==l){var d=o(c,r);return i.isASN1HEX(d.substr(2))?(_=n+"BITSTRING, encapsulates\n")+s(d.substr(2),t,0,n+" "):n+"BITSTRING "+u(d,h)+"\n"}if("04"==l)return d=o(c,r),i.isASN1HEX(d)?(_=n+"OCTETSTRING, encapsulates\n")+s(d,t,0,n+" "):n+"OCTETSTRING "+u(d,h)+"\n";if("05"==l)return n+"NULL\n";if("06"==l){var f=o(c,r),p=ce.asn1.ASN1Util.oidHexToInt(f),g=ce.asn1.x509.OID.oid2name(p),y=p.replace(/\./g," ");return""!=g?n+"ObjectIdentifier "+g+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0a"==l)return n+"ENUMERATED "+parseInt(o(c,r))+"\n";if("0c"==l)return n+"UTF8String '"+_e(o(c,r))+"'\n";if("13"==l)return n+"PrintableString '"+_e(o(c,r))+"'\n";if("14"==l)return n+"TeletexString '"+_e(o(c,r))+"'\n";if("16"==l)return n+"IA5String '"+_e(o(c,r))+"'\n";if("17"==l)return n+"UTCTime "+_e(o(c,r))+"\n";if("18"==l)return n+"GeneralizedTime "+_e(o(c,r))+"\n";if("1a"==l)return n+"VisualString '"+_e(o(c,r))+"'\n";if("1e"==l)return n+"BMPString '"+Ue(o(c,r))+"'\n";if("30"==l){if("3000"==c.substr(r,4))return n+"SEQUENCE {}\n";_=n+"SEQUENCE\n";var m=t;if((2==(b=a(c,r)).length||3==b.length)&&"06"==c.substr(b[0],2)&&"04"==c.substr(b[b.length-1],2)){g=i.oidname(o(c,b[0]));var v=JSON.parse(JSON.stringify(t));v.x509ExtName=g,m=v}for(var w=0;w<b.length;w++)_+=s(c,m,b[w],n+" ");return _}if("31"==l){_=n+"SET\n";var b=a(c,r);for(w=0;w<b.length;w++)_+=s(c,t,b[w],n+" ");return _}if(128&(l=parseInt(l,16))){var _,S=31&l;if(32&l){for(_=n+"["+S+"]\n",b=a(c,r),w=0;w<b.length;w++)_+=s(c,t,b[w],n+" ");return _}return d=o(c,r),he.isASN1HEX(d)?(_=n+"["+S+"]\n")+s(d,t,0,n+" "):(("68747470"==d.substr(0,8)||"subjectAltName"===t.x509ExtName&&2==S)&&(d=_e(d)),n+"["+S+"] "+d+"\n")}return n+"UNKNOWN("+l+") "+o(c,r)+"\n"},he.isContextTag=function(e,t){var r,n;e=e.toLowerCase();try{r=parseInt(e,16)}catch(e){return-1}if(void 0===t)return 128==(192&r);try{return null!=t.match(/^\[[0-9]+\]$/)&&!((n=parseInt(t.substr(1,t.length-1),10))>31)&&128==(192&r)&&(31&r)==n}catch(e){return!1}},he.isASN1HEX=function(e){var t=he;if(e.length%2==1)return!1;var r=t.getVblen(e,0),n=e.substr(0,2),i=t.getL(e,0);return e.length-n.length-i.length==2*r},he.checkStrictDER=function(e,t,r,n,i){var o=he;if(void 0===r){if("string"!=typeof e)throw new Error("not hex string");if(e=e.toLowerCase(),!ce.lang.String.isHex(e))throw new Error("not hex string");r=e.length,i=(n=e.length/2)<128?1:Math.ceil(n.toString(16))+1}if(o.getL(e,t).length>2*i)throw new Error("L of TLV too long: idx="+t);var s=o.getVblen(e,t);if(s>n)throw new Error("value of L too long than hex: idx="+t);var a=o.getTLV(e,t),c=a.length-2-o.getL(e,t).length;if(c!==2*s)throw new Error("V string length and L's value not the same:"+c+"/"+2*s);if(0===t&&e.length!=a.length)throw new Error("total length and TLV length unmatch:"+e.length+"!="+a.length);var u=e.substr(t,2);if("02"===u){var l=o.getVidx(e,t);if("00"==e.substr(l,2)&&e.charCodeAt(l+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(u,16)){for(var h=o.getVblen(e,t),d=0,f=o.getChildIdx(e,t),p=0;p<f.length;p++)d+=o.getTLV(e,f[p]).length,o.checkStrictDER(e,f[p],r,n,i);if(2*h!=d)throw new Error("sum of children's TLV length and L unmatch: "+2*h+"!="+d)}},he.oidname=function(e){var t=ce.asn1;ce.lang.String.isHex(e)&&(e=t.ASN1Util.oidHexToInt(e));var r=t.x509.OID.oid2name(e);return""===r&&(r=e),r},void 0!==ce&&ce||(t.KJUR=ce={}),void 0!==ce.lang&&ce.lang||(ce.lang={}),ce.lang.String=function(){},"function"==typeof e?(t.utf8tob64u=ue=function(t){return ye(e.from(t,"utf8").toString("base64"))},t.b64utoutf8=le=function(t){return e.from(me(t),"base64").toString("utf8")}):(t.utf8tob64u=ue=function(e){return ve(Ne(Le(e)))},t.b64utoutf8=le=function(e){return decodeURIComponent(Re(we(e)))}),ce.lang.String.isInteger=function(e){return!!e.match(/^[0-9]+$/)||!!e.match(/^-[0-9]+$/)},ce.lang.String.isHex=function(e){return je(e)},ce.lang.String.isBase64=function(e){return!(!(e=e.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||e.length%4!=0)},ce.lang.String.isBase64URL=function(e){return!e.match(/[+/=]/)&&(e=me(e),ce.lang.String.isBase64(e))},ce.lang.String.isIntegerArray=function(e){return!!(e=e.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},ce.lang.String.isPrintable=function(e){return null!==e.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},ce.lang.String.isIA5=function(e){return null!==e.match(/^[\x20-\x21\x23-\x7f]*$/)},ce.lang.String.isMail=function(e){return null!==e.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};var He=function(e,t,r){return null==r&&(r="0"),e.length>=t?e:new Array(t-e.length+1).join(r)+e};function Be(e,t){var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e,e.superclass=t.prototype,t.prototype.constructor==Object.prototype.constructor&&(t.prototype.constructor=t)}void 0!==ce&&ce||(t.KJUR=ce={}),void 0!==ce.crypto&&ce.crypto||(ce.crypto={}),ce.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414"},this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:y.algo.MD5,sha1:y.algo.SHA1,sha224:y.algo.SHA224,sha256:y.algo.SHA256,sha384:y.algo.SHA384,sha512:y.algo.SHA512,ripemd160:y.algo.RIPEMD160},this.getDigestInfoHex=function(e,t){if(void 0===this.DIGESTINFOHEAD[t])throw"alg not supported in Util.DIGESTINFOHEAD: "+t;return this.DIGESTINFOHEAD[t]+e},this.getPaddedDigestInfoHex=function(e,t,r){var n=this.getDigestInfoHex(e,t),i=r/4;if(n.length+22>i)throw"key is too short for SigAlg: keylen="+r+","+t;for(var o="0001",s="00"+n,a="",c=i-4-s.length,u=0;u<c;u+=2)a+="ff";return o+a+s},this.hashString=function(e,t){return new ce.crypto.MessageDigest({alg:t}).digestString(e)},this.hashHex=function(e,t){return new ce.crypto.MessageDigest({alg:t}).digestHex(e)},this.sha1=function(e){return this.hashString(e,"sha1")},this.sha256=function(e){return this.hashString(e,"sha256")},this.sha256Hex=function(e){return this.hashHex(e,"sha256")},this.sha512=function(e){return this.hashString(e,"sha512")},this.sha512Hex=function(e){return this.hashHex(e,"sha512")},this.isKey=function(e){return e instanceof ne||e instanceof ce.crypto.DSA||e instanceof ce.crypto.ECDSA}},ce.crypto.Util.md5=function(e){return new ce.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(e)},ce.crypto.Util.ripemd160=function(e){return new ce.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(e)},ce.crypto.Util.SECURERANDOMGEN=new ee,ce.crypto.Util.getRandomHexOfNbytes=function(e){var t=new Array(e);return ce.crypto.Util.SECURERANDOMGEN.nextBytes(t),pe(t)},ce.crypto.Util.getRandomBigIntegerOfNbytes=function(e){return new S(ce.crypto.Util.getRandomHexOfNbytes(e),16)},ce.crypto.Util.getRandomHexOfNbits=function(e){var t=e%8,r=new Array((e-t)/8+1);return ce.crypto.Util.SECURERANDOMGEN.nextBytes(r),r[0]=(255<<t&255^255)&r[0],pe(r)},ce.crypto.Util.getRandomBigIntegerOfNbits=function(e){return new S(ce.crypto.Util.getRandomHexOfNbits(e),16)},ce.crypto.Util.getRandomBigIntegerZeroToMax=function(e){for(var t=e.bitLength();;){var r=ce.crypto.Util.getRandomBigIntegerOfNbits(t);if(-1!=e.compareTo(r))return r}},ce.crypto.Util.getRandomBigIntegerMinToMax=function(e,t){var r=e.compareTo(t);if(1==r)throw"biMin is greater than biMax";if(0==r)return e;var n=t.subtract(e);return ce.crypto.Util.getRandomBigIntegerZeroToMax(n).add(e)},ce.crypto.MessageDigest=function(e){this.setAlgAndProvider=function(e,t){if(null!==(e=ce.crypto.MessageDigest.getCanonicalAlgName(e))&&void 0===t&&(t=ce.crypto.Util.DEFAULTPROVIDER[e]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(e)&&"cryptojs"==t){try{this.md=ce.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[e].create()}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(e){this.md.update(e)},this.updateHex=function(e){var t=y.enc.Hex.parse(e);this.md.update(t)},this.digest=function(){return this.md.finalize().toString(y.enc.Hex)},this.digestString=function(e){return this.updateString(e),this.digest()},this.digestHex=function(e){return this.updateHex(e),this.digest()}}if(-1!=":sha256:".indexOf(e)&&"sjcl"==t){try{this.md=new sjcl.hash.sha256}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(e){this.md.update(e)},this.updateHex=function(e){var t=sjcl.codec.hex.toBits(e);this.md.update(t)},this.digest=function(){var e=this.md.finalize();return sjcl.codec.hex.fromBits(e)},this.digestString=function(e){return this.updateString(e),this.digest()},this.digestHex=function(e){return this.updateHex(e),this.digest()}}},this.updateString=function(e){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(e){throw"updateHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digest=function(){throw"digest() not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestString=function(e){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(e){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==e&&void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov&&(this.provName=ce.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},ce.crypto.MessageDigest.getCanonicalAlgName=function(e){return"string"==typeof e&&(e=(e=e.toLowerCase()).replace(/-/,"")),e},ce.crypto.MessageDigest.getHashLength=function(e){var t=ce.crypto.MessageDigest,r=t.getCanonicalAlgName(e);if(void 0===t.HASHLENGTH[r])throw"not supported algorithm: "+e;return t.HASHLENGTH[r]},ce.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},ce.crypto.Mac=function(e){this.setAlgAndProvider=function(e,t){if(null==(e=e.toLowerCase())&&(e="hmacsha1"),"hmac"!=(e=e.toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+e;void 0===t&&(t=ce.crypto.Util.DEFAULTPROVIDER[e]),this.algProv=e+"/"+t;var r=e.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(r)&&"cryptojs"==t){try{var n=ce.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[r];this.mac=y.algo.HMAC.create(n,this.pass)}catch(e){throw"setAlgAndProvider hash alg set fail hashAlg="+r+"/"+e}this.updateString=function(e){this.mac.update(e)},this.updateHex=function(e){var t=y.enc.Hex.parse(e);this.mac.update(t)},this.doFinal=function(){return this.mac.finalize().toString(y.enc.Hex)},this.doFinalString=function(e){return this.updateString(e),this.doFinal()},this.doFinalHex=function(e){return this.updateHex(e),this.doFinal()}}},this.updateString=function(e){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(e){throw"updateHex(hex) not supported for this alg/prov: "+this.algProv},this.doFinal=function(){throw"digest() not supported for this alg/prov: "+this.algProv},this.doFinalString=function(e){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(e){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(e){if("string"==typeof e){var t=e;return e.length%2!=1&&e.match(/^[0-9A-Fa-f]+$/)||(t=Ee(e)),void(this.pass=y.enc.Hex.parse(t))}if("object"!=(void 0===e?"undefined":f(e)))throw"KJUR.crypto.Mac unsupported password type: "+e;if(t=null,void 0!==e.hex){if(e.hex.length%2!=0||!e.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+e.hex;t=e.hex}if(void 0!==e.utf8&&(t=be(e.utf8)),void 0!==e.rstr&&(t=Ee(e.rstr)),void 0!==e.b64&&(t=b(e.b64)),void 0!==e.b64u&&(t=we(e.b64u)),null==t)throw"KJUR.crypto.Mac unsupported password type: "+e;this.pass=y.enc.Hex.parse(t)},void 0!==e&&(void 0!==e.pass&&this.setPassword(e.pass),void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov&&(this.provName=ce.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},ce.crypto.Signature=function(e){var t=null;if(this._setAlgNames=function(){var e=this.algName.match(/^(.+)with(.+)$/);e&&(this.mdAlgName=e[1].toLowerCase(),this.pubkeyAlgName=e[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(e,t){for(var r="",n=t/4-e.length,i=0;i<n;i++)r+="0";return r+e},this.setAlgAndProvider=function(e,t){if(this._setAlgNames(),"cryptojs/jsrsa"!=t)throw new Error("provider not supported: "+t);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new ce.crypto.MessageDigest({alg:this.mdAlgName})}catch(e){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+e)}this.init=function(e,t){var r=null;try{r=void 0===t?qe.getKey(e):qe.getKey(e,t)}catch(e){throw"init failed:"+e}if(!0===r.isPrivate)this.prvKey=r,this.state="SIGN";else{if(!0!==r.isPublic)throw"init failed.:"+r;this.pubKey=r,this.state="VERIFY"}},this.updateString=function(e){this.md.updateString(e)},this.updateHex=function(e){this.md.updateHex(e)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==ce.crypto.ECDSA&&(this.prvKey=new ce.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof ne&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof ne&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof ce.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof ce.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(e){return this.updateString(e),this.sign()},this.signHex=function(e){return this.updateHex(e),this.sign()},this.verify=function(e){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==ce.crypto.ECDSA&&(this.pubKey=new ce.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof ne&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,e,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof ne&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);if(void 0!==ce.crypto.ECDSA&&this.pubKey instanceof ce.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);if(void 0!==ce.crypto.DSA&&this.pubKey instanceof ce.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(e,t){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(e){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(e){throw"updateHex(hex) not supported for this alg:prov="+this.algProvName},this.sign=function(){throw"sign() not supported for this alg:prov="+this.algProvName},this.signString=function(e){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(e){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(e){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=e,void 0!==e&&(void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov?this.provName=ce.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=e.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==e.psssaltlen&&(this.pssSaltLen=e.psssaltlen),void 0!==e.prvkeypem)){if(void 0!==e.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{t=qe.getKey(e.prvkeypem),this.init(t)}catch(e){throw"fatal error to load pem private key: "+e}}},ce.crypto.Cipher=function(e){},ce.crypto.Cipher.encrypt=function(e,t,r){if(t instanceof ne&&t.isPublic){var n=ce.crypto.Cipher.getAlgByKeyAndName(t,r);if("RSA"===n)return t.encrypt(e);if("RSAOAEP"===n)return t.encryptOAEP(e,"sha1");var i=n.match(/^RSAOAEP(\d+)$/);if(null!==i)return t.encryptOAEP(e,"sha"+i[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.encrypt: unsupported key or algorithm"},ce.crypto.Cipher.decrypt=function(e,t,r){if(t instanceof ne&&t.isPrivate){var n=ce.crypto.Cipher.getAlgByKeyAndName(t,r);if("RSA"===n)return t.decrypt(e);if("RSAOAEP"===n)return t.decryptOAEP(e,"sha1");var i=n.match(/^RSAOAEP(\d+)$/);if(null!==i)return t.decryptOAEP(e,"sha"+i[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.decrypt: unsupported key or algorithm"},ce.crypto.Cipher.getAlgByKeyAndName=function(e,t){if(e instanceof ne){if(-1!=":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(t))return t;if(null==t)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+t}throw"getAlgByKeyAndName: not supported algorithm name: "+t},ce.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040023":"secp521r1","2b81040022":"secp384r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}},void 0!==ce&&ce||(t.KJUR=ce={}),void 0!==ce.crypto&&ce.crypto||(ce.crypto={}),ce.crypto.ECDSA=function(e){var t=Error,r=S,n=oe,i=ce.crypto.ECDSA,o=ce.crypto.ECParameterDB,s=i.getName,a=he,c=a.getVbyListEx,u=a.isASN1HEX,l=new ee;this.type="EC",this.isPrivate=!1,this.isPublic=!1,this.getBigRandom=function(e){return new r(e.bitLength(),l).mod(e.subtract(r.ONE)).add(r.ONE)},this.setNamedCurve=function(e){this.ecparams=o.getByName(e),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=e},this.setPrivateKeyHex=function(e){this.isPrivate=!0,this.prvKeyHex=e},this.setPublicKeyHex=function(e){this.isPublic=!0,this.pubKeyHex=e},this.getPublicKeyXYHex=function(){var e=this.pubKeyHex;if("04"!==e.substr(0,2))throw"this method supports uncompressed format(04) only";var t=this.ecparams.keylen/4;if(e.length!==2+2*t)throw"malformed public key hex length";var r={};return r.x=e.substr(2,t),r.y=e.substr(2+t),r},this.getShortNISTPCurveName=function(){var e=this.curveName;return"secp256r1"===e||"NIST P-256"===e||"P-256"===e||"prime256v1"===e?"P-256":"secp384r1"===e||"NIST P-384"===e||"P-384"===e?"P-384":null},this.generateKeyPairHex=function(){var e=this.ecparams.n,t=this.getBigRandom(e),r=this.ecparams.G.multiply(t),n=r.getX().toBigInteger(),i=r.getY().toBigInteger(),o=this.ecparams.keylen/4,s=("0000000000"+t.toString(16)).slice(-o),a="04"+("0000000000"+n.toString(16)).slice(-o)+("0000000000"+i.toString(16)).slice(-o);return this.setPrivateKeyHex(s),this.setPublicKeyHex(a),{ecprvhex:s,ecpubhex:a}},this.signWithMessageHash=function(e){return this.signHex(e,this.prvKeyHex)},this.signHex=function(e,t){var n=new r(t,16),o=this.ecparams.n,s=new r(e.substring(0,this.ecparams.keylen/4),16);do{var a=this.getBigRandom(o),c=this.ecparams.G.multiply(a).getX().toBigInteger().mod(o)}while(c.compareTo(r.ZERO)<=0);var u=a.modInverse(o).multiply(s.add(n.multiply(c))).mod(o);return i.biRSSigToASN1Sig(c,u)},this.sign=function(e,t){var n=t,i=this.ecparams.n,o=r.fromByteArrayUnsigned(e);do{var s=this.getBigRandom(i),a=this.ecparams.G.multiply(s).getX().toBigInteger().mod(i)}while(a.compareTo(S.ZERO)<=0);var c=s.modInverse(i).multiply(o.add(n.multiply(a))).mod(i);return this.serializeSig(a,c)},this.verifyWithMessageHash=function(e,t){return this.verifyHex(e,t,this.pubKeyHex)},this.verifyHex=function(e,t,o){try{var s,a,c=i.parseSigHex(t);s=c.r,a=c.s;var u=n.decodeFromHex(this.ecparams.curve,o),l=new r(e.substring(0,this.ecparams.keylen/4),16);return this.verifyRaw(l,s,a,u)}catch(e){return!1}},this.verify=function(e,t,i){var o,s,a;if(Bitcoin.Util.isArray(t)){var c=this.parseSig(t);o=c.r,s=c.s}else{if("object"!==(void 0===t?"undefined":f(t))||!t.r||!t.s)throw"Invalid value for signature";o=t.r,s=t.s}if(i instanceof oe)a=i;else{if(!Bitcoin.Util.isArray(i))throw"Invalid format for pubkey value, must be byte array or ECPointFp";a=n.decodeFrom(this.ecparams.curve,i)}var u=r.fromByteArrayUnsigned(e);return this.verifyRaw(u,o,s,a)},this.verifyRaw=function(e,t,n,i){var o=this.ecparams.n,s=this.ecparams.G;if(t.compareTo(r.ONE)<0||t.compareTo(o)>=0)return!1;if(n.compareTo(r.ONE)<0||n.compareTo(o)>=0)return!1;var a=n.modInverse(o),c=e.multiply(a).mod(o),u=t.multiply(a).mod(o);return s.multiply(c).add(i.multiply(u)).getX().toBigInteger().mod(o).equals(t)},this.serializeSig=function(e,t){var r=e.toByteArraySigned(),n=t.toByteArraySigned(),i=[];return i.push(2),i.push(r.length),(i=i.concat(r)).push(2),i.push(n.length),(i=i.concat(n)).unshift(i.length),i.unshift(48),i},this.parseSig=function(e){var t;if(48!=e[0])throw new Error("Signature not a valid DERSequence");if(2!=e[t=2])throw new Error("First element in signature must be a DERInteger");var n=e.slice(t+2,t+2+e[t+1]);if(2!=e[t+=2+e[t+1]])throw new Error("Second element in signature must be a DERInteger");var i=e.slice(t+2,t+2+e[t+1]);return t+=2+e[t+1],{r:r.fromByteArrayUnsigned(n),s:r.fromByteArrayUnsigned(i)}},this.parseSigCompact=function(e){if(65!==e.length)throw"Signature has the wrong length";var t=e[0]-27;if(t<0||t>7)throw"Invalid signature type";var n=this.ecparams.n;return{r:r.fromByteArrayUnsigned(e.slice(1,33)).mod(n),s:r.fromByteArrayUnsigned(e.slice(33,65)).mod(n),i:t}},this.readPKCS5PrvKeyHex=function(e){if(!1===u(e))throw new Error("not ASN.1 hex string");var t,r,n;try{t=c(e,0,["[0]",0],"06"),r=c(e,0,[1],"04");try{n=c(e,0,["[1]",0],"03")}catch(e){}}catch(e){throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=s(t),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(r),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(e){if(!1===u(e))throw new t("not ASN.1 hex string");var r,n,i;try{c(e,0,[1,0],"06"),r=c(e,0,[1,1],"06"),n=c(e,0,[2,0,1],"04");try{i=c(e,0,[2,0,"[1]",0],"03")}catch(e){}}catch(e){throw new t("malformed PKCS#8 plain ECC private key")}if(this.curveName=s(r),void 0===this.curveName)throw new t("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(i),this.setPrivateKeyHex(n),this.isPublic=!1},this.readPKCS8PubKeyHex=function(e){if(!1===u(e))throw new t("not ASN.1 hex string");var r,n;try{c(e,0,[0,0],"06"),r=c(e,0,[0,1],"06"),n=c(e,0,[1],"03")}catch(e){throw new t("malformed PKCS#8 ECC public key")}if(this.curveName=s(r),null===this.curveName)throw new t("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},this.readCertPubKeyHex=function(e,r){if(!1===u(e))throw new t("not ASN.1 hex string");var n,i;try{n=c(e,0,[0,5,0,1],"06"),i=c(e,0,[0,5,1],"03")}catch(e){throw new t("malformed X.509 certificate ECC public key")}if(this.curveName=s(n),null===this.curveName)throw new t("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},void 0!==e&&void 0!==e.curve&&(this.curveName=e.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==e&&(void 0!==e.prv&&this.setPrivateKeyHex(e.prv),void 0!==e.pub&&this.setPublicKeyHex(e.pub))},ce.crypto.ECDSA.parseSigHex=function(e){var t=ce.crypto.ECDSA.parseSigHexInHexRS(e);return{r:new S(t.r,16),s:new S(t.s,16)}},ce.crypto.ECDSA.parseSigHexInHexRS=function(e){var t=he,r=t.getChildIdx,n=t.getV;if(t.checkStrictDER(e,0),"30"!=e.substr(0,2))throw new Error("signature is not a ASN.1 sequence");var i=r(e,0);if(2!=i.length)throw new Error("signature shall have two elements");var o=i[0],s=i[1];if("02"!=e.substr(o,2))throw new Error("1st item not ASN.1 integer");if("02"!=e.substr(s,2))throw new Error("2nd item not ASN.1 integer");return{r:n(e,o),s:n(e,s)}},ce.crypto.ECDSA.asn1SigToConcatSig=function(e){var t=ce.crypto.ECDSA.parseSigHexInHexRS(e),r=t.r,n=t.s;if("00"==r.substr(0,2)&&r.length%32==2&&(r=r.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),r.length%32==30&&(r="00"+r),n.length%32==30&&(n="00"+n),r.length%32!=0)throw"unknown ECDSA sig r length error";if(n.length%32!=0)throw"unknown ECDSA sig s length error";return r+n},ce.crypto.ECDSA.concatSigToASN1Sig=function(e){if(e.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var t=e.substr(0,e.length/2),r=e.substr(e.length/2);return ce.crypto.ECDSA.hexRSSigToASN1Sig(t,r)},ce.crypto.ECDSA.hexRSSigToASN1Sig=function(e,t){var r=new S(e,16),n=new S(t,16);return ce.crypto.ECDSA.biRSSigToASN1Sig(r,n)},ce.crypto.ECDSA.biRSSigToASN1Sig=function(e,t){var r=ce.asn1,n=new r.DERInteger({bigint:e}),i=new r.DERInteger({bigint:t});return new r.DERSequence({array:[n,i]}).getEncodedHex()},ce.crypto.ECDSA.getName=function(e){return"2b8104001f"===e?"secp192k1":"2a8648ce3d030107"===e?"secp256r1":"2b8104000a"===e?"secp256k1":"2b81040021"===e?"secp224r1":"2b81040022"===e?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(e)?"secp256r1":-1!=="|secp256k1|".indexOf(e)?"secp256k1":-1!=="|secp224r1|NIST P-224|P-224|".indexOf(e)?"secp224r1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(e)?"secp384r1":null},void 0!==ce&&ce||(t.KJUR=ce={}),void 0!==ce.crypto&&ce.crypto||(ce.crypto={}),ce.crypto.ECParameterDB=new function(){var e={},t={};function r(e){return new S(e,16)}this.getByName=function(r){var n=r;if(void 0!==t[n]&&(n=t[r]),void 0!==e[n])return e[n];throw"unregistered EC curve name: "+n},this.regist=function(n,i,o,s,a,c,u,l,h,d,f,p){e[n]={};var g=r(o),y=r(s),m=r(a),v=r(c),w=r(u),b=new se(g,y,m),_=b.decodePointHex("04"+l+h);e[n].name=n,e[n].keylen=i,e[n].curve=b,e[n].G=_,e[n].n=v,e[n].h=w,e[n].oid=f,e[n].info=p;for(var S=0;S<d.length;S++)t[d[S]]=n}},ce.crypto.ECParameterDB.regist("secp128r1",128,"FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC","E87579C11079F43DD824993C2CEE5ED3","FFFFFFFE0000000075A30D1B9038A115","1","161FF7528B899B2D0C28607CA52C5B86","CF5AC8395BAFEB13C02DA292DDED7A83",[],"","secp128r1 : SECG curve over a 128 bit prime field"),ce.crypto.ECParameterDB.regist("secp160k1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73","0","7","0100000000000000000001B8FA16DFAB9ACA16B6B3","1","3B4C382CE37AA192A4019E763036F4F5DD4D7EBB","938CF935318FDCED6BC28286531733C3F03C4FEE",[],"","secp160k1 : SECG curve over a 160 bit prime field"),ce.crypto.ECParameterDB.regist("secp160r1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC","1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45","0100000000000000000001F4C8F927AED3CA752257","1","4A96B5688EF573284664698968C38BB913CBFC82","23A628553168947D59DCC912042351377AC5FB32",[],"","secp160r1 : SECG curve over a 160 bit prime field"),ce.crypto.ECParameterDB.regist("secp192k1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37","0","3","FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D","1","DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D","9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D",[]),ce.crypto.ECParameterDB.regist("secp192r1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC","64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1","FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831","1","188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012","07192B95FFC8DA78631011ED6B24CDD573F977A11E794811",[]),ce.crypto.ECParameterDB.regist("secp224r1",224,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE","B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4","FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D","1","B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21","BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",[]),ce.crypto.ECParameterDB.regist("secp256k1",256,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","0","7","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","1","79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8",[]),ce.crypto.ECParameterDB.regist("secp256r1",256,"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC","5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B","FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551","1","6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296","4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",["NIST P-256","P-256","prime256v1"]),ce.crypto.ECParameterDB.regist("secp384r1",384,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC","B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973","1","AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7","3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",["NIST P-384","P-384"]),ce.crypto.ECParameterDB.regist("secp521r1",521,"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC","051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409","1","C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66","011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",["NIST P-521","P-521"]);var qe=function(){var e=function(e,r,n){return t(y.AES,e,r,n)},t=function(e,t,r,n){var i=y.enc.Hex.parse(t),o=y.enc.Hex.parse(r),s=y.enc.Hex.parse(n),a={};a.key=o,a.iv=s,a.ciphertext=i;var c=e.decrypt(a,o,{iv:s});return y.enc.Hex.stringify(c)},r=function(e,t,r){return n(y.AES,e,t,r)},n=function(e,t,r,n){var i=y.enc.Hex.parse(t),o=y.enc.Hex.parse(r),s=y.enc.Hex.parse(n),a=e.encrypt(i,o,{iv:s}),c=y.enc.Hex.parse(a.toString());return y.enc.Base64.stringify(c)},i={"AES-256-CBC":{proc:e,eproc:r,keylen:32,ivlen:16},"AES-192-CBC":{proc:e,eproc:r,keylen:24,ivlen:16},"AES-128-CBC":{proc:e,eproc:r,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(e,r,n){return t(y.TripleDES,e,r,n)},eproc:function(e,t,r){return n(y.TripleDES,e,t,r)},keylen:24,ivlen:8},"DES-CBC":{proc:function(e,r,n){return t(y.DES,e,r,n)},eproc:function(e,t,r){return n(y.DES,e,t,r)},keylen:8,ivlen:8}},o=function(e){var t={},r=e.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));r&&(t.cipher=r[1],t.ivsalt=r[2]);var n=e.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(t.type=n[1]);var i=-1,o=0;-1!=e.indexOf("\r\n\r\n")&&(i=e.indexOf("\r\n\r\n"),o=2),-1!=e.indexOf("\n\n")&&(i=e.indexOf("\n\n"),o=1);var s=e.indexOf("-----END");if(-1!=i&&-1!=s){var a=e.substring(i+2*o,s-o);a=a.replace(/\s+/g,""),t.data=a}return t},s=function(e,t,r){for(var n=r.substring(0,16),o=y.enc.Hex.parse(n),s=y.enc.Utf8.parse(t),a=i[e].keylen+i[e].ivlen,c="",u=null;;){var l=y.algo.MD5.create();if(null!=u&&l.update(u),l.update(s),l.update(o),u=l.finalize(),(c+=y.enc.Hex.stringify(u)).length>=2*a)break}var h={};return h.keyhex=c.substr(0,2*i[e].keylen),h.ivhex=c.substr(2*i[e].keylen,2*i[e].ivlen),h},a=function(e,t,r,n){var o=y.enc.Base64.parse(e),s=y.enc.Hex.stringify(o);return(0,i[t].proc)(s,r,n)};return{version:"1.0.0",parsePKCS5PEM:function(e){return o(e)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(e,t,r){return s(e,t,r)},decryptKeyB64:function(e,t,r,n){return a(e,t,r,n)},getDecryptedKeyHex:function(e,t){var r=o(e),n=(r.type,r.cipher),i=r.ivsalt,c=r.data,u=s(n,t,i).keyhex;return a(c,n,u,i)},getEncryptedPKCS5PEMFromPrvKeyHex:function(e,t,r,n,o){var a="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===i[n])throw new Error("KEYUTIL unsupported algorithm: "+n);void 0!==o&&null!=o||(o=function(e){var t=y.lib.WordArray.random(e);return y.enc.Hex.stringify(t)}(i[n].ivlen).toUpperCase());var c=function(e,t,r,n){return(0,i[t].eproc)(e,r,n)}(t,n,s(n,r,o).keyhex,o);return a="-----BEGIN "+e+" PRIVATE KEY-----\r\n",a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+n+","+o+"\r\n",a+="\r\n",(a+=c.replace(/(.{64})/g,"$1\r\n"))+"\r\n-----END "+e+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(e){var t=he,r=t.getChildIdx,n=t.getV,i={},o=r(e,0);if(2!=o.length)throw new Error("malformed format: SEQUENCE(0).items != 2: "+o.length);i.ciphertext=n(e,o[1]);var s=r(e,o[0]);if(2!=s.length)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+s.length);if("2a864886f70d01050d"!=n(e,s[0]))throw new Error("this only supports pkcs5PBES2");var a=r(e,s[1]);if(2!=s.length)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+a.length);var c=r(e,a[1]);if(2!=c.length)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+c.length);if("2a864886f70d0307"!=n(e,c[0]))throw"this only supports TripleDES";i.encryptionSchemeAlg="TripleDES",i.encryptionSchemeIV=n(e,c[1]);var u=r(e,a[0]);if(2!=u.length)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length);if("2a864886f70d01050c"!=n(e,u[0]))throw new Error("this only supports pkcs5PBKDF2");var l=r(e,u[1]);if(l.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+l.length);i.pbkdf2Salt=n(e,l[0]);var h=n(e,l[1]);try{i.pbkdf2Iter=parseInt(h,16)}catch(e){throw new Error("malformed format pbkdf2Iter: "+h)}return i},getPBKDF2KeyHexFromParam:function(e,t){var r=y.enc.Hex.parse(e.pbkdf2Salt),n=e.pbkdf2Iter,i=y.PBKDF2(t,r,{keySize:6,iterations:n});return y.enc.Hex.stringify(i)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(e,t){var r=ke(e,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(r),i=qe.getPBKDF2KeyHexFromParam(n,t),o={};o.ciphertext=y.enc.Hex.parse(n.ciphertext);var s=y.enc.Hex.parse(i),a=y.enc.Hex.parse(n.encryptionSchemeIV),c=y.TripleDES.decrypt(o,s,{iv:a});return y.enc.Hex.stringify(c)},getKeyFromEncryptedPKCS8PEM:function(e,t){var r=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(e,t);return this.getKeyFromPlainPrivatePKCS8Hex(r)},parsePlainPrivatePKCS8Hex:function(e){var t=he,r=t.getChildIdx,n=t.getV,i={algparam:null};if("30"!=e.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var o=r(e,0);if(o.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=e.substr(o[1],2))throw new Error("malformed PKCS8 private key(code:003)");var s=r(e,o[1]);if(2!=s.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=e.substr(s[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(i.algoid=n(e,s[0]),"06"==e.substr(s[1],2)&&(i.algparam=n(e,s[1])),"04"!=e.substr(o[2],2))throw new Error("malformed PKCS8 private key(code:006)");return i.keyidx=t.getVidx(e,o[2]),i},getKeyFromPlainPrivatePKCS8PEM:function(e){var t=ke(e,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(t)},getKeyFromPlainPrivatePKCS8Hex:function(e){var t,r=this.parsePlainPrivatePKCS8Hex(e);if("2a864886f70d010101"==r.algoid)t=new ne;else if("2a8648ce380401"==r.algoid)t=new ce.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw new Error("unsupported private key algorithm");t=new ce.crypto.ECDSA}return t.readPKCS8PrvKeyHex(e),t},_getKeyFromPublicPKCS8Hex:function(e){var t,r=he.getVbyList(e,0,[0,0],"06");if("2a864886f70d010101"===r)t=new ne;else if("2a8648ce380401"===r)t=new ce.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw new Error("unsupported PKCS#8 public key hex");t=new ce.crypto.ECDSA}return t.readPKCS8PubKeyHex(e),t},parsePublicRawRSAKeyHex:function(e){var t=he,r=t.getChildIdx,n=t.getV,i={};if("30"!=e.substr(0,2))throw new Error("malformed RSA key(code:001)");var o=r(e,0);if(2!=o.length)throw new Error("malformed RSA key(code:002)");if("02"!=e.substr(o[0],2))throw new Error("malformed RSA key(code:003)");if(i.n=n(e,o[0]),"02"!=e.substr(o[1],2))throw new Error("malformed RSA key(code:004)");return i.e=n(e,o[1]),i},parsePublicPKCS8Hex:function(e){var t=he,r=t.getChildIdx,n=t.getV,i={algparam:null},o=r(e,0);if(2!=o.length)throw new Error("outer DERSequence shall have 2 elements: "+o.length);var s=o[0];if("30"!=e.substr(s,2))throw new Error("malformed PKCS8 public key(code:001)");var a=r(e,s);if(2!=a.length)throw new Error("malformed PKCS8 public key(code:002)");if("06"!=e.substr(a[0],2))throw new Error("malformed PKCS8 public key(code:003)");if(i.algoid=n(e,a[0]),"06"==e.substr(a[1],2)?i.algparam=n(e,a[1]):"30"==e.substr(a[1],2)&&(i.algparam={},i.algparam.p=t.getVbyList(e,a[1],[0],"02"),i.algparam.q=t.getVbyList(e,a[1],[1],"02"),i.algparam.g=t.getVbyList(e,a[1],[2],"02")),"03"!=e.substr(o[1],2))throw new Error("malformed PKCS8 public key(code:004)");return i.key=n(e,o[1]).substr(2),i}}}();function Ke(e,t){for(var r="",n=t/4-e.length,i=0;i<n;i++)r+="0";return r+e}function We(e,t,r){for(var n="",i=0;n.length<t;)n+=Se(r(Ee(e+String.fromCharCode.apply(String,[(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i])))),i+=1;return n}function Je(e){for(var t in ce.crypto.Util.DIGESTINFOHEAD){var r=ce.crypto.Util.DIGESTINFOHEAD[t],n=r.length;if(e.substring(0,n)==r)return[t,e.substring(n)]}return[]}function Ve(e){var t,r=he,n=r.getChildIdx,i=r.getV,o=r.getTLV,s=r.getVbyList,a=r.getVbyListEx,c=r.getTLVbyList,u=r.getTLVbyListEx,l=r.getIdxbyList,h=r.getIdxbyListEx,d=r.getVidx,f=r.getInt,p=r.oidname,g=r.hextooidstr,y=ke;try{t=ce.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(e){}this.HEX2STAG={"0c":"utf8",13:"prn",16:"ia5","1a":"vis","1e":"bmp"},this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){if(null===this.hex||0!==this.version)return this.version;var e=c(this.hex,0,[0,0]);if("a0"==e.substr(0,2)){var t=c(e,0,[0]),r=f(t,0);if(r<0||2<r)throw new Error("malformed version field");return this.version=r+1,this.version}return this.version=1,this.foffset=-1,1},this.getSerialNumberHex=function(){return a(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var e=u(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(e)},this.getAlgorithmIdentifierName=function(e){for(var r in t)if(e===t[r])return r;return p(a(e,0,[0],"06"))},this.getIssuer=function(){return this.getX500Name(this.getIssuerHex())},this.getIssuerHex=function(){return c(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return this.getIssuer().str},this.getSubject=function(){return this.getX500Name(this.getSubjectHex())},this.getSubjectHex=function(){return c(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return this.getSubject().str},this.getNotBefore=function(){var e=s(this.hex,0,[0,4+this.foffset,0]);return e=e.replace(/(..)/g,"%$1"),decodeURIComponent(e)},this.getNotAfter=function(){var e=s(this.hex,0,[0,4+this.foffset,1]);return e=e.replace(/(..)/g,"%$1"),decodeURIComponent(e)},this.getPublicKeyHex=function(){return r.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return l(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var e=this.getPublicKeyIdx();return l(this.hex,e,[1,0],"30")},this.getPublicKey=function(){return qe.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var e=c(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(e)},this.getSignatureValueHex=function(){return s(this.hex,0,[2],"03",!0)},this.verifySignature=function(e){var t=this.getSignatureAlgorithmField(),r=this.getSignatureValueHex(),n=c(this.hex,0,[0],"30"),i=new ce.crypto.Signature({alg:t});return i.init(e),i.updateHex(n),i.verify(r)},this.parseExt=function(e){var t,o,a;if(void 0===e){if(a=this.hex,3!==this.version)return-1;t=l(a,0,[0,7,0],"30"),o=n(a,t)}else{a=ke(e);var c=l(a,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=i(a,c))return void(this.aExtInfo=new Array);t=l(a,0,[0,3,0,1,0],"30"),o=n(a,t),this.hex=a}this.aExtInfo=new Array;for(var u=0;u<o.length;u++){var h={critical:!1},f=0;3===n(a,o[u]).length&&(h.critical=!0,f=1),h.oid=r.hextooidstr(s(a,o[u],[0],"06"));var p=l(a,o[u],[1+f]);h.vidx=d(a,p),this.aExtInfo.push(h)}},this.getExtInfo=function(e){var t=this.aExtInfo,r=e;if(e.match(/^[0-9.]+$/)||(r=ce.asn1.x509.OID.name2oid(e)),""!==r)for(var n=0;n<t.length;n++)if(t[n].oid===r)return t[n]},this.getExtBasicConstraints=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("basicConstraints");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var n={extname:"basicConstraints"};if(t&&(n.critical=!0),"3000"===e)return n;if("30030101ff"===e)return n.cA=!0,n;if("30060101ff02"===e.substr(0,12)){var s=i(e,10),a=parseInt(s,16);return n.cA=!0,n.pathLen=a,n}throw new Error("hExtV parse error: "+e)},this.getExtKeyUsage=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("keyUsage");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var n={extname:"keyUsage"};return t&&(n.critical=!0),n.names=this.getExtKeyUsageString(e).split(","),n},this.getExtKeyUsageBin=function(e){if(void 0===e){var t=this.getExtInfo("keyUsage");if(void 0===t)return"";e=o(this.hex,t.vidx)}if(8!=e.length&&10!=e.length)throw new Error("malformed key usage value: "+e);var r="000000000000000"+parseInt(e.substr(6),16).toString(2);return 8==e.length&&(r=r.slice(-8)),10==e.length&&(r=r.slice(-16)),""==(r=r.replace(/0+$/,""))&&(r="0"),r},this.getExtKeyUsageString=function(e){for(var t=this.getExtKeyUsageBin(e),r=new Array,n=0;n<t.length;n++)"1"==t.substr(n,1)&&r.push(Ve.KEYUSAGE_NAME[n]);return r.join(",")},this.getExtSubjectKeyIdentifier=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("subjectKeyIdentifier");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var n={extname:"subjectKeyIdentifier"};t&&(n.critical=!0);var s=i(e,0);return n.kid={hex:s},n},this.getExtAuthorityKeyIdentifier=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("authorityKeyIdentifier");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var s={extname:"authorityKeyIdentifier"};t&&(s.critical=!0);for(var a=n(e,0),c=0;c<a.length;c++){var u=e.substr(a[c],2);if("80"===u&&(s.kid={hex:i(e,a[c])}),"a1"===u){var l=o(e,a[c]),h=this.getGeneralNames(l);s.issuer=h[0].dn}"82"===u&&(s.sn={hex:i(e,a[c])})}return s},this.getExtExtKeyUsage=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("extKeyUsage");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var s={extname:"extKeyUsage",array:[]};t&&(s.critical=!0);for(var a=n(e,0),c=0;c<a.length;c++)s.array.push(p(i(e,a[c])));return s},this.getExtExtKeyUsageName=function(){var e=this.getExtInfo("extKeyUsage");if(void 0===e)return e;var t=new Array,r=o(this.hex,e.vidx);if(""===r)return t;for(var s=n(r,0),a=0;a<s.length;a++)t.push(p(i(r,s[a])));return t},this.getExtSubjectAltName=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("subjectAltName");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var n={extname:"subjectAltName",array:[]};return t&&(n.critical=!0),n.array=this.getGeneralNames(e),n},this.getExtIssuerAltName=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("issuerAltName");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var n={extname:"issuerAltName",array:[]};return t&&(n.critical=!0),n.array=this.getGeneralNames(e),n},this.getGeneralNames=function(e){for(var t=n(e,0),r=[],i=0;i<t.length;i++){var s=this.getGeneralName(o(e,t[i]));void 0!==s&&r.push(s)}return r},this.getGeneralName=function(e){var t=e.substr(0,2),r=i(e,0),n=Se(r);return"81"==t?{rfc822:n}:"82"==t?{dns:n}:"86"==t?{uri:n}:"87"==t?{ip:De(r)}:"a4"==t?{dn:this.getX500Name(r)}:void 0},this.getExtSubjectAltName2=function(){var e,t,r,s=this.getExtInfo("subjectAltName");if(void 0===s)return s;for(var a=new Array,c=o(this.hex,s.vidx),u=n(c,0),l=0;l<u.length;l++)r=c.substr(u[l],2),e=i(c,u[l]),"81"===r&&(t=_e(e),a.push(["MAIL",t])),"82"===r&&(t=_e(e),a.push(["DNS",t])),"84"===r&&(t=Ve.hex2dn(e,0),a.push(["DN",t])),"86"===r&&(t=_e(e),a.push(["URI",t])),"87"===r&&(t=De(e),a.push(["IP",t]));return a},this.getExtCRLDistributionPoints=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("cRLDistributionPoints");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var i={extname:"cRLDistributionPoints",array:[]};t&&(i.critical=!0);for(var s=n(e,0),a=0;a<s.length;a++){var c=o(e,s[a]);i.array.push(this.getDistributionPoint(c))}return i},this.getDistributionPoint=function(e){for(var t={},r=n(e,0),i=0;i<r.length;i++){var s=e.substr(r[i],2),a=o(e,r[i]);"a0"==s&&(t.dpname=this.getDistributionPointName(a))}return t},this.getDistributionPointName=function(e){for(var t={},r=n(e,0),i=0;i<r.length;i++){var s=e.substr(r[i],2),a=o(e,r[i]);"a0"==s&&(t.full=this.getGeneralNames(a))}return t},this.getExtCRLDistributionPointsURI=function(){var e=this.getExtInfo("cRLDistributionPoints");if(void 0===e)return e;for(var t=new Array,r=n(this.hex,e.vidx),i=0;i<r.length;i++)try{var o=_e(s(this.hex,r[i],[0,0,0],"86"));t.push(o)}catch(e){}return t},this.getExtAIAInfo=function(){var e=this.getExtInfo("authorityInfoAccess");if(void 0===e)return e;for(var t={ocsp:[],caissuer:[]},r=n(this.hex,e.vidx),i=0;i<r.length;i++){var o=s(this.hex,r[i],[0],"06"),a=s(this.hex,r[i],[1],"86");"2b06010505073001"===o&&t.ocsp.push(_e(a)),"2b06010505073002"===o&&t.caissuer.push(_e(a))}return t},this.getExtAuthorityInfoAccess=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("authorityInfoAccess");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var i={extname:"authorityInfoAccess",array:[]};t&&(i.critical=!0);for(var c=n(e,0),u=0;u<c.length;u++){var l=a(e,c[u],[0],"06"),h=_e(s(e,c[u],[1],"86"));if("2b06010505073001"==l)i.array.push({ocsp:h});else{if("2b06010505073002"!=l)throw new Error("unknown method: "+l);i.array.push({caissuer:h})}}return i},this.getExtCertificatePolicies=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("certificatePolicies");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var i={extname:"certificatePolicies",array:[]};t&&(i.critical=!0);for(var s=n(e,0),a=0;a<s.length;a++){var c=o(e,s[a]),u=this.getPolicyInformation(c);i.array.push(u)}return i},this.getPolicyInformation=function(e){var t={},r=s(e,0,[0],"06");t.policyoid=p(r);var i=h(e,0,[1],"30");if(-1!=i){t.array=[];for(var a=n(e,i),c=0;c<a.length;c++){var u=o(e,a[c]),l=this.getPolicyQualifierInfo(u);t.array.push(l)}}return t},this.getPolicyQualifierInfo=function(e){var t={},r=s(e,0,[0],"06");if("2b06010505070201"===r){var n=a(e,0,[1],"16");t.cps=Se(n)}else if("2b06010505070202"===r){var i=c(e,0,[1],"30");t.unotice=this.getUserNotice(i)}return t},this.getUserNotice=function(e){for(var t={},r=n(e,0),i=0;i<r.length;i++){var s=o(e,r[i]);"30"!=s.substr(0,2)&&(t.exptext=this.getDisplayText(s))}return t},this.getDisplayText=function(e){var t={};return t.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[e.substr(0,2)],t.str=Se(i(e,0)),t},this.getExtCRLNumber=function(e,t){var r={extname:"cRLNumber"};if(t&&(r.critical=!0),"02"==e.substr(0,2))return r.num={hex:i(e,0)},r;throw new Error("hExtV parse error: "+e)},this.getExtCRLReason=function(e,t){var r={extname:"cRLReason"};if(t&&(r.critical=!0),"0a"==e.substr(0,2))return r.code=parseInt(i(e,0),16),r;throw new Error("hExtV parse error: "+e)},this.getExtOcspNonce=function(e,t){var r={extname:"ocspNonce"};t&&(r.critical=!0);var n=i(e,0);return r.hex=n,r},this.getExtOcspNoCheck=function(e,t){var r={extname:"ocspNoCheck"};return t&&(r.critical=!0),r},this.getExtAdobeTimeStamp=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("adobeTimeStamp");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var i={extname:"adobeTimeStamp"};t&&(i.critical=!0);var s=n(e,0);if(s.length>1){var a=o(e,s[1]),c=this.getGeneralName(a);null!=c.uri&&(i.uri=c.uri)}if(s.length>2){var u=o(e,s[2]);"0101ff"==u&&(i.reqauth=!0),"010100"==u&&(i.reqauth=!1)}return i},this.getX500NameRule=function(e){for(var t=null,r=[],n=0;n<e.length;n++)for(var i=e[n],o=0;o<i.length;o++)r.push(i[o]);for(n=0;n<r.length;n++){var s=r[n],a=s.ds,c=s.value,u=s.type;if("prn"!=a&&"utf8"!=a&&"ia5"!=a)return"mixed";if("ia5"==a){if("CN"!=u)return"mixed";if(ce.lang.String.isMail(c))continue;return"mixed"}if("C"==u){if("prn"==a)continue;return"mixed"}if(null==t)t=a;else if(t!==a)return"mixed"}return null==t?"prn":t},this.getX500Name=function(e){var t=this.getX500NameArray(e);return{array:t,str:this.dnarraytostr(t)}},this.getX500NameArray=function(e){for(var t=[],r=n(e,0),i=0;i<r.length;i++)t.push(this.getRDN(o(e,r[i])));return t},this.getRDN=function(e){for(var t=[],r=n(e,0),i=0;i<r.length;i++)t.push(this.getAttrTypeAndValue(o(e,r[i])));return t},this.getAttrTypeAndValue=function(e){var t={type:null,value:null,ds:null},r=n(e,0),i=s(e,r[0],[],"06"),o=s(e,r[1],[]),a=ce.asn1.ASN1Util.oidHexToInt(i);return t.type=ce.asn1.x509.OID.oid2atype(a),t.ds=this.HEX2STAG[e.substr(r[1],2)],"bmp"!=t.ds?t.value=_e(o):t.value=Ue(o),t},this.readCertPEM=function(e){this.readCertHex(y(e))},this.readCertHex=function(e){this.hex=e,this.getVersion();try{l(this.hex,0,[0,7],"a3"),this.parseExt()}catch(e){}},this.getParam=function(){var e={};return e.version=this.getVersion(),e.serial={hex:this.getSerialNumberHex()},e.sigalg=this.getSignatureAlgorithmField(),e.issuer=this.getIssuer(),e.notbefore=this.getNotBefore(),e.notafter=this.getNotAfter(),e.subject=this.getSubject(),e.sbjpubkey=Fe(this.getPublicKeyHex(),"PUBLIC KEY"),this.aExtInfo.length>0&&(e.ext=this.getExtParamArray()),e.sighex=this.getSignatureValueHex(),e},this.getExtParamArray=function(e){null==e&&-1!=h(this.hex,0,[0,"[3]"])&&(e=u(this.hex,0,[0,"[3]",0],"30"));for(var t=[],r=n(e,0),i=0;i<r.length;i++){var s=o(e,r[i]),a=this.getExtParam(s);null!=a&&t.push(a)}return t},this.getExtParam=function(e){var t=n(e,0).length;if(2!=t&&3!=t)throw new Error("wrong number elements in Extension: "+t+" "+e);var r=g(s(e,0,[0],"06")),i=!1;3==t&&"0101ff"==c(e,0,[1])&&(i=!0);var o=c(e,0,[t-1,0]),a=void 0;if("2.5.29.14"==r?a=this.getExtSubjectKeyIdentifier(o,i):"2.5.29.15"==r?a=this.getExtKeyUsage(o,i):"2.5.29.17"==r?a=this.getExtSubjectAltName(o,i):"2.5.29.18"==r?a=this.getExtIssuerAltName(o,i):"2.5.29.19"==r?a=this.getExtBasicConstraints(o,i):"2.5.29.31"==r?a=this.getExtCRLDistributionPoints(o,i):"2.5.29.32"==r?a=this.getExtCertificatePolicies(o,i):"2.5.29.35"==r?a=this.getExtAuthorityKeyIdentifier(o,i):"2.5.29.37"==r?a=this.getExtExtKeyUsage(o,i):"1.3.6.1.5.5.7.1.1"==r?a=this.getExtAuthorityInfoAccess(o,i):"2.5.29.20"==r?a=this.getExtCRLNumber(o,i):"2.5.29.21"==r?a=this.getExtCRLReason(o,i):"1.3.6.1.5.5.7.48.1.2"==r?a=this.getExtOcspNonce(o,i):"1.3.6.1.5.5.7.48.1.5"==r?a=this.getExtOcspNoCheck(o,i):"1.2.840.113583.1.1.9.1"==r&&(a=this.getExtAdobeTimeStamp(o,i)),null!=a)return a;var u={extname:r,extn:o};return i&&(u.critical=!0),u},this.findExt=function(e,t){for(var r=0;r<e.length;r++)if(e[r].extname==t)return e[r];return null},this.updateExtCDPFullURI=function(e,t){var r=this.findExt(e,"cRLDistributionPoints");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)if(null!=n[i].dpname&&null!=n[i].dpname.full)for(var o=n[i].dpname.full,s=0;s<o.length;s++){var a=o[i];null!=a.uri&&(a.uri=t)}},this.updateExtAIAOCSP=function(e,t){var r=this.findExt(e,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)null!=n[i].ocsp&&(n[i].ocsp=t)},this.updateExtAIACAIssuer=function(e,t){var r=this.findExt(e,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)null!=n[i].caissuer&&(n[i].caissuer=t)},this.dnarraytostr=function(e){return"/"+e.map(function(e){return function(e){return e.map(function(e){return function(e){return e.type+"="+e.value}(e).replace(/\+/,"\\+")}).join("+")}(e).replace(/\//,"\\/")}).join("/")},this.getInfo=function(){var e,t,r,n=function(e){return JSON.stringify(e.array).replace(/[\[\]\{\}\"]/g,"")},i=function(e){for(var t="",r=e.array,n=0;n<r.length;n++){var i=r[n];if(t+=" policy oid: "+i.policyoid+"\n",void 0!==i.array)for(var o=0;o<i.array.length;o++){var s=i.array[o];void 0!==s.cps&&(t+=" cps: "+s.cps+"\n")}}return t},o=function(e){for(var t="",r=e.array,n=0;n<r.length;n++){var i=r[n];try{void 0!==i.dpname.full[0].uri&&(t+=" "+i.dpname.full[0].uri+"\n")}catch(e){}try{void 0!==i.dname.full[0].dn.hex&&(t+=" "+Ve.hex2dn(i.dpname.full[0].dn.hex)+"\n")}catch(e){}}return t},s=function(e){for(var t="",r=e.array,n=0;n<r.length;n++){var i=r[n];void 0!==i.caissuer&&(t+=" caissuer: "+i.caissuer+"\n"),void 0!==i.ocsp&&(t+=" ocsp: "+i.ocsp+"\n")}return t};if(e="Basic Fields\n",e+=" serial number: "+this.getSerialNumberHex()+"\n",e+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",e+=" issuer: "+this.getIssuerString()+"\n",e+=" notBefore: "+this.getNotBefore()+"\n",e+=" notAfter: "+this.getNotAfter()+"\n",e+=" subject: "+this.getSubjectString()+"\n",e+=" subject public key info: \n",e+=" key algorithm: "+(t=this.getPublicKey()).type+"\n","RSA"===t.type&&(e+=" n="+Me(t.n.toString(16)).substr(0,16)+"...\n",e+=" e="+Me(t.e.toString(16))+"\n"),null!=(r=this.aExtInfo)){e+="X509v3 Extensions:\n";for(var a=0;a<r.length;a++){var c=r[a],u=ce.asn1.x509.OID.oid2name(c.oid);""===u&&(u=c.oid);var l="";if(!0===c.critical&&(l="CRITICAL"),e+=" "+u+" "+l+":\n","basicConstraints"===u){var h=this.getExtBasicConstraints();void 0===h.cA?e+=" {}\n":(e+=" cA=true",void 0!==h.pathLen&&(e+=", pathLen="+h.pathLen),e+="\n")}else if("keyUsage"===u)e+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"===u)e+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"===u){var d=this.getExtAuthorityKeyIdentifier();void 0!==d.kid&&(e+=" kid="+d.kid.hex+"\n")}else"extKeyUsage"===u?e+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n":"subjectAltName"===u?e+=" "+n(this.getExtSubjectAltName())+"\n":"cRLDistributionPoints"===u?e+=o(this.getExtCRLDistributionPoints()):"authorityInfoAccess"===u?e+=s(this.getExtAuthorityInfoAccess()):"certificatePolicies"===u&&(e+=i(this.getExtCertificatePolicies()))}}return(e+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n")+"signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof e&&(-1!=e.indexOf("-----BEGIN")?this.readCertPEM(e):ce.lang.String.isHex(e)&&this.readCertHex(e))}qe.getKey=function(e,t,r){var n,i=(m=he).getChildIdx,o=(m.getV,m.getVbyList),s=ce.crypto,a=s.ECDSA,c=s.DSA,u=ne,l=ke,h=qe;if(void 0!==u&&e instanceof u)return e;if(void 0!==a&&e instanceof a)return e;if(void 0!==c&&e instanceof c)return e;if(void 0!==e.curve&&void 0!==e.xy&&void 0===e.d)return new a({pub:e.xy,curve:e.curve});if(void 0!==e.curve&&void 0!==e.d)return new a({prv:e.d,curve:e.curve});if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0===e.d)return(I=new u).setPublic(e.n,e.e),I;if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0!==e.p&&void 0!==e.q&&void 0!==e.dp&&void 0!==e.dq&&void 0!==e.co&&void 0===e.qi)return(I=new u).setPrivateEx(e.n,e.e,e.d,e.p,e.q,e.dp,e.dq,e.co),I;if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0===e.p)return(I=new u).setPrivate(e.n,e.e,e.d),I;if(void 0!==e.p&&void 0!==e.q&&void 0!==e.g&&void 0!==e.y&&void 0===e.x)return(I=new c).setPublic(e.p,e.q,e.g,e.y),I;if(void 0!==e.p&&void 0!==e.q&&void 0!==e.g&&void 0!==e.y&&void 0!==e.x)return(I=new c).setPrivate(e.p,e.q,e.g,e.y,e.x),I;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0===e.d)return(I=new u).setPublic(we(e.n),we(e.e)),I;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0!==e.p&&void 0!==e.q&&void 0!==e.dp&&void 0!==e.dq&&void 0!==e.qi)return(I=new u).setPrivateEx(we(e.n),we(e.e),we(e.d),we(e.p),we(e.q),we(e.dp),we(e.dq),we(e.qi)),I;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d)return(I=new u).setPrivate(we(e.n),we(e.e),we(e.d)),I;if("EC"===e.kty&&void 0!==e.crv&&void 0!==e.x&&void 0!==e.y&&void 0===e.d){var d=(k=new a({curve:e.crv})).ecparams.keylen/4,f="04"+("0000000000"+we(e.x)).slice(-d)+("0000000000"+we(e.y)).slice(-d);return k.setPublicKeyHex(f),k}if("EC"===e.kty&&void 0!==e.crv&&void 0!==e.x&&void 0!==e.y&&void 0!==e.d){d=(k=new a({curve:e.crv})).ecparams.keylen/4,f="04"+("0000000000"+we(e.x)).slice(-d)+("0000000000"+we(e.y)).slice(-d);var p=("0000000000"+we(e.d)).slice(-d);return k.setPublicKeyHex(f),k.setPrivateKeyHex(p),k}if("pkcs5prv"===r){var g,y=e,m=he;if(9===(g=i(y,0)).length)(I=new u).readPKCS5PrvKeyHex(y);else if(6===g.length)(I=new c).readPKCS5PrvKeyHex(y);else{if(!(g.length>2&&"04"===y.substr(g[1],2)))throw new Error("unsupported PKCS#1/5 hexadecimal key");(I=new a).readPKCS5PrvKeyHex(y)}return I}if("pkcs8prv"===r)return h.getKeyFromPlainPrivatePKCS8Hex(e);if("pkcs8pub"===r)return h._getKeyFromPublicPKCS8Hex(e);if("x509pub"===r)return Ve.getPublicKeyFromCertHex(e);if(-1!=e.indexOf("-END CERTIFICATE-",0)||-1!=e.indexOf("-END X509 CERTIFICATE-",0)||-1!=e.indexOf("-END TRUSTED CERTIFICATE-",0))return Ve.getPublicKeyFromCertPEM(e);if(-1!=e.indexOf("-END PUBLIC KEY-")){var v=ke(e,"PUBLIC KEY");return h._getKeyFromPublicPKCS8Hex(v)}if(-1!=e.indexOf("-END RSA PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){var w=l(e,"RSA PRIVATE KEY");return h.getKey(w,null,"pkcs5prv")}if(-1!=e.indexOf("-END DSA PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){var b=o(n=l(e,"DSA PRIVATE KEY"),0,[1],"02"),_=o(n,0,[2],"02"),E=o(n,0,[3],"02"),A=o(n,0,[4],"02"),x=o(n,0,[5],"02");return(I=new c).setPrivate(new S(b,16),new S(_,16),new S(E,16),new S(A,16),new S(x,16)),I}if(-1!=e.indexOf("-END EC PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED"))return w=l(e,"EC PRIVATE KEY"),h.getKey(w,null,"pkcs5prv");if(-1!=e.indexOf("-END PRIVATE KEY-"))return h.getKeyFromPlainPrivatePKCS8PEM(e);if(-1!=e.indexOf("-END RSA PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var T=h.getDecryptedKeyHex(e,t),F=new ne;return F.readPKCS5PrvKeyHex(T),F}if(-1!=e.indexOf("-END EC PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var k,I=o(n=h.getDecryptedKeyHex(e,t),0,[1],"04"),C=o(n,0,[2,0],"06"),N=o(n,0,[3,0],"03").substr(2);if(void 0===ce.crypto.OID.oidhex2name[C])throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+C);return(k=new a({curve:ce.crypto.OID.oidhex2name[C]})).setPublicKeyHex(N),k.setPrivateKeyHex(I),k.isPublic=!1,k}if(-1!=e.indexOf("-END DSA PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED"))return b=o(n=h.getDecryptedKeyHex(e,t),0,[1],"02"),_=o(n,0,[2],"02"),E=o(n,0,[3],"02"),A=o(n,0,[4],"02"),x=o(n,0,[5],"02"),(I=new c).setPrivate(new S(b,16),new S(_,16),new S(E,16),new S(A,16),new S(x,16)),I;if(-1!=e.indexOf("-END ENCRYPTED PRIVATE KEY-"))return h.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")},qe.generateKeypair=function(e,t){if("RSA"==e){var r=t;(s=new ne).generate(r,"10001"),s.isPrivate=!0,s.isPublic=!0;var n=new ne,i=s.n.toString(16),o=s.e.toString(16);return n.setPublic(i,o),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=s,a.pubKeyObj=n,a}if("EC"==e){var s,a,c=t,u=new ce.crypto.ECDSA({curve:c}).generateKeyPairHex();return(s=new ce.crypto.ECDSA({curve:c})).setPublicKeyHex(u.ecpubhex),s.setPrivateKeyHex(u.ecprvhex),s.isPrivate=!0,s.isPublic=!1,(n=new ce.crypto.ECDSA({curve:c})).setPublicKeyHex(u.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=s,a.pubKeyObj=n,a}throw new Error("unknown algorithm: "+e)},qe.getPEM=function(e,t,r,n,i,o){var s=ce,a=s.asn1,c=a.DERObjectIdentifier,u=a.DERInteger,l=a.ASN1Util.newObject,h=a.x509.SubjectPublicKeyInfo,d=s.crypto,f=d.DSA,p=d.ECDSA,g=ne;function m(e){return l({seq:[{int:0},{int:{bigint:e.n}},{int:e.e},{int:{bigint:e.d}},{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.dmp1}},{int:{bigint:e.dmq1}},{int:{bigint:e.coeff}}]})}function v(e){return l({seq:[{int:1},{octstr:{hex:e.prvKeyHex}},{tag:["a0",!0,{oid:{name:e.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]}]})}function w(e){return l({seq:[{int:0},{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}},{int:{bigint:e.y}},{int:{bigint:e.x}}]})}if((void 0!==g&&e instanceof g||void 0!==f&&e instanceof f||void 0!==p&&e instanceof p)&&1==e.isPublic&&(void 0===t||"PKCS8PUB"==t))return Fe(E=new h(e).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==t&&void 0!==g&&e instanceof g&&(void 0===r||null==r)&&1==e.isPrivate)return Fe(E=m(e).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==t&&void 0!==p&&e instanceof p&&(void 0===r||null==r)&&1==e.isPrivate){var b=new c({name:e.curveName}).getEncodedHex(),_=v(e).getEncodedHex(),S="";return(S+=Fe(b,"EC PARAMETERS"))+Fe(_,"EC PRIVATE KEY")}if("PKCS1PRV"==t&&void 0!==f&&e instanceof f&&(void 0===r||null==r)&&1==e.isPrivate)return Fe(E=w(e).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==t&&void 0!==g&&e instanceof g&&void 0!==r&&null!=r&&1==e.isPrivate){var E=m(e).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",E,r,n,o)}if("PKCS5PRV"==t&&void 0!==p&&e instanceof p&&void 0!==r&&null!=r&&1==e.isPrivate)return E=v(e).getEncodedHex(),void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",E,r,n,o);if("PKCS5PRV"==t&&void 0!==f&&e instanceof f&&void 0!==r&&null!=r&&1==e.isPrivate)return E=w(e).getEncodedHex(),void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",E,r,n,o);var A=function(e,t){var r=x(e,t);return new l({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:r.pbkdf2Salt}},{int:r.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:r.encryptionSchemeIV}}]}]}]},{octstr:{hex:r.ciphertext}}]}).getEncodedHex()},x=function(e,t){var r=y.lib.WordArray.random(8),n=y.lib.WordArray.random(8),i=y.PBKDF2(t,r,{keySize:6,iterations:100}),o=y.enc.Hex.parse(e),s=y.TripleDES.encrypt(o,i,{iv:n})+"",a={};return a.ciphertext=s,a.pbkdf2Salt=y.enc.Hex.stringify(r),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=y.enc.Hex.stringify(n),a};if("PKCS8PRV"==t&&null!=g&&e instanceof g&&1==e.isPrivate){var T=m(e).getEncodedHex();return E=l({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:T}}]}).getEncodedHex(),void 0===r||null==r?Fe(E,"PRIVATE KEY"):Fe(_=A(E,r),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==t&&void 0!==p&&e instanceof p&&1==e.isPrivate)return T=new l({seq:[{int:1},{octstr:{hex:e.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]}]}).getEncodedHex(),E=l({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:T}}]}).getEncodedHex(),void 0===r||null==r?Fe(E,"PRIVATE KEY"):Fe(_=A(E,r),"ENCRYPTED PRIVATE KEY");if("PKCS8PRV"==t&&void 0!==f&&e instanceof f&&1==e.isPrivate)return T=new u({bigint:e.x}).getEncodedHex(),E=l({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:T}}]}).getEncodedHex(),void 0===r||null==r?Fe(E,"PRIVATE KEY"):Fe(_=A(E,r),"ENCRYPTED PRIVATE KEY");throw new Error("unsupported object nor format")},qe.getKeyFromCSRPEM=function(e){var t=ke(e,"CERTIFICATE REQUEST");return qe.getKeyFromCSRHex(t)},qe.getKeyFromCSRHex=function(e){var t=qe.parseCSRHex(e);return qe.getKey(t.p8pubkeyhex,null,"pkcs8pub")},qe.parseCSRHex=function(e){var t=he,r=t.getChildIdx,n=t.getTLV,i={},o=e;if("30"!=o.substr(0,2))throw new Error("malformed CSR(code:001)");var s=r(o,0);if(s.length<1)throw new Error("malformed CSR(code:002)");if("30"!=o.substr(s[0],2))throw new Error("malformed CSR(code:003)");var a=r(o,s[0]);if(a.length<3)throw new Error("malformed CSR(code:004)");return i.p8pubkeyhex=n(o,a[2]),i},qe.getKeyID=function(e){var t=qe,r=he;"string"==typeof e&&-1!=e.indexOf("BEGIN ")&&(e=t.getKey(e));var n=ke(t.getPEM(e)),i=r.getIdxbyList(n,0,[1]),o=r.getV(n,i).substring(2);return ce.crypto.Util.hashHex(o,"sha1")},qe.getJWKFromKey=function(e){var t={};if(e instanceof ne&&e.isPrivate)return t.kty="RSA",t.n=ve(e.n.toString(16)),t.e=ve(e.e.toString(16)),t.d=ve(e.d.toString(16)),t.p=ve(e.p.toString(16)),t.q=ve(e.q.toString(16)),t.dp=ve(e.dmp1.toString(16)),t.dq=ve(e.dmq1.toString(16)),t.qi=ve(e.coeff.toString(16)),t;if(e instanceof ne&&e.isPublic)return t.kty="RSA",t.n=ve(e.n.toString(16)),t.e=ve(e.e.toString(16)),t;if(e instanceof ce.crypto.ECDSA&&e.isPrivate){if("P-256"!==(n=e.getShortNISTPCurveName())&&"P-384"!==n)throw new Error("unsupported curve name for JWT: "+n);var r=e.getPublicKeyXYHex();return t.kty="EC",t.crv=n,t.x=ve(r.x),t.y=ve(r.y),t.d=ve(e.prvKeyHex),t}if(e instanceof ce.crypto.ECDSA&&e.isPublic){var n;if("P-256"!==(n=e.getShortNISTPCurveName())&&"P-384"!==n)throw new Error("unsupported curve name for JWT: "+n);return r=e.getPublicKeyXYHex(),t.kty="EC",t.crv=n,t.x=ve(r.x),t.y=ve(r.y),t}throw new Error("not supported key object")},ne.getPosArrayOfChildrenFromHex=function(e){return he.getChildIdx(e,0)},ne.getHexValueArrayOfChildrenFromHex=function(e){var t,r=he.getV,n=r(e,(t=ne.getPosArrayOfChildrenFromHex(e))[0]),i=r(e,t[1]),o=r(e,t[2]),s=r(e,t[3]),a=r(e,t[4]),c=r(e,t[5]),u=r(e,t[6]),l=r(e,t[7]),h=r(e,t[8]);return(t=new Array).push(n,i,o,s,a,c,u,l,h),t},ne.prototype.readPrivateKeyFromPEMString=function(e){var t=ke(e),r=ne.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])},ne.prototype.readPKCS5PrvKeyHex=function(e){var t=ne.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},ne.prototype.readPKCS8PrvKeyHex=function(e){var t,r,n,i,o,s,a,c,u=he,l=u.getVbyListEx;if(!1===u.isASN1HEX(e))throw new Error("not ASN.1 hex string");try{t=l(e,0,[2,0,1],"02"),r=l(e,0,[2,0,2],"02"),n=l(e,0,[2,0,3],"02"),i=l(e,0,[2,0,4],"02"),o=l(e,0,[2,0,5],"02"),s=l(e,0,[2,0,6],"02"),a=l(e,0,[2,0,7],"02"),c=l(e,0,[2,0,8],"02")}catch(e){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(t,r,n,i,o,s,a,c)},ne.prototype.readPKCS5PubKeyHex=function(e){var t=he,r=t.getV;if(!1===t.isASN1HEX(e))throw new Error("keyHex is not ASN.1 hex string");var n=t.getChildIdx(e,0);if(2!==n.length||"02"!==e.substr(n[0],2)||"02"!==e.substr(n[1],2))throw new Error("wrong hex for PKCS#5 public key");var i=r(e,n[0]),o=r(e,n[1]);this.setPublic(i,o)},ne.prototype.readPKCS8PubKeyHex=function(e){var t=he;if(!1===t.isASN1HEX(e))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==t.getTLVbyListEx(e,0,[0,0]))throw new Error("not PKCS8 RSA public key");var r=t.getTLVbyListEx(e,0,[1,0]);this.readPKCS5PubKeyHex(r)},ne.prototype.readCertPubKeyHex=function(e,t){var r,n;(r=new Ve).readCertHex(e),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)},new RegExp("[^0-9a-f]","gi"),ne.prototype.sign=function(e,t){var r=function(e){return ce.crypto.Util.hashString(e,t)}(e);return this.signWithMessageHash(r,t)},ne.prototype.signWithMessageHash=function(e,t){var r=te(ce.crypto.Util.getPaddedDigestInfoHex(e,t,this.n.bitLength()),16);return Ke(this.doPrivate(r).toString(16),this.n.bitLength())},ne.prototype.signPSS=function(e,t,r){var n=function(e){return ce.crypto.Util.hashHex(e,t)}(Ee(e));return void 0===r&&(r=-1),this.signWithMessageHashPSS(n,t,r)},ne.prototype.signWithMessageHashPSS=function(e,t,r){var n,i=Se(e),o=i.length,s=this.n.bitLength()-1,a=Math.ceil(s/8),c=function(e){return ce.crypto.Util.hashHex(e,t)};if(-1===r||void 0===r)r=o;else if(-2===r)r=a-o-2;else if(r<-2)throw new Error("invalid salt length");if(a<o+r+2)throw new Error("data too long");var u="";r>0&&(u=new Array(r),(new ee).nextBytes(u),u=String.fromCharCode.apply(String,u));var l=Se(c(Ee("\0\0\0\0\0\0\0\0"+i+u))),h=[];for(n=0;n<a-r-o-2;n+=1)h[n]=0;var d=String.fromCharCode.apply(String,h)+""+u,f=We(l,d.length,c),p=[];for(n=0;n<d.length;n+=1)p[n]=d.charCodeAt(n)^f.charCodeAt(n);var g=65280>>8*a-s&255;for(p[0]&=~g,n=0;n<o;n++)p.push(l.charCodeAt(n));return p.push(188),Ke(this.doPrivate(new S(p)).toString(16),this.n.bitLength())},ne.prototype.verify=function(e,t){if(null==(t=t.toLowerCase()).match(/^[0-9a-f]+$/))return!1;var r=te(t,16),n=this.n.bitLength();if(r.bitLength()>n)return!1;var i=this.doPublic(r).toString(16);if(i.length+3!=n/4)return!1;var o=Je(i.replace(/^1f+00/,""));if(0==o.length)return!1;var s=o[0];return o[1]==function(e){return ce.crypto.Util.hashString(e,s)}(e)},ne.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=te(t,16);if(r.bitLength()>this.n.bitLength())return 0;var n=Je(this.doPublic(r).toString(16).replace(/^1f+00/,""));return 0!=n.length&&(n[0],n[1]==e)},ne.prototype.verifyPSS=function(e,t,r,n){var i=function(e){return ce.crypto.Util.hashHex(e,r)}(Ee(e));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(i,t,r,n)},ne.prototype.verifyWithMessageHashPSS=function(e,t,r,n){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var i,o=new S(t,16),s=function(e){return ce.crypto.Util.hashHex(e,r)},a=Se(e),c=a.length,u=this.n.bitLength()-1,l=Math.ceil(u/8);if(-1===n||void 0===n)n=c;else if(-2===n)n=l-c-2;else if(n<-2)throw new Error("invalid salt length");if(l<c+n+2)throw new Error("data too long");var h=this.doPublic(o).toByteArray();for(i=0;i<h.length;i+=1)h[i]&=255;for(;h.length<l;)h.unshift(0);if(188!==h[l-1])throw new Error("encoded message does not end in 0xbc");var d=(h=String.fromCharCode.apply(String,h)).substr(0,l-c-1),f=h.substr(d.length,c),p=65280>>8*l-u&255;if(0!=(d.charCodeAt(0)&p))throw new Error("bits beyond keysize not zero");var g=We(f,d.length,s),y=[];for(i=0;i<d.length;i+=1)y[i]=d.charCodeAt(i)^g.charCodeAt(i);y[0]&=~p;var m=l-c-n-2;for(i=0;i<m;i+=1)if(0!==y[i])throw new Error("leftmost octets not zero");if(1!==y[m])throw new Error("0x01 marker not found");return f===Se(s(Ee("\0\0\0\0\0\0\0\0"+a+String.fromCharCode.apply(String,y.slice(-n)))))},ne.SALT_LEN_HLEN=-1,ne.SALT_LEN_MAX=-2,ne.SALT_LEN_RECOVER=-2,Ve.hex2dn=function(e,t){void 0===t&&(t=0);var r=new Ve;return he.getTLV(e,t),r.getX500Name(e).str},Ve.hex2rdn=function(e,t){if(void 0===t&&(t=0),"31"!==e.substr(t,2))throw new Error("malformed RDN");for(var r=new Array,n=he.getChildIdx(e,t),i=0;i<n.length;i++)r.push(Ve.hex2attrTypeValue(e,n[i]));return(r=r.map(function(e){return e.replace("+","\\+")})).join("+")},Ve.hex2attrTypeValue=function(e,t){var r=he,n=r.getV;if(void 0===t&&(t=0),"30"!==e.substr(t,2))throw new Error("malformed attribute type and value");var i=r.getChildIdx(e,t);2!==i.length||e.substr(i[0],2);var o=n(e,i[0]),s=ce.asn1.ASN1Util.oidHexToInt(o);return ce.asn1.x509.OID.oid2atype(s)+"="+Se(n(e,i[1]))},Ve.getPublicKeyFromCertHex=function(e){var t=new Ve;return t.readCertHex(e),t.getPublicKey()},Ve.getPublicKeyFromCertPEM=function(e){var t=new Ve;return t.readCertPEM(e),t.getPublicKey()},Ve.getPublicKeyInfoPropOfCertPEM=function(e){var t,r,n=he.getVbyList,i={algparam:null};return(t=new Ve).readCertPEM(e),r=t.getPublicKeyHex(),i.keyhex=n(r,0,[1],"03").substr(2),i.algoid=n(r,0,[0,0],"06"),"2a8648ce3d0201"===i.algoid&&(i.algparam=n(r,0,[0,1],"06")),i},Ve.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"],void 0!==ce&&ce||(t.KJUR=ce={}),void 0!==ce.jws&&ce.jws||(ce.jws={}),ce.jws.JWS=function(){var e=ce.jws.JWS.isSafeJSONString;this.parseJWS=function(t,r){if(void 0===this.parsedJWS||!r&&void 0===this.parsedJWS.sigvalH){var n=t.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(null==n)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var i=n[1],o=n[2],s=n[3],a=i+"."+o;if(this.parsedJWS={},this.parsedJWS.headB64U=i,this.parsedJWS.payloadB64U=o,this.parsedJWS.sigvalB64U=s,this.parsedJWS.si=a,!r){var c=we(s),u=te(c,16);this.parsedJWS.sigvalH=c,this.parsedJWS.sigvalBI=u}var l=le(i),h=le(o);if(this.parsedJWS.headS=l,this.parsedJWS.payloadS=h,!e(l,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+l}}},ce.jws.JWS.sign=function(e,t,r,n,i){var o,s,a,c=ce,u=c.jws.JWS,l=u.readSafeJSONString,h=u.isSafeJSONString,d=c.crypto,p=(d.ECDSA,d.Mac),g=d.Signature,y=JSON;if("string"!=typeof t&&"object"!=(void 0===t?"undefined":f(t)))throw"spHeader must be JSON string or object: "+t;if("object"==(void 0===t?"undefined":f(t))&&(s=t,o=y.stringify(s)),"string"==typeof t){if(!h(o=t))throw"JWS Head is not safe JSON string: "+o;s=l(o)}if(a=r,"object"==(void 0===r?"undefined":f(r))&&(a=y.stringify(r)),""!=e&&null!=e||void 0===s.alg||(e=s.alg),""!=e&&null!=e&&void 0===s.alg&&(s.alg=e,o=y.stringify(s)),e!==s.alg)throw"alg and sHeader.alg doesn't match: "+e+"!="+s.alg;var m=null;if(void 0===u.jwsalg2sigalg[e])throw"unsupported alg name: "+e;m=u.jwsalg2sigalg[e];var v=ue(o)+"."+ue(a),w="";if("Hmac"==m.substr(0,4)){if(void 0===n)throw"mac key shall be specified for HS* alg";var b=new p({alg:m,prov:"cryptojs",pass:n});b.updateString(v),w=b.doFinal()}else if(-1!=m.indexOf("withECDSA")){(S=new g({alg:m})).init(n,i),S.updateString(v);var _=S.sign();w=ce.crypto.ECDSA.asn1SigToConcatSig(_)}else{var S;"none"!=m&&((S=new g({alg:m})).init(n,i),S.updateString(v),w=S.sign())}return v+"."+ve(w)},ce.jws.JWS.verify=function(e,t,r){var n,i=ce,o=i.jws.JWS,s=o.readSafeJSONString,a=i.crypto,c=a.ECDSA,u=a.Mac,l=a.Signature;void 0!==f(ne)&&(n=ne);var h=e.split(".");if(3!==h.length)return!1;var d,p=h[0]+"."+h[1],g=we(h[2]),y=s(le(h[0])),m=null;if(void 0===y.alg)throw"algorithm not specified in header";if(d=(m=y.alg).substr(0,2),null!=r&&"[object Array]"===Object.prototype.toString.call(r)&&r.length>0&&-1==(":"+r.join(":")+":").indexOf(":"+m+":"))throw"algorithm '"+m+"' not accepted in the list";if("none"!=m&&null===t)throw"key shall be specified to verify.";if("string"==typeof t&&-1!=t.indexOf("-----BEGIN ")&&(t=qe.getKey(t)),!("RS"!=d&&"PS"!=d||t instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==d&&!(t instanceof c))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===o.jwsalg2sigalg[y.alg])throw"unsupported alg name: "+m;if("none"==(v=o.jwsalg2sigalg[m]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===t)throw"hexadecimal key shall be specified for HMAC";var w=new u({alg:v,pass:t});return w.updateString(p),g==w.doFinal()}if(-1!=v.indexOf("withECDSA")){var b,_=null;try{_=c.concatSigToASN1Sig(g)}catch(e){return!1}return(b=new l({alg:v})).init(t),b.updateString(p),b.verify(_)}return(b=new l({alg:v})).init(t),b.updateString(p),b.verify(g)},ce.jws.JWS.parse=function(e){var t,r,n,i=e.split("."),o={};if(2!=i.length&&3!=i.length)throw"malformed sJWS: wrong number of '.' splitted elements";return t=i[0],r=i[1],3==i.length&&(n=i[2]),o.headerObj=ce.jws.JWS.readSafeJSONString(le(t)),o.payloadObj=ce.jws.JWS.readSafeJSONString(le(r)),o.headerPP=JSON.stringify(o.headerObj,null," "),null==o.payloadObj?o.payloadPP=le(r):o.payloadPP=JSON.stringify(o.payloadObj,null," "),void 0!==n&&(o.sigHex=we(n)),o},ce.jws.JWS.verifyJWT=function(e,t,r){var n=ce.jws,i=n.JWS,o=i.readSafeJSONString,s=i.inArray,a=i.includedArray,c=e.split("."),u=c[0],l=c[1],h=(we(c[2]),o(le(u))),d=o(le(l));if(void 0===h.alg)return!1;if(void 0===r.alg)throw"acceptField.alg shall be specified";if(!s(h.alg,r.alg))return!1;if(void 0!==d.iss&&"object"===f(r.iss)&&!s(d.iss,r.iss))return!1;if(void 0!==d.sub&&"object"===f(r.sub)&&!s(d.sub,r.sub))return!1;if(void 0!==d.aud&&"object"===f(r.aud))if("string"==typeof d.aud){if(!s(d.aud,r.aud))return!1}else if("object"==f(d.aud)&&!a(d.aud,r.aud))return!1;var p=n.IntDate.getNow();return void 0!==r.verifyAt&&"number"==typeof r.verifyAt&&(p=r.verifyAt),void 0!==r.gracePeriod&&"number"==typeof r.gracePeriod||(r.gracePeriod=0),!(void 0!==d.exp&&"number"==typeof d.exp&&d.exp+r.gracePeriod<p||void 0!==d.nbf&&"number"==typeof d.nbf&&p<d.nbf-r.gracePeriod||void 0!==d.iat&&"number"==typeof d.iat&&p<d.iat-r.gracePeriod||void 0!==d.jti&&void 0!==r.jti&&d.jti!==r.jti||!i.verify(e,t,r.alg))},ce.jws.JWS.includedArray=function(e,t){var r=ce.jws.JWS.inArray;if(null===e)return!1;if("object"!==(void 0===e?"undefined":f(e)))return!1;if("number"!=typeof e.length)return!1;for(var n=0;n<e.length;n++)if(!r(e[n],t))return!1;return!0},ce.jws.JWS.inArray=function(e,t){if(null===t)return!1;if("object"!==(void 0===t?"undefined":f(t)))return!1;if("number"!=typeof t.length)return!1;for(var r=0;r<t.length;r++)if(t[r]==e)return!0;return!1},ce.jws.JWS.jwsalg2sigalg={HS256:"HmacSHA256",HS384:"HmacSHA384",HS512:"HmacSHA512",RS256:"SHA256withRSA",RS384:"SHA384withRSA",RS512:"SHA512withRSA",ES256:"SHA256withECDSA",ES384:"SHA384withECDSA",PS256:"SHA256withRSAandMGF1",PS384:"SHA384withRSAandMGF1",PS512:"SHA512withRSAandMGF1",none:"none"},ce.jws.JWS.isSafeJSONString=function(e,t,r){var n=null;try{return"object"!=(void 0===(n=ae(e))?"undefined":f(n))||n.constructor===Array?0:(t&&(t[r]=n),1)}catch(e){return 0}},ce.jws.JWS.readSafeJSONString=function(e){var t=null;try{return"object"!=(void 0===(t=ae(e))?"undefined":f(t))||t.constructor===Array?null:t}catch(e){return null}},ce.jws.JWS.getEncodedSignatureValueFromJWS=function(e){var t=e.match(/^[^.]+\.[^.]+\.([^.]+)$/);if(null==t)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";return t[1]},ce.jws.JWS.getJWKthumbprint=function(e){if("RSA"!==e.kty&&"EC"!==e.kty&&"oct"!==e.kty)throw"unsupported algorithm for JWK Thumprint";var t="{";if("RSA"===e.kty){if("string"!=typeof e.n||"string"!=typeof e.e)throw"wrong n and e value for RSA key";t+='"e":"'+e.e+'",',t+='"kty":"'+e.kty+'",',t+='"n":"'+e.n+'"}'}else if("EC"===e.kty){if("string"!=typeof e.crv||"string"!=typeof e.x||"string"!=typeof e.y)throw"wrong crv, x and y value for EC key";t+='"crv":"'+e.crv+'",',t+='"kty":"'+e.kty+'",',t+='"x":"'+e.x+'",',t+='"y":"'+e.y+'"}'}else if("oct"===e.kty){if("string"!=typeof e.k)throw"wrong k value for oct(symmetric) key";t+='"kty":"'+e.kty+'",',t+='"k":"'+e.k+'"}'}var r=Ee(t);return ve(ce.crypto.Util.hashHex(r,"sha256"))},ce.jws.IntDate={},ce.jws.IntDate.get=function(e){var t=ce.jws.IntDate,r=t.getNow,n=t.getZulu;if("now"==e)return r();if("now + 1hour"==e)return r()+3600;if("now + 1day"==e)return r()+86400;if("now + 1month"==e)return r()+2592e3;if("now + 1year"==e)return r()+31536e3;if(e.match(/Z$/))return n(e);if(e.match(/^[0-9]+$/))return parseInt(e);throw"unsupported format: "+e},ce.jws.IntDate.getZulu=function(e){return Ce(e)},ce.jws.IntDate.getNow=function(){return~~(new Date/1e3)},ce.jws.IntDate.intDate2UTCString=function(e){return new Date(1e3*e).toUTCString()},ce.jws.IntDate.intDate2Zulu=function(e){var t=new Date(1e3*e);return("0000"+t.getUTCFullYear()).slice(-4)+("00"+(t.getUTCMonth()+1)).slice(-2)+("00"+t.getUTCDate()).slice(-2)+("00"+t.getUTCHours()).slice(-2)+("00"+t.getUTCMinutes()).slice(-2)+("00"+t.getUTCSeconds()).slice(-2)+"Z"},t.SecureRandom=ee,t.rng_seed_time=z,t.BigInteger=S,t.RSAKey=ne;var $e=ce.crypto.EDSA;t.EDSA=$e;var ze=ce.crypto.DSA;t.DSA=ze;var Ge=ce.crypto.Signature;t.Signature=Ge;var Xe=ce.crypto.MessageDigest;t.MessageDigest=Xe;var Ye=ce.crypto.Mac;t.Mac=Ye;var Qe=ce.crypto.Cipher;t.Cipher=Qe,t.KEYUTIL=qe,t.ASN1HEX=he,t.X509=Ve,t.CryptoJS=y,t.b64tohex=b,t.b64toBA=_,t.stoBA=de,t.BAtos=fe,t.BAtohex=pe,t.stohex=ge,t.stob64=function(e){return w(ge(e))},t.stob64u=function(e){return ye(w(ge(e)))},t.b64utos=function(e){return fe(_(me(e)))},t.b64tob64u=ye,t.b64utob64=me,t.hex2b64=w,t.hextob64u=ve,t.b64utohex=we,t.utf8tob64u=ue,t.b64utoutf8=le,t.utf8tob64=function(e){return w(Ne(Le(e)))},t.b64toutf8=function(e){return decodeURIComponent(Re(b(e)))},t.utf8tohex=be,t.hextoutf8=_e,t.hextorstr=Se,t.rstrtohex=Ee,t.hextob64=Ae,t.hextob64nl=xe,t.b64nltohex=Te,t.hextopem=Fe,t.pemtohex=ke,t.hextoArrayBuffer=function(e){if(e.length%2!=0)throw"input is not even length";if(null==e.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var t=new ArrayBuffer(e.length/2),r=new DataView(t),n=0;n<e.length/2;n++)r.setUint8(n,parseInt(e.substr(2*n,2),16));return t},t.ArrayBuffertohex=function(e){for(var t="",r=new DataView(e),n=0;n<e.byteLength;n++)t+=("00"+r.getUint8(n).toString(16)).slice(-2);return t},t.zulutomsec=Ie,t.zulutosec=Ce,t.zulutodate=function(e){return new Date(Ie(e))},t.datetozulu=function(e,t,r){var n,i=e.getUTCFullYear();if(t){if(i<1950||2049<i)throw"not proper year for UTCTime: "+i;n=(""+i).slice(-2)}else n=("000"+i).slice(-4);if(n+=("0"+(e.getUTCMonth()+1)).slice(-2),n+=("0"+e.getUTCDate()).slice(-2),n+=("0"+e.getUTCHours()).slice(-2),n+=("0"+e.getUTCMinutes()).slice(-2),n+=("0"+e.getUTCSeconds()).slice(-2),r){var o=e.getUTCMilliseconds();0!==o&&(n+="."+(o=(o=("00"+o).slice(-3)).replace(/0+$/g,"")))}return n+"Z"},t.uricmptohex=Ne,t.hextouricmp=Re,t.ipv6tohex=Pe,t.hextoipv6=Oe,t.hextoip=De,t.iptohex=function(e){var t="malformed IP address";if(!(e=e.toLowerCase(e)).match(/^[0-9.]+$/)){if(e.match(/^[0-9a-f:]+$/)&&-1!==e.indexOf(":"))return Pe(e);throw t}var r=e.split(".");if(4!==r.length)throw t;var n="";try{for(var i=0;i<4;i++)n+=("0"+parseInt(r[i]).toString(16)).slice(-2);return n}catch(e){throw t}},t.encodeURIComponentAll=Le,t.newline_toUnix=function(e){return e.replace(/\r\n/gm,"\n")},t.newline_toDos=function(e){return(e=e.replace(/\r\n/gm,"\n")).replace(/\n/gm,"\r\n")},t.hextoposhex=Me,t.intarystrtohex=function(e){e=(e=(e=e.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return e.split(/,/).map(function(e,t,r){var n=parseInt(e);if(n<0||255<n)throw"integer not in range 0-255";return("00"+n.toString(16)).slice(-2)}).join("")}catch(e){throw"malformed integer array string: "+e}},t.strdiffidx=function(e,t){var r=e.length;e.length>t.length&&(r=t.length);for(var n=0;n<r;n++)if(e.charCodeAt(n)!=t.charCodeAt(n))return n;return e.length!=t.length?r:-1},t.KJUR=ce;var Ze=ce.crypto;t.crypto=Ze;var et=ce.asn1;t.asn1=et;var tt=ce.jws;t.jws=tt;var rt=ce.lang;t.lang=rt}).call(this,r(28).Buffer)},function(e,t,r){"use strict";(function(e){
|
|
25
|
-
/*!
|
|
26
|
-
* The buffer module from node.js, for the browser.
|
|
27
|
-
*
|
|
28
|
-
* @author Feross Aboukhadijeh <http://feross.org>
|
|
29
|
-
* @license MIT
|
|
30
|
-
*/
|
|
31
|
-
var n=r(30),i=r(31),o=r(32);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return h(this,e)}return u(this,e,t,r)}function u(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n),c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=d(e,t),e}(e,t,r,n):"string"==typeof t?function(e,t,r){if("string"==typeof r&&""!==r||(r="utf8"),!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(t,r),i=(e=a(e,n)).write(t,r);return i!==n&&(e=e.slice(0,i)),e}(e,t,r):function(e,t){if(c.isBuffer(t)){var r=0|f(t.length);return 0===(e=a(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||function(e){return e!=e}(t.length)?a(e,0):d(e,t);if("Buffer"===t.type&&o(t.data))return d(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function h(e,t){if(l(t),e=a(e,t<0?0:0|f(t)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function d(e,t){var r=t.length<0?0:0|f(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function f(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function p(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(e).length;default:if(n)return B(e).length;t=(""+t).toLowerCase(),n=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return k(this,t,r);case"latin1":case"binary":return I(this,t,r);case"base64":return x(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function m(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,i){var o,s=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var l=-1;for(o=r;o<a;o++)if(u(e,o)===u(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===c)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(r+c>a&&(r=a-c),o=r;o>=0;o--){for(var h=!0,d=0;d<c;d++)if(u(e,o+d)!==u(t,d)){h=!1;break}if(h)return o}return-1}function w(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[r+s]=a}return s}function b(e,t,r,n){return K(B(t,e.length-r),e,r,n)}function _(e,t,r,n){return K(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function S(e,t,r,n){return _(e,t,r,n)}function E(e,t,r,n){return K(q(t),e,r,n)}function A(e,t,r,n){return K(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function x(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,a,c,u=e[i],l=null,h=u>239?4:u>223?3:u>191?2:1;if(i+h<=r)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&u)<<6|63&o)>127&&(l=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=h}return function(e){var t=e.length;if(t<=F)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=F));return r}(n)}t.Buffer=c,t.SlowBuffer=function(e){return+e!=e&&(e=0),c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,r){return u(null,e,t,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,r){return function(e,t,r,n){return l(t),t<=0?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}(null,e,t,r)},c.allocUnsafe=function(e){return h(null,e)},c.allocUnsafeSlow=function(e){return h(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=c.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var s=e[r];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,i),i+=s.length}return n},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?T(this,0,e):g.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,r,n,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),l=e.slice(t,r),h=0;h<a;++h)if(u[h]!==l[h]){o=u[h],s=l[h];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},c.prototype.indexOf=function(e,t,r){return m(this,e,t,r,!0)},c.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,!1)},c.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return b(this,e,t,r);case"ascii":return _(this,e,t,r);case"latin1":case"binary":return S(this,e,t,r);case"base64":return E(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var F=4096;function k(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function I(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function C(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=H(e[o]);return i}function N(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function R(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,r,n,i,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function O(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function D(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function U(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(e,t,r,n,o){return o||U(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function j(e,t,r,n,o){return o||U(e,0,r,8),i.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=c.prototype;else{var i=t-e;r=new c(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+e]}return r},c.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},c.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},c.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||R(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){t||R(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||R(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,r,n){e=+e,t|=0,r|=0,n||P(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},c.prototype.writeUIntBE=function(e,t,r,n){e=+e,t|=0,r|=0,n||P(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},c.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):D(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},c.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):D(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,r){return L(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return L(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return j(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return j(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,o=n-r;if(this===e&&r<t&&t<n)for(i=o-1;i>=0;--i)e[i+t]=this[i+r];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},c.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=c.isBuffer(e)?e:B(new c(e,n).toString()),a=s.length;for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var M=/[^+\/0-9A-Za-z-_]/g;function H(e){return e<16?"0"+e.toString(16):e.toString(16)}function B(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function q(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(M,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function K(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(29))},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=c(e),s=n[0],a=n[1],u=new o(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),l=0,h=a>0?s-4:s;for(r=0;r<h;r+=4)t=i[e.charCodeAt(r)]<<18|i[e.charCodeAt(r+1)]<<12|i[e.charCodeAt(r+2)]<<6|i[e.charCodeAt(r+3)],u[l++]=t>>16&255,u[l++]=t>>8&255,u[l++]=255&t;return 2===a&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,u[l++]=255&t),1===a&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t),u},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=16383,a=0,c=r-i;a<c;a+=s)o.push(u(e,a,a+s>c?c:a+s));return 1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)n[a]=s[a],i[s.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,o,s=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){
|
|
32
|
-
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
33
|
-
t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,c=(1<<a)-1,u=c>>1,l=-7,h=r?i-1:0,d=r?-1:1,f=e[t+h];for(h+=d,o=f&(1<<-l)-1,f>>=-l,l+=a;l>0;o=256*o+e[t+h],h+=d,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+e[t+h],h+=d,l-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),o-=u}return(f?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,c,u=8*o-i-1,l=(1<<u)-1,h=l>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(t*c-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[r+f]=255&s,f+=p,s/=256,u-=8);e[r+f-p]|=128*g}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=e.jws,r=e.KeyUtil,i=e.X509,o=e.crypto,s=e.hextob64u,a=e.b64tohex,c=e.AllowedSigningAlgs;return function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.parseJwt=function e(r){n.Log.debug("JoseUtil.parseJwt");try{var i=t.JWS.parse(r);return{header:i.headerObj,payload:i.payloadObj}}catch(e){n.Log.error(e)}},e.validateJwt=function(t,o,s,c,u,l,h){n.Log.debug("JoseUtil.validateJwt");try{if("RSA"===o.kty)if(o.e&&o.n)o=r.getKey(o);else{if(!o.x5c||!o.x5c.length)return n.Log.error("JoseUtil.validateJwt: RSA key missing key material",o),Promise.reject(new Error("RSA key missing key material"));var d=a(o.x5c[0]);o=i.getPublicKeyFromCertHex(d)}else{if("EC"!==o.kty)return n.Log.error("JoseUtil.validateJwt: Unsupported key type",o&&o.kty),Promise.reject(new Error(o.kty));if(!(o.crv&&o.x&&o.y))return n.Log.error("JoseUtil.validateJwt: EC key missing key material",o),Promise.reject(new Error("EC key missing key material"));o=r.getKey(o)}return e._validateJwt(t,o,s,c,u,l,h)}catch(e){return n.Log.error(e&&e.message||e),Promise.reject("JWT validation failed")}},e.validateJwtAttributes=function(t,r,i,o,s,a){o||(o=0),s||(s=parseInt(Date.now()/1e3));var c=e.parseJwt(t).payload;if(!c.iss)return n.Log.error("JoseUtil._validateJwt: issuer was not provided"),Promise.reject(new Error("issuer was not provided"));if(c.iss!==r)return n.Log.error("JoseUtil._validateJwt: Invalid issuer in token",c.iss),Promise.reject(new Error("Invalid issuer in token: "+c.iss));if(!c.aud)return n.Log.error("JoseUtil._validateJwt: aud was not provided"),Promise.reject(new Error("aud was not provided"));if(!(c.aud===i||Array.isArray(c.aud)&&c.aud.indexOf(i)>=0))return n.Log.error("JoseUtil._validateJwt: Invalid audience in token",c.aud),Promise.reject(new Error("Invalid audience in token: "+c.aud));if(c.azp&&c.azp!==i)return n.Log.error("JoseUtil._validateJwt: Invalid azp in token",c.azp),Promise.reject(new Error("Invalid azp in token: "+c.azp));if(!a){var u=s+o,l=s-o;if(!c.iat)return n.Log.error("JoseUtil._validateJwt: iat was not provided"),Promise.reject(new Error("iat was not provided"));if(u<c.iat)return n.Log.error("JoseUtil._validateJwt: iat is in the future",c.iat),Promise.reject(new Error("iat is in the future: "+c.iat));if(c.nbf&&u<c.nbf)return n.Log.error("JoseUtil._validateJwt: nbf is in the future",c.nbf),Promise.reject(new Error("nbf is in the future: "+c.nbf));if(!c.exp)return n.Log.error("JoseUtil._validateJwt: exp was not provided"),Promise.reject(new Error("exp was not provided"));if(c.exp<l)return n.Log.error("JoseUtil._validateJwt: exp is in the past",c.exp),Promise.reject(new Error("exp is in the past:"+c.exp))}return Promise.resolve(c)},e._validateJwt=function(r,i,o,s,a,u,l){return e.validateJwtAttributes(r,o,s,a,u,l).then(function(e){try{return t.JWS.verify(r,i,c)?e:(n.Log.error("JoseUtil._validateJwt: signature validation failed"),Promise.reject(new Error("signature validation failed")))}catch(e){return n.Log.error(e&&e.message||e),Promise.reject(new Error("signature validation failed"))}})},e.hashString=function e(t,r){try{return o.Util.hashString(t,r)}catch(e){n.Log.error(e)}},e.hexToBase64Url=function e(t){try{return s(t)}catch(e){n.Log.error(e)}},e}()};var n=r(0);e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SigninResponse=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(3);t.SigninResponse=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=i.UrlUtility.parseUrlFragment(t,r);this.error=n.error,this.error_description=n.error_description,this.error_uri=n.error_uri,this.code=n.code,this.state=n.state,this.id_token=n.id_token,this.session_state=n.session_state,this.access_token=n.access_token,this.token_type=n.token_type,this.scope=n.scope,this.profile=void 0,this.expires_in=n.expires_in}return n(e,[{key:"expires_in",get:function(){if(this.expires_at){var e=parseInt(Date.now()/1e3);return this.expires_at-e}},set:function(e){var t=parseInt(e);if("number"==typeof t&&t>0){var r=parseInt(Date.now()/1e3);this.expires_at=r+t}}},{key:"expired",get:function(){var e=this.expires_in;if(void 0!==e)return e<=0}},{key:"scopes",get:function(){return(this.scope||"").split(" ")}},{key:"isOpenIdConnect",get:function(){return this.scopes.indexOf("openid")>=0||!!this.id_token}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SignoutRequest=void 0;var n=r(0),i=r(3),o=r(9);t.SignoutRequest=function e(t){var r=t.url,s=t.id_token_hint,a=t.post_logout_redirect_uri,c=t.data,u=t.extraQueryParams,l=t.request_type;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!r)throw n.Log.error("SignoutRequest.ctor: No url passed"),new Error("url");for(var h in s&&(r=i.UrlUtility.addQueryParam(r,"id_token_hint",s)),a&&(r=i.UrlUtility.addQueryParam(r,"post_logout_redirect_uri",a),c&&(this.state=new o.State({data:c,request_type:l}),r=i.UrlUtility.addQueryParam(r,"state",this.state.id))),u)r=i.UrlUtility.addQueryParam(r,h,u[h]);this.url=r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SignoutResponse=void 0;var n=r(3);t.SignoutResponse=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var r=n.UrlUtility.parseUrlFragment(t,"?");this.error=r.error,this.error_description=r.error_description,this.error_uri=r.error_uri,this.state=r.state}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InMemoryWebStorage=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0);t.InMemoryWebStorage=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._data={}}return e.prototype.getItem=function(e){return i.Log.debug("InMemoryWebStorage.getItem",e),this._data[e]},e.prototype.setItem=function(e,t){i.Log.debug("InMemoryWebStorage.setItem",e),this._data[e]=t},e.prototype.removeItem=function(e){i.Log.debug("InMemoryWebStorage.removeItem",e),delete this._data[e]},e.prototype.key=function(e){return Object.getOwnPropertyNames(this._data)[e]},n(e,[{key:"length",get:function(){return Object.getOwnPropertyNames(this._data).length}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserManager=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=r(10),s=r(39),a=r(15),c=r(45),u=r(47),l=r(18),h=r(8),d=r(20),f=r(11),p=r(4);t.UserManager=function(e){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u.SilentRenewService,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.SessionMonitor,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:d.TokenRevocationClient,h=arguments.length>4&&void 0!==arguments[4]?arguments[4]:f.TokenClient,g=arguments.length>5&&void 0!==arguments[5]?arguments[5]:p.JoseUtil;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,t),r instanceof s.UserManagerSettings||(r=new s.UserManagerSettings(r));var y=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,r));return y._events=new c.UserManagerEvents(r),y._silentRenewService=new n(y),y.settings.automaticSilentRenew&&(i.Log.debug("UserManager.ctor: automaticSilentRenew is configured, setting up silent renew"),y.startSilentRenew()),y.settings.monitorSession&&(i.Log.debug("UserManager.ctor: monitorSession is configured, setting up session monitor"),y._sessionMonitor=new o(y)),y._tokenRevocationClient=new a(y._settings),y._tokenClient=new h(y._settings),y._joseUtil=g,y}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.getUser=function(){var e=this;return this._loadUser().then(function(t){return t?(i.Log.info("UserManager.getUser: user loaded"),e._events.load(t,!1),t):(i.Log.info("UserManager.getUser: user not found in storage"),null)})},t.prototype.removeUser=function(){var e=this;return this.storeUser(null).then(function(){i.Log.info("UserManager.removeUser: user removed from storage"),e._events.unload()})},t.prototype.signinRedirect=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(e=Object.assign({},e)).request_type="si:r";var t={useReplaceToNavigate:e.useReplaceToNavigate};return this._signinStart(e,this._redirectNavigator,t).then(function(){i.Log.info("UserManager.signinRedirect: successful")})},t.prototype.signinRedirectCallback=function(e){return this._signinEnd(e||this._redirectNavigator.url).then(function(e){return e.profile&&e.profile.sub?i.Log.info("UserManager.signinRedirectCallback: successful, signed in sub: ",e.profile.sub):i.Log.info("UserManager.signinRedirectCallback: no sub"),e})},t.prototype.signinPopup=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(e=Object.assign({},e)).request_type="si:p";var t=e.redirect_uri||this.settings.popup_redirect_uri||this.settings.redirect_uri;return t?(e.redirect_uri=t,e.display="popup",this._signin(e,this._popupNavigator,{startUrl:t,popupWindowFeatures:e.popupWindowFeatures||this.settings.popupWindowFeatures,popupWindowTarget:e.popupWindowTarget||this.settings.popupWindowTarget}).then(function(e){return e&&(e.profile&&e.profile.sub?i.Log.info("UserManager.signinPopup: signinPopup successful, signed in sub: ",e.profile.sub):i.Log.info("UserManager.signinPopup: no sub")),e})):(i.Log.error("UserManager.signinPopup: No popup_redirect_uri or redirect_uri configured"),Promise.reject(new Error("No popup_redirect_uri or redirect_uri configured")))},t.prototype.signinPopupCallback=function(e){return this._signinCallback(e,this._popupNavigator).then(function(e){return e&&(e.profile&&e.profile.sub?i.Log.info("UserManager.signinPopupCallback: successful, signed in sub: ",e.profile.sub):i.Log.info("UserManager.signinPopupCallback: no sub")),e}).catch(function(e){i.Log.error(e.message)})},t.prototype.signinSilent=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=Object.assign({},t),this._loadUser().then(function(r){return r&&r.refresh_token?(t.refresh_token=r.refresh_token,e._useRefreshToken(t)):(t.request_type="si:s",t.id_token_hint=t.id_token_hint||e.settings.includeIdTokenInSilentRenew&&r&&r.id_token,r&&e._settings.validateSubOnSilentRenew&&(i.Log.debug("UserManager.signinSilent, subject prior to silent renew: ",r.profile.sub),t.current_sub=r.profile.sub),e._signinSilentIframe(t))})},t.prototype._useRefreshToken=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._tokenClient.exchangeRefreshToken(t).then(function(t){return t?t.access_token?e._loadUser().then(function(r){if(r){var n=Promise.resolve();return t.id_token&&(n=e._validateIdTokenFromTokenRefreshToken(r.profile,t.id_token)),n.then(function(){return i.Log.debug("UserManager._useRefreshToken: refresh token response success"),r.id_token=t.id_token||r.id_token,r.access_token=t.access_token,r.refresh_token=t.refresh_token||r.refresh_token,r.expires_in=t.expires_in,e.storeUser(r).then(function(){return e._events.load(r),r})})}return null}):(i.Log.error("UserManager._useRefreshToken: No access token returned from token endpoint"),Promise.reject("No access token returned from token endpoint")):(i.Log.error("UserManager._useRefreshToken: No response returned from token endpoint"),Promise.reject("No response returned from token endpoint"))})},t.prototype._validateIdTokenFromTokenRefreshToken=function(e,t){var r=this;return this._metadataService.getIssuer().then(function(n){return r.settings.getEpochTime().then(function(o){return r._joseUtil.validateJwtAttributes(t,n,r._settings.client_id,r._settings.clockSkew,o).then(function(t){return t?t.sub!==e.sub?(i.Log.error("UserManager._validateIdTokenFromTokenRefreshToken: sub in id_token does not match current sub"),Promise.reject(new Error("sub in id_token does not match current sub"))):t.auth_time&&t.auth_time!==e.auth_time?(i.Log.error("UserManager._validateIdTokenFromTokenRefreshToken: auth_time in id_token does not match original auth_time"),Promise.reject(new Error("auth_time in id_token does not match original auth_time"))):t.azp&&t.azp!==e.azp?(i.Log.error("UserManager._validateIdTokenFromTokenRefreshToken: azp in id_token does not match original azp"),Promise.reject(new Error("azp in id_token does not match original azp"))):!t.azp&&e.azp?(i.Log.error("UserManager._validateIdTokenFromTokenRefreshToken: azp not in id_token, but present in original id_token"),Promise.reject(new Error("azp not in id_token, but present in original id_token"))):void 0:(i.Log.error("UserManager._validateIdTokenFromTokenRefreshToken: Failed to validate id_token"),Promise.reject(new Error("Failed to validate id_token")))})})})},t.prototype._signinSilentIframe=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.redirect_uri||this.settings.silent_redirect_uri||this.settings.redirect_uri;return t?(e.redirect_uri=t,e.prompt=e.prompt||"none",this._signin(e,this._iframeNavigator,{startUrl:t,silentRequestTimeout:e.silentRequestTimeout||this.settings.silentRequestTimeout}).then(function(e){return e&&(e.profile&&e.profile.sub?i.Log.info("UserManager.signinSilent: successful, signed in sub: ",e.profile.sub):i.Log.info("UserManager.signinSilent: no sub")),e})):(i.Log.error("UserManager.signinSilent: No silent_redirect_uri configured"),Promise.reject(new Error("No silent_redirect_uri configured")))},t.prototype.signinSilentCallback=function(e){return this._signinCallback(e,this._iframeNavigator).then(function(e){return e&&(e.profile&&e.profile.sub?i.Log.info("UserManager.signinSilentCallback: successful, signed in sub: ",e.profile.sub):i.Log.info("UserManager.signinSilentCallback: no sub")),e})},t.prototype.signinCallback=function(e){var t=this;return this.readSigninResponseState(e).then(function(r){var n=r.state;return r.response,"si:r"===n.request_type?t.signinRedirectCallback(e):"si:p"===n.request_type?t.signinPopupCallback(e):"si:s"===n.request_type?t.signinSilentCallback(e):Promise.reject(new Error("invalid response_type in state"))})},t.prototype.signoutCallback=function(e,t){var r=this;return this.readSignoutResponseState(e).then(function(n){var i=n.state,o=n.response;return i?"so:r"===i.request_type?r.signoutRedirectCallback(e):"so:p"===i.request_type?r.signoutPopupCallback(e,t):Promise.reject(new Error("invalid response_type in state")):o})},t.prototype.querySessionStatus=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(t=Object.assign({},t)).request_type="si:s";var r=t.redirect_uri||this.settings.silent_redirect_uri||this.settings.redirect_uri;return r?(t.redirect_uri=r,t.prompt="none",t.response_type=t.response_type||this.settings.query_status_response_type,t.scope=t.scope||"openid",t.skipUserInfo=!0,this._signinStart(t,this._iframeNavigator,{startUrl:r,silentRequestTimeout:t.silentRequestTimeout||this.settings.silentRequestTimeout}).then(function(t){return e.processSigninResponse(t.url).then(function(e){if(i.Log.debug("UserManager.querySessionStatus: got signin response"),e.session_state&&e.profile.sub)return i.Log.info("UserManager.querySessionStatus: querySessionStatus success for sub: ",e.profile.sub),{session_state:e.session_state,sub:e.profile.sub,sid:e.profile.sid};i.Log.info("querySessionStatus successful, user not authenticated")}).catch(function(t){if(t.session_state&&e.settings.monitorAnonymousSession&&("login_required"==t.message||"consent_required"==t.message||"interaction_required"==t.message||"account_selection_required"==t.message))return i.Log.info("UserManager.querySessionStatus: querySessionStatus success for anonymous user"),{session_state:t.session_state};throw t})})):(i.Log.error("UserManager.querySessionStatus: No silent_redirect_uri configured"),Promise.reject(new Error("No silent_redirect_uri configured")))},t.prototype._signin=function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._signinStart(e,t,n).then(function(t){return r._signinEnd(t.url,e)})},t.prototype._signinStart=function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.prepare(n).then(function(t){return i.Log.debug("UserManager._signinStart: got navigator window handle"),r.createSigninRequest(e).then(function(e){return i.Log.debug("UserManager._signinStart: got signin request"),n.url=e.url,n.id=e.state.id,t.navigate(n)}).catch(function(e){throw t.close&&(i.Log.debug("UserManager._signinStart: Error after preparing navigator, closing navigator window"),t.close()),e})})},t.prototype._signinEnd=function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.processSigninResponse(e).then(function(e){i.Log.debug("UserManager._signinEnd: got signin response");var n=new a.User(e);if(r.current_sub){if(r.current_sub!==n.profile.sub)return i.Log.debug("UserManager._signinEnd: current user does not match user returned from signin. sub from signin: ",n.profile.sub),Promise.reject(new Error("login_required"));i.Log.debug("UserManager._signinEnd: current user matches user returned from signin")}return t.storeUser(n).then(function(){return i.Log.debug("UserManager._signinEnd: user stored"),t._events.load(n),n})})},t.prototype._signinCallback=function(e,t){i.Log.debug("UserManager._signinCallback");var r="query"===this._settings.response_mode||!this._settings.response_mode&&h.SigninRequest.isCode(this._settings.response_type)?"?":"#";return t.callback(e,void 0,r)},t.prototype.signoutRedirect=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(e=Object.assign({},e)).request_type="so:r";var t=e.post_logout_redirect_uri||this.settings.post_logout_redirect_uri;t&&(e.post_logout_redirect_uri=t);var r={useReplaceToNavigate:e.useReplaceToNavigate};return this._signoutStart(e,this._redirectNavigator,r).then(function(){i.Log.info("UserManager.signoutRedirect: successful")})},t.prototype.signoutRedirectCallback=function(e){return this._signoutEnd(e||this._redirectNavigator.url).then(function(e){return i.Log.info("UserManager.signoutRedirectCallback: successful"),e})},t.prototype.signoutPopup=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(e=Object.assign({},e)).request_type="so:p";var t=e.post_logout_redirect_uri||this.settings.popup_post_logout_redirect_uri||this.settings.post_logout_redirect_uri;return e.post_logout_redirect_uri=t,e.display="popup",e.post_logout_redirect_uri&&(e.state=e.state||{}),this._signout(e,this._popupNavigator,{startUrl:t,popupWindowFeatures:e.popupWindowFeatures||this.settings.popupWindowFeatures,popupWindowTarget:e.popupWindowTarget||this.settings.popupWindowTarget}).then(function(){i.Log.info("UserManager.signoutPopup: successful")})},t.prototype.signoutPopupCallback=function(e,t){return void 0===t&&"boolean"==typeof e&&(t=e,e=null),this._popupNavigator.callback(e,t,"?").then(function(){i.Log.info("UserManager.signoutPopupCallback: successful")})},t.prototype._signout=function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._signoutStart(e,t,n).then(function(e){return r._signoutEnd(e.url)})},t.prototype._signoutStart=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return arguments[1].prepare(r).then(function(n){return i.Log.debug("UserManager._signoutStart: got navigator window handle"),t._loadUser().then(function(o){return i.Log.debug("UserManager._signoutStart: loaded current user from storage"),(t._settings.revokeAccessTokenOnSignout?t._revokeInternal(o):Promise.resolve()).then(function(){var s=e.id_token_hint||o&&o.id_token;return s&&(i.Log.debug("UserManager._signoutStart: Setting id_token into signout request"),e.id_token_hint=s),t.removeUser().then(function(){return i.Log.debug("UserManager._signoutStart: user removed, creating signout request"),t.createSignoutRequest(e).then(function(e){return i.Log.debug("UserManager._signoutStart: got signout request"),r.url=e.url,e.state&&(r.id=e.state.id),n.navigate(r)})})})}).catch(function(e){throw n.close&&(i.Log.debug("UserManager._signoutStart: Error after preparing navigator, closing navigator window"),n.close()),e})})},t.prototype._signoutEnd=function(e){return this.processSignoutResponse(e).then(function(e){return i.Log.debug("UserManager._signoutEnd: got signout response"),e})},t.prototype.revokeAccessToken=function(){var e=this;return this._loadUser().then(function(t){return e._revokeInternal(t,!0).then(function(r){if(r)return i.Log.debug("UserManager.revokeAccessToken: removing token properties from user and re-storing"),t.access_token=null,t.refresh_token=null,t.expires_at=null,t.token_type=null,e.storeUser(t).then(function(){i.Log.debug("UserManager.revokeAccessToken: user stored"),e._events.load(t)})})}).then(function(){i.Log.info("UserManager.revokeAccessToken: access token revoked successfully")})},t.prototype._revokeInternal=function(e,t){var r=this;if(e){var n=e.access_token,o=e.refresh_token;return this._revokeAccessTokenInternal(n,t).then(function(e){return r._revokeRefreshTokenInternal(o,t).then(function(t){return e||t||i.Log.debug("UserManager.revokeAccessToken: no need to revoke due to no token(s), or JWT format"),e||t})})}return Promise.resolve(!1)},t.prototype._revokeAccessTokenInternal=function(e,t){return!e||e.indexOf(".")>=0?Promise.resolve(!1):this._tokenRevocationClient.revoke(e,t).then(function(){return!0})},t.prototype._revokeRefreshTokenInternal=function(e,t){return e?this._tokenRevocationClient.revoke(e,t,"refresh_token").then(function(){return!0}):Promise.resolve(!1)},t.prototype.startSilentRenew=function(){this._silentRenewService.start()},t.prototype.stopSilentRenew=function(){this._silentRenewService.stop()},t.prototype._loadUser=function(){return this._userStore.get(this._userStoreKey).then(function(e){return e?(i.Log.debug("UserManager._loadUser: user storageString loaded"),a.User.fromStorageString(e)):(i.Log.debug("UserManager._loadUser: no user storageString"),null)})},t.prototype.storeUser=function(e){if(e){i.Log.debug("UserManager.storeUser: storing user");var t=e.toStorageString();return this._userStore.set(this._userStoreKey,t)}return i.Log.debug("storeUser.storeUser: removing user"),this._userStore.remove(this._userStoreKey)},n(t,[{key:"_redirectNavigator",get:function(){return this.settings.redirectNavigator}},{key:"_popupNavigator",get:function(){return this.settings.popupNavigator}},{key:"_iframeNavigator",get:function(){return this.settings.iframeNavigator}},{key:"_userStore",get:function(){return this.settings.userStore}},{key:"events",get:function(){return this._events}},{key:"_userStoreKey",get:function(){return"user:"+this.settings.authority+":"+this.settings.client_id}}]),t}(o.OidcClient)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserManagerSettings=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=(r(0),r(5)),o=r(40),s=r(41),a=r(43),c=r(6),u=r(1),l=r(8);t.UserManagerSettings=function(e){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r.popup_redirect_uri,i=r.popup_post_logout_redirect_uri,h=r.popupWindowFeatures,d=r.popupWindowTarget,f=r.silent_redirect_uri,p=r.silentRequestTimeout,g=r.automaticSilentRenew,y=void 0!==g&&g,m=r.validateSubOnSilentRenew,v=void 0!==m&&m,w=r.includeIdTokenInSilentRenew,b=void 0===w||w,_=r.monitorSession,S=void 0===_||_,E=r.monitorAnonymousSession,A=void 0!==E&&E,x=r.checkSessionInterval,T=void 0===x?2e3:x,F=r.stopCheckSessionOnError,k=void 0===F||F,I=r.query_status_response_type,C=r.revokeAccessTokenOnSignout,N=void 0!==C&&C,R=r.accessTokenExpiringNotificationTime,P=void 0===R?60:R,O=r.redirectNavigator,D=void 0===O?new o.RedirectNavigator:O,U=r.popupNavigator,L=void 0===U?new s.PopupNavigator:U,j=r.iframeNavigator,M=void 0===j?new a.IFrameNavigator:j,H=r.userStore,B=void 0===H?new c.WebStorageStateStore({store:u.Global.sessionStorage}):H;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var q=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,arguments[0]));return q._popup_redirect_uri=n,q._popup_post_logout_redirect_uri=i,q._popupWindowFeatures=h,q._popupWindowTarget=d,q._silent_redirect_uri=f,q._silentRequestTimeout=p,q._automaticSilentRenew=y,q._validateSubOnSilentRenew=v,q._includeIdTokenInSilentRenew=b,q._accessTokenExpiringNotificationTime=P,q._monitorSession=S,q._monitorAnonymousSession=A,q._checkSessionInterval=T,q._stopCheckSessionOnError=k,I?q._query_status_response_type=I:arguments[0]&&arguments[0].response_type?q._query_status_response_type=l.SigninRequest.isOidc(arguments[0].response_type)?"id_token":"code":q._query_status_response_type="id_token",q._revokeAccessTokenOnSignout=N,q._redirectNavigator=D,q._popupNavigator=L,q._iframeNavigator=M,q._userStore=B,q}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),n(t,[{key:"popup_redirect_uri",get:function(){return this._popup_redirect_uri}},{key:"popup_post_logout_redirect_uri",get:function(){return this._popup_post_logout_redirect_uri}},{key:"popupWindowFeatures",get:function(){return this._popupWindowFeatures}},{key:"popupWindowTarget",get:function(){return this._popupWindowTarget}},{key:"silent_redirect_uri",get:function(){return this._silent_redirect_uri}},{key:"silentRequestTimeout",get:function(){return this._silentRequestTimeout}},{key:"automaticSilentRenew",get:function(){return this._automaticSilentRenew}},{key:"validateSubOnSilentRenew",get:function(){return this._validateSubOnSilentRenew}},{key:"includeIdTokenInSilentRenew",get:function(){return this._includeIdTokenInSilentRenew}},{key:"accessTokenExpiringNotificationTime",get:function(){return this._accessTokenExpiringNotificationTime}},{key:"monitorSession",get:function(){return this._monitorSession}},{key:"monitorAnonymousSession",get:function(){return this._monitorAnonymousSession}},{key:"checkSessionInterval",get:function(){return this._checkSessionInterval}},{key:"stopCheckSessionOnError",get:function(){return this._stopCheckSessionOnError}},{key:"query_status_response_type",get:function(){return this._query_status_response_type}},{key:"revokeAccessTokenOnSignout",get:function(){return this._revokeAccessTokenOnSignout}},{key:"redirectNavigator",get:function(){return this._redirectNavigator}},{key:"popupNavigator",get:function(){return this._popupNavigator}},{key:"iframeNavigator",get:function(){return this._iframeNavigator}},{key:"userStore",get:function(){return this._userStore}}]),t}(i.OidcClientSettings)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RedirectNavigator=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0);t.RedirectNavigator=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.prototype.prepare=function(){return Promise.resolve(this)},e.prototype.navigate=function(e){return e&&e.url?(e.useReplaceToNavigate?window.location.replace(e.url):window.location=e.url,Promise.resolve()):(i.Log.error("RedirectNavigator.navigate: No url provided"),Promise.reject(new Error("No url provided")))},n(e,[{key:"url",get:function(){return window.location.href}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PopupNavigator=void 0;var n=r(0),i=r(42);t.PopupNavigator=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.prototype.prepare=function(e){var t=new i.PopupWindow(e);return Promise.resolve(t)},e.prototype.callback=function e(t,r,o){n.Log.debug("PopupNavigator.callback");try{return i.PopupWindow.notifyOpener(t,r,o),Promise.resolve()}catch(e){return Promise.reject(e)}},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PopupWindow=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=r(3);t.PopupWindow=function(){function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._promise=new Promise(function(e,t){r._resolve=e,r._reject=t});var n=t.popupWindowTarget||"_blank",o=t.popupWindowFeatures||"location=no,toolbar=no,width=500,height=500,left=100,top=100;";this._popup=window.open("",n,o),this._popup&&(i.Log.debug("PopupWindow.ctor: popup successfully created"),this._checkForPopupClosedTimer=window.setInterval(this._checkForPopupClosed.bind(this),500))}return e.prototype.navigate=function(e){return this._popup?e&&e.url?(i.Log.debug("PopupWindow.navigate: Setting URL in popup"),this._id=e.id,this._id&&(window["popupCallback_"+e.id]=this._callback.bind(this)),this._popup.focus(),this._popup.window.location=e.url):(this._error("PopupWindow.navigate: no url provided"),this._error("No url provided")):this._error("PopupWindow.navigate: Error opening popup window"),this.promise},e.prototype._success=function(e){i.Log.debug("PopupWindow.callback: Successful response from popup window"),this._cleanup(),this._resolve(e)},e.prototype._error=function(e){i.Log.error("PopupWindow.error: ",e),this._cleanup(),this._reject(new Error(e))},e.prototype.close=function(){this._cleanup(!1)},e.prototype._cleanup=function(e){i.Log.debug("PopupWindow.cleanup"),window.clearInterval(this._checkForPopupClosedTimer),this._checkForPopupClosedTimer=null,delete window["popupCallback_"+this._id],this._popup&&!e&&this._popup.close(),this._popup=null},e.prototype._checkForPopupClosed=function(){this._popup&&!this._popup.closed||this._error("Popup window closed")},e.prototype._callback=function(e,t){this._cleanup(t),e?(i.Log.debug("PopupWindow.callback success"),this._success({url:e})):(i.Log.debug("PopupWindow.callback: Invalid response from popup"),this._error("Invalid response from popup"))},e.notifyOpener=function(e,t,r){if(window.opener){if(e=e||window.location.href){var n=o.UrlUtility.parseUrlFragment(e,r);if(n.state){var s="popupCallback_"+n.state,a=window.opener[s];a?(i.Log.debug("PopupWindow.notifyOpener: passing url message to opener"),a(e,t)):i.Log.warn("PopupWindow.notifyOpener: no matching callback found on opener")}else i.Log.warn("PopupWindow.notifyOpener: no state found in response url")}}else i.Log.warn("PopupWindow.notifyOpener: no window.opener. Can't complete notification.")},n(e,[{key:"promise",get:function(){return this._promise}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IFrameNavigator=void 0;var n=r(0),i=r(44);t.IFrameNavigator=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.prototype.prepare=function(e){var t=new i.IFrameWindow(e);return Promise.resolve(t)},e.prototype.callback=function e(t){n.Log.debug("IFrameNavigator.callback");try{return i.IFrameWindow.notifyParent(t),Promise.resolve()}catch(e){return Promise.reject(e)}},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IFrameWindow=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0);t.IFrameWindow=function(){function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._promise=new Promise(function(e,t){r._resolve=e,r._reject=t}),this._boundMessageEvent=this._message.bind(this),window.addEventListener("message",this._boundMessageEvent,!1),this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="absolute",this._frame.width=0,this._frame.height=0,window.document.body.appendChild(this._frame)}return e.prototype.navigate=function(e){if(e&&e.url){var t=e.silentRequestTimeout||1e4;i.Log.debug("IFrameWindow.navigate: Using timeout of:",t),this._timer=window.setTimeout(this._timeout.bind(this),t),this._frame.src=e.url}else this._error("No url provided");return this.promise},e.prototype._success=function(e){this._cleanup(),i.Log.debug("IFrameWindow: Successful response from frame window"),this._resolve(e)},e.prototype._error=function(e){this._cleanup(),i.Log.error(e),this._reject(new Error(e))},e.prototype.close=function(){this._cleanup()},e.prototype._cleanup=function(){this._frame&&(i.Log.debug("IFrameWindow: cleanup"),window.removeEventListener("message",this._boundMessageEvent,!1),window.clearTimeout(this._timer),window.document.body.removeChild(this._frame),this._timer=null,this._frame=null,this._boundMessageEvent=null)},e.prototype._timeout=function(){i.Log.debug("IFrameWindow.timeout"),this._error("Frame window timed out")},e.prototype._message=function(e){if(i.Log.debug("IFrameWindow.message"),this._timer&&e.origin===this._origin&&e.source===this._frame.contentWindow&&"string"==typeof e.data&&(e.data.startsWith("http://")||e.data.startsWith("https://"))){var t=e.data;t?this._success({url:t}):this._error("Invalid response from frame")}},e.notifyParent=function(e){i.Log.debug("IFrameWindow.notifyParent"),(e=e||window.location.href)&&(i.Log.debug("IFrameWindow.notifyParent: posting url message to parent"),window.parent.postMessage(e,location.protocol+"//"+location.host))},n(e,[{key:"promise",get:function(){return this._promise}},{key:"_origin",get:function(){return location.protocol+"//"+location.host}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserManagerEvents=void 0;var n=r(0),i=r(16),o=r(17);t.UserManagerEvents=function(e){function t(r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,r));return n._userLoaded=new o.Event("User loaded"),n._userUnloaded=new o.Event("User unloaded"),n._silentRenewError=new o.Event("Silent renew error"),n._userSignedIn=new o.Event("User signed in"),n._userSignedOut=new o.Event("User signed out"),n._userSessionChanged=new o.Event("User session changed"),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.load=function(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];n.Log.debug("UserManagerEvents.load"),e.prototype.load.call(this,t),r&&this._userLoaded.raise(t)},t.prototype.unload=function(){n.Log.debug("UserManagerEvents.unload"),e.prototype.unload.call(this),this._userUnloaded.raise()},t.prototype.addUserLoaded=function(e){this._userLoaded.addHandler(e)},t.prototype.removeUserLoaded=function(e){this._userLoaded.removeHandler(e)},t.prototype.addUserUnloaded=function(e){this._userUnloaded.addHandler(e)},t.prototype.removeUserUnloaded=function(e){this._userUnloaded.removeHandler(e)},t.prototype.addSilentRenewError=function(e){this._silentRenewError.addHandler(e)},t.prototype.removeSilentRenewError=function(e){this._silentRenewError.removeHandler(e)},t.prototype._raiseSilentRenewError=function(e){n.Log.debug("UserManagerEvents._raiseSilentRenewError",e.message),this._silentRenewError.raise(e)},t.prototype.addUserSignedIn=function(e){this._userSignedIn.addHandler(e)},t.prototype.removeUserSignedIn=function(e){this._userSignedIn.removeHandler(e)},t.prototype._raiseUserSignedIn=function(){n.Log.debug("UserManagerEvents._raiseUserSignedIn"),this._userSignedIn.raise()},t.prototype.addUserSignedOut=function(e){this._userSignedOut.addHandler(e)},t.prototype.removeUserSignedOut=function(e){this._userSignedOut.removeHandler(e)},t.prototype._raiseUserSignedOut=function(){n.Log.debug("UserManagerEvents._raiseUserSignedOut"),this._userSignedOut.raise()},t.prototype.addUserSessionChanged=function(e){this._userSessionChanged.addHandler(e)},t.prototype.removeUserSessionChanged=function(e){this._userSessionChanged.removeHandler(e)},t.prototype._raiseUserSessionChanged=function(){n.Log.debug("UserManagerEvents._raiseUserSessionChanged"),this._userSessionChanged.raise()},t}(i.AccessTokenEvents)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Timer=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=r(1),s=r(17);t.Timer=function(e){function t(r){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.Global.timer,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var s=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,r));return s._timer=n,s._nowFunc=i||function(){return Date.now()/1e3},s}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.init=function(e){e<=0&&(e=1),e=parseInt(e);var t=this.now+e;if(this.expiration===t&&this._timerHandle)i.Log.debug("Timer.init timer "+this._name+" skipping initialization since already initialized for expiration:",this.expiration);else{this.cancel(),i.Log.debug("Timer.init timer "+this._name+" for duration:",e),this._expiration=t;var r=5;e<r&&(r=e),this._timerHandle=this._timer.setInterval(this._callback.bind(this),1e3*r)}},t.prototype.cancel=function(){this._timerHandle&&(i.Log.debug("Timer.cancel: ",this._name),this._timer.clearInterval(this._timerHandle),this._timerHandle=null)},t.prototype._callback=function(){var t=this._expiration-this.now;i.Log.debug("Timer.callback; "+this._name+" timer expires in:",t),this._expiration<=this.now&&(this.cancel(),e.prototype.raise.call(this))},n(t,[{key:"now",get:function(){return parseInt(this._nowFunc())}},{key:"expiration",get:function(){return this._expiration}}]),t}(s.Event)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SilentRenewService=void 0;var n=r(0);t.SilentRenewService=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._userManager=t}return e.prototype.start=function(){this._callback||(this._callback=this._tokenExpiring.bind(this),this._userManager.events.addAccessTokenExpiring(this._callback),this._userManager.getUser().then(function(e){}).catch(function(e){n.Log.error("SilentRenewService.start: Error from getUser:",e.message)}))},e.prototype.stop=function(){this._callback&&(this._userManager.events.removeAccessTokenExpiring(this._callback),delete this._callback)},e.prototype._tokenExpiring=function(){var e=this;this._userManager.signinSilent().then(function(e){n.Log.debug("SilentRenewService._tokenExpiring: Silent token renewal successful")},function(t){n.Log.error("SilentRenewService._tokenExpiring: Error from signinSilent:",t.message),e._userManager.events._raiseSilentRenewError(t)})},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CordovaPopupNavigator=void 0;var n=r(21);t.CordovaPopupNavigator=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.prototype.prepare=function(e){var t=new n.CordovaPopupWindow(e);return Promise.resolve(t)},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CordovaIFrameNavigator=void 0;var n=r(21);t.CordovaIFrameNavigator=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.prototype.prepare=function(e){e.popupWindowFeatures="hidden=yes";var t=new n.CordovaPopupWindow(e);return Promise.resolve(t)},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Version="1.11.6"}])},e.exports=t()},6559:(e,t,r)=>{"use strict";var n=r(4582).freeze;t.XML_ENTITIES=n({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'}),t.HTML_ENTITIES=n({Aacute:"Á",aacute:"á",Abreve:"Ă",abreve:"ă",ac:"∾",acd:"∿",acE:"∾̳",Acirc:"Â",acirc:"â",acute:"´",Acy:"А",acy:"а",AElig:"Æ",aelig:"æ",af:"",Afr:"𝔄",afr:"𝔞",Agrave:"À",agrave:"à",alefsym:"ℵ",aleph:"ℵ",Alpha:"Α",alpha:"α",Amacr:"Ā",amacr:"ā",amalg:"⨿",AMP:"&",amp:"&",And:"⩓",and:"∧",andand:"⩕",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsd:"∡",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",Aogon:"Ą",aogon:"ą",Aopf:"𝔸",aopf:"𝕒",ap:"≈",apacir:"⩯",apE:"⩰",ape:"≊",apid:"≋",apos:"'",ApplyFunction:"",approx:"≈",approxeq:"≊",Aring:"Å",aring:"å",Ascr:"𝒜",ascr:"𝒶",Assign:"≔",ast:"*",asymp:"≈",asympeq:"≍",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",awconint:"∳",awint:"⨑",backcong:"≌",backepsilon:"϶",backprime:"‵",backsim:"∽",backsimeq:"⋍",Backslash:"∖",Barv:"⫧",barvee:"⊽",Barwed:"⌆",barwed:"⌅",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",Bcy:"Б",bcy:"б",bdquo:"„",becaus:"∵",Because:"∵",because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"ℬ",Bernoullis:"ℬ",Beta:"Β",beta:"β",beth:"ℶ",between:"≬",Bfr:"𝔅",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"⋃",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"⋁",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bNot:"⫭",bnot:"⌐",Bopf:"𝔹",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxbox:"⧉",boxDL:"╗",boxDl:"╖",boxdL:"╕",boxdl:"┐",boxDR:"╔",boxDr:"╓",boxdR:"╒",boxdr:"┌",boxH:"═",boxh:"─",boxHD:"╦",boxHd:"╤",boxhD:"╥",boxhd:"┬",boxHU:"╩",boxHu:"╧",boxhU:"╨",boxhu:"┴",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxUL:"╝",boxUl:"╜",boxuL:"╛",boxul:"┘",boxUR:"╚",boxUr:"╙",boxuR:"╘",boxur:"└",boxV:"║",boxv:"│",boxVH:"╬",boxVh:"╫",boxvH:"╪",boxvh:"┼",boxVL:"╣",boxVl:"╢",boxvL:"╡",boxvl:"┤",boxVR:"╠",boxVr:"╟",boxvR:"╞",boxvr:"├",bprime:"‵",Breve:"˘",breve:"˘",brvbar:"¦",Bscr:"ℬ",bscr:"𝒷",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsol:"\\",bsolb:"⧅",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",Bumpeq:"≎",bumpeq:"≏",Cacute:"Ć",cacute:"ć",Cap:"⋒",cap:"∩",capand:"⩄",capbrcup:"⩉",capcap:"⩋",capcup:"⩇",capdot:"⩀",CapitalDifferentialD:"ⅅ",caps:"∩︀",caret:"⁁",caron:"ˇ",Cayleys:"ℭ",ccaps:"⩍",Ccaron:"Č",ccaron:"č",Ccedil:"Ç",ccedil:"ç",Ccirc:"Ĉ",ccirc:"ĉ",Cconint:"∰",ccups:"⩌",ccupssm:"⩐",Cdot:"Ċ",cdot:"ċ",cedil:"¸",Cedilla:"¸",cemptyv:"⦲",cent:"¢",CenterDot:"·",centerdot:"·",Cfr:"ℭ",cfr:"𝔠",CHcy:"Ч",chcy:"ч",check:"✓",checkmark:"✓",Chi:"Χ",chi:"χ",cir:"○",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",CircleDot:"⊙",circledR:"®",circledS:"Ⓢ",CircleMinus:"⊖",CirclePlus:"⊕",CircleTimes:"⊗",cirE:"⧃",cire:"≗",cirfnint:"⨐",cirmid:"⫯",cirscir:"⧂",ClockwiseContourIntegral:"∲",CloseCurlyDoubleQuote:"”",CloseCurlyQuote:"’",clubs:"♣",clubsuit:"♣",Colon:"∷",colon:":",Colone:"⩴",colone:"≔",coloneq:"≔",comma:",",commat:"@",comp:"∁",compfn:"∘",complement:"∁",complexes:"ℂ",cong:"≅",congdot:"⩭",Congruent:"≡",Conint:"∯",conint:"∮",ContourIntegral:"∮",Copf:"ℂ",copf:"𝕔",coprod:"∐",Coproduct:"∐",COPY:"©",copy:"©",copysr:"℗",CounterClockwiseContourIntegral:"∳",crarr:"↵",Cross:"⨯",cross:"✗",Cscr:"𝒞",cscr:"𝒸",csub:"⫏",csube:"⫑",csup:"⫐",csupe:"⫒",ctdot:"⋯",cudarrl:"⤸",cudarrr:"⤵",cuepr:"⋞",cuesc:"⋟",cularr:"↶",cularrp:"⤽",Cup:"⋓",cup:"∪",cupbrcap:"⩈",CupCap:"≍",cupcap:"⩆",cupcup:"⩊",cupdot:"⊍",cupor:"⩅",cups:"∪︀",curarr:"↷",curarrm:"⤼",curlyeqprec:"⋞",curlyeqsucc:"⋟",curlyvee:"⋎",curlywedge:"⋏",curren:"¤",curvearrowleft:"↶",curvearrowright:"↷",cuvee:"⋎",cuwed:"⋏",cwconint:"∲",cwint:"∱",cylcty:"⌭",Dagger:"‡",dagger:"†",daleth:"ℸ",Darr:"↡",dArr:"⇓",darr:"↓",dash:"‐",Dashv:"⫤",dashv:"⊣",dbkarow:"⤏",dblac:"˝",Dcaron:"Ď",dcaron:"ď",Dcy:"Д",dcy:"д",DD:"ⅅ",dd:"ⅆ",ddagger:"‡",ddarr:"⇊",DDotrahd:"⤑",ddotseq:"⩷",deg:"°",Del:"∇",Delta:"Δ",delta:"δ",demptyv:"⦱",dfisht:"⥿",Dfr:"𝔇",dfr:"𝔡",dHar:"⥥",dharl:"⇃",dharr:"⇂",DiacriticalAcute:"´",DiacriticalDot:"˙",DiacriticalDoubleAcute:"˝",DiacriticalGrave:"`",DiacriticalTilde:"˜",diam:"⋄",Diamond:"⋄",diamond:"⋄",diamondsuit:"♦",diams:"♦",die:"¨",DifferentialD:"ⅆ",digamma:"ϝ",disin:"⋲",div:"÷",divide:"÷",divideontimes:"⋇",divonx:"⋇",DJcy:"Ђ",djcy:"ђ",dlcorn:"⌞",dlcrop:"⌍",dollar:"$",Dopf:"𝔻",dopf:"𝕕",Dot:"¨",dot:"˙",DotDot:"⃜",doteq:"≐",doteqdot:"≑",DotEqual:"≐",dotminus:"∸",dotplus:"∔",dotsquare:"⊡",doublebarwedge:"⌆",DoubleContourIntegral:"∯",DoubleDot:"¨",DoubleDownArrow:"⇓",DoubleLeftArrow:"⇐",DoubleLeftRightArrow:"⇔",DoubleLeftTee:"⫤",DoubleLongLeftArrow:"⟸",DoubleLongLeftRightArrow:"⟺",DoubleLongRightArrow:"⟹",DoubleRightArrow:"⇒",DoubleRightTee:"⊨",DoubleUpArrow:"⇑",DoubleUpDownArrow:"⇕",DoubleVerticalBar:"∥",DownArrow:"↓",Downarrow:"⇓",downarrow:"↓",DownArrowBar:"⤓",DownArrowUpArrow:"⇵",DownBreve:"̑",downdownarrows:"⇊",downharpoonleft:"⇃",downharpoonright:"⇂",DownLeftRightVector:"⥐",DownLeftTeeVector:"⥞",DownLeftVector:"↽",DownLeftVectorBar:"⥖",DownRightTeeVector:"⥟",DownRightVector:"⇁",DownRightVectorBar:"⥗",DownTee:"⊤",DownTeeArrow:"↧",drbkarow:"⤐",drcorn:"⌟",drcrop:"⌌",Dscr:"𝒟",dscr:"𝒹",DScy:"Ѕ",dscy:"ѕ",dsol:"⧶",Dstrok:"Đ",dstrok:"đ",dtdot:"⋱",dtri:"▿",dtrif:"▾",duarr:"⇵",duhar:"⥯",dwangle:"⦦",DZcy:"Џ",dzcy:"џ",dzigrarr:"⟿",Eacute:"É",eacute:"é",easter:"⩮",Ecaron:"Ě",ecaron:"ě",ecir:"≖",Ecirc:"Ê",ecirc:"ê",ecolon:"≕",Ecy:"Э",ecy:"э",eDDot:"⩷",Edot:"Ė",eDot:"≑",edot:"ė",ee:"ⅇ",efDot:"≒",Efr:"𝔈",efr:"𝔢",eg:"⪚",Egrave:"È",egrave:"è",egs:"⪖",egsdot:"⪘",el:"⪙",Element:"∈",elinters:"⏧",ell:"ℓ",els:"⪕",elsdot:"⪗",Emacr:"Ē",emacr:"ē",empty:"∅",emptyset:"∅",EmptySmallSquare:"◻",emptyv:"∅",EmptyVerySmallSquare:"▫",emsp:" ",emsp13:" ",emsp14:" ",ENG:"Ŋ",eng:"ŋ",ensp:" ",Eogon:"Ę",eogon:"ę",Eopf:"𝔼",eopf:"𝕖",epar:"⋕",eparsl:"⧣",eplus:"⩱",epsi:"ε",Epsilon:"Ε",epsilon:"ε",epsiv:"ϵ",eqcirc:"≖",eqcolon:"≕",eqsim:"≂",eqslantgtr:"⪖",eqslantless:"⪕",Equal:"⩵",equals:"=",EqualTilde:"≂",equest:"≟",Equilibrium:"⇌",equiv:"≡",equivDD:"⩸",eqvparsl:"⧥",erarr:"⥱",erDot:"≓",Escr:"ℰ",escr:"ℯ",esdot:"≐",Esim:"⩳",esim:"≂",Eta:"Η",eta:"η",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",euro:"€",excl:"!",exist:"∃",Exists:"∃",expectation:"ℰ",ExponentialE:"ⅇ",exponentiale:"ⅇ",fallingdotseq:"≒",Fcy:"Ф",fcy:"ф",female:"♀",ffilig:"ffi",fflig:"ff",ffllig:"ffl",Ffr:"𝔉",ffr:"𝔣",filig:"fi",FilledSmallSquare:"◼",FilledVerySmallSquare:"▪",fjlig:"fj",flat:"♭",fllig:"fl",fltns:"▱",fnof:"ƒ",Fopf:"𝔽",fopf:"𝕗",ForAll:"∀",forall:"∀",fork:"⋔",forkv:"⫙",Fouriertrf:"ℱ",fpartint:"⨍",frac12:"½",frac13:"⅓",frac14:"¼",frac15:"⅕",frac16:"⅙",frac18:"⅛",frac23:"⅔",frac25:"⅖",frac34:"¾",frac35:"⅗",frac38:"⅜",frac45:"⅘",frac56:"⅚",frac58:"⅝",frac78:"⅞",frasl:"⁄",frown:"⌢",Fscr:"ℱ",fscr:"𝒻",gacute:"ǵ",Gamma:"Γ",gamma:"γ",Gammad:"Ϝ",gammad:"ϝ",gap:"⪆",Gbreve:"Ğ",gbreve:"ğ",Gcedil:"Ģ",Gcirc:"Ĝ",gcirc:"ĝ",Gcy:"Г",gcy:"г",Gdot:"Ġ",gdot:"ġ",gE:"≧",ge:"≥",gEl:"⪌",gel:"⋛",geq:"≥",geqq:"≧",geqslant:"⩾",ges:"⩾",gescc:"⪩",gesdot:"⪀",gesdoto:"⪂",gesdotol:"⪄",gesl:"⋛︀",gesles:"⪔",Gfr:"𝔊",gfr:"𝔤",Gg:"⋙",gg:"≫",ggg:"⋙",gimel:"ℷ",GJcy:"Ѓ",gjcy:"ѓ",gl:"≷",gla:"⪥",glE:"⪒",glj:"⪤",gnap:"⪊",gnapprox:"⪊",gnE:"≩",gne:"⪈",gneq:"⪈",gneqq:"≩",gnsim:"⋧",Gopf:"𝔾",gopf:"𝕘",grave:"`",GreaterEqual:"≥",GreaterEqualLess:"⋛",GreaterFullEqual:"≧",GreaterGreater:"⪢",GreaterLess:"≷",GreaterSlantEqual:"⩾",GreaterTilde:"≳",Gscr:"𝒢",gscr:"ℊ",gsim:"≳",gsime:"⪎",gsiml:"⪐",Gt:"≫",GT:">",gt:">",gtcc:"⪧",gtcir:"⩺",gtdot:"⋗",gtlPar:"⦕",gtquest:"⩼",gtrapprox:"⪆",gtrarr:"⥸",gtrdot:"⋗",gtreqless:"⋛",gtreqqless:"⪌",gtrless:"≷",gtrsim:"≳",gvertneqq:"≩︀",gvnE:"≩︀",Hacek:"ˇ",hairsp:" ",half:"½",hamilt:"ℋ",HARDcy:"Ъ",hardcy:"ъ",hArr:"⇔",harr:"↔",harrcir:"⥈",harrw:"↭",Hat:"^",hbar:"ℏ",Hcirc:"Ĥ",hcirc:"ĥ",hearts:"♥",heartsuit:"♥",hellip:"…",hercon:"⊹",Hfr:"ℌ",hfr:"𝔥",HilbertSpace:"ℋ",hksearow:"⤥",hkswarow:"⤦",hoarr:"⇿",homtht:"∻",hookleftarrow:"↩",hookrightarrow:"↪",Hopf:"ℍ",hopf:"𝕙",horbar:"―",HorizontalLine:"─",Hscr:"ℋ",hscr:"𝒽",hslash:"ℏ",Hstrok:"Ħ",hstrok:"ħ",HumpDownHump:"≎",HumpEqual:"≏",hybull:"⁃",hyphen:"‐",Iacute:"Í",iacute:"í",ic:"",Icirc:"Î",icirc:"î",Icy:"И",icy:"и",Idot:"İ",IEcy:"Е",iecy:"е",iexcl:"¡",iff:"⇔",Ifr:"ℑ",ifr:"𝔦",Igrave:"Ì",igrave:"ì",ii:"ⅈ",iiiint:"⨌",iiint:"∭",iinfin:"⧜",iiota:"℩",IJlig:"IJ",ijlig:"ij",Im:"ℑ",Imacr:"Ī",imacr:"ī",image:"ℑ",ImaginaryI:"ⅈ",imagline:"ℐ",imagpart:"ℑ",imath:"ı",imof:"⊷",imped:"Ƶ",Implies:"⇒",in:"∈",incare:"℅",infin:"∞",infintie:"⧝",inodot:"ı",Int:"∬",int:"∫",intcal:"⊺",integers:"ℤ",Integral:"∫",intercal:"⊺",Intersection:"⋂",intlarhk:"⨗",intprod:"⨼",InvisibleComma:"",InvisibleTimes:"",IOcy:"Ё",iocy:"ё",Iogon:"Į",iogon:"į",Iopf:"𝕀",iopf:"𝕚",Iota:"Ι",iota:"ι",iprod:"⨼",iquest:"¿",Iscr:"ℐ",iscr:"𝒾",isin:"∈",isindot:"⋵",isinE:"⋹",isins:"⋴",isinsv:"⋳",isinv:"∈",it:"",Itilde:"Ĩ",itilde:"ĩ",Iukcy:"І",iukcy:"і",Iuml:"Ï",iuml:"ï",Jcirc:"Ĵ",jcirc:"ĵ",Jcy:"Й",jcy:"й",Jfr:"𝔍",jfr:"𝔧",jmath:"ȷ",Jopf:"𝕁",jopf:"𝕛",Jscr:"𝒥",jscr:"𝒿",Jsercy:"Ј",jsercy:"ј",Jukcy:"Є",jukcy:"є",Kappa:"Κ",kappa:"κ",kappav:"ϰ",Kcedil:"Ķ",kcedil:"ķ",Kcy:"К",kcy:"к",Kfr:"𝔎",kfr:"𝔨",kgreen:"ĸ",KHcy:"Х",khcy:"х",KJcy:"Ќ",kjcy:"ќ",Kopf:"𝕂",kopf:"𝕜",Kscr:"𝒦",kscr:"𝓀",lAarr:"⇚",Lacute:"Ĺ",lacute:"ĺ",laemptyv:"⦴",lagran:"ℒ",Lambda:"Λ",lambda:"λ",Lang:"⟪",lang:"⟨",langd:"⦑",langle:"⟨",lap:"⪅",Laplacetrf:"ℒ",laquo:"«",Larr:"↞",lArr:"⇐",larr:"←",larrb:"⇤",larrbfs:"⤟",larrfs:"⤝",larrhk:"↩",larrlp:"↫",larrpl:"⤹",larrsim:"⥳",larrtl:"↢",lat:"⪫",lAtail:"⤛",latail:"⤙",late:"⪭",lates:"⪭︀",lBarr:"⤎",lbarr:"⤌",lbbrk:"❲",lbrace:"{",lbrack:"[",lbrke:"⦋",lbrksld:"⦏",lbrkslu:"⦍",Lcaron:"Ľ",lcaron:"ľ",Lcedil:"Ļ",lcedil:"ļ",lceil:"⌈",lcub:"{",Lcy:"Л",lcy:"л",ldca:"⤶",ldquo:"“",ldquor:"„",ldrdhar:"⥧",ldrushar:"⥋",ldsh:"↲",lE:"≦",le:"≤",LeftAngleBracket:"⟨",LeftArrow:"←",Leftarrow:"⇐",leftarrow:"←",LeftArrowBar:"⇤",LeftArrowRightArrow:"⇆",leftarrowtail:"↢",LeftCeiling:"⌈",LeftDoubleBracket:"⟦",LeftDownTeeVector:"⥡",LeftDownVector:"⇃",LeftDownVectorBar:"⥙",LeftFloor:"⌊",leftharpoondown:"↽",leftharpoonup:"↼",leftleftarrows:"⇇",LeftRightArrow:"↔",Leftrightarrow:"⇔",leftrightarrow:"↔",leftrightarrows:"⇆",leftrightharpoons:"⇋",leftrightsquigarrow:"↭",LeftRightVector:"⥎",LeftTee:"⊣",LeftTeeArrow:"↤",LeftTeeVector:"⥚",leftthreetimes:"⋋",LeftTriangle:"⊲",LeftTriangleBar:"⧏",LeftTriangleEqual:"⊴",LeftUpDownVector:"⥑",LeftUpTeeVector:"⥠",LeftUpVector:"↿",LeftUpVectorBar:"⥘",LeftVector:"↼",LeftVectorBar:"⥒",lEg:"⪋",leg:"⋚",leq:"≤",leqq:"≦",leqslant:"⩽",les:"⩽",lescc:"⪨",lesdot:"⩿",lesdoto:"⪁",lesdotor:"⪃",lesg:"⋚︀",lesges:"⪓",lessapprox:"⪅",lessdot:"⋖",lesseqgtr:"⋚",lesseqqgtr:"⪋",LessEqualGreater:"⋚",LessFullEqual:"≦",LessGreater:"≶",lessgtr:"≶",LessLess:"⪡",lesssim:"≲",LessSlantEqual:"⩽",LessTilde:"≲",lfisht:"⥼",lfloor:"⌊",Lfr:"𝔏",lfr:"𝔩",lg:"≶",lgE:"⪑",lHar:"⥢",lhard:"↽",lharu:"↼",lharul:"⥪",lhblk:"▄",LJcy:"Љ",ljcy:"љ",Ll:"⋘",ll:"≪",llarr:"⇇",llcorner:"⌞",Lleftarrow:"⇚",llhard:"⥫",lltri:"◺",Lmidot:"Ŀ",lmidot:"ŀ",lmoust:"⎰",lmoustache:"⎰",lnap:"⪉",lnapprox:"⪉",lnE:"≨",lne:"⪇",lneq:"⪇",lneqq:"≨",lnsim:"⋦",loang:"⟬",loarr:"⇽",lobrk:"⟦",LongLeftArrow:"⟵",Longleftarrow:"⟸",longleftarrow:"⟵",LongLeftRightArrow:"⟷",Longleftrightarrow:"⟺",longleftrightarrow:"⟷",longmapsto:"⟼",LongRightArrow:"⟶",Longrightarrow:"⟹",longrightarrow:"⟶",looparrowleft:"↫",looparrowright:"↬",lopar:"⦅",Lopf:"𝕃",lopf:"𝕝",loplus:"⨭",lotimes:"⨴",lowast:"∗",lowbar:"_",LowerLeftArrow:"↙",LowerRightArrow:"↘",loz:"◊",lozenge:"◊",lozf:"⧫",lpar:"(",lparlt:"⦓",lrarr:"⇆",lrcorner:"⌟",lrhar:"⇋",lrhard:"⥭",lrm:"",lrtri:"⊿",lsaquo:"‹",Lscr:"ℒ",lscr:"𝓁",Lsh:"↰",lsh:"↰",lsim:"≲",lsime:"⪍",lsimg:"⪏",lsqb:"[",lsquo:"‘",lsquor:"‚",Lstrok:"Ł",lstrok:"ł",Lt:"≪",LT:"<",lt:"<",ltcc:"⪦",ltcir:"⩹",ltdot:"⋖",lthree:"⋋",ltimes:"⋉",ltlarr:"⥶",ltquest:"⩻",ltri:"◃",ltrie:"⊴",ltrif:"◂",ltrPar:"⦖",lurdshar:"⥊",luruhar:"⥦",lvertneqq:"≨︀",lvnE:"≨︀",macr:"¯",male:"♂",malt:"✠",maltese:"✠",Map:"⤅",map:"↦",mapsto:"↦",mapstodown:"↧",mapstoleft:"↤",mapstoup:"↥",marker:"▮",mcomma:"⨩",Mcy:"М",mcy:"м",mdash:"—",mDDot:"∺",measuredangle:"∡",MediumSpace:" ",Mellintrf:"ℳ",Mfr:"𝔐",mfr:"𝔪",mho:"℧",micro:"µ",mid:"∣",midast:"*",midcir:"⫰",middot:"·",minus:"−",minusb:"⊟",minusd:"∸",minusdu:"⨪",MinusPlus:"∓",mlcp:"⫛",mldr:"…",mnplus:"∓",models:"⊧",Mopf:"𝕄",mopf:"𝕞",mp:"∓",Mscr:"ℳ",mscr:"𝓂",mstpos:"∾",Mu:"Μ",mu:"μ",multimap:"⊸",mumap:"⊸",nabla:"∇",Nacute:"Ń",nacute:"ń",nang:"∠⃒",nap:"≉",napE:"⩰̸",napid:"≋̸",napos:"ʼn",napprox:"≉",natur:"♮",natural:"♮",naturals:"ℕ",nbsp:" ",nbump:"≎̸",nbumpe:"≏̸",ncap:"⩃",Ncaron:"Ň",ncaron:"ň",Ncedil:"Ņ",ncedil:"ņ",ncong:"≇",ncongdot:"⩭̸",ncup:"⩂",Ncy:"Н",ncy:"н",ndash:"–",ne:"≠",nearhk:"⤤",neArr:"⇗",nearr:"↗",nearrow:"↗",nedot:"≐̸",NegativeMediumSpace:"",NegativeThickSpace:"",NegativeThinSpace:"",NegativeVeryThinSpace:"",nequiv:"≢",nesear:"⤨",nesim:"≂̸",NestedGreaterGreater:"≫",NestedLessLess:"≪",NewLine:"\n",nexist:"∄",nexists:"∄",Nfr:"𝔑",nfr:"𝔫",ngE:"≧̸",nge:"≱",ngeq:"≱",ngeqq:"≧̸",ngeqslant:"⩾̸",nges:"⩾̸",nGg:"⋙̸",ngsim:"≵",nGt:"≫⃒",ngt:"≯",ngtr:"≯",nGtv:"≫̸",nhArr:"⇎",nharr:"↮",nhpar:"⫲",ni:"∋",nis:"⋼",nisd:"⋺",niv:"∋",NJcy:"Њ",njcy:"њ",nlArr:"⇍",nlarr:"↚",nldr:"‥",nlE:"≦̸",nle:"≰",nLeftarrow:"⇍",nleftarrow:"↚",nLeftrightarrow:"⇎",nleftrightarrow:"↮",nleq:"≰",nleqq:"≦̸",nleqslant:"⩽̸",nles:"⩽̸",nless:"≮",nLl:"⋘̸",nlsim:"≴",nLt:"≪⃒",nlt:"≮",nltri:"⋪",nltrie:"⋬",nLtv:"≪̸",nmid:"∤",NoBreak:"",NonBreakingSpace:" ",Nopf:"ℕ",nopf:"𝕟",Not:"⫬",not:"¬",NotCongruent:"≢",NotCupCap:"≭",NotDoubleVerticalBar:"∦",NotElement:"∉",NotEqual:"≠",NotEqualTilde:"≂̸",NotExists:"∄",NotGreater:"≯",NotGreaterEqual:"≱",NotGreaterFullEqual:"≧̸",NotGreaterGreater:"≫̸",NotGreaterLess:"≹",NotGreaterSlantEqual:"⩾̸",NotGreaterTilde:"≵",NotHumpDownHump:"≎̸",NotHumpEqual:"≏̸",notin:"∉",notindot:"⋵̸",notinE:"⋹̸",notinva:"∉",notinvb:"⋷",notinvc:"⋶",NotLeftTriangle:"⋪",NotLeftTriangleBar:"⧏̸",NotLeftTriangleEqual:"⋬",NotLess:"≮",NotLessEqual:"≰",NotLessGreater:"≸",NotLessLess:"≪̸",NotLessSlantEqual:"⩽̸",NotLessTilde:"≴",NotNestedGreaterGreater:"⪢̸",NotNestedLessLess:"⪡̸",notni:"∌",notniva:"∌",notnivb:"⋾",notnivc:"⋽",NotPrecedes:"⊀",NotPrecedesEqual:"⪯̸",NotPrecedesSlantEqual:"⋠",NotReverseElement:"∌",NotRightTriangle:"⋫",NotRightTriangleBar:"⧐̸",NotRightTriangleEqual:"⋭",NotSquareSubset:"⊏̸",NotSquareSubsetEqual:"⋢",NotSquareSuperset:"⊐̸",NotSquareSupersetEqual:"⋣",NotSubset:"⊂⃒",NotSubsetEqual:"⊈",NotSucceeds:"⊁",NotSucceedsEqual:"⪰̸",NotSucceedsSlantEqual:"⋡",NotSucceedsTilde:"≿̸",NotSuperset:"⊃⃒",NotSupersetEqual:"⊉",NotTilde:"≁",NotTildeEqual:"≄",NotTildeFullEqual:"≇",NotTildeTilde:"≉",NotVerticalBar:"∤",npar:"∦",nparallel:"∦",nparsl:"⫽⃥",npart:"∂̸",npolint:"⨔",npr:"⊀",nprcue:"⋠",npre:"⪯̸",nprec:"⊀",npreceq:"⪯̸",nrArr:"⇏",nrarr:"↛",nrarrc:"⤳̸",nrarrw:"↝̸",nRightarrow:"⇏",nrightarrow:"↛",nrtri:"⋫",nrtrie:"⋭",nsc:"⊁",nsccue:"⋡",nsce:"⪰̸",Nscr:"𝒩",nscr:"𝓃",nshortmid:"∤",nshortparallel:"∦",nsim:"≁",nsime:"≄",nsimeq:"≄",nsmid:"∤",nspar:"∦",nsqsube:"⋢",nsqsupe:"⋣",nsub:"⊄",nsubE:"⫅̸",nsube:"⊈",nsubset:"⊂⃒",nsubseteq:"⊈",nsubseteqq:"⫅̸",nsucc:"⊁",nsucceq:"⪰̸",nsup:"⊅",nsupE:"⫆̸",nsupe:"⊉",nsupset:"⊃⃒",nsupseteq:"⊉",nsupseteqq:"⫆̸",ntgl:"≹",Ntilde:"Ñ",ntilde:"ñ",ntlg:"≸",ntriangleleft:"⋪",ntrianglelefteq:"⋬",ntriangleright:"⋫",ntrianglerighteq:"⋭",Nu:"Ν",nu:"ν",num:"#",numero:"№",numsp:" ",nvap:"≍⃒",nVDash:"⊯",nVdash:"⊮",nvDash:"⊭",nvdash:"⊬",nvge:"≥⃒",nvgt:">⃒",nvHarr:"⤄",nvinfin:"⧞",nvlArr:"⤂",nvle:"≤⃒",nvlt:"<⃒",nvltrie:"⊴⃒",nvrArr:"⤃",nvrtrie:"⊵⃒",nvsim:"∼⃒",nwarhk:"⤣",nwArr:"⇖",nwarr:"↖",nwarrow:"↖",nwnear:"⤧",Oacute:"Ó",oacute:"ó",oast:"⊛",ocir:"⊚",Ocirc:"Ô",ocirc:"ô",Ocy:"О",ocy:"о",odash:"⊝",Odblac:"Ő",odblac:"ő",odiv:"⨸",odot:"⊙",odsold:"⦼",OElig:"Œ",oelig:"œ",ofcir:"⦿",Ofr:"𝔒",ofr:"𝔬",ogon:"˛",Ograve:"Ò",ograve:"ò",ogt:"⧁",ohbar:"⦵",ohm:"Ω",oint:"∮",olarr:"↺",olcir:"⦾",olcross:"⦻",oline:"‾",olt:"⧀",Omacr:"Ō",omacr:"ō",Omega:"Ω",omega:"ω",Omicron:"Ο",omicron:"ο",omid:"⦶",ominus:"⊖",Oopf:"𝕆",oopf:"𝕠",opar:"⦷",OpenCurlyDoubleQuote:"“",OpenCurlyQuote:"‘",operp:"⦹",oplus:"⊕",Or:"⩔",or:"∨",orarr:"↻",ord:"⩝",order:"ℴ",orderof:"ℴ",ordf:"ª",ordm:"º",origof:"⊶",oror:"⩖",orslope:"⩗",orv:"⩛",oS:"Ⓢ",Oscr:"𝒪",oscr:"ℴ",Oslash:"Ø",oslash:"ø",osol:"⊘",Otilde:"Õ",otilde:"õ",Otimes:"⨷",otimes:"⊗",otimesas:"⨶",Ouml:"Ö",ouml:"ö",ovbar:"⌽",OverBar:"‾",OverBrace:"⏞",OverBracket:"⎴",OverParenthesis:"⏜",par:"∥",para:"¶",parallel:"∥",parsim:"⫳",parsl:"⫽",part:"∂",PartialD:"∂",Pcy:"П",pcy:"п",percnt:"%",period:".",permil:"‰",perp:"⊥",pertenk:"‱",Pfr:"𝔓",pfr:"𝔭",Phi:"Φ",phi:"φ",phiv:"ϕ",phmmat:"ℳ",phone:"☎",Pi:"Π",pi:"π",pitchfork:"⋔",piv:"ϖ",planck:"ℏ",planckh:"ℎ",plankv:"ℏ",plus:"+",plusacir:"⨣",plusb:"⊞",pluscir:"⨢",plusdo:"∔",plusdu:"⨥",pluse:"⩲",PlusMinus:"±",plusmn:"±",plussim:"⨦",plustwo:"⨧",pm:"±",Poincareplane:"ℌ",pointint:"⨕",Popf:"ℙ",popf:"𝕡",pound:"£",Pr:"⪻",pr:"≺",prap:"⪷",prcue:"≼",prE:"⪳",pre:"⪯",prec:"≺",precapprox:"⪷",preccurlyeq:"≼",Precedes:"≺",PrecedesEqual:"⪯",PrecedesSlantEqual:"≼",PrecedesTilde:"≾",preceq:"⪯",precnapprox:"⪹",precneqq:"⪵",precnsim:"⋨",precsim:"≾",Prime:"″",prime:"′",primes:"ℙ",prnap:"⪹",prnE:"⪵",prnsim:"⋨",prod:"∏",Product:"∏",profalar:"⌮",profline:"⌒",profsurf:"⌓",prop:"∝",Proportion:"∷",Proportional:"∝",propto:"∝",prsim:"≾",prurel:"⊰",Pscr:"𝒫",pscr:"𝓅",Psi:"Ψ",psi:"ψ",puncsp:" ",Qfr:"𝔔",qfr:"𝔮",qint:"⨌",Qopf:"ℚ",qopf:"𝕢",qprime:"⁗",Qscr:"𝒬",qscr:"𝓆",quaternions:"ℍ",quatint:"⨖",quest:"?",questeq:"≟",QUOT:'"',quot:'"',rAarr:"⇛",race:"∽̱",Racute:"Ŕ",racute:"ŕ",radic:"√",raemptyv:"⦳",Rang:"⟫",rang:"⟩",rangd:"⦒",range:"⦥",rangle:"⟩",raquo:"»",Rarr:"↠",rArr:"⇒",rarr:"→",rarrap:"⥵",rarrb:"⇥",rarrbfs:"⤠",rarrc:"⤳",rarrfs:"⤞",rarrhk:"↪",rarrlp:"↬",rarrpl:"⥅",rarrsim:"⥴",Rarrtl:"⤖",rarrtl:"↣",rarrw:"↝",rAtail:"⤜",ratail:"⤚",ratio:"∶",rationals:"ℚ",RBarr:"⤐",rBarr:"⤏",rbarr:"⤍",rbbrk:"❳",rbrace:"}",rbrack:"]",rbrke:"⦌",rbrksld:"⦎",rbrkslu:"⦐",Rcaron:"Ř",rcaron:"ř",Rcedil:"Ŗ",rcedil:"ŗ",rceil:"⌉",rcub:"}",Rcy:"Р",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",Re:"ℜ",real:"ℜ",realine:"ℛ",realpart:"ℜ",reals:"ℝ",rect:"▭",REG:"®",reg:"®",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",rfisht:"⥽",rfloor:"⌋",Rfr:"ℜ",rfr:"𝔯",rHar:"⥤",rhard:"⇁",rharu:"⇀",rharul:"⥬",Rho:"Ρ",rho:"ρ",rhov:"ϱ",RightAngleBracket:"⟩",RightArrow:"→",Rightarrow:"⇒",rightarrow:"→",RightArrowBar:"⇥",RightArrowLeftArrow:"⇄",rightarrowtail:"↣",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVector:"⇂",RightDownVectorBar:"⥕",RightFloor:"⌋",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",RightTee:"⊢",RightTeeArrow:"↦",RightTeeVector:"⥛",rightthreetimes:"⋌",RightTriangle:"⊳",RightTriangleBar:"⧐",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVector:"↾",RightUpVectorBar:"⥔",RightVector:"⇀",RightVectorBar:"⥓",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"",rmoust:"⎱",rmoustache:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",Ropf:"ℝ",ropf:"𝕣",roplus:"⨮",rotimes:"⨵",RoundImplies:"⥰",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",Rrightarrow:"⇛",rsaquo:"›",Rscr:"ℛ",rscr:"𝓇",Rsh:"↱",rsh:"↱",rsqb:"]",rsquo:"’",rsquor:"’",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",RuleDelayed:"⧴",ruluhar:"⥨",rx:"℞",Sacute:"Ś",sacute:"ś",sbquo:"‚",Sc:"⪼",sc:"≻",scap:"⪸",Scaron:"Š",scaron:"š",sccue:"≽",scE:"⪴",sce:"⪰",Scedil:"Ş",scedil:"ş",Scirc:"Ŝ",scirc:"ŝ",scnap:"⪺",scnE:"⪶",scnsim:"⋩",scpolint:"⨓",scsim:"≿",Scy:"С",scy:"с",sdot:"⋅",sdotb:"⊡",sdote:"⩦",searhk:"⤥",seArr:"⇘",searr:"↘",searrow:"↘",sect:"§",semi:";",seswar:"⤩",setminus:"∖",setmn:"∖",sext:"✶",Sfr:"𝔖",sfr:"𝔰",sfrown:"⌢",sharp:"♯",SHCHcy:"Щ",shchcy:"щ",SHcy:"Ш",shcy:"ш",ShortDownArrow:"↓",ShortLeftArrow:"←",shortmid:"∣",shortparallel:"∥",ShortRightArrow:"→",ShortUpArrow:"↑",shy:"",Sigma:"Σ",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"∼",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",SmallCircle:"∘",smallsetminus:"∖",smashp:"⨳",smeparsl:"⧤",smid:"∣",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",SOFTcy:"Ь",softcy:"ь",sol:"/",solb:"⧄",solbar:"⌿",Sopf:"𝕊",sopf:"𝕤",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",Sqrt:"√",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",squ:"□",Square:"□",square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",squarf:"▪",squf:"▪",srarr:"→",Sscr:"𝒮",sscr:"𝓈",ssetmn:"∖",ssmile:"⌣",sstarf:"⋆",Star:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",Sub:"⋐",sub:"⊂",subdot:"⪽",subE:"⫅",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",Subset:"⋐",subset:"⊂",subseteq:"⊆",subseteqq:"⫅",SubsetEqual:"⊆",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succ:"≻",succapprox:"⪸",succcurlyeq:"≽",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",SuchThat:"∋",Sum:"∑",sum:"∑",sung:"♪",Sup:"⋑",sup:"⊃",sup1:"¹",sup2:"²",sup3:"³",supdot:"⪾",supdsub:"⫘",supE:"⫆",supe:"⊇",supedot:"⫄",Superset:"⊃",SupersetEqual:"⊇",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",Supset:"⋑",supset:"⊃",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swarhk:"⤦",swArr:"⇙",swarr:"↙",swarrow:"↙",swnwar:"⤪",szlig:"ß",Tab:"\t",target:"⌖",Tau:"Τ",tau:"τ",tbrk:"⎴",Tcaron:"Ť",tcaron:"ť",Tcedil:"Ţ",tcedil:"ţ",Tcy:"Т",tcy:"т",tdot:"⃛",telrec:"⌕",Tfr:"𝔗",tfr:"𝔱",there4:"∴",Therefore:"∴",therefore:"∴",Theta:"Θ",theta:"θ",thetasym:"ϑ",thetav:"ϑ",thickapprox:"≈",thicksim:"∼",ThickSpace:" ",thinsp:" ",ThinSpace:" ",thkap:"≈",thksim:"∼",THORN:"Þ",thorn:"þ",Tilde:"∼",tilde:"˜",TildeEqual:"≃",TildeFullEqual:"≅",TildeTilde:"≈",times:"×",timesb:"⊠",timesbar:"⨱",timesd:"⨰",tint:"∭",toea:"⤨",top:"⊤",topbot:"⌶",topcir:"⫱",Topf:"𝕋",topf:"𝕥",topfork:"⫚",tosa:"⤩",tprime:"‴",TRADE:"™",trade:"™",triangle:"▵",triangledown:"▿",triangleleft:"◃",trianglelefteq:"⊴",triangleq:"≜",triangleright:"▹",trianglerighteq:"⊵",tridot:"◬",trie:"≜",triminus:"⨺",TripleDot:"⃛",triplus:"⨹",trisb:"⧍",tritime:"⨻",trpezium:"⏢",Tscr:"𝒯",tscr:"𝓉",TScy:"Ц",tscy:"ц",TSHcy:"Ћ",tshcy:"ћ",Tstrok:"Ŧ",tstrok:"ŧ",twixt:"≬",twoheadleftarrow:"↞",twoheadrightarrow:"↠",Uacute:"Ú",uacute:"ú",Uarr:"↟",uArr:"⇑",uarr:"↑",Uarrocir:"⥉",Ubrcy:"Ў",ubrcy:"ў",Ubreve:"Ŭ",ubreve:"ŭ",Ucirc:"Û",ucirc:"û",Ucy:"У",ucy:"у",udarr:"⇅",Udblac:"Ű",udblac:"ű",udhar:"⥮",ufisht:"⥾",Ufr:"𝔘",ufr:"𝔲",Ugrave:"Ù",ugrave:"ù",uHar:"⥣",uharl:"↿",uharr:"↾",uhblk:"▀",ulcorn:"⌜",ulcorner:"⌜",ulcrop:"⌏",ultri:"◸",Umacr:"Ū",umacr:"ū",uml:"¨",UnderBar:"_",UnderBrace:"⏟",UnderBracket:"⎵",UnderParenthesis:"⏝",Union:"⋃",UnionPlus:"⊎",Uogon:"Ų",uogon:"ų",Uopf:"𝕌",uopf:"𝕦",UpArrow:"↑",Uparrow:"⇑",uparrow:"↑",UpArrowBar:"⤒",UpArrowDownArrow:"⇅",UpDownArrow:"↕",Updownarrow:"⇕",updownarrow:"↕",UpEquilibrium:"⥮",upharpoonleft:"↿",upharpoonright:"↾",uplus:"⊎",UpperLeftArrow:"↖",UpperRightArrow:"↗",Upsi:"ϒ",upsi:"υ",upsih:"ϒ",Upsilon:"Υ",upsilon:"υ",UpTee:"⊥",UpTeeArrow:"↥",upuparrows:"⇈",urcorn:"⌝",urcorner:"⌝",urcrop:"⌎",Uring:"Ů",uring:"ů",urtri:"◹",Uscr:"𝒰",uscr:"𝓊",utdot:"⋰",Utilde:"Ũ",utilde:"ũ",utri:"▵",utrif:"▴",uuarr:"⇈",Uuml:"Ü",uuml:"ü",uwangle:"⦧",vangrt:"⦜",varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",vArr:"⇕",varr:"↕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",Vbar:"⫫",vBar:"⫨",vBarv:"⫩",Vcy:"В",vcy:"в",VDash:"⊫",Vdash:"⊩",vDash:"⊨",vdash:"⊢",Vdashl:"⫦",Vee:"⋁",vee:"∨",veebar:"⊻",veeeq:"≚",vellip:"⋮",Verbar:"‖",verbar:"|",Vert:"‖",vert:"|",VerticalBar:"∣",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:" ",Vfr:"𝔙",vfr:"𝔳",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",Vopf:"𝕍",vopf:"𝕧",vprop:"∝",vrtri:"⊳",Vscr:"𝒱",vscr:"𝓋",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",Vvdash:"⊪",vzigzag:"⦚",Wcirc:"Ŵ",wcirc:"ŵ",wedbar:"⩟",Wedge:"⋀",wedge:"∧",wedgeq:"≙",weierp:"℘",Wfr:"𝔚",wfr:"𝔴",Wopf:"𝕎",wopf:"𝕨",wp:"℘",wr:"≀",wreath:"≀",Wscr:"𝒲",wscr:"𝓌",xcap:"⋂",xcirc:"◯",xcup:"⋃",xdtri:"▽",Xfr:"𝔛",xfr:"𝔵",xhArr:"⟺",xharr:"⟷",Xi:"Ξ",xi:"ξ",xlArr:"⟸",xlarr:"⟵",xmap:"⟼",xnis:"⋻",xodot:"⨀",Xopf:"𝕏",xopf:"𝕩",xoplus:"⨁",xotime:"⨂",xrArr:"⟹",xrarr:"⟶",Xscr:"𝒳",xscr:"𝓍",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"⋁",xwedge:"⋀",Yacute:"Ý",yacute:"ý",YAcy:"Я",yacy:"я",Ycirc:"Ŷ",ycirc:"ŷ",Ycy:"Ы",ycy:"ы",yen:"¥",Yfr:"𝔜",yfr:"𝔶",YIcy:"Ї",yicy:"ї",Yopf:"𝕐",yopf:"𝕪",Yscr:"𝒴",yscr:"𝓎",YUcy:"Ю",yucy:"ю",Yuml:"Ÿ",yuml:"ÿ",Zacute:"Ź",zacute:"ź",Zcaron:"Ž",zcaron:"ž",Zcy:"З",zcy:"з",Zdot:"Ż",zdot:"ż",zeetrf:"ℨ",ZeroWidthSpace:"",Zeta:"Ζ",zeta:"ζ",Zfr:"ℨ",zfr:"𝔷",ZHcy:"Ж",zhcy:"ж",zigrarr:"⇝",Zopf:"ℤ",zopf:"𝕫",Zscr:"𝒵",zscr:"𝓏",zwj:"",zwnj:""}),t.entityMap=t.HTML_ENTITIES},6568:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1797),i=r(6011);t.default=function(e){const t=function(e){return Uint8Array.of((15&e[6])<<4|e[7]>>4&15,(15&e[7])<<4|(240&e[4])>>4,(15&e[4])<<4|(240&e[5])>>4,(15&e[5])<<4|(240&e[0])>>4,(15&e[0])<<4|(240&e[1])>>4,(15&e[1])<<4|(240&e[2])>>4,96|15&e[2],e[3],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}("string"==typeof e?(0,n.default)(e):e);return"string"==typeof e?(0,i.unsafeStringify)(t):t}},6697:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i},6711:(e,t,r)=>{"use strict";r.d(t,{Z:()=>v});var n=r(1436),i=r(1020),o=r(7991),s=r(4495),a=r(676);const c=async(e,t,r,n)=>{const c=await(0,a.A)(e,t,"verify");(0,s.A)(e,c);const u=(0,i.A)(e,c.algorithm);try{return await o.A.subtle.verify(u,c,r,n)}catch{return!1}};var u=r(7493),l=r(1476),h=r(9874),d=r(149),f=r(8858),p=r(2168),g=r(4618),y=r(5500),m=r(8278);async function v(e,t,r){if(!(0,d.A)(e))throw new u.JWSInvalid("Flattened JWS must be an object");if(void 0===e.protected&&void 0===e.header)throw new u.JWSInvalid('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==e.protected&&"string"!=typeof e.protected)throw new u.JWSInvalid("JWS Protected Header incorrect type");if(void 0===e.payload)throw new u.JWSInvalid("JWS Payload missing");if("string"!=typeof e.signature)throw new u.JWSInvalid("JWS Signature missing or incorrect type");if(void 0!==e.header&&!(0,d.A)(e.header))throw new u.JWSInvalid("JWS Unprotected Header incorrect type");let i={};if(e.protected)try{const t=(0,n.D4)(e.protected);i=JSON.parse(l.D0.decode(t))}catch{throw new u.JWSInvalid("JWS Protected Header is invalid")}if(!(0,h.A)(i,e.header))throw new u.JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const o={...i,...e.header};let s=!0;if((0,p.A)(u.JWSInvalid,new Map([["b64",!0]]),r?.crit,i,o).has("b64")&&(s=i.b64,"boolean"!=typeof s))throw new u.JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:a}=o;if("string"!=typeof a||!a)throw new u.JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');const v=r&&(0,g.A)("algorithms",r.algorithms);if(v&&!v.has(a))throw new u.JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');if(s){if("string"!=typeof e.payload)throw new u.JWSInvalid("JWS Payload must be a string")}else if("string"!=typeof e.payload&&!(e.payload instanceof Uint8Array))throw new u.JWSInvalid("JWS Payload must be a string or an Uint8Array instance");let w=!1;"function"==typeof t?(t=await t(i,e),w=!0,(0,f.I)(a,t,"verify"),(0,y.ll)(t)&&(t=await(0,m.Og)(t,a))):(0,f.I)(a,t,"verify");const b=(0,l.xW)(l.Rd.encode(e.protected??""),l.Rd.encode("."),"string"==typeof e.payload?l.Rd.encode(e.payload):e.payload);let _;try{_=(0,n.D4)(e.signature)}catch{throw new u.JWSInvalid("Failed to base64url decode the signature")}if(!await c(a,t,_,b))throw new u.JWSSignatureVerificationFailed;let S;if(s)try{S=(0,n.D4)(e.payload)}catch{throw new u.JWSInvalid("Failed to base64url decode the payload")}else S="string"==typeof e.payload?l.Rd.encode(e.payload):e.payload;const E={payload:S};return void 0!==e.protected&&(E.protectedHeader=i),void 0!==e.header&&(E.unprotectedHeader=e.header),w?{...E,key:t}:E}},6769:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ACL_LINK=void 0,t.createAclLogic=function(e){const r=i.ns;function o(e,t,i,o={}){const s=o.public||[],a=(0,n.graph)(),c=(0,n.Namespace)("http://www.w3.org/ns/auth/acl#");let u=a.sym(`${i}#a1`);const l=a.sym(i),h=a.sym(e);if(a.add(u,r.rdf("type"),c("Authorization"),l),a.add(u,c("accessTo"),h,l),o.defaultForNew&&a.add(u,c("default"),h,l),a.add(u,c("agent"),t,l),a.add(u,c("mode"),c("Read"),l),a.add(u,c("mode"),c("Write"),l),a.add(u,c("mode"),c("Control"),l),s.length){u=a.sym(`${i}#a2`),a.add(u,r.rdf("type"),c("Authorization"),l),a.add(u,c("accessTo"),h,l),a.add(u,c("agentClass"),r.foaf("Agent"),l);for(let e=0;e<s.length;e++)a.add(u,c("mode"),c(s[e]),l)}return(0,n.serialize)(l,a,i)}return{findAclDocUrl:async function(r){await e.fetcher.load(r);const n=e.any(r,t.ACL_LINK);if(!n)throw new Error(`No ACL link discovered for ${r}`);return n.value},setACLUserPublic:function(r,n,i){const s=e.any(e.sym(r),t.ACL_LINK);return Promise.resolve().then(()=>s||function(r){const n=e.fetcher;if(!n)throw new Error("Cannot fetch ACL rel, store has no fetcher");return n.load(r).then(n=>{if(!n.ok)throw new Error("fetchACLRel: While loading:"+n.error);const i=e.any(e.sym(r),t.ACL_LINK);if(!i)throw new Error("fetchACLRel: No Link rel=ACL header for "+r);return i})}(r).catch(e=>{throw new Error(`Error fetching rel=ACL header for ${r}: ${e}`)})).then(t=>{const s=o(r,n,t.uri,i);if(!e.fetcher)throw new Error("Cannot PUT this, store has no fetcher");return e.fetcher.webOperation("PUT",t.uri,{data:s,contentType:"text/turtle"}).then(e=>{if(!e.ok)throw new Error("Error writing ACL text: "+e.error);return t})})},genACLText:o}};const n=r(4090),i=r(6118);t.ACL_LINK=(0,n.sym)("http://www.iana.org/assignments/link-relations/acl")},6848:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.newThing=function(e){return(0,n.sym)(e.uri+"#id"+Date.now())},t.uniqueNodes=function(e){const t=e.map(e=>e.uri),r=new Set(t),i=Array.from(r);return i.map(e=>new n.NamedNode(e))},t.getArchiveUrl=function(e,t){const r=t.getUTCFullYear(),n=("0"+(t.getUTCMonth()+1)).slice(-2),i=("0"+t.getUTCDate()).slice(-2),o=e.split("/"),s=o[o.length-1];return new URL(`./archive/${r}/${n}/${i}/${s}`,e).toString()},t.differentOrigin=function(e){if(!e)return!0;return`${window.location.origin}/`!==new URL(e.value).origin},t.suggestPreferencesFile=function(e){const t=e.uri.replace("/profile/","/").replace("/public/","/"),r=t.split("/").slice(0,-1).join("/")+"/Settings/Preferences.ttl";return(0,n.sym)(r)},t.determineChatContainer=function(e,t){const r=new URL(`IndividualChats/${new URL(e.value).host}/`,t.value).toString();return new n.NamedNode(r)};const n=r(4090)},6957:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});const n=86400,i=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,o=e=>{const t=i.exec(e);if(!t||t[4]&&t[1])throw new TypeError("Invalid time period format");const r=parseFloat(t[2]);let o;switch(t[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":o=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":o=Math.round(60*r);break;case"hour":case"hours":case"hr":case"hrs":case"h":o=Math.round(3600*r);break;case"day":case"days":case"d":o=Math.round(r*n);break;case"week":case"weeks":case"w":o=Math.round(604800*r);break;default:o=Math.round(31557600*r)}return"-"===t[1]||"ago"===t[4]?-o:o}},7007:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}g(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&g(e,"error",t,r)}(e,i,{once:!0})})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var i,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=c(e))>0&&s.length>i&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=l.bind(n);return i.listener=r,n.wrapFn=i,i}function d(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):p(i,i.length)}function f(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function g(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function i(o){n.once&&e.removeEventListener(t,i),r(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var u=c.length,l=p(c,u);for(r=0;r<u;++r)n(l[r],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,h(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,h(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,n,i,o,s;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return d(this,e,!0)},o.prototype.rawListeners=function(e){return d(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},7248:(e,t,r)=>{"use strict";r.d(t,{P:()=>a});var n=r(2609),i=r(7493),o=r(1476),s=r(3085);class a extends s.G{setProtectedHeader(e){return this._protectedHeader=e,this}async sign(e,t){const r=new n.T(o.Rd.encode(JSON.stringify(this._payload)));if(r.setProtectedHeader(this._protectedHeader),Array.isArray(this._protectedHeader?.crit)&&this._protectedHeader.crit.includes("b64")&&!1===this._protectedHeader.b64)throw new i.JWTInvalid("JWTs MUST NOT use unencoded payload");return r.sign(e,t)}}},7307:(e,t,r)=>{"use strict";r.d(t,{T:()=>i});var n=r(8793);async function i(e,t){return(0,n.T)(e,t)}},7493:(e,t,r)=>{"use strict";r.r(t),r.d(t,{JOSEAlgNotAllowed:()=>s,JOSEError:()=>n,JOSENotSupported:()=>a,JWEDecryptionFailed:()=>c,JWEInvalid:()=>u,JWKInvalid:()=>d,JWKSInvalid:()=>f,JWKSMultipleMatchingKeys:()=>g,JWKSNoMatchingKey:()=>p,JWKSTimeout:()=>y,JWSInvalid:()=>l,JWSSignatureVerificationFailed:()=>m,JWTClaimValidationFailed:()=>i,JWTExpired:()=>o,JWTInvalid:()=>h});class n extends Error{constructor(e,t){super(e,t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}n.code="ERR_JOSE_GENERIC";class i extends n{constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=r,this.reason=n,this.payload=t}}i.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class o extends n{constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}}),this.code="ERR_JWT_EXPIRED",this.claim=r,this.reason=n,this.payload=t}}o.code="ERR_JWT_EXPIRED";class s extends n{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}s.code="ERR_JOSE_ALG_NOT_ALLOWED";class a extends n{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}}a.code="ERR_JOSE_NOT_SUPPORTED";class c extends n{constructor(e="decryption operation failed",t){super(e,t),this.code="ERR_JWE_DECRYPTION_FAILED"}}c.code="ERR_JWE_DECRYPTION_FAILED";class u extends n{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}}u.code="ERR_JWE_INVALID";class l extends n{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}}l.code="ERR_JWS_INVALID";class h extends n{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}}h.code="ERR_JWT_INVALID";class d extends n{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}}d.code="ERR_JWK_INVALID";class f extends n{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}}f.code="ERR_JWKS_INVALID";class p extends n{constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t),this.code="ERR_JWKS_NO_MATCHING_KEY"}}p.code="ERR_JWKS_NO_MATCHING_KEY";class g extends n{constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}Symbol.asyncIterator,g.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class y extends n{constructor(e="request timed out",t){super(e,t),this.code="ERR_JWKS_TIMEOUT"}}y.code="ERR_JWKS_TIMEOUT";class m extends n{constructor(e="signature verification failed",t){super(e,t),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}m.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"},7526:(e,t)=>{"use strict";t.byteLength=function(e){var t=a(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,o=a(e),s=o[0],c=o[1],u=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,c)),l=0,h=c>0?s-4:s;for(r=0;r<h;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],u[l++]=t>>16&255,u[l++]=t>>8&255,u[l++]=255&t;2===c&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[l++]=255&t);1===c&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t);return u},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=16383,a=0,c=n-i;a<c;a+=s)o.push(u(e,a,a+s>c?c:a+s));1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function c(e){return r[e>>18&63]+r[e>>12&63]+r[e>>6&63]+r[63&e]}function u(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),i.push(c(n));return i.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},7813:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createInboxLogic=function(e,t,r,i,o){return{createInboxFor:async function(e,n){const o=await t.loadMe(),s=`${(await t.getPodRoot(o)).value}p2p-inboxes/${encodeURIComponent(n)}/`;return await i.createContainer(s),await r.setSinglePeerAccess({ownerWebId:o.value,peerWebId:e,accessToModes:"acl:Append",target:s}),s},getNewMessages:async function(e){e||(e=await t.loadMe());const r=await t.getMainInbox(e);return(await i.getContainerMembers(r)).filter(e=>!i.isContainer(e))},markAsRead:async function(t,r){const i=await e.fetcher._fetch(t);if(200!==i.status)throw new Error(`Not OK! ${t}`);const o=(0,n.getArchiveUrl)(t,r),s={method:"PUT",body:await i.text(),headers:[["Content-Type",i.headers.get("Content-Type")||"application/octet-stream"]]};"2"===(await e.fetcher._fetch(o,s)).status.toString()[0]&&await e.fetcher._fetch(t,{method:"DELETE"})}}};const n=r(6848)},7991:(e,t,r)=>{"use strict";r.d(t,{A:()=>n,R:()=>i});const n=crypto,i=e=>e instanceof CryptoKey},8057:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(7991);const i=n.A.getRandomValues.bind(n.A)},8134:(e,t,r)=>{"use strict";r.r(t),r.d(t,{CordovaIFrameNavigator:()=>n.CordovaIFrameNavigator,CordovaPopupNavigator:()=>n.CordovaPopupNavigator,InMemoryWebStorage:()=>n.InMemoryWebStorage,Log:()=>n.Log,OidcClient:()=>n.OidcClient,SessionMonitor:()=>n.SessionMonitor,User:()=>n.User,UserManager:()=>n.UserManager,Version:()=>n.Version,WebStorageStateStore:()=>n.WebStorageStateStore,clearOidcPersistentStorage:()=>I,getTokens:()=>x,normalizeCallbackUrl:()=>k,refresh:()=>F,registerClient:()=>S});var n=r(6516),i=r(9380),o=r(3584),s=r(7248),a=r(7307),c=r(5130);const u={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let l;const h=new Uint8Array(16);const d=[];for(let e=0;e<256;++e)d.push((e+256).toString(16).slice(1));function f(e,t=0){return(d[e[t+0]]+d[e[t+1]]+d[e[t+2]]+d[e[t+3]]+"-"+d[e[t+4]]+d[e[t+5]]+"-"+d[e[t+6]]+d[e[t+7]]+"-"+d[e[t+8]]+d[e[t+9]]+"-"+d[e[t+10]]+d[e[t+11]]+d[e[t+12]]+d[e[t+13]]+d[e[t+14]]+d[e[t+15]]).toLowerCase()}const p=function(e,t,r){if(u.randomUUID&&!t&&!e)return u.randomUUID();const n=(e=e||{}).random??e.rng?.()??function(){if(!l){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");l=crypto.getRandomValues.bind(crypto)}return l(h)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){if((r=r||0)<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=n[e];return t}return f(n)},g=["ES256","RS256"];async function y(e,t,r,n){let s,a;try{const{payload:a}=await(0,i.V)(e,(0,o.RD)(new URL(t)),{issuer:r,audience:n});s=a}catch(e){throw new Error(`Token verification failed: ${e.stack}`)}if("string"==typeof s.azp&&(a=s.azp),"string"==typeof s.webid)return{webId:s.webid,clientId:a};if("string"!=typeof s.sub)throw new Error(`The token ${JSON.stringify(s)} is invalid: it has no 'webid' claim and no 'sub' claim.`);try{return new URL(s.sub),{webId:s.sub,clientId:a}}catch(e){throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${s.sub}] is invalid as a URL - error [${e}].`)}}Error;Error;class m extends Error{missingFields;constructor(e){super(`Invalid response from OIDC provider: missing fields ${e}`),this.missingFields=e}}class v extends Error{error;errorDescription;constructor(e,t,r){super(e),this.error=t,this.errorDescription=r}}function w(e){const t=new URL(e);return new URL(t.pathname,t.origin).toString()}async function b(e,t,r){return new s.P({htu:w(e),htm:t.toUpperCase(),jti:p()}).setProtectedHeader({alg:g[0],jwk:r.publicKey,typ:"dpop+jwt"}).setIssuedAt().sign(r.privateKey,{})}function _(e,t){if("string"!=typeof e.client_id)throw new Error(`Dynamic client registration failed: no client_id has been found on ${JSON.stringify(e)}`);if(t.redirectUrl&&function(e){return Array.isArray(e.redirect_uris)&&e.redirect_uris.every(e=>"string"==typeof e)}(e)&&e.redirect_uris[0]!==t.redirectUrl.toString())throw new Error(`Dynamic client registration failed: the returned redirect URIs ${JSON.stringify(e.redirect_uris)} don't match the provided ${JSON.stringify([t.redirectUrl.toString()])}`);return!0}async function S(e,t){if(!t.registrationEndpoint)throw new Error("Dynamic Registration could not be completed because the issuer has no registration endpoint.");if(!Array.isArray(t.idTokenSigningAlgValuesSupported))throw new Error("The OIDC issuer discovery profile is missing the 'id_token_signing_alg_values_supported' value, which is mandatory.");const r=(n=t.idTokenSigningAlgValuesSupported,g.find(e=>n.includes(e))??null);var n;const i={client_name:e.clientName,application_type:"web",redirect_uris:[e.redirectUrl?.toString()],subject_type:"public",token_endpoint_auth_method:"client_secret_basic",id_token_signed_response_alg:r,grant_types:["authorization_code","refresh_token"]},o=await fetch(t.registrationEndpoint.toString(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(o.ok){const t=await o.json();return _(t,e),{clientId:t.client_id,clientSecret:t.client_secret,expiresAt:t.client_secret_expires_at,idTokenSignedResponseAlg:t.id_token_signed_response_alg,clientType:"dynamic"}}throw 400===o.status&&function(e,t){if("invalid_redirect_uri"===e.error)throw new Error(`Dynamic client registration failed: the provided redirect uri [${t.redirectUrl?.toString()}] is invalid - ${e.error_description??""}`);if("invalid_client_metadata"===e.error)throw new Error(`Dynamic client registration failed: the provided client metadata ${JSON.stringify(t)} is invalid - ${e.error_description??""}`);throw new Error(`Dynamic client registration failed: ${e.error} - ${e.error_description??""}`)}(await o.json(),e),new Error(`Dynamic client registration failed: the server returned ${o.status} ${o.statusText} - ${await o.text()}`)}function E(e){return void 0!==e.error_description&&"string"==typeof e.error_description}function A(e,t){if(void 0!==(r=e).error&&"string"==typeof r.error)throw new v(`Token endpoint returned error [${e.error}]${E(e)?`: ${e.error_description}`:""}${function(e){return void 0!==e.error_uri&&"string"==typeof e.error_uri}(e)?` (see ${e.error_uri})`:""}`,e.error,E(e)?e.error_description:void 0);var r;if(!function(e){return void 0!==e.access_token&&"string"==typeof e.access_token}(e))throw new m(["access_token"]);if(!function(e){return void 0!==e.id_token&&"string"==typeof e.id_token}(e))throw new m(["id_token"]);if(!function(e){return void 0!==e.token_type&&"string"==typeof e.token_type}(e))throw new m(["token_type"]);if(!function(e){return void 0===e.expires_in||"number"==typeof e.expires_in}(e))throw new m(["expires_in"]);if(!t&&"bearer"!==e.token_type.toLowerCase())throw new Error(`Invalid token endpoint response: requested a [Bearer] token, but got a 'token_type' value of [${e.token_type}].`);return e}async function x(e,t,r,n){!function(e,t){if(t.grantType&&(!e.grantTypesSupported||!e.grantTypesSupported.includes(t.grantType)))throw new Error(`The issuer [${e.issuer}] does not support the [${t.grantType}] grant`);if(!e.tokenEndpoint)throw new Error(`This issuer [${e.issuer}] does not have a token endpoint`)}(e,r);const i={"content-type":"application/x-www-form-urlencoded"};let o;n&&(o=await async function(){const{privateKey:e,publicKey:t}=await(0,a.T)(g[0]),r={privateKey:e,publicKey:await(0,c.JU)(t)};return[r.publicKey.alg]=g,r}(),i.DPoP=await b(e.tokenEndpoint,"POST",o)),t.clientSecret&&(i.Authorization=`Basic ${btoa(`${t.clientId}:${t.clientSecret}`)}`);const s={grant_type:r.grantType,redirect_uri:r.redirectUrl,code:r.code,code_verifier:r.codeVerifier,client_id:t.clientId},u={method:"POST",headers:i,body:new URLSearchParams(s).toString()},l=await fetch(e.tokenEndpoint,u),h=A(await l.json(),n),{webId:d,clientId:f}=await y(h.id_token,e.jwksUri,e.issuer,t.clientId);return{accessToken:h.access_token,idToken:h.id_token,refreshToken:(p=h,void 0!==p.refresh_token&&"string"==typeof p.refresh_token?h.refresh_token:void 0),webId:d,clientId:f,dpopKey:o,expiresIn:h.expires_in};var p}const T=e=>{try{return new URL(e),!0}catch{return!1}};async function F(e,t,r,n){if(void 0===r.clientId)throw new Error("No client ID available when trying to refresh the access token.");const i={grant_type:"refresh_token",refresh_token:e};let o={};void 0!==n&&(o={DPoP:await b(t.tokenEndpoint,"POST",n)});let s={};void 0!==r.clientSecret?s={Authorization:`Basic ${btoa(`${r.clientId}:${r.clientSecret}`)}`}:T(r.clientId)&&(i.client_id=r.clientId);const a=await fetch(t.tokenEndpoint,{method:"POST",body:new URLSearchParams(i).toString(),headers:{...o,...s,"Content-Type":"application/x-www-form-urlencoded"}});let c;try{c=await a.json()}catch(e){throw new Error(`The token endpoint of issuer ${t.issuer} returned a malformed response.`)}const u=A(c,void 0!==n),{webId:l}=await y(u.id_token,t.jwksUri,t.issuer,r.clientId);return{accessToken:u.access_token,idToken:u.id_token,refreshToken:"string"==typeof u.refresh_token?u.refresh_token:void 0,webId:l,dpopKey:n,expiresIn:u.expires_in}}function k(e){const t=function(e){const t=new URL(e);return t.searchParams.delete("state"),t.searchParams.delete("code"),t.searchParams.delete("error"),t.searchParams.delete("error_description"),t.searchParams.delete("iss"),t}(e);return t.hash="",e.includes(`${t.origin}/`)?t.href:`${t.origin}${t.href.substring(t.origin.length+1)}`}async function I(){const e=new n.OidcClient({response_mode:"query"});await e.clearStaleState(new n.WebStorageStateStore({}));const t=window.localStorage,r=[];for(let e=0;e<=t.length;e+=1){const n=t.key(e);n&&(n.match(/^oidc\..+$/)||n.match(/^solidClientAuthenticationUser:.+$/))&&r.push(n)}r.forEach(e=>t.removeItem(e))}},8278:(e,t,r)=>{"use strict";r.d(t,{Lf:()=>l,Mh:()=>u,Og:()=>h,jU:()=>c});var n=r(1436),i=r(5141),o=r(1542),s=r(7493),a=r(149);async function c(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PUBLIC KEY-----"))throw new TypeError('"spki" must be SPKI formatted string');return(0,i.sc)(e,t,r)}async function u(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN CERTIFICATE-----"))throw new TypeError('"x509" must be X.509 formatted string');return(0,i.zp)(e,t,r)}async function l(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PRIVATE KEY-----"))throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return(0,i.IG)(e,t,r)}async function h(e,t){if(!(0,a.A)(e))throw new TypeError("JWK must be an object");switch(t||(t=e.alg),e.kty){case"oct":if("string"!=typeof e.k||!e.k)throw new TypeError('missing "k" (Key Value) Parameter value');return(0,n.D4)(e.k);case"RSA":if("oth"in e&&void 0!==e.oth)throw new s.JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return(0,o.A)({...e,alg:t});default:throw new s.JOSENotSupported('Unsupported "kty" (Key Type) Parameter value')}}},8286:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(3779),i=r(2291),o=r(6011);t.default=function(e,t,r){if(n.default.randomUUID&&!t&&!e)return n.default.randomUUID();const s=(e=e||{}).random??e.rng?.()??(0,i.default)();if(s.length<16)throw new Error("Random bytes length must be >= 16");if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t){if((r=r||0)<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=s[e];return t}return(0,o.unsafeStringify)(s)}},8287:(e,t,r)=>{"use strict";
|
|
34
|
-
/*!
|
|
35
|
-
* The buffer module from node.js, for the browser.
|
|
36
|
-
*
|
|
37
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
38
|
-
* @license MIT
|
|
39
|
-
*/
|
|
40
|
-
const n=r(7526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=c,t.IS=50;const s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return u(e,t,r)}function u(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|g(e,t);let n=a(r);const i=n.write(e,t);i!==r&&(n=n.slice(0,i));return n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(G(e,Uint8Array)){const t=new Uint8Array(e);return f(t.buffer,t.byteOffset,t.byteLength)}return d(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(G(e,ArrayBuffer)||e&&G(e.buffer,ArrayBuffer))return f(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(G(e,SharedArrayBuffer)||e&&G(e.buffer,SharedArrayBuffer)))return f(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return c.from(n,t,r);const i=function(e){if(c.isBuffer(e)){const t=0|p(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}if(void 0!==e.length)return"number"!=typeof e.length||X(e.length)?a(0):d(e);if("Buffer"===e.type&&Array.isArray(e.data))return d(e.data)}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return l(e),a(e<0?0:0|p(e))}function d(e){const t=e.length<0?0:0|p(e.length),r=a(t);for(let n=0;n<t;n+=1)r[n]=255&e[n];return r}function f(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(n,c.prototype),n}function p(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function g(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||G(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return $(e).length;default:if(i)return n?-1:V(e).length;t=(""+t).toLowerCase(),i=!0}}function y(e,t,r){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return k(this,t,r);case"latin1":case"binary":return I(this,t,r);case"base64":return x(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function m(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function v(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),X(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:w(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):w(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function w(e,t,r,n,i){let o,s=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){let n=-1;for(o=r;o<a;o++)if(u(e,o)===u(t,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===c)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(r+c>a&&(r=a-c),o=r;o>=0;o--){let r=!0;for(let n=0;n<c;n++)if(u(e,o+n)!==u(t,n)){r=!1;break}if(r)return o}return-1}function b(e,t,r,n){r=Number(r)||0;const i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=t.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(t.substr(2*s,2),16);if(X(n))return s;e[r+s]=n}return s}function _(e,t,r,n){return z(V(t,e.length-r),e,r,n)}function S(e,t,r,n){return z(function(e){const t=[];for(let r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function E(e,t,r,n){return z($(t),e,r,n)}function A(e,t,r,n){return z(function(e,t){let r,n,i;const o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function x(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);const n=[];let i=t;for(;i<r;){const t=e[i];let o=null,s=t>239?4:t>223?3:t>191?2:1;if(i+s<=r){let r,n,a,c;switch(s){case 1:t<128&&(o=t);break;case 2:r=e[i+1],128==(192&r)&&(c=(31&t)<<6|63&r,c>127&&(o=c));break;case 3:r=e[i+1],n=e[i+2],128==(192&r)&&128==(192&n)&&(c=(15&t)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=e[i+1],n=e[i+2],a=e[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&t)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(e){const t=e.length;if(t<=F)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=F));return r}(n)}c.TYPED_ARRAY_SUPPORT=function(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),c.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}}),c.poolSize=8192,c.from=function(e,t,r){return u(e,t,r)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array),c.alloc=function(e,t,r){return function(e,t,r){return l(e),e<=0?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)}(e,t,r)},c.allocUnsafe=function(e){return h(e)},c.allocUnsafeSlow=function(e){return h(e)},c.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==c.prototype},c.compare=function(e,t){if(G(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),G(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,n=t.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);let r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;const n=c.allocUnsafe(t);let i=0;for(r=0;r<e.length;++r){let t=e[r];if(G(t,Uint8Array))i+t.length>n.length?(c.isBuffer(t)||(t=c.from(t)),t.copy(n,i)):Uint8Array.prototype.set.call(n,t,i);else{if(!c.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(n,i)}i+=t.length}return n},c.byteLength=g,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)m(this,t,t+1);return this},c.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)m(this,t,t+3),m(this,t+1,t+2);return this},c.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},c.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?T(this,0,e):y.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){let e="";const r=t.IS;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(e,t,r,n,i){if(G(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0);const a=Math.min(o,s),u=this.slice(n,i),l=e.slice(t,r);for(let e=0;e<a;++e)if(u[e]!==l[e]){o=u[e],s=l[e];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},c.prototype.indexOf=function(e,t,r){return v(this,e,t,r,!0)},c.prototype.lastIndexOf=function(e,t,r){return v(this,e,t,r,!1)},c.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return _(this,e,t,r);case"ascii":case"latin1":case"binary":return S(this,e,t,r);case"base64":return E(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const F=4096;function k(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function I(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function C(e,t,r){const n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=t;n<r;++n)i+=Y[e[n]];return i}function N(e,t,r){const n=e.slice(t,r);let i="";for(let e=0;e<n.length-1;e+=2)i+=String.fromCharCode(n[e]+256*n[e+1]);return i}function R(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,r,n,i,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function O(e,t,r,n,i){q(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,r}function D(e,t,r,n,i){q(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o>>=8,e[r+6]=o,o>>=8,e[r+5]=o,o>>=8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s>>=8,e[r+2]=s,s>>=8,e[r+1]=s,s>>=8,e[r]=s,r+8}function U(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(e,t,r,n,o){return t=+t,r>>>=0,o||U(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function j(e,t,r,n,o){return t=+t,r>>>=0,o||U(e,0,r,8),i.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);const n=this.subarray(e,t);return Object.setPrototypeOf(n,c.prototype),n},c.prototype.readUintLE=c.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||R(e,t,this.length);let n=this[e],i=1,o=0;for(;++o<t&&(i*=256);)n+=this[e+o]*i;return n},c.prototype.readUintBE=c.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||R(e,t,this.length);let n=this[e+--t],i=1;for(;t>0&&(i*=256);)n+=this[e+--t]*i;return n},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||R(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||R(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||R(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readBigUInt64LE=Q(function(e){K(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||W(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,i=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),c.prototype.readBigUInt64BE=Q(function(e){K(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||W(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],i=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)}),c.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||R(e,t,this.length);let n=this[e],i=1,o=0;for(;++o<t&&(i*=256);)n+=this[e+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||R(e,t,this.length);let n=t,i=1,o=this[e+--n];for(;n>0&&(i*=256);)o+=this[e+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return e>>>=0,t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||R(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){e>>>=0,t||R(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readBigInt64LE=Q(function(e){K(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||W(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)}),c.prototype.readBigInt64BE=Q(function(e){K(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||W(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+r)}),c.prototype.readFloatLE=function(e,t){return e>>>=0,t||R(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||R(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||R(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||R(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){P(this,e,t,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){P(this,e,t,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigUInt64LE=Q(function(e,t=0){return O(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=Q(function(e,t=0){return D(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);P(this,e,t,r,n-1,-n)}let i=0,o=1,s=0;for(this[t]=255&e;++i<r&&(o*=256);)e<0&&0===s&&0!==this[t+i-1]&&(s=1),this[t+i]=(e/o|0)-s&255;return t+r},c.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);P(this,e,t,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/o|0)-s&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigInt64LE=Q(function(e,t=0){return O(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=Q(function(e,t=0){return D(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeFloatLE=function(e,t,r){return L(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return L(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return j(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return j(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);const i=n-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),i},c.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){const t=e.charCodeAt(0);("utf8"===n&&t<128||"latin1"===n)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;let i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{const o=c.isBuffer(e)?e:c.from(e,n),s=o.length;if(0===s)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=o[i%s]}return this};const M={};function H(e,t,r){M[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function B(e){let t="",r=e.length;const n="-"===e[0]?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function q(e,t,r,n,i,o){if(e>r||e<t){const n="bigint"==typeof t?"n":"";let i;throw i=o>3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${t}${n} and <= ${r}${n}`,new M.ERR_OUT_OF_RANGE("value",i,e)}!function(e,t,r){K(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||W(t,e.length-(r+1))}(n,i,o)}function K(e,t){if("number"!=typeof e)throw new M.ERR_INVALID_ARG_TYPE(t,"number",e)}function W(e,t,r){if(Math.floor(e)!==e)throw K(e,r),new M.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new M.ERR_BUFFER_OUT_OF_BOUNDS;throw new M.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}H("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),H("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),H("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=B(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=B(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);const J=/[^+/0-9A-Za-z-_]/g;function V(e,t){let r;t=t||1/0;const n=e.length;let i=null;const o=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function $(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(J,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function z(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function G(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function X(e){return e!=e}const Y=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t}();function Q(e){return"undefined"==typeof BigInt?Z:e}function Z(){throw new Error("BigInt not supported")}},8793:(e,t,r)=>{"use strict";r.d(t,{K:()=>s,T:()=>c});var n=r(7991),i=r(7493),o=r(8057);async function s(e,t){let r,s,a;switch(e){case"HS256":case"HS384":case"HS512":r=parseInt(e.slice(-3),10),s={name:"HMAC",hash:`SHA-${r}`,length:r},a=["sign","verify"];break;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r=parseInt(e.slice(-3),10),(0,o.A)(new Uint8Array(r>>3));case"A128KW":case"A192KW":case"A256KW":r=parseInt(e.slice(1,4),10),s={name:"AES-KW",length:r},a=["wrapKey","unwrapKey"];break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":case"A128GCM":case"A192GCM":case"A256GCM":r=parseInt(e.slice(1,4),10),s={name:"AES-GCM",length:r},a=["encrypt","decrypt"];break;default:throw new i.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return n.A.subtle.generateKey(s,t?.extractable??!1,a)}function a(e){const t=e?.modulusLength??2048;if("number"!=typeof t||t<2048)throw new i.JOSENotSupported("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return t}async function c(e,t){let r,o;switch(e){case"PS256":case"PS384":case"PS512":r={name:"RSA-PSS",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:a(t)},o=["sign","verify"];break;case"RS256":case"RS384":case"RS512":r={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:a(t)},o=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":r={name:"RSA-OAEP",hash:`SHA-${parseInt(e.slice(-3),10)||1}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:a(t)},o=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":r={name:"ECDSA",namedCurve:"P-256"},o=["sign","verify"];break;case"ES384":r={name:"ECDSA",namedCurve:"P-384"},o=["sign","verify"];break;case"ES512":r={name:"ECDSA",namedCurve:"P-521"},o=["sign","verify"];break;case"Ed25519":r={name:"Ed25519"},o=["sign","verify"];break;case"EdDSA":{o=["sign","verify"];const e=t?.crv??"Ed25519";switch(e){case"Ed25519":case"Ed448":r={name:e};break;default:throw new i.JOSENotSupported("Invalid or unsupported crv option provided")}break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{o=["deriveKey","deriveBits"];const e=t?.crv??"P-256";switch(e){case"P-256":case"P-384":case"P-521":r={name:"ECDH",namedCurve:e};break;case"X25519":case"X448":r={name:e};break;default:throw new i.JOSENotSupported("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448")}break}default:throw new i.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return n.A.subtle.generateKey(r,t?.extractable??!1,o)}},8858:(e,t,r)=>{"use strict";r.d(t,{A:()=>u,I:()=>l});var n=r(1575),i=r(5994),o=r(5500);const s=e=>e?.[Symbol.toStringTag],a=(e,t,r)=>{if(void 0!==t.use&&"sig"!==t.use)throw new TypeError("Invalid key for this operation, when present its use must be sig");if(void 0!==t.key_ops&&!0!==t.key_ops.includes?.(r))throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${r}`);if(void 0!==t.alg&&t.alg!==e)throw new TypeError(`Invalid key for this operation, when present its alg must be ${e}`);return!0};function c(e,t,r,c){t.startsWith("HS")||"dir"===t||t.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(t)?((e,t,r,c)=>{if(!(t instanceof Uint8Array)){if(c&&o.ll(t)){if(o.t9(t)&&a(e,t,r))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!(0,i.A)(t))throw new TypeError((0,n.t)(e,t,...i.g,"Uint8Array",c?"JSON Web Key":null));if("secret"!==t.type)throw new TypeError(`${s(t)} instances for symmetric algorithms must be of type "secret"`)}})(t,r,c,e):((e,t,r,c)=>{if(c&&o.ll(t))switch(r){case"sign":if(o.W2(t)&&a(e,t,r))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"verify":if(o.M3(t)&&a(e,t,r))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!(0,i.A)(t))throw new TypeError((0,n.t)(e,t,...i.g,c?"JSON Web Key":null));if("secret"===t.type)throw new TypeError(`${s(t)} instances for asymmetric algorithms must not be of type "secret"`);if("sign"===r&&"public"===t.type)throw new TypeError(`${s(t)} instances for asymmetric algorithm signing must be of type "private"`);if("decrypt"===r&&"public"===t.type)throw new TypeError(`${s(t)} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&"verify"===r&&"private"===t.type)throw new TypeError(`${s(t)} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&"encrypt"===r&&"private"===t.type)throw new TypeError(`${s(t)} instances for asymmetric algorithm encryption must be of type "public"`)})(t,r,c,e)}const u=c.bind(void 0,!1),l=c.bind(void 0,!0)},8936:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(4705);class i{constructor(e){(0,n.A)(this,"termType",void 0),(0,n.A)(this,"classOrder",void 0),(0,n.A)(this,"value",void 0),this.value=e}substitute(e){return this}compareTerm(e){return this.classOrder<e.classOrder?-1:this.classOrder>e.classOrder?1:this.value<e.value?-1:this.value>e.value?1:0}equals(e){return!!e&&(this.termType===e.termType&&this.value===e.value)}hashString(){return this.toCanonical()}sameTerm(e){return this.equals(e)}toCanonical(){return this.toNT()}toNT(){return this.toString()}toNQ(){return this.toNT()}toString(){throw new Error("Node.toString() is abstract - see the subclasses instead")}}(0,n.A)(i,"fromValue",void 0),(0,n.A)(i,"toJS",void 0)},8978:(e,t,r)=>{var n=r(4722);n.DOMImplementation,n.XMLSerializer,t.DOMParser=r(5752).DOMParser},9095:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.authSession=void 0;const n=r(2452);t.authSession=new n.Session},9378:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.log=function(...e){console.log(...e)},t.warn=function(...e){console.warn(...e)},t.error=function(...e){console.error(...e)},t.trace=function(...e){console.trace(...e)}},9380:(e,t,r)=>{"use strict";r.d(t,{V:()=>s});var n=r(5609),i=r(9803),o=r(7493);async function s(e,t,r){const s=await(0,n.B)(e,t,r);if(s.protectedHeader.crit?.includes("b64")&&!1===s.protectedHeader.b64)throw new o.JWTInvalid("JWTs MUST NOT use unencoded payload");const a={payload:(0,i.A)(s.protectedHeader,s.payload,r),protectedHeader:s.protectedHeader};return"function"==typeof t?{...a,key:s.key}:a}},9403:(e,t,r)=>{"use strict";r.d(t,{$Q:()=>i,BR:()=>g,Fn:()=>b,H:()=>E,JG:()=>v,K9:()=>w,Kk:()=>n,MG:()=>p,P2:()=>s,QW:()=>o,S:()=>u,_0:()=>y,bD:()=>l,bM:()=>m,hu:()=>S,i2:()=>d,ic:()=>a,lc:()=>h,ny:()=>f,r0:()=>c,sT:()=>_});const n="NamedNode",i="BlankNode",o="Literal",s="Variable",a="DefaultGraph",c="Collection",u="Empty",l="Graph",h="text/html",d="application/ld+json",f="text/n3",p="application/n3",g="application/nquads",y="application/n-quads",m="application/n-triples",v="application/rdf+xml",w="application/sparql-update",b="application/sparql-update-single-match",_="text/turtle",S="application/x-turtle",E="application/xhtml+xml"},9746:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6697);t.default=function(e){return"string"==typeof e&&n.default.test(e)}},9803:(e,t,r)=>{"use strict";r.d(t,{A:()=>u});var n=r(7493),i=r(1476),o=r(2222),s=r(6957),a=r(149);const c=e=>e.toLowerCase().replace(/^application\//,""),u=(e,t,r={})=>{let u;try{u=JSON.parse(i.D0.decode(t))}catch{}if(!(0,a.A)(u))throw new n.JWTInvalid("JWT Claims Set must be a top-level JSON object");const{typ:l}=r;if(l&&("string"!=typeof e.typ||c(e.typ)!==c(l)))throw new n.JWTClaimValidationFailed('unexpected "typ" JWT header value',u,"typ","check_failed");const{requiredClaims:h=[],issuer:d,subject:f,audience:p,maxTokenAge:g}=r,y=[...h];void 0!==g&&y.push("iat"),void 0!==p&&y.push("aud"),void 0!==f&&y.push("sub"),void 0!==d&&y.push("iss");for(const e of new Set(y.reverse()))if(!(e in u))throw new n.JWTClaimValidationFailed(`missing required "${e}" claim`,u,e,"missing");if(d&&!(Array.isArray(d)?d:[d]).includes(u.iss))throw new n.JWTClaimValidationFailed('unexpected "iss" claim value',u,"iss","check_failed");if(f&&u.sub!==f)throw new n.JWTClaimValidationFailed('unexpected "sub" claim value',u,"sub","check_failed");if(p&&(m=u.aud,v="string"==typeof p?[p]:p,!("string"==typeof m?v.includes(m):Array.isArray(m)&&v.some(Set.prototype.has.bind(new Set(m))))))throw new n.JWTClaimValidationFailed('unexpected "aud" claim value',u,"aud","check_failed");var m,v;let w;switch(typeof r.clockTolerance){case"string":w=(0,s.A)(r.clockTolerance);break;case"number":w=r.clockTolerance;break;case"undefined":w=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:b}=r,_=(0,o.A)(b||new Date);if((void 0!==u.iat||g)&&"number"!=typeof u.iat)throw new n.JWTClaimValidationFailed('"iat" claim must be a number',u,"iat","invalid");if(void 0!==u.nbf){if("number"!=typeof u.nbf)throw new n.JWTClaimValidationFailed('"nbf" claim must be a number',u,"nbf","invalid");if(u.nbf>_+w)throw new n.JWTClaimValidationFailed('"nbf" claim timestamp check failed',u,"nbf","check_failed")}if(void 0!==u.exp){if("number"!=typeof u.exp)throw new n.JWTClaimValidationFailed('"exp" claim must be a number',u,"exp","invalid");if(u.exp<=_-w)throw new n.JWTExpired('"exp" claim timestamp check failed',u,"exp","check_failed")}if(g){const e=_-u.iat;if(e-w>("number"==typeof g?g:(0,s.A)(g)))throw new n.JWTExpired('"iat" claim timestamp check failed (too far in the past)',u,"iat","check_failed");if(e<0-w)throw new n.JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)',u,"iat","check_failed")}return u}},9874:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});const n=(...e)=>{const t=e.filter(Boolean);if(0===t.length||1===t.length)return!0;let r;for(const e of t){const t=Object.keys(e);if(r&&0!==r.size)for(const e of t){if(r.has(e))return!1;r.add(e)}else r=new Set(t)}return!0}}},o={};function s(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={id:e,loaded:!1,exports:{}};return i[e].call(r.exports,r,r.exports,s),r.loaded=!0,r.exports}s.m=i,s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var i=Object.create(null);s.r(i);var o={};e=e||[null,t({}),t([]),t(t)];for(var a=2&n&&r;("object"==typeof a||"function"==typeof a)&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach(e=>o[e]=()=>r[e]);return o.default=()=>r,s.d(i,o),i},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce((t,r)=>(s.f[r](e,t),t),[])),s.u=e=>e+".solid-logic.min.js",s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},n="SolidLogic:",s.l=(e,t,i,o)=>{if(r[e])r[e].push(t);else{var a,c;if(void 0!==i)for(var u=document.getElementsByTagName("script"),l=0;l<u.length;l++){var h=u[l];if(h.getAttribute("src")==e||h.getAttribute("data-webpack")==n+i){a=h;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,s.nc&&a.setAttribute("nonce",s.nc),a.setAttribute("data-webpack",n+i),a.src=e),r[e]=[t];var d=(t,n)=>{a.onerror=a.onload=null,clearTimeout(f);var i=r[e];if(delete r[e],a.parentNode&&a.parentNode.removeChild(a),i&&i.forEach(e=>e(n)),t)return t(n)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=d.bind(null,a.onerror),a.onload=d.bind(null,a.onload),c&&document.head.appendChild(a)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;s.g.importScripts&&(e=s.g.location+"");var t=s.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.p=e})(),(()=>{var e={792:0};s.f.j=(t,r)=>{var n=s.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise((r,i)=>n=e[t]=[r,i]);r.push(n[2]=i);var o=s.p+s.u(t),a=new Error;s.l(o,r=>{if(s.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;a.message="Loading chunk "+t+" failed.\n("+i+": "+o+")",a.name="ChunkLoadError",a.type=i,a.request=o,n[1](a)}},"chunk-"+t,t)}};var t=(t,r)=>{var n,i,[o,a,c]=r,u=0;if(o.some(t=>0!==e[t])){for(n in a)s.o(a,n)&&(s.m[n]=a[n]);if(c)c(s)}for(t&&t(r);u<o.length;u++)i=o[u],s.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunkSolidLogic=this.webpackChunkSolidLogic||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var a={};return(()=>{"use strict";var e=a;Object.defineProperty(e,"__esModule",{value:!0}),e.authSession=e.authn=e.store=e.solidLogicSingleton=e.WebOperationError=e.NotEditableError=e.FetchError=e.NotFoundError=e.SameOriginForbiddenError=e.CrossOriginForbiddenError=e.UnauthorizedError=e.createTypeIndexLogic=e.getSuggestedIssuers=e.appContext=e.offlineTestID=e.ACL_LINK=void 0;const t=s(1781);Object.defineProperty(e,"solidLogicSingleton",{enumerable:!0,get:function(){return t.solidLogicSingleton}});const r=t.solidLogicSingleton.authn;e.authn=r;const n=t.solidLogicSingleton.authn.authSession;e.authSession=n;const i=t.solidLogicSingleton.store;e.store=i;var o=s(6769);Object.defineProperty(e,"ACL_LINK",{enumerable:!0,get:function(){return o.ACL_LINK}});var c=s(2233);Object.defineProperty(e,"offlineTestID",{enumerable:!0,get:function(){return c.offlineTestID}}),Object.defineProperty(e,"appContext",{enumerable:!0,get:function(){return c.appContext}});var u=s(4353);Object.defineProperty(e,"getSuggestedIssuers",{enumerable:!0,get:function(){return u.getSuggestedIssuers}});var l=s(1177);Object.defineProperty(e,"createTypeIndexLogic",{enumerable:!0,get:function(){return l.createTypeIndexLogic}});var h=s(390);Object.defineProperty(e,"UnauthorizedError",{enumerable:!0,get:function(){return h.UnauthorizedError}}),Object.defineProperty(e,"CrossOriginForbiddenError",{enumerable:!0,get:function(){return h.CrossOriginForbiddenError}}),Object.defineProperty(e,"SameOriginForbiddenError",{enumerable:!0,get:function(){return h.SameOriginForbiddenError}}),Object.defineProperty(e,"NotFoundError",{enumerable:!0,get:function(){return h.NotFoundError}}),Object.defineProperty(e,"FetchError",{enumerable:!0,get:function(){return h.FetchError}}),Object.defineProperty(e,"NotEditableError",{enumerable:!0,get:function(){return h.NotEditableError}}),Object.defineProperty(e,"WebOperationError",{enumerable:!0,get:function(){return h.WebOperationError}})})(),a})());
|
|
41
|
-
//# sourceMappingURL=solid-logic.min.js.map
|