UNPKG

rehype-citation

Version:

rehype plugin to add citation and bibliography from bibtex files

1 lines 205 kB
import{parse as e,format as t}from"@citation-js/name";import{parse as r,format as i}from"@citation-js/date";import o from"citeproc";import n from"js-yaml";var a={__proto__:null,currentVersion:function(){return this.log.length},retrieveVersion:function(e=1){if(e<=0||e>this.currentVersion())return null;{const[t,r]=this.log[e-1],i=new this.constructor(JSON.parse(t),JSON.parse(r));return i.log=this.log.slice(0,e),i}},retrieveLastVersion:function(){return this.retrieveVersion(this.currentVersion())},undo:function(e=1){return this.retrieveVersion(this.currentVersion()-e)},save:function(){return this.log.push([JSON.stringify(this.data),JSON.stringify(this._options)]),this}};const s=["real","string"],l=["json","html","string","rtf"],c=["csl","bibtex","bibtxt","citation-*","ris","ndjson"],u=["string","function"];function m(e){if("object"!=typeof e)throw new TypeError("Options not an object!");const{format:t,type:r,style:i,lang:o,append:n,prepend:a}=e;if(t&&!s.includes(t))throw new TypeError(`Option format ("${t}") should be one of: ${s}`);if(r&&!l.includes(r))throw new TypeError(`Option type ("${r}") should be one of: ${l}`);if(i&&!c.includes(i)&&!/^citation/.test(i))throw new TypeError(`Option style ("${i}") should be one of: ${c}`);if(o&&"string"!=typeof o)throw new TypeError("Option lang should be a string, but is a "+typeof o);if(a&&!u.includes(typeof a))throw new TypeError("Option prepend should be a string or a function, but is a "+typeof a);if(n&&!u.includes(typeof n))throw new TypeError("Option append should be a string or a function, but is a "+typeof n);if(/^citation/.test(i)&&"json"===r)throw new Error(`Combination type/style of json/citation-* is not valid: ${r}/${i}`);return!0}var p={__proto__:null,options:function(e,t){return m(e),t&&this.save(),Object.assign(this._options,e),this},defaultOptions:{format:"real",type:"json",style:"csl",lang:"en-US"}};function f(e){switch(e){case void 0:return"Undefined";case null:return"Null";default:return e.constructor.name}}function h(e){switch(typeof e){case"string":return"String";case"object":if(Array.isArray(e))return"Array";if("Object"===f(e))return"SimpleObject";if("Null"!==f(e))return"ComplexObject";default:return"Primitive"}}var d={__proto__:null,typeOf:f,dataTypeOf:h};function g(e,t){if(e._graph){const r=t.findIndex(({type:e})=>"@else/list+object"===e);-1!==r&&t.splice(r+1,0,...e._graph.slice(0,-1))}return e._graph=t,e}function b(e){return delete e._graph,e}var y={__proto__:null,applyGraph:g,removeGraph:b};const v={_output(e,t,r){this._log.push(t,r),this._levels.indexOf(e)<this._levels.indexOf(this.level)||this._console.log(t,...r)},_console:null,_log:[],_levels:["http","debug","unmapped","info","warn","error","silent"],level:"silent"};for(const e of v._levels)v[e]=(t,...r)=>v._output(e,t,r);v._console="function"==typeof console.Console?new console.Console(process.stderr):console;const w={},x={},k={};function T(e,t){switch(t){case"Array":return 0===e.length||e.every(e=>"@csl/object"===j(e))?"@csl/list+object":"@else/list+object";case"SimpleObject":case"ComplexObject":return"@csl/object";default:return"@invalid"}}function O(e=[],t){for(const r of e)if(w[r].predicate(t))return O(w[r].extensions,t)||r}function j(e){const t=h(e);return"Array"===t&&0===e.length?T(e,t):O(x[t],e)||T(e,t)}function E(e,{dataType:t,predicate:r,extends:i}){let o=[];if(e in k&&(o=k[e],delete k[e],v.debug("[core]",`Subclasses "${o}" finally registered to parent type "${e}"`)),w[e]={predicate:r,extensions:o},i){const t=w[i];t?t.extensions.push(e):(k[i]||(k[i]=[]),k[i].push(e),v.debug("[core]",`Subclass "${e}" is waiting on parent type "${i}"`))}else(x[t]||(x[t]=[])).push(e)}function S(e){delete w[e];const t=[...Object.keys(x).map(e=>x[e]),...Object.keys(w).map(e=>w[e].extensions).filter(e=>e.length>0)];t.forEach(t=>{const r=t.indexOf(e);r>-1&&t.splice(r,1)})}const _=/^(?:@(.+?))(?:\/(?:(.+?)\+)?(?:(.+)))?$/;class A{constructor(e){var t,r,i;t=this,i=["String","Array","SimpleObject","ComplexObject","Primitive"],r=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(r="validDataTypes"),r in t?Object.defineProperty(t,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[r]=i,this.data=e}validateDataType(){const e=this.data.dataType;if(e&&!this.validDataTypes.includes(e))throw new RangeError(`dataType was ${e}; expected one of ${this.validDataTypes}`)}validateParseType(){const e=this.data.predicate;if(e&&!(e instanceof RegExp||"function"==typeof e))throw new TypeError(`predicate was ${typeof e}; expected RegExp or function`)}validateTokenList(){const e=this.data.tokenList;if(e&&"object"!=typeof e)throw new TypeError(`tokenList was ${typeof e}; expected object or RegExp`)}validatePropertyConstraint(){const e=this.data.propertyConstraint;if(e&&"object"!=typeof e)throw new TypeError(`propertyConstraint was ${typeof e}; expected array or object`)}validateElementConstraint(){const e=this.data.elementConstraint;if(e&&"string"!=typeof e)throw new TypeError(`elementConstraint was ${typeof e}; expected string`)}validateExtends(){const e=this.data.extends;if(e&&"string"!=typeof e)throw new TypeError(`extends was ${typeof e}; expected string`)}validate(){if(null===this.data||"object"!=typeof this.data)throw new TypeError(`typeParser was ${typeof this.data}; expected object`);this.validateDataType(),this.validateParseType(),this.validateTokenList(),this.validatePropertyConstraint(),this.validateElementConstraint(),this.validateExtends()}parseTokenList(){let e=this.data.tokenList;if(!e)return[];e instanceof RegExp&&(e={token:e});const{token:t,split:r=/\s+/,trim:i=!0,every:o=!0}=e,n=o?"every":"some";return[e=>(e=>i?e.trim():e)(e).split(r)[n](e=>t.test(e))]}parsePropertyConstraint(){return[].concat(this.data.propertyConstraint||[]).map(({props:e,match:t,value:r})=>{switch(e=[].concat(e),t){case"any":case"some":return t=>e.some(e=>e in t&&(!r||r(t[e])));case"none":return t=>!e.some(e=>e in t&&(!r||r(t[e])));default:return t=>e.every(e=>e in t&&(!r||r(t[e])))}})}parseElementConstraint(){const e=this.data.elementConstraint;return e?[t=>t.every(t=>j(t)===e)]:[]}parsePredicate(){return this.data.predicate instanceof RegExp?[this.data.predicate.test.bind(this.data.predicate)]:this.data.predicate?[this.data.predicate]:[]}getCombinedPredicate(){const e=[...this.parsePredicate(),...this.parseTokenList(),...this.parsePropertyConstraint(),...this.parseElementConstraint()];return 0===e.length?()=>!0:1===e.length?e[0]:t=>e.every(e=>e(t))}getDataType(){return this.data.dataType?this.data.dataType:this.data.predicate instanceof RegExp||this.data.tokenList?"String":this.data.elementConstraint?"Array":"Primitive"}get dataType(){return this.getDataType()}get predicate(){return this.getCombinedPredicate()}get extends(){return this.data.extends}}class P{constructor(e,{async:t}={}){this.parser=e,this.async=t}validate(){const e=this.parser;if("function"!=typeof e)throw new TypeError(`parser was ${typeof e}; expected function`)}}class C{constructor(e,t={}){this.format=e,t.parseType&&(this.typeParser=new A(t.parseType)),t.parse&&(this.dataParser=new P(t.parse,{async:!1})),t.parseAsync&&(this.asyncDataParser=new P(t.parseAsync,{async:!0}))}validateFormat(){const e=this.format;if(!_.test(e))throw new TypeError(`format name was "${e}"; didn't match expected pattern`)}validate(){this.validateFormat(),this.typeParser&&this.typeParser.validate(),this.dataParser&&this.dataParser.validate(),this.asyncDataParser&&this.asyncDataParser.validate()}}var R={__proto__:null,TypeParser:A,DataParser:P,FormatParser:C};function I(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function B(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?I(Object(r),!0).forEach(function(t){var i,o,n;i=e,n=r[t],o=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(o=t),o in i?Object.defineProperty(i,o,{value:n,enumerable:!0,configurable:!0,writable:!0}):i[o]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}const L=1,D=2,z=3,U=4,$={article:!0,"article-journal":!0,"article-magazine":!0,"article-newspaper":!0,bill:!0,book:!0,broadcast:!0,chapter:!0,classic:!0,collection:!0,dataset:!0,document:!0,entry:!0,"entry-dictionary":!0,"entry-encyclopedia":!0,event:!0,figure:!0,graphic:!0,hearing:!0,interview:!0,legal_case:!0,legislation:!0,manuscript:!0,map:!0,motion_picture:!0,musical_score:!0,pamphlet:!0,"paper-conference":!0,patent:!0,performance:!0,periodical:!0,personal_communication:!0,post:!0,"post-weblog":!0,regulation:!0,report:!0,review:!0,"review-book":!0,software:!0,song:!0,speech:!0,standard:!0,thesis:!0,treaty:!0,webpage:!0,"journal-article":"article-journal","book-chapter":"chapter","posted-content":"manuscript","proceedings-article":"paper-conference",dissertation:"thesis"},M={author:D,chair:D,"collection-editor":D,compiler:D,composer:D,"container-author":D,contributor:D,curator:D,director:D,editor:D,"editorial-director":D,"executive-producer":D,guest:D,host:D,interviewer:D,illustrator:D,narrator:D,organizer:D,"original-author":D,performer:D,producer:D,"reviewed-author":D,recipient:D,"script-writer":D,"series-creator":D,translator:D,accessed:z,"available-date":z,container:z,"event-date":z,issued:z,"original-date":z,submitted:z,type:U,categories:"object",custom:"object",id:["string","number"],language:"string",journalAbbreviation:"string",shortTitle:"string",abstract:"string",annote:"string",archive:"string",archive_collection:"string",archive_location:"string","archive-place":"string",authority:"string","call-number":"string","chapter-number":"string","citation-number":"string","citation-key":"string","citation-label":"string","collection-number":"string","collection-title":"string","container-title":"string","container-title-short":"string",dimensions:"string",division:"string",DOI:"string",edition:["string","number"],event:"string","event-title":"string","event-place":"string","first-reference-note-number":"string",genre:"string",ISBN:"string",ISSN:"string",issue:["string","number"],jurisdiction:"string",keyword:"string",locator:"string",medium:"string",note:"string",number:["string","number"],"number-of-pages":"string","number-of-volumes":["string","number"],"original-publisher":"string","original-publisher-place":"string","original-title":"string",page:"string","page-first":"string","part-number":["string","number"],"part-title":"string",PMCID:"string",PMID:"string",printing:"string",publisher:"string","publisher-place":"string",references:"string","reviewed-title":"string","reviewed-genre":"string",scale:"string",section:"string",source:"string",status:"string",supplement:["string","number"],title:"string","title-short":"string",URL:"string",version:"string",volume:["string","number"],"volume-title":"string","volume-title-short":"string","year-suffix":"string"};function N(t,r){return"object"==typeof t&&null!==t&&(t.literal||t.given||t.family)?((t.ORCID||t.orcid||t._ORCID)&&(delete(t=B({_orcid:t.ORCID||t.orcid||t._ORCID},t)).ORCID,delete t.orcid,delete t._ORCID),t):r&&"string"==typeof t?e(t):void 0}function q(e,t){return e.every(e=>"number"==typeof e)?e:!t||e.some(e=>isNaN(parseInt(e)))?void 0:e.map(e=>parseInt(e))}function F(e,t){if(e=H("language",e,t),!0===$[e])return e;if(t){if(e in $)return $[e];if(e.toLowerCase()!==e)return F(e.toLowerCase(),t)}}function H(e,t,r){const i=[].concat(M[e]);switch(M[e]){case L:return N(t,r);case D:return function(e,t){if(e instanceof Array){const r=e.map(e=>N(e,t)).filter(Boolean);return r.length?r:void 0}}(t,r);case z:return function(e,t){const r="date-parts";if("object"==typeof e&&null!==e){if(e[r]instanceof Array&&e[r].every(e=>e instanceof Array)){const i=e[r].map(e=>q(e,t)).filter(Boolean);return i.length?B(B({},e),{},{"date-parts":i}):void 0}if(e instanceof Array&&e.every(e=>e[r]instanceof Array)){const i=e.map(e=>q(e[r],t)).filter(Boolean);return i.length?{"date-parts":i}:void 0}if(e[r]instanceof Array){const i=q(e[r],t);return i&&{"date-parts":[i]}}return"literal"in e||"raw"in e?e:void 0}}(t,r);case U:return F(t,r)}if(r){if("string"==typeof t&&i.includes("number")&&!i.includes("string")&&!isNaN(+t))return parseFloat(t);if("number"==typeof t&&i.includes("string")&&!i.includes("number"))return t.toString();if(Array.isArray(t)&&t.length)return H(e,t[0],r)}if(i.includes(typeof t))return t}function G(e,t=!0){return e.map(function(e){const r={};for(const i in e){const o=H(i,e[i],t);void 0!==o&&(r[i]=o)}return r})}var J={__proto__:null,clean:G};function V(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function K(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?V(Object(r),!0).forEach(function(t){var i,o,n;i=e,n=r[t],o=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(o=t),o in i?Object.defineProperty(i,o,{value:n,enumerable:!0,configurable:!0,writable:!0}):i[o]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):V(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function W(e){return Array.isArray(e)?e.map(W):("event"in(e=K({},e))&&(e["event-title"]=e.event,delete e.event),"book"===e.type&&"version"in e&&(e.type="software"),e)}function X(e){return Array.isArray(e)?e.map(X):("event-title"in(e=K({},e))&&(e.event=e["event-title"],delete e["event-title"]),"software"===e.type&&(e.type="book"),e)}function Y(e,t=new Set){if("object"!=typeof e||null===e||e.constructor!==Object&&e.constructor!==Array)return e;if(t.has(e))throw new TypeError("Recursively copying circular structure");let r;if(t.add(e),e.constructor===Array)r=e.map(e=>Y(e,t));else{const i={};for(const r in e)i[r]=Y(e[r],t);r=i}return t.delete(e),r}var Z="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Q(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ee(e){var t={exports:{}};return e(t,t.exports),t.exports}for(var te=[],re=[],ie="undefined"!=typeof Uint8Array?Uint8Array:Array,oe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ne=0;ne<64;++ne)te[ne]=oe[ne],re[oe.charCodeAt(ne)]=ne;function ae(e,t,r){for(var i,o=[],n=t;n<r;n+=3)o.push(te[(i=(e[n]<<16&16711680)+(e[n+1]<<8&65280)+(255&e[n+2]))>>18&63]+te[i>>12&63]+te[i>>6&63]+te[63&i]);return o.join("")}re["-".charCodeAt(0)]=62,re["_".charCodeAt(0)]=63;var se=function(e,t,r,i,o){var n,a,s=8*o-i-1,l=(1<<s)-1,c=l>>1,u=-7,m=r?o-1:0,p=r?-1:1,f=e[t+m];for(m+=p,n=f&(1<<-u)-1,f>>=-u,u+=s;u>0;n=256*n+e[t+m],m+=p,u-=8);for(a=n&(1<<-u)-1,n>>=-u,u+=i;u>0;a=256*a+e[t+m],m+=p,u-=8);if(0===n)n=1-c;else{if(n===l)return a?NaN:Infinity*(f?-1:1);a+=Math.pow(2,i),n-=c}return(f?-1:1)*a*Math.pow(2,n-i)},le=function(e,t,r,i,o,n){var a,s,l,c=8*n-o-1,u=(1<<c)-1,m=u>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:n-1,h=i?1:-1,d=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||Infinity===t?(s=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+m>=1?p/l:p*Math.pow(2,1-m))*l>=2&&(a++,l/=2),a+m>=u?(s=0,a=u):a+m>=1?(s=(t*l-1)*Math.pow(2,o),a+=m):(s=t*Math.pow(2,m-1)*Math.pow(2,o),a=0));o>=8;e[r+f]=255&s,f+=h,s/=256,o-=8);for(a=a<<o|s,c+=o;c>0;e[r+f]=255&a,f+=h,a/=256,c-=8);e[r+f-h]|=128*d},ce=ee(function(e,t){var r="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=n,t.SlowBuffer=function(e){return+e!=e&&(e=0),n.alloc(+e)},t.INSPECT_MAX_BYTES=50;var i=2147483647;function o(e){if(e>i)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,n.prototype),t}function n(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 l(e)}return a(e,t,r)}function a(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!n.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|p(e,t),i=o(r),a=i.write(e,t);return a!==r&&(i=i.slice(0,a)),i}(e,t);if(ArrayBuffer.isView(e))return function(e){if(U(e,Uint8Array)){var t=new Uint8Array(e);return u(t.buffer,t.byteOffset,t.byteLength)}return c(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(U(e,ArrayBuffer)||e&&U(e.buffer,ArrayBuffer))return u(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(U(e,SharedArrayBuffer)||e&&U(e.buffer,SharedArrayBuffer)))return u(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return n.from(i,t,r);var a=function(e){if(n.isBuffer(e)){var t=0|m(e.length),r=o(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||$(e.length)?o(0):c(e):"Buffer"===e.type&&Array.isArray(e.data)?c(e.data):void 0}(e);if(a)return a;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return n.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 s(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 l(e){return s(e),o(e<0?0:0|m(e))}function c(e){for(var t=e.length<0?0:0|m(e.length),r=o(t),i=0;i<t;i+=1)r[i]=255&e[i];return r}function u(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');var i;return i=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(i,n.prototype),i}function m(e){if(e>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|e}function p(e,t){if(n.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||U(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);var r=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return D(e).length;default:if(o)return i?-1:L(e).length;t=(""+t).toLowerCase(),o=!0}}function f(e,t,r){var i=!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 S(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return j(this,t,r);case"latin1":case"binary":return E(this,t,r);case"base64":return k(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function h(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function d(e,t,r,i,o){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),$(r=+r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=n.from(t,i)),n.isBuffer(t))return 0===t.length?-1:g(e,t,r,i,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):g(e,[t],r,i,o);throw new TypeError("val must be string, number or Buffer")}function g(e,t,r,i,o){var n,a=1,s=e.length,l=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;a=2,s/=2,l/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(o){var u=-1;for(n=r;n<s;n++)if(c(e,n)===c(t,-1===u?0:n-u)){if(-1===u&&(u=n),n-u+1===l)return u*a}else-1!==u&&(n-=n-u),u=-1}else for(r+l>s&&(r=s-l),n=r;n>=0;n--){for(var m=!0,p=0;p<l;p++)if(c(e,n+p)!==c(t,p)){m=!1;break}if(m)return n}return-1}function b(e,t,r,i){r=Number(r)||0;var o=e.length-r;i?(i=Number(i))>o&&(i=o):i=o;var n=t.length;i>n/2&&(i=n/2);for(var a=0;a<i;++a){var s=parseInt(t.substr(2*a,2),16);if($(s))return a;e[r+a]=s}return a}function y(e,t,r,i){return z(L(t,e.length-r),e,r,i)}function v(e,t,r,i){return z(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,i)}function w(e,t,r,i){return z(D(t),e,r,i)}function x(e,t,r,i){return z(function(e,t){for(var r,i,o=[],n=0;n<e.length&&!((t-=2)<0);++n)i=(r=e.charCodeAt(n))>>8,o.push(r%256),o.push(i);return o}(t,e.length-r),e,r,i)}function k(e,t,r){return function(e){for(var t,r=e.length,i=r%3,o=[],n=16383,a=0,s=r-i;a<s;a+=n)o.push(ae(e,a,a+n>s?s:a+n));return 1===i?o.push(te[(t=e[r-1])>>2]+te[t<<4&63]+"=="):2===i&&o.push(te[(t=(e[r-2]<<8)+e[r-1])>>10]+te[t>>4&63]+te[t<<2&63]+"="),o.join("")}(0===t&&r===e.length?e:e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);for(var i=[],o=t;o<r;){var n,a,s,l,c=e[o],u=null,m=c>239?4:c>223?3:c>191?2:1;if(o+m<=r)switch(m){case 1:c<128&&(u=c);break;case 2:128==(192&(n=e[o+1]))&&(l=(31&c)<<6|63&n)>127&&(u=l);break;case 3:a=e[o+2],128==(192&(n=e[o+1]))&&128==(192&a)&&(l=(15&c)<<12|(63&n)<<6|63&a)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:a=e[o+2],s=e[o+3],128==(192&(n=e[o+1]))&&128==(192&a)&&128==(192&s)&&(l=(15&c)<<18|(63&n)<<12|(63&a)<<6|63&s)>65535&&l<1114112&&(u=l)}null===u?(u=65533,m=1):u>65535&&(i.push((u-=65536)>>>10&1023|55296),u=56320|1023&u),i.push(u),o+=m}return function(e){var t=e.length;if(t<=O)return String.fromCharCode.apply(String,e);for(var r="",i=0;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=O));return r}(i)}t.kMaxLength=i,(n.TYPED_ARRAY_SUPPORT=function(){try{var 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}}())||"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(n.prototype,"parent",{enumerable:!0,get:function(){if(n.isBuffer(this))return this.buffer}}),Object.defineProperty(n.prototype,"offset",{enumerable:!0,get:function(){if(n.isBuffer(this))return this.byteOffset}}),n.poolSize=8192,n.from=function(e,t,r){return a(e,t,r)},Object.setPrototypeOf(n.prototype,Uint8Array.prototype),Object.setPrototypeOf(n,Uint8Array),n.alloc=function(e,t,r){return function(e,t,r){return s(e),e<=0?o(e):void 0!==t?"string"==typeof r?o(e).fill(t,r):o(e).fill(t):o(e)}(e,t,r)},n.allocUnsafe=function(e){return l(e)},n.allocUnsafeSlow=function(e){return l(e)},n.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==n.prototype},n.compare=function(e,t){if(U(e,Uint8Array)&&(e=n.from(e,e.offset,e.byteLength)),U(t,Uint8Array)&&(t=n.from(t,t.offset,t.byteLength)),!n.isBuffer(e)||!n.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,i=t.length,o=0,a=Math.min(r,i);o<a;++o)if(e[o]!==t[o]){r=e[o],i=t[o];break}return r<i?-1:i<r?1:0},n.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}},n.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return n.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var i=n.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var a=e[r];if(U(a,Uint8Array))o+a.length>i.length?n.from(a).copy(i,o):Uint8Array.prototype.set.call(i,a,o);else{if(!n.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(i,o)}o+=a.length}return i},n.byteLength=p,n.prototype._isBuffer=!0,n.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)h(this,t,t+1);return this},n.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)h(this,t,t+3),h(this,t+1,t+2);return this},n.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)h(this,t,t+7),h(this,t+1,t+6),h(this,t+2,t+5),h(this,t+3,t+4);return this},n.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?T(this,0,e):f.apply(this,arguments)},n.prototype.toLocaleString=n.prototype.toString,n.prototype.equals=function(e){if(!n.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===n.compare(this,e)},n.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},r&&(n.prototype[r]=n.prototype.inspect),n.prototype.compare=function(e,t,r,i,o){if(U(e,Uint8Array)&&(e=n.from(e,e.offset,e.byteLength)),!n.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===i&&(i=0),void 0===o&&(o=this.length),t<0||r>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&t>=r)return 0;if(i>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var a=(o>>>=0)-(i>>>=0),s=(r>>>=0)-(t>>>=0),l=Math.min(a,s),c=this.slice(i,o),u=e.slice(t,r),m=0;m<l;++m)if(c[m]!==u[m]){a=c[m],s=u[m];break}return a<s?-1:s<a?1:0},n.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},n.prototype.indexOf=function(e,t,r){return d(this,e,t,r,!0)},n.prototype.lastIndexOf=function(e,t,r){return d(this,e,t,r,!1)},n.prototype.write=function(e,t,r,i){if(void 0===t)i="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)i=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===i&&(i="utf8")):(i=r,r=void 0)}var o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var n=!1;;)switch(i){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return y(this,e,t,r);case"ascii":case"latin1":case"binary":return v(this,e,t,r);case"base64":return w(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,r);default:if(n)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),n=!0}},n.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var O=4096;function j(e,t,r){var i="";r=Math.min(e.length,r);for(var o=t;o<r;++o)i+=String.fromCharCode(127&e[o]);return i}function E(e,t,r){var i="";r=Math.min(e.length,r);for(var o=t;o<r;++o)i+=String.fromCharCode(e[o]);return i}function S(e,t,r){var i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var o="",n=t;n<r;++n)o+=M[e[n]];return o}function _(e,t,r){for(var i=e.slice(t,r),o="",n=0;n<i.length-1;n+=2)o+=String.fromCharCode(i[n]+256*i[n+1]);return o}function A(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,i,o,a){if(!n.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<a)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}function C(e,t,r,i,o,n){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(e,t,r,i,o){return t=+t,r>>>=0,o||C(e,0,r,4),le(e,t,r,i,23,4),r+4}function I(e,t,r,i,o){return t=+t,r>>>=0,o||C(e,0,r,8),le(e,t,r,i,52,8),r+8}n.prototype.slice=function(e,t){var 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);var i=this.subarray(e,t);return Object.setPrototypeOf(i,n.prototype),i},n.prototype.readUintLE=n.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||A(e,t,this.length);for(var i=this[e],o=1,n=0;++n<t&&(o*=256);)i+=this[e+n]*o;return i},n.prototype.readUintBE=n.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||A(e,t,this.length);for(var i=this[e+--t],o=1;t>0&&(o*=256);)i+=this[e+--t]*o;return i},n.prototype.readUint8=n.prototype.readUInt8=function(e,t){return e>>>=0,t||A(e,1,this.length),this[e]},n.prototype.readUint16LE=n.prototype.readUInt16LE=function(e,t){return e>>>=0,t||A(e,2,this.length),this[e]|this[e+1]<<8},n.prototype.readUint16BE=n.prototype.readUInt16BE=function(e,t){return e>>>=0,t||A(e,2,this.length),this[e]<<8|this[e+1]},n.prototype.readUint32LE=n.prototype.readUInt32LE=function(e,t){return e>>>=0,t||A(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},n.prototype.readUint32BE=n.prototype.readUInt32BE=function(e,t){return e>>>=0,t||A(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},n.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||A(e,t,this.length);for(var i=this[e],o=1,n=0;++n<t&&(o*=256);)i+=this[e+n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},n.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||A(e,t,this.length);for(var i=t,o=1,n=this[e+--i];i>0&&(o*=256);)n+=this[e+--i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},n.prototype.readInt8=function(e,t){return e>>>=0,t||A(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},n.prototype.readInt16LE=function(e,t){e>>>=0,t||A(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt16BE=function(e,t){e>>>=0,t||A(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt32LE=function(e,t){return e>>>=0,t||A(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},n.prototype.readInt32BE=function(e,t){return e>>>=0,t||A(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},n.prototype.readFloatLE=function(e,t){return e>>>=0,t||A(e,4,this.length),se(this,e,!0,23,4)},n.prototype.readFloatBE=function(e,t){return e>>>=0,t||A(e,4,this.length),se(this,e,!1,23,4)},n.prototype.readDoubleLE=function(e,t){return e>>>=0,t||A(e,8,this.length),se(this,e,!0,52,8)},n.prototype.readDoubleBE=function(e,t){return e>>>=0,t||A(e,8,this.length),se(this,e,!1,52,8)},n.prototype.writeUintLE=n.prototype.writeUIntLE=function(e,t,r,i){e=+e,t>>>=0,r>>>=0,i||P(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,n=0;for(this[t]=255&e;++n<r&&(o*=256);)this[t+n]=e/o&255;return t+r},n.prototype.writeUintBE=n.prototype.writeUIntBE=function(e,t,r,i){e=+e,t>>>=0,r>>>=0,i||P(this,e,t,r,Math.pow(2,8*r)-1,0);var o=r-1,n=1;for(this[t+o]=255&e;--o>=0&&(n*=256);)this[t+o]=e/n&255;return t+r},n.prototype.writeUint8=n.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},n.prototype.writeUint16LE=n.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},n.prototype.writeUint16BE=n.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},n.prototype.writeUint32LE=n.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},n.prototype.writeUint32BE=n.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},n.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var o=Math.pow(2,8*r-1);P(this,e,t,r,o-1,-o)}var n=0,a=1,s=0;for(this[t]=255&e;++n<r&&(a*=256);)e<0&&0===s&&0!==this[t+n-1]&&(s=1),this[t+n]=(e/a>>0)-s&255;return t+r},n.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var o=Math.pow(2,8*r-1);P(this,e,t,r,o-1,-o)}var n=r-1,a=1,s=0;for(this[t+n]=255&e;--n>=0&&(a*=256);)e<0&&0===s&&0!==this[t+n+1]&&(s=1),this[t+n]=(e/a>>0)-s&255;return t+r},n.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},n.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},n.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},n.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},n.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},n.prototype.writeFloatLE=function(e,t,r){return R(this,e,t,!0,r)},n.prototype.writeFloatBE=function(e,t,r){return R(this,e,t,!1,r)},n.prototype.writeDoubleLE=function(e,t,r){return I(this,e,t,!0,r)},n.prototype.writeDoubleBE=function(e,t,r){return I(this,e,t,!1,r)},n.prototype.copy=function(e,t,r,i){if(!n.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<r&&(i=r),i===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(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-r&&(i=e.length-t+r);var o=i-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,i):Uint8Array.prototype.set.call(e,this.subarray(r,i),t),o},n.prototype.fill=function(e,t,r,i){if("string"==typeof e){if("string"==typeof t?(i=t,t=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!n.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===e.length){var o=e.charCodeAt(0);("utf8"===i&&o<128||"latin1"===i)&&(e=o)}}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;var a;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(a=t;a<r;++a)this[a]=e;else{var s=n.isBuffer(e)?e:n.from(e,i),l=s.length;if(0===l)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(a=0;a<r-t;++a)this[a+t]=s[a%l]}return this};var B=/[^+/0-9A-Za-z-_]/g;function L(e,t){var r;t=t||Infinity;for(var i=e.length,o=null,n=[],a=0;a<i;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&n.push(239,191,189);continue}if(a+1===i){(t-=3)>-1&&n.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&n.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&n.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;n.push(r)}else if(r<2048){if((t-=2)<0)break;n.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;n.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;n.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return n}function D(e){return function(e){var t,r,i=function(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]}(e),o=i[0],n=i[1],a=new ie(function(e,t,r){return 3*(t+r)/4-r}(0,o,n)),s=0,l=n>0?o-4:o;for(r=0;r<l;r+=4)t=re[e.charCodeAt(r)]<<18|re[e.charCodeAt(r+1)]<<12|re[e.charCodeAt(r+2)]<<6|re[e.charCodeAt(r+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=255&t;return 2===n&&(t=re[e.charCodeAt(r)]<<2|re[e.charCodeAt(r+1)]>>4,a[s++]=255&t),1===n&&(t=re[e.charCodeAt(r)]<<10|re[e.charCodeAt(r+1)]<<4|re[e.charCodeAt(r+2)]>>2,a[s++]=t>>8&255,a[s++]=255&t),a}(function(e){if((e=(e=e.split("=")[0]).trim().replace(B,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function z(e,t,r,i){for(var o=0;o<i&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function U(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function $(e){return e!=e}var M=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var i=16*r,o=0;o<16;++o)t[i+o]=e[r]+e[o];return t}()});const{Buffer:ue}=ce;function me(...e){const t=new me.Request(...e),r=new XMLHttpRequest;r.withCredentials="include"===t.credentials,r.timeout=t[pe].timeout,r.open(t.method,t.url,!1);let i=!1;try{r.responseType="arraybuffer"}catch(e){r.overrideMimeType("text/plain; charset=x-user-defined"),i=!0}for(const e of t.headers)r.setRequestHeader(...e);r.send(t.body||null);let o=r.getAllResponseHeaders();o=o&&o.split("\r\n").filter(Boolean).map(e=>e.split(": ",2));let n=r.response;if(i){const e=ue.alloc(n.length);for(let t=0;t<n.length;t++)e[t]=255&n.charCodeAt(t);n=e}const a=new me.Response(n,{headers:o,status:r.status,statusText:r.statusText});return a[pe].url=r.responseURL,a[pe].redirected=r.responseURL!==t.url,a}const pe=Symbol("SyncFetch Internals"),fe=["mode","cache","redirect","referrer","integrity"],he={100:"Continue",101:"Switching Protocols",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",426:"Upgrade Required",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported"};class de{constructor(e,t={}){for(const e of fe)if(e in t)throw new TypeError(`option ${e} not supported`);if("same-origin"===t.credentials)throw new TypeError("option credentials with value 'same-origin' not supported");if(this[pe]={method:t.method||"GET",headers:new me.Headers(t.headers),body:t.body?ue.from(t.body):null,credentials:t.credentials||"omit",timeout:t.timeout||0},"string"==typeof e)this[pe].url=e;else{if(!(e instanceof de))throw new TypeError("Request input should be a URL string or a Request object");this[pe].url=e.url,t.method||(this[pe].method=e.method),t.headers||(this[pe].headers=e.headers),t.body||(this[pe].body=e[pe].body),t.credentials||(this[pe].credentials=e.credentials)}}get cache(){return"default"}get credentials(){return this[pe].credentials}get destination(){return""}get headers(){return this[pe].headers}get integrity(){return""}get method(){return this[pe].method}get mode(){return"cors"}get priority(){return"auto"}get redirect(){return"follow"}get referrer(){return"about:client"}get referrerPolicy(){return""}get url(){return this[pe].url}clone(){return ye(this),new de(this.url,this[pe])}}class ge{constructor(e,t={}){this[pe]={body:e?ue.from(e):null,bodyUsed:!1,headers:new me.Headers(t.headers),status:t.status,statusText:t.statusText}}get headers(){return this[pe].headers}get ok(){const e=this[pe].status;return e>=200&&e<300}get redirected(){return this[pe].redirected}get status(){return this[pe].status}get statusText(){return this[pe].statusText}get url(){return this[pe].url}clone(){return this.redirect(this[pe].url,this[pe].status)}redirect(e,t){ye(this);const r=new ge(this[pe].body,{headers:this[pe].headers,status:t||this[pe].status,statusText:he[t]||this[pe].statusText});return r[pe].url=e||this[pe].url,r[pe].redirected=this[pe].redirected,r}}class be{constructor(e){this[pe]={body:ue.from(e),bodyUsed:!1}}get bodyUsed(){return this[pe].bodyUsed}static mixin(e){for(const t of Object.getOwnPropertyNames(be.prototype)){if("constructor"===t)continue;const r=Object.getOwnPropertyDescriptor(be.prototype,t);Object.defineProperty(e,t,{...r,enumerable:!0})}}arrayBuffer(){const e=ve(this);return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}blob(){const e=this.headers&&this.headers.get("content-type");return new Blob([ve(this)],e&&{type:e})}text(){return ve(this).toString()}json(){try{return JSON.parse(ve(this).toString())}catch(e){throw new TypeError(`invalid json response body at ${this.url} reason: ${e.message}`,"invalid-json")}}buffer(){return ve(this).clone()}}function ye(e){if(e.bodyUsed)throw new TypeError(`body used already for: ${e.url}`)}function ve(e){return ye(e),e[pe].bodyUsed=!0,e[pe].body||ue.alloc(0)}be.mixin(de.prototype),be.mixin(ge.prototype);class we{constructor(e){if(e instanceof me.Headers)this[pe]={...e[pe]};else if(this[pe]={},Array.isArray(e))for(const[t,r]of e)this.append(t,r);else if("object"==typeof e)for(const t in e)this.set(t,e[t])}append(e,t){e=e.toLowerCase(),this[pe][e]||(this[pe][e]=[]),this[pe][e].push(t)}delete(e){delete this[pe][e.toLowerCase()]}set(e,t){this[pe][e.toLowerCase()]=[t]}entries(){const e=[];for(const t in this[pe])for(const r of this[pe][t])e.push([t,r]);return e}get(e){return(e=e.toLowerCase())in this[pe]?this[pe][e].join(", "):null}keys(){return Object.keys(this[pe])}has(e){return e.toLowerCase()in this[pe]}values(){const e=[];for(const t in this[pe])for(const r of this[pe][t])e.push(r);return e}*[Symbol.iterator](){for(const e in this[pe])for(const t of this[pe][e])yield[e,t]}}me.Headers=we,me.Request=de,me.Response=ge;var xe=ee(function(e,t){!function(r){e.exports=function(e){var i=e&&e.Promise||r.Promise,o=e&&e.XMLHttpRequest||r.XMLHttpRequest;return function(){var e=Object.create(r,{fetch:{value:void 0,writable:!0}});return function(t){var r=void 0!==e&&e||"undefined"!=typeof self&&self||void 0!==r&&r,n="URLSearchParams"in r,a="Symbol"in r&&"iterator"in Symbol,s="FileReader"in r&&"Blob"in r&&function(){try{return new Blob,!0}catch(e){return!1}}(),l="FormData"in r,c="ArrayBuffer"in r;if(c)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],m=ArrayBuffer.isView||function(e){return e&&u.indexOf(Object.prototype.toString.call(e))>-1};function p(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function f(e){return"string"!=typeof e&&(e=String(e)),e}function h(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return a&&(t[Symbol.iterator]=function(){return t}),t}function d(e){this.map={},e instanceof d?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){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.bodyUsed)return i.reject(new TypeError("Already read"));e.bodyUsed=!0}function b(e){return new i(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function y(e){var t=new FileReader,r=b(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:l&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:n&&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)||m(e))?this._bodyArrayBuffer=v(e):this._bodyText=e=Object.prototype.toString.call(e):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):n&&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 i.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return i.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return i.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?g(this)||(ArrayBuffer.isView(this._bodyArrayBuffer)?i.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):i.resolve(this._bodyArrayBuffer)):this.blob().then(y)}),this.text=function(){var e,t,r,o=g(this);if(o)return o;if(this._bodyBlob)return e=this._bodyBlob,r=b(t=new FileReader),t.readAsText(e),r;if(this._bodyArrayBuffer)return i.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),i=0;i<t.length;i++)r[i]=String.fromCharCode(t[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return i.resolve(this._bodyText)},l&&(this.formData=function(){return this.text().then(T)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(e,t){e=p(e),t=f(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},d.prototype.delete=function(e){delete this.map[p(e)]},d.prototype.get=function(e){return e=p(e),this.has(e)?this.map[e]:null},d.prototype.has=function(e){return this.map.hasOwnProperty(p(e))},d.prototype.set=function(e,t){this.map[p(e)]=f(t)},d.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},d.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),h(e)},d.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),h(e)},d.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),h(e)},a&&(d.prototype[Symbol.iterator]=d.prototype.entries);var x=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function k(e,t){if(!(this instanceof k))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 k){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new d(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 d(t.headers)),this.method=(i=(r=t.method||this.method||"GET").toUpperCase(),x.indexOf(i)>-1?i:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.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 n=/([?&])_=[^&]*/;n.test(this.url)?this.url=this.url.replace(n,"$1_="+(new Date).getTime()):this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}function T(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),i=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(o))}}),t}function O(e,t){if(!(this instanceof O))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"",this.headers=new d(t.headers),this.url=t.url||"",this._initBody(e)}k.prototype.clone=function(){return new k(this,{body:this._bodyInit})},w.call(k.prototype),w.call(O.prototype),O.prototype.clone=function(){return new O(this._bodyInit,{status:this.status,