s3db.js 4.1.10 → 4.1.13
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 +786 -1706
- package/dist/s3db.cjs.js +392 -111
- package/dist/s3db.cjs.min.js +14 -12
- package/dist/s3db.es.js +380 -112
- package/dist/s3db.es.min.js +11 -9
- package/dist/s3db.iife.js +392 -111
- package/dist/s3db.iife.min.js +14 -12
- package/package.json +14 -14
package/dist/s3db.cjs.min.js
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
/* istanbul ignore file */
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var Lc=Object.create;var Bi=Object.defineProperty;var $c=Object.getOwnPropertyDescriptor;var Bc=Object.getOwnPropertyNames;var Uc=Object.getPrototypeOf,zc=Object.prototype.hasOwnProperty;var Zc=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Bc(t))!zc.call(e,i)&&i!==r&&Bi(e,i,{get:()=>t[i],enumerable:!(n=$c(t,i))||n.enumerable});return e};var qc=(e,t,r)=>(r=e!=null?Lc(Uc(e)):{},Zc(t||!e||!e.__esModule?Bi(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,"__esModule",{value:!0});var Nr=require("nanoid"),M=require("lodash-es"),de=require("@supercharge/promise-pool"),pe=require("@aws-sdk/client-s3"),Ui=require("crypto"),tr=require("flat"),Hc=require("fastest-validator"),Kc=require("node:stream/web");function zi(e,t){for(var r=0,n=e.length-1;n>=0;n--){var i=e[n];i==="."?e.splice(n,1):i===".."?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}var Vc=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,Mr=function(e){return Vc.exec(e).slice(1)};function Lr(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)continue;e=n+"/"+e,t=n.charAt(0)==="/"}return e=zi($r(e.split("/"),function(i){return!!i}),!t).join("/"),(t?"/":"")+e||"."}function Zi(e){var t=qi(e),r=ef(e,-1)==="/";return e=zi($r(e.split("/"),function(n){return!!n}),!t).join("/"),!e&&!t&&(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function qi(e){return e.charAt(0)==="/"}function Ee(){var e=Array.prototype.slice.call(arguments,0);return Zi($r(e,function(t,r){if(typeof t!="string")throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function Wc(e,t){e=Lr(e).substr(1),t=Lr(t).substr(1);function r(c){for(var l=0;l<c.length&&c[l]==="";l++);for(var d=c.length-1;d>=0&&c[d]==="";d--);return l>d?[]:c.slice(l,d-l+1)}for(var n=r(e.split("/")),i=r(t.split("/")),a=Math.min(n.length,i.length),o=a,s=0;s<a;s++)if(n[s]!==i[s]){o=s;break}for(var f=[],s=o;s<n.length;s++)f.push("..");return f=f.concat(i.slice(o)),f.join("/")}var Gc="/",Yc=":";function Jc(e){var t=Mr(e),r=t[0],n=t[1];return!r&&!n?".":(n&&(n=n.substr(0,n.length-1)),r+n)}function Xc(e,t){var r=Mr(e)[2];return t&&r.substr(-1*t.length)===t&&(r=r.substr(0,r.length-t.length)),r}function Qc(e){return Mr(e)[3]}var ye={extname:Qc,basename:Xc,dirname:Jc,sep:Gc,delimiter:Yc,relative:Wc,join:Ee,isAbsolute:qi,normalize:Zi,resolve:Lr};function $r(e,t){if(e.filter)return e.filter(t);for(var r=[],n=0;n<e.length;n++)t(e[n],n,e)&&r.push(e[n]);return r}var ef="ab".substr(-1)==="b"?function(e,t,r){return e.substr(t,r)}:function(e,t,r){return t<0&&(t=e.length+t),e.substr(t,r)};const Hi=Nr.customAlphabet(Nr.urlAlphabet,22),tf="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789";Nr.customAlphabet(tf,12);var Br;function Ie(){}Ie.prototype=Object.create(null);function R(){R.init.call(this)}R.EventEmitter=R,R.usingDomains=!1,R.prototype.domain=void 0,R.prototype._events=void 0,R.prototype._maxListeners=void 0,R.defaultMaxListeners=10,R.init=function(){this.domain=null,R.usingDomains&&Br.active&&!(this instanceof Br.Domain)&&(this.domain=Br.active),(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new Ie,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},R.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this};function Ki(e){return e._maxListeners===void 0?R.defaultMaxListeners:e._maxListeners}R.prototype.getMaxListeners=function(){return Ki(this)};function rf(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Ot(e,n),a=0;a<n;++a)i[a].call(r)}function nf(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,a=Ot(e,i),o=0;o<i;++o)a[o].call(r,n)}function af(e,t,r,n,i){if(t)e.call(r,n,i);else for(var a=e.length,o=Ot(e,a),s=0;s<a;++s)o[s].call(r,n,i)}function of(e,t,r,n,i,a){if(t)e.call(r,n,i,a);else for(var o=e.length,s=Ot(e,o),f=0;f<o;++f)s[f].call(r,n,i,a)}function sf(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,a=Ot(e,i),o=0;o<i;++o)a[o].apply(r,n)}R.prototype.emit=function(t){var r,n,i,a,o,s,f,c=t==="error";if(s=this._events,s)c=c&&s.error==null;else if(!c)return!1;if(f=this.domain,c){if(r=arguments[1],f)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=f,r.domainThrown=!1,f.emit("error",r);else{if(r instanceof Error)throw r;var l=new Error('Uncaught, unspecified "error" event. ('+r+")");throw l.context=r,l}return!1}if(n=s[t],!n)return!1;var d=typeof n=="function";switch(i=arguments.length,i){case 1:rf(n,d,this);break;case 2:nf(n,d,this,arguments[1]);break;case 3:af(n,d,this,arguments[1],arguments[2]);break;case 4:of(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),o=1;o<i;o++)a[o-1]=arguments[o];sf(n,d,this,a)}return!0};function Vi(e,t,r,n){var i,a,o;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(a=e._events,a?(a.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),o=a[t]):(a=e._events=new Ie,e._eventsCount=0),!o)o=a[t]=r,++e._eventsCount;else if(typeof o=="function"?o=a[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),!o.warned&&(i=Ki(e),i&&i>0&&o.length>i)){o.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=o.length,cf(s)}return e}function cf(e){typeof console.warn=="function"?console.warn(e):console.log(e)}R.prototype.addListener=function(t,r){return Vi(this,t,r,!1)},R.prototype.on=R.prototype.addListener,R.prototype.prependListener=function(t,r){return Vi(this,t,r,!0)};function Wi(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}R.prototype.once=function(t,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.on(t,Wi(this,t,r)),this},R.prototype.prependOnceListener=function(t,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(t,Wi(this,t,r)),this},R.prototype.removeListener=function(t,r){var n,i,a,o,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[t],!n)return this;if(n===r||n.listener&&n.listener===r)--this._eventsCount===0?this._events=new Ie:(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||r));else if(typeof n!="function"){for(a=-1,o=n.length;o-- >0;)if(n[o]===r||n[o].listener&&n[o].listener===r){s=n[o].listener,a=o;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new Ie,this;delete i[t]}else ff(n,a);i.removeListener&&this.emit("removeListener",t,s||r)}return this},R.prototype.off=function(e,t){return this.removeListener(e,t)},R.prototype.removeAllListeners=function(t){var r,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new Ie,this._eventsCount=0):n[t]&&(--this._eventsCount===0?this._events=new Ie:delete n[t]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,o;a<i.length;++a)o=i[a],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=new Ie,this._eventsCount=0,this}if(r=n[t],typeof r=="function")this.removeListener(t,r);else if(r)do this.removeListener(t,r[r.length-1]);while(r[0]);return this},R.prototype.listeners=function(t){var r,n,i=this._events;return i?(r=i[t],r?typeof r=="function"?n=[r.listener||r]:n=lf(r):n=[]):n=[],n},R.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Gi.call(e,t)},R.prototype.listenerCount=Gi;function Gi(e){var t=this._events;if(t){var r=t[e];if(typeof r=="function")return 1;if(r)return r.length}return 0}R.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function ff(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}function Ot(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}function lf(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}class Yi extends Error{constructor({verbose:t,bucket:r,message:n,...i}){t&&(n=n+`
|
|
3
3
|
|
|
4
4
|
Verbose:
|
|
5
5
|
|
|
6
|
-
${JSON.stringify(i,null,2)}`),super(n),typeof Error.captureStackTrace=="function"?Error.captureStackTrace(this,this.constructor):this.stack=new Error(n).stack,super.name=this.constructor.name,this.name=this.constructor.name,this.bucket=r,this.thrownAt=new Date}toJson(){return{...this}}toString(){return`${this.name} | ${this.message}`}}class
|
|
7
|
-
${JSON.stringify(i,null,2)}
|
|
8
|
-
`,r:"\r",t:" "},n;function i(u){throw{name:"SyntaxError",message:u,at:e,text:n}}function a(u){return u&&u!==t&&i("Expected '"+u+"' instead of '"+t+"'"),t=n.charAt(e),e+=1,t}function o(){var u,p="";for(t==="-"&&(p="-",a("-"));t>="0"&&t<="9";)p+=t,a();if(t===".")for(p+=".";a()&&t>="0"&&t<="9";)p+=t;if(t==="e"||t==="E")for(p+=t,a(),(t==="-"||t==="+")&&(p+=t,a());t>="0"&&t<="9";)p+=t,a();return u=Number(p),isFinite(u)||i("Bad number"),u}function s(){var u,p,g="",w;if(t==='"')for(;a();){if(t==='"')return a(),g;if(t==="\\")if(a(),t==="u"){for(w=0,p=0;p<4&&(u=parseInt(a(),16),!!isFinite(u));p+=1)w=w*16+u;g+=String.fromCharCode(w)}else if(typeof r[t]=="string")g+=r[t];else break;else g+=t}i("Bad string")}function
|
|
6
|
+
${JSON.stringify(i,null,2)}`),super(n),typeof Error.captureStackTrace=="function"?Error.captureStackTrace(this,this.constructor):this.stack=new Error(n).stack,super.name=this.constructor.name,this.name=this.constructor.name,this.bucket=r,this.thrownAt=new Date}toJson(){return{...this}}toString(){return`${this.name} | ${this.message}`}}class te extends Yi{constructor(t,r={}){super({message:t,...r})}}class uf extends te{constructor(t,r={}){super(t,r),Object.assign(this,r)}}class hf extends te{constructor(t,r={}){super(t,r),Object.assign(this,r)}}class df extends te{constructor(t,r={}){super(t,r),Object.assign(this,r)}}class pf extends te{constructor(t,r={}){super(t,r),Object.assign(this,r)}}class yf extends te{constructor(t,r={}){super(t,r),Object.assign(this,r)}}class Ji extends te{constructor({bucket:t,resourceName:r,id:n,...i}){super(`Resource not found: ${r}/${n} [bucket:${t}]`,{bucket:t,resourceName:r,id:n,...i})}}class Xi extends te{constructor({bucket:t,...r}){super(`Bucket does not exists [bucket:${t}]`,{bucket:t,...r})}}class Ur extends te{constructor({bucket:t,key:r,...n}){super(`Key [${r}] does not exists [bucket:${t}/${r}]`,{bucket:t,key:r,...n})}}class Qi extends Ur{}class ea extends te{constructor({bucket:t,...r}){super(`Missing metadata for bucket [bucket:${t}]`,{bucket:t,...r})}}class rr extends te{constructor({bucket:t,resourceName:r,attributes:n,validation:i}){super(`This item is not valid. Resource=${r} [bucket:${t}].
|
|
7
|
+
${JSON.stringify(i,null,2)}`,{bucket:t,resourceName:r,attributes:n,validation:i})}}class ta extends te{}const ra={NotFound:Qi,NoSuchKey:Ur,UnknownError:ta,NoSuchBucket:Xi,MissingMetadata:ea,InvalidResourceItem:rr},na="us-east-1",ia="https://s3.us-east-1.amazonaws.com";class zr{constructor(t){let r;try{r=new URL(t)}catch{throw new Error("Invalid connection string: "+t)}this.region=na,r.protocol==="s3:"?this.defineS3(r):this.defineMinio(r);for(const[n,i]of r.searchParams.entries())this[n]=i}defineS3(t){if(this.bucket=decodeURIComponent(t.hostname),this.accessKeyId=decodeURIComponent(t.username),this.secretAccessKey=decodeURIComponent(t.password),this.endpoint=ia,["/","",null].includes(t.pathname))this.keyPrefix="";else{let[,...r]=t.pathname.split("/");this.keyPrefix=[...r||[]].join("/")}}defineMinio(t){if(this.forcePathStyle=!0,this.endpoint=t.origin,this.accessKeyId=decodeURIComponent(t.username),this.secretAccessKey=decodeURIComponent(t.password),["/","",null].includes(t.pathname))this.bucket="s3db",this.keyPrefix="";else{let[,r,...n]=t.pathname.split("/");this.bucket=decodeURIComponent(r),this.keyPrefix=[...n||[]].join("/")}}}class aa extends R{constructor({verbose:t=!1,id:r=null,AwsS3Client:n,connectionString:i,parallelism:a=10}){super(),this.verbose=t,this.id=r??Hi(),this.parallelism=a,this.config=new zr(i),this.client=n||this.createClient()}createClient(){let t={region:this.config.region,endpoint:this.config.endpoint};return this.config.forcePathStyle&&(t.forcePathStyle=!0),this.config.accessKeyId&&(t.credentials={accessKeyId:this.config.accessKeyId,secretAccessKey:this.config.secretAccessKey}),new pe.S3Client(t)}async sendCommand(t){this.emit("command.request",t.constructor.name,t.input);const r=console.warn;try{console.warn=i=>{i.includes("Stream of unknown length")||r(i)}}catch(i){console.error(i)}const n=await this.client.send(t);this.emit("command.response",t.constructor.name,n,t.input);try{console.warn=r}catch(i){console.error(i)}return n}errorProxy(t,r){this.verbose&&(r.bucket=this.config.bucket,r.config=this.config,r.verbose=this.verbose),t.data=r;const n=ra[t.name];return n?new n(r):t}async putObject({key:t,metadata:r,contentType:n,body:i,contentEncoding:a}){const o={Bucket:this.config.bucket,Key:this.config.keyPrefix?ye.join(this.config.keyPrefix,t):t,Metadata:{...r},Body:i||Buffer.alloc(0)};n!==void 0&&(o.ContentType=n),a!==void 0&&(o.ContentEncoding=a);try{const s=await this.sendCommand(new pe.PutObjectCommand(o));return this.emit("putObject",s,o),s}catch(s){throw this.errorProxy(s,{key:t,command:o})}}async getObject(t){const r={Bucket:this.config.bucket,Key:ye.join(this.config.keyPrefix,t)};try{const n=await this.sendCommand(new pe.GetObjectCommand(r));return this.emit("getObject",n,r),n}catch(n){throw this.errorProxy(n,{key:t,command:r})}}async headObject(t){const r={Bucket:this.config.bucket,Key:this.config.keyPrefix?ye.join(this.config.keyPrefix,t):t};try{const n=await this.sendCommand(new pe.HeadObjectCommand(r));return this.emit("headObject",n,r),n}catch(n){throw this.errorProxy(n,{key:t,command:r})}}async copyObject({from:t,to:r}){const n={Bucket:this.config.bucket,Key:this.config.keyPrefix?ye.join(this.config.keyPrefix,r):r,CopySource:ye.join(this.config.bucket,this.config.keyPrefix?ye.join(this.config.keyPrefix,t):t)};try{const i=await this.client.send(new pe.CopyObjectCommand(n));return this.emit("copyObject",i,n),i}catch(i){throw this.errorProxy(i,{from:t,to:r,command:n})}}async exists(t){try{return await this.headObject(t),!0}catch(r){if(r.name==="NoSuchKey")return!1;if(r.name==="NotFound")return!1;throw r}}async deleteObject(t){const r={Bucket:this.config.bucket,Key:this.config.keyPrefix?ye.join(this.config.keyPrefix,t):t};try{const n=await this.sendCommand(new pe.DeleteObjectCommand(r));return this.emit("deleteObject",n,r),n}catch(n){throw this.errorProxy(n,{key:t,command:r})}}async deleteObjects(t){const r=M.chunk(t,1e3),{results:n,errors:i}=await de.PromisePool.for(r).withConcurrency(this.parallelism).process(async o=>{const s={Bucket:this.config.bucket,Delete:{Objects:o.map(f=>({Key:this.config.keyPrefix?ye.join(this.config.keyPrefix,f):f}))}};try{return await this.sendCommand(new pe.DeleteObjectsCommand(s))}catch(f){throw this.errorProxy(f,{keys:o,command:s})}}),a={deleted:n,notFound:i};return this.emit("deleteObjects",a,t),a}async deleteAll({prefix:t}={}){let r,n=0;do{const i=new pe.ListObjectsV2Command({Bucket:this.config.bucket,Prefix:this.config.keyPrefix?ye.join(this.config.keyPrefix,t):t,ContinuationToken:r}),a=await this.client.send(i);if(a.Contents&&a.Contents.length>0){const o=new pe.DeleteObjectsCommand({Bucket:this.config.bucket,Delete:{Objects:a.Contents.map(c=>({Key:c.Key}))}}),s=await this.client.send(o),f=s.Deleted?s.Deleted.length:0;n+=f,this.emit("deleteAll",{prefix:t,batch:f,total:n})}r=a.IsTruncated?a.NextContinuationToken:void 0}while(r);return this.emit("deleteAllComplete",{prefix:t,totalDeleted:n}),n}async moveObject({from:t,to:r}){try{return await this.copyObject({from:t,to:r}),await this.deleteObject(t),!0}catch(n){throw this.errorProxy(n,{from:t,to:r,command:options})}}async listObjects({prefix:t,maxKeys:r=1e3,continuationToken:n}={}){const i={Bucket:this.config.bucket,MaxKeys:r,ContinuationToken:n,Prefix:this.config.keyPrefix?ye.join(this.config.keyPrefix,t||""):t||""};try{const a=await this.sendCommand(new pe.ListObjectsV2Command(i));return this.emit("listObjects",a,i),a}catch(a){throw this.errorProxy(a,{command:i})}}async count({prefix:t}={}){let r=0,n=!0,i;for(;n;){const a={prefix:t,continuationToken:i},o=await this.listObjects(a);r+=o.KeyCount||0,n=o.IsTruncated||!1,i=o.NextContinuationToken}return this.emit("count",r,{prefix:t}),r}async getAllKeys({prefix:t}={}){let r=[],n=!0,i;for(;n;){const a={prefix:t,continuationToken:i},o=await this.listObjects(a);o.Contents&&(r=r.concat(o.Contents.map(s=>s.Key))),n=o.IsTruncated||!1,i=o.NextContinuationToken}return this.config.keyPrefix&&(r=r.map(a=>a.replace(this.config.keyPrefix,"")).map(a=>a.startsWith("/")?a.replace("/",""):a)),this.emit("getAllKeys",r,{prefix:t}),r}async getContinuationTokenAfterOffset(t={}){const{prefix:r,offset:n=1e3}=t;if(n===0)return null;let i=!0,a,o=0;for(;i;){let s=n<1e3?n:n-o>1e3?1e3:n-o;const f={prefix:r,maxKeys:s,continuationToken:a},c=await this.listObjects(f);if(c.Contents&&(o+=c.Contents.length),i=c.IsTruncated||!1,a=c.NextContinuationToken,o>=n)break}return this.emit("getContinuationTokenAfterOffset",a||null,t),a||null}async getKeysPage(t={}){const{prefix:r,offset:n=0,amount:i=100}=t;let a=[],o=!0,s;for(n>0&&(s=await this.getContinuationTokenAfterOffset({prefix:r,offset:n}));o;){const f={prefix:r,continuationToken:s},c=await this.listObjects(f);if(c.Contents&&(a=a.concat(c.Contents.map(l=>l.Key))),o=c.IsTruncated||!1,s=c.NextContinuationToken,a.length>i){a=a.splice(0,i);break}}return this.config.keyPrefix&&(a=a.map(f=>f.replace(this.config.keyPrefix,"")).map(f=>f.startsWith("/")?f.replace("/",""):f)),this.emit("getKeysPage",a,t),a}async moveAllObjects({prefixFrom:t,prefixTo:r}){const n=await this.getAllKeys({prefix:t}),{results:i,errors:a}=await de.PromisePool.for(n).withConcurrency(this.parallelism).process(async o=>{const s=o.replace(t,r);try{return await this.moveObject({from:o,to:s}),s}catch(f){throw this.errorProxy(f,{from:o,to:s})}});if(this.emit("moveAllObjects",{results:i,errors:a},{prefixFrom:t,prefixTo:r}),a.length>0)throw new Error("Some objects could not be moved");return i}}async function nr(){let e;if(typeof process<"u")try{const{webcrypto:t}=await import("crypto");e=t}catch{throw new Error("Crypto API not available")}else typeof window<"u"&&(e=window.crypto);if(!e)throw new Error("Could not load any crypto library");return e}async function oa(e){const t=await nr(),n=new TextEncoder().encode(e),i=await t.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(i)).map(s=>s.toString(16).padStart(2,"0")).join("")}async function Zr(e,t){const r=await nr(),n=r.getRandomValues(new Uint8Array(16)),i=await ca(t,n),a=r.getRandomValues(new Uint8Array(12)),s=new TextEncoder().encode(e),f=await r.subtle.encrypt({name:"AES-GCM",iv:a},i,s),c=new Uint8Array(n.length+a.length+f.byteLength);return c.set(n),c.set(a,n.length),c.set(new Uint8Array(f),n.length+a.length),gf(c)}async function sa(e,t){const r=await nr(),n=vf(e),i=n.slice(0,16),a=n.slice(16,28),o=n.slice(28),s=await ca(t,i),f=await r.subtle.decrypt({name:"AES-GCM",iv:a},s,o);return new TextDecoder().decode(f)}async function ca(e,t){const r=await nr(),i=new TextEncoder().encode(e),a=await r.subtle.importKey("raw",i,{name:"PBKDF2"},!1,["deriveKey"]);return await r.subtle.deriveKey({name:"PBKDF2",salt:t,iterations:1e5,hash:"SHA-256"},a,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"])}function gf(e){if(typeof process<"u")return Buffer.from(e).toString("base64");{const t=String.fromCharCode.apply(null,new Uint8Array(e));return window.btoa(t)}}function vf(e){if(typeof process<"u")return new Uint8Array(Buffer.from(e,"base64"));{const t=window.atob(e),r=t.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t.charCodeAt(i);return n}}function wf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ir={},qr,fa;function _f(){if(fa)return qr;fa=1;var e,t,r={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
8
|
+
`,r:"\r",t:" "},n;function i(u){throw{name:"SyntaxError",message:u,at:e,text:n}}function a(u){return u&&u!==t&&i("Expected '"+u+"' instead of '"+t+"'"),t=n.charAt(e),e+=1,t}function o(){var u,p="";for(t==="-"&&(p="-",a("-"));t>="0"&&t<="9";)p+=t,a();if(t===".")for(p+=".";a()&&t>="0"&&t<="9";)p+=t;if(t==="e"||t==="E")for(p+=t,a(),(t==="-"||t==="+")&&(p+=t,a());t>="0"&&t<="9";)p+=t,a();return u=Number(p),isFinite(u)||i("Bad number"),u}function s(){var u,p,g="",w;if(t==='"')for(;a();){if(t==='"')return a(),g;if(t==="\\")if(a(),t==="u"){for(w=0,p=0;p<4&&(u=parseInt(a(),16),!!isFinite(u));p+=1)w=w*16+u;g+=String.fromCharCode(w)}else if(typeof r[t]=="string")g+=r[t];else break;else g+=t}i("Bad string")}function f(){for(;t&&t<=" ";)a()}function c(){switch(t){case"t":return a("t"),a("r"),a("u"),a("e"),!0;case"f":return a("f"),a("a"),a("l"),a("s"),a("e"),!1;case"n":return a("n"),a("u"),a("l"),a("l"),null;default:i("Unexpected '"+t+"'")}}function l(){var u=[];if(t==="["){if(a("["),f(),t==="]")return a("]"),u;for(;t;){if(u.push(h()),f(),t==="]")return a("]"),u;a(","),f()}}i("Bad array")}function d(){var u,p={};if(t==="{"){if(a("{"),f(),t==="}")return a("}"),p;for(;t;){if(u=s(),f(),a(":"),Object.prototype.hasOwnProperty.call(p,u)&&i('Duplicate key "'+u+'"'),p[u]=h(),f(),t==="}")return a("}"),p;a(","),f()}}i("Bad object")}function h(){switch(f(),t){case"{":return d();case"[":return l();case'"':return s();case"-":return o();default:return t>="0"&&t<="9"?o():c()}}return qr=function(u,p){var g;return n=u,e=0,t=" ",g=h(),f(),t&&i("Syntax error"),typeof p=="function"?function w(_,m){var x,v,A=_[m];if(A&&typeof A=="object")for(x in h)Object.prototype.hasOwnProperty.call(A,x)&&(v=w(A,x),typeof v>"u"?delete A[x]:A[x]=v);return p.call(_,m,A)}({"":g},""):g},qr}var Hr,la;function bf(){if(la)return Hr;la=1;var e=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,t,r,n={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},i;function a(s){return e.lastIndex=0,e.test(s)?'"'+s.replace(e,function(f){var c=n[f];return typeof c=="string"?c:"\\u"+("0000"+f.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+s+'"'}function o(s,f){var c,l,d,h,u=t,p,g=f[s];switch(g&&typeof g=="object"&&typeof g.toJSON=="function"&&(g=g.toJSON(s)),typeof i=="function"&&(g=i.call(f,s,g)),typeof g){case"string":return a(g);case"number":return isFinite(g)?String(g):"null";case"boolean":case"null":return String(g);case"object":if(!g)return"null";if(t+=r,p=[],Object.prototype.toString.apply(g)==="[object Array]"){for(h=g.length,c=0;c<h;c+=1)p[c]=o(c,g)||"null";return d=p.length===0?"[]":t?`[
|
|
9
9
|
`+t+p.join(`,
|
|
10
10
|
`+t)+`
|
|
11
|
-
`+u+"]":"["+p.join(",")+"]",t=u,d}if(i&&typeof i=="object")for(h=i.length,
|
|
11
|
+
`+u+"]":"["+p.join(",")+"]",t=u,d}if(i&&typeof i=="object")for(h=i.length,c=0;c<h;c+=1)l=i[c],typeof l=="string"&&(d=o(l,g),d&&p.push(a(l)+(t?": ":":")+d));else for(l in g)Object.prototype.hasOwnProperty.call(g,l)&&(d=o(l,g),d&&p.push(a(l)+(t?": ":":")+d));return d=p.length===0?"{}":t?`{
|
|
12
12
|
`+t+p.join(`,
|
|
13
13
|
`+t)+`
|
|
14
|
-
`+u+"}":"{"+p.join(",")+"}",t=u,d}}return Zr=function(s,c,f){var l;if(t="",r="",typeof f=="number")for(l=0;l<f;l+=1)r+=" ";else typeof f=="string"&&(r=f);if(i=c,c&&typeof c!="function"&&(typeof c!="object"||typeof c.length!="number"))throw new Error("JSON.stringify");return o("",{"":s})},Zr}var fa;function hc(){return fa||(fa=1,ir.parse=lc(),ir.stringify=uc()),ir}var qr,ca;function dc(){if(ca)return qr;ca=1;var e={}.toString;return qr=Array.isArray||function(t){return e.call(t)=="[object Array]"},qr}var Hr,la;function ua(){if(la)return Hr;la=1;var e=Object.prototype.toString;return Hr=function(r){var n=e.call(r),i=n==="[object Arguments]";return i||(i=n!=="[object Array]"&&r!==null&&typeof r=="object"&&typeof r.length=="number"&&r.length>=0&&e.call(r.callee)==="[object Function]"),i},Hr}var Kr,ha;function pc(){if(ha)return Kr;ha=1;var e;if(!Object.keys){var t=Object.prototype.hasOwnProperty,r=Object.prototype.toString,n=ua(),i=Object.prototype.propertyIsEnumerable,a=!i.call({toString:null},"toString"),o=i.call(function(){},"prototype"),s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(h){var u=h.constructor;return u&&u.prototype===h},f={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},l=function(){if(typeof window>"u")return!1;for(var h in window)try{if(!f["$"+h]&&t.call(window,h)&&window[h]!==null&&typeof window[h]=="object")try{c(window[h])}catch{return!0}}catch{return!0}return!1}(),d=function(h){if(typeof window>"u"||!l)return c(h);try{return c(h)}catch{return!1}};e=function(u){var p=u!==null&&typeof u=="object",g=r.call(u)==="[object Function]",w=n(u),_=p&&r.call(u)==="[object String]",x=[];if(!p&&!g&&!w)throw new TypeError("Object.keys called on a non-object");var A=o&&g;if(_&&u.length>0&&!t.call(u,0))for(var v=0;v<u.length;++v)x.push(String(v));if(w&&u.length>0)for(var S=0;S<u.length;++S)x.push(String(S));else for(var T in u)!(A&&T==="prototype")&&t.call(u,T)&&x.push(String(T));if(a)for(var b=d(u),E=0;E<s.length;++E)!(b&&s[E]==="constructor")&&t.call(u,s[E])&&x.push(s[E]);return x}}return Kr=e,Kr}var Wr,da;function yc(){if(da)return Wr;da=1;var e=Array.prototype.slice,t=ua(),r=Object.keys,n=r?function(o){return r(o)}:pc(),i=Object.keys;return n.shim=function(){if(Object.keys){var o=function(){var s=Object.keys(arguments);return s&&s.length===arguments.length}(1,2);o||(Object.keys=function(c){return t(c)?i(e.call(c)):i(c)})}else Object.keys=n;return Object.keys||n},Wr=n,Wr}var Vr={exports:{}},Gr,pa;function ya(){return pa||(pa=1,Gr=Object),Gr}var Yr,ga;function gc(){return ga||(ga=1,Yr=Error),Yr}var Jr,va;function vc(){return va||(va=1,Jr=EvalError),Jr}var Xr,wa;function wc(){return wa||(wa=1,Xr=RangeError),Xr}var Qr,_a;function _c(){return _a||(_a=1,Qr=ReferenceError),Qr}var en,ba;function ma(){return ba||(ba=1,en=SyntaxError),en}var tn,xa;function ar(){return xa||(xa=1,tn=TypeError),tn}var rn,Ea;function bc(){return Ea||(Ea=1,rn=URIError),rn}var nn,Sa;function mc(){return Sa||(Sa=1,nn=Math.abs),nn}var an,Aa;function xc(){return Aa||(Aa=1,an=Math.floor),an}var on,ka;function Ec(){return ka||(ka=1,on=Math.max),on}var sn,Ra;function Sc(){return Ra||(Ra=1,sn=Math.min),sn}var fn,Oa;function Ac(){return Oa||(Oa=1,fn=Math.pow),fn}var cn,Ta;function kc(){return Ta||(Ta=1,cn=Math.round),cn}var ln,Pa;function Rc(){return Pa||(Pa=1,ln=Number.isNaN||function(t){return t!==t}),ln}var un,Ia;function Oc(){if(Ia)return un;Ia=1;var e=Rc();return un=function(r){return e(r)||r===0?r:r<0?-1:1},un}var hn,Fa;function Tc(){return Fa||(Fa=1,hn=Object.getOwnPropertyDescriptor),hn}var dn,Ca;function or(){if(Ca)return dn;Ca=1;var e=Tc();if(e)try{e([],"length")}catch{e=null}return dn=e,dn}var pn,Da;function sr(){if(Da)return pn;Da=1;var e=Object.defineProperty||!1;if(e)try{e({},"a",{value:1})}catch{e=!1}return pn=e,pn}var yn,ja;function Pc(){return ja||(ja=1,yn=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;t[r]=i;for(var a in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var s=Object.getOwnPropertyDescriptor(t,r);if(s.value!==i||s.enumerable!==!0)return!1}return!0}),yn}var gn,Ma;function Ic(){if(Ma)return gn;Ma=1;var e=typeof Symbol<"u"&&Symbol,t=Pc();return gn=function(){return typeof e!="function"||typeof Symbol!="function"||typeof e("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},gn}var vn,La;function Na(){return La||(La=1,vn=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),vn}var wn,Ba;function $a(){if(Ba)return wn;Ba=1;var e=ya();return wn=e.getPrototypeOf||null,wn}var _n,Ua;function Fc(){if(Ua)return _n;Ua=1;var e="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,r=Math.max,n="[object Function]",i=function(c,f){for(var l=[],d=0;d<c.length;d+=1)l[d]=c[d];for(var h=0;h<f.length;h+=1)l[h+c.length]=f[h];return l},a=function(c,f){for(var l=[],d=f,h=0;d<c.length;d+=1,h+=1)l[h]=c[d];return l},o=function(s,c){for(var f="",l=0;l<s.length;l+=1)f+=s[l],l+1<s.length&&(f+=c);return f};return _n=function(c){var f=this;if(typeof f!="function"||t.apply(f)!==n)throw new TypeError(e+f);for(var l=a(arguments,1),d,h=function(){if(this instanceof d){var _=f.apply(this,i(l,arguments));return Object(_)===_?_:this}return f.apply(c,i(l,arguments))},u=r(0,f.length-l.length),p=[],g=0;g<u;g++)p[g]="$"+g;if(d=Function("binder","return function ("+o(p,",")+"){ return binder.apply(this,arguments); }")(h),f.prototype){var w=function(){};w.prototype=f.prototype,d.prototype=new w,w.prototype=null}return d},_n}var bn,za;function Tt(){if(za)return bn;za=1;var e=Fc();return bn=Function.prototype.bind||e,bn}var mn,Za;function xn(){return Za||(Za=1,mn=Function.prototype.call),mn}var En,qa;function Sn(){return qa||(qa=1,En=Function.prototype.apply),En}var An,Ha;function Cc(){return Ha||(Ha=1,An=typeof Reflect<"u"&&Reflect&&Reflect.apply),An}var kn,Ka;function Wa(){if(Ka)return kn;Ka=1;var e=Tt(),t=Sn(),r=xn(),n=Cc();return kn=n||e.call(r,t),kn}var Rn,Va;function On(){if(Va)return Rn;Va=1;var e=Tt(),t=ar(),r=xn(),n=Wa();return Rn=function(a){if(a.length<1||typeof a[0]!="function")throw new t("a function is required");return n(e,r,a)},Rn}var Tn,Ga;function Dc(){if(Ga)return Tn;Ga=1;var e=On(),t=or(),r;try{r=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var n=!!r&&t&&t(Object.prototype,"__proto__"),i=Object,a=i.getPrototypeOf;return Tn=n&&typeof n.get=="function"?e([n.get]):typeof a=="function"?function(s){return a(s==null?s:i(s))}:!1,Tn}var Pn,Ya;function jc(){if(Ya)return Pn;Ya=1;var e=Na(),t=$a(),r=Dc();return Pn=e?function(i){return e(i)}:t?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return t(i)}:r?function(i){return r(i)}:null,Pn}var In,Ja;function Mc(){if(Ja)return In;Ja=1;var e=Function.prototype.call,t=Object.prototype.hasOwnProperty,r=Tt();return In=r.call(e,t),In}var Fn,Xa;function Qa(){if(Xa)return Fn;Xa=1;var e,t=ya(),r=gc(),n=vc(),i=wc(),a=_c(),o=ma(),s=ar(),c=bc(),f=mc(),l=xc(),d=Ec(),h=Sc(),u=Ac(),p=kc(),g=Oc(),w=Function,_=function(le){try{return w('"use strict"; return ('+le+").constructor;")()}catch{}},x=or(),A=sr(),v=function(){throw new s},S=x?function(){try{return arguments.callee,v}catch{try{return x(arguments,"callee").get}catch{return v}}}():v,T=Ic()(),b=jc(),E=$a(),O=Na(),k=Sn(),C=xn(),q={},G=typeof Uint8Array>"u"||!b?e:b(Uint8Array),ne={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?e:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?e:ArrayBuffer,"%ArrayIteratorPrototype%":T&&b?b([][Symbol.iterator]()):e,"%AsyncFromSyncIteratorPrototype%":e,"%AsyncFunction%":q,"%AsyncGenerator%":q,"%AsyncGeneratorFunction%":q,"%AsyncIteratorPrototype%":q,"%Atomics%":typeof Atomics>"u"?e:Atomics,"%BigInt%":typeof BigInt>"u"?e:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?e:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?e:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?e:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":r,"%eval%":eval,"%EvalError%":n,"%Float16Array%":typeof Float16Array>"u"?e:Float16Array,"%Float32Array%":typeof Float32Array>"u"?e:Float32Array,"%Float64Array%":typeof Float64Array>"u"?e:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?e:FinalizationRegistry,"%Function%":w,"%GeneratorFunction%":q,"%Int8Array%":typeof Int8Array>"u"?e:Int8Array,"%Int16Array%":typeof Int16Array>"u"?e:Int16Array,"%Int32Array%":typeof Int32Array>"u"?e:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":T&&b?b(b([][Symbol.iterator]())):e,"%JSON%":typeof JSON=="object"?JSON:e,"%Map%":typeof Map>"u"?e:Map,"%MapIteratorPrototype%":typeof Map>"u"||!T||!b?e:b(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":t,"%Object.getOwnPropertyDescriptor%":x,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?e:Promise,"%Proxy%":typeof Proxy>"u"?e:Proxy,"%RangeError%":i,"%ReferenceError%":a,"%Reflect%":typeof Reflect>"u"?e:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?e:Set,"%SetIteratorPrototype%":typeof Set>"u"||!T||!b?e:b(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?e:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":T&&b?b(""[Symbol.iterator]()):e,"%Symbol%":T?Symbol:e,"%SyntaxError%":o,"%ThrowTypeError%":S,"%TypedArray%":G,"%TypeError%":s,"%Uint8Array%":typeof Uint8Array>"u"?e:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?e:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?e:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?e:Uint32Array,"%URIError%":c,"%WeakMap%":typeof WeakMap>"u"?e:WeakMap,"%WeakRef%":typeof WeakRef>"u"?e:WeakRef,"%WeakSet%":typeof WeakSet>"u"?e:WeakSet,"%Function.prototype.call%":C,"%Function.prototype.apply%":k,"%Object.defineProperty%":A,"%Object.getPrototypeOf%":E,"%Math.abs%":f,"%Math.floor%":l,"%Math.max%":d,"%Math.min%":h,"%Math.pow%":u,"%Math.round%":p,"%Math.sign%":g,"%Reflect.getPrototypeOf%":O};if(b)try{null.error}catch(le){var ze=b(b(le));ne["%Error.prototype%"]=ze}var J=function le(M){var W;if(M==="%AsyncFunction%")W=_("async function () {}");else if(M==="%GeneratorFunction%")W=_("function* () {}");else if(M==="%AsyncGeneratorFunction%")W=_("async function* () {}");else if(M==="%AsyncGenerator%"){var B=le("%AsyncGeneratorFunction%");B&&(W=B.prototype)}else if(M==="%AsyncIteratorPrototype%"){var Y=le("%AsyncGenerator%");Y&&b&&(W=b(Y.prototype))}return ne[M]=W,W},ce={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Ze=Tt(),qe=Mc(),kt=Ze.call(C,Array.prototype.concat),Pf=Ze.call(k,Array.prototype.splice),Mi=Ze.call(C,String.prototype.replace),Gt=Ze.call(C,String.prototype.slice),If=Ze.call(C,RegExp.prototype.exec),Ff=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Cf=/\\(\\)?/g,Df=function(M){var W=Gt(M,0,1),B=Gt(M,-1);if(W==="%"&&B!=="%")throw new o("invalid intrinsic syntax, expected closing `%`");if(B==="%"&&W!=="%")throw new o("invalid intrinsic syntax, expected opening `%`");var Y=[];return Mi(M,Ff,function(ue,ut,X,Yt){Y[Y.length]=X?Mi(Yt,Cf,"$1"):ut||ue}),Y},jf=function(M,W){var B=M,Y;if(qe(ce,B)&&(Y=ce[B],B="%"+Y[0]+"%"),qe(ne,B)){var ue=ne[B];if(ue===q&&(ue=J(B)),typeof ue>"u"&&!W)throw new s("intrinsic "+M+" exists, but is not available. Please file an issue!");return{alias:Y,name:B,value:ue}}throw new o("intrinsic "+M+" does not exist!")};return Fn=function(M,W){if(typeof M!="string"||M.length===0)throw new s("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof W!="boolean")throw new s('"allowMissing" argument must be a boolean');if(If(/^%?[^%]*%?$/,M)===null)throw new o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var B=Df(M),Y=B.length>0?B[0]:"",ue=jf("%"+Y+"%",W),ut=ue.name,X=ue.value,Yt=!1,jr=ue.alias;jr&&(Y=jr[0],Pf(B,kt([0,1],jr)));for(var Jt=1,Rt=!0;Jt<B.length;Jt+=1){var be=B[Jt],Xt=Gt(be,0,1),Qt=Gt(be,-1);if((Xt==='"'||Xt==="'"||Xt==="`"||Qt==='"'||Qt==="'"||Qt==="`")&&Xt!==Qt)throw new o("property names with quotes must have matching quotes");if((be==="constructor"||!Rt)&&(Yt=!0),Y+="."+be,ut="%"+Y+"%",qe(ne,ut))X=ne[ut];else if(X!=null){if(!(be in X)){if(!W)throw new s("base intrinsic for "+M+" exists, but the property is not available.");return}if(x&&Jt+1>=B.length){var er=x(X,be);Rt=!!er,Rt&&"get"in er&&!("originalValue"in er.get)?X=er.get:X=X[be]}else Rt=qe(X,be),X=X[be];Rt&&!Yt&&(ne[ut]=X)}}return X},Fn}var Cn,eo;function Lc(){if(eo)return Cn;eo=1;var e=sr(),t=ma(),r=ar(),n=or();return Cn=function(a,o,s){if(!a||typeof a!="object"&&typeof a!="function")throw new r("`obj` must be an object or a function`");if(typeof o!="string"&&typeof o!="symbol")throw new r("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new r("`loose`, if provided, must be a boolean");var c=arguments.length>3?arguments[3]:null,f=arguments.length>4?arguments[4]:null,l=arguments.length>5?arguments[5]:null,d=arguments.length>6?arguments[6]:!1,h=!!n&&n(a,o);if(e)e(a,o,{configurable:l===null&&h?h.configurable:!l,enumerable:c===null&&h?h.enumerable:!c,value:s,writable:f===null&&h?h.writable:!f});else if(d||!c&&!f&&!l)a[o]=s;else throw new t("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Cn}var Dn,to;function Nc(){if(to)return Dn;to=1;var e=sr(),t=function(){return!!e};return t.hasArrayLengthDefineBug=function(){if(!e)return null;try{return e([],"length",{value:1}).length!==1}catch{return!0}},Dn=t,Dn}var jn,ro;function Bc(){if(ro)return jn;ro=1;var e=Qa(),t=Lc(),r=Nc()(),n=or(),i=ar(),a=e("%Math.floor%");return jn=function(s,c){if(typeof s!="function")throw new i("`fn` is not a function");if(typeof c!="number"||c<0||c>4294967295||a(c)!==c)throw new i("`length` must be a positive 32-bit integer");var f=arguments.length>2&&!!arguments[2],l=!0,d=!0;if("length"in s&&n){var h=n(s,"length");h&&!h.configurable&&(l=!1),h&&!h.writable&&(d=!1)}return(l||d||!f)&&(r?t(s,"length",c,!0,!0):t(s,"length",c)),s},jn}var Mn,no;function $c(){if(no)return Mn;no=1;var e=Tt(),t=Sn(),r=Wa();return Mn=function(){return r(e,t,arguments)},Mn}var io;function Uc(){return io||(io=1,function(e){var t=Bc(),r=sr(),n=On(),i=$c();e.exports=function(o){var s=n(arguments),c=o.length-(arguments.length-1);return t(s,1+(c>0?c:0),!0)},r?r(e.exports,"apply",{value:i}):e.exports.apply=i}(Vr)),Vr.exports}var Ln,ao;function zc(){if(ao)return Ln;ao=1;var e=Qa(),t=On(),r=t([e("%String.prototype.indexOf%")]);return Ln=function(i,a){var o=e(i,!!a);return typeof o=="function"&&r(i,".prototype.")>-1?t([o]):o},Ln}var Nn,oo;function Zc(){if(oo)return Nn;oo=1;var e=(typeof JSON<"u"?JSON:hc()).stringify,t=dc(),r=yc(),n=Uc(),i=zc(),a=i("Array.prototype.join"),o=i("Array.prototype.indexOf"),s=i("Array.prototype.splice"),c=i("Array.prototype.sort"),f=function(h,u){for(var p="",g=0;g<h;g+=1)p+=u;return p},l=function(d,h,u){return u};return Nn=function(h){var u=arguments.length>1?arguments[1]:void 0,p=u&&u.space||"";typeof p=="number"&&(p=f(p," "));var g=!!u&&typeof u.cycles=="boolean"&&u.cycles,w=u&&u.replacer?n(u.replacer):l;if(u&&typeof u.collapseEmpty<"u"&&typeof u.collapseEmpty!="boolean")throw new TypeError("`collapseEmpty` must be a boolean, if provided");var _=!!u&&u.collapseEmpty,x=typeof u=="function"?u:u&&u.cmp,A=x&&function(S){var T=x.length>2&&function(E){return S[E]};return function(b,E){return x({key:b,value:S[b]},{key:E,value:S[E]},T?{__proto__:null,get:T}:void 0)}},v=[];return function S(T,b,E,O){var k=p?`
|
|
15
|
-
`+
|
|
14
|
+
`+u+"}":"{"+p.join(",")+"}",t=u,d}}return Hr=function(s,f,c){var l;if(t="",r="",typeof c=="number")for(l=0;l<c;l+=1)r+=" ";else typeof c=="string"&&(r=c);if(i=f,f&&typeof f!="function"&&(typeof f!="object"||typeof f.length!="number"))throw new Error("JSON.stringify");return o("",{"":s})},Hr}var ua;function mf(){return ua||(ua=1,ir.parse=_f(),ir.stringify=bf()),ir}var Kr,ha;function Ef(){if(ha)return Kr;ha=1;var e={}.toString;return Kr=Array.isArray||function(t){return e.call(t)=="[object Array]"},Kr}var Vr,da;function pa(){if(da)return Vr;da=1;var e=Object.prototype.toString;return Vr=function(r){var n=e.call(r),i=n==="[object Arguments]";return i||(i=n!=="[object Array]"&&r!==null&&typeof r=="object"&&typeof r.length=="number"&&r.length>=0&&e.call(r.callee)==="[object Function]"),i},Vr}var Wr,ya;function xf(){if(ya)return Wr;ya=1;var e;if(!Object.keys){var t=Object.prototype.hasOwnProperty,r=Object.prototype.toString,n=pa(),i=Object.prototype.propertyIsEnumerable,a=!i.call({toString:null},"toString"),o=i.call(function(){},"prototype"),s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],f=function(h){var u=h.constructor;return u&&u.prototype===h},c={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},l=function(){if(typeof window>"u")return!1;for(var h in window)try{if(!c["$"+h]&&t.call(window,h)&&window[h]!==null&&typeof window[h]=="object")try{f(window[h])}catch{return!0}}catch{return!0}return!1}(),d=function(h){if(typeof window>"u"||!l)return f(h);try{return f(h)}catch{return!1}};e=function(u){var p=u!==null&&typeof u=="object",g=r.call(u)==="[object Function]",w=n(u),_=p&&r.call(u)==="[object String]",m=[];if(!p&&!g&&!w)throw new TypeError("Object.keys called on a non-object");var x=o&&g;if(_&&u.length>0&&!t.call(u,0))for(var v=0;v<u.length;++v)m.push(String(v));if(w&&u.length>0)for(var A=0;A<u.length;++A)m.push(String(A));else for(var O in u)!(x&&O==="prototype")&&t.call(u,O)&&m.push(String(O));if(a)for(var b=d(u),S=0;S<s.length;++S)!(b&&s[S]==="constructor")&&t.call(u,s[S])&&m.push(s[S]);return m}}return Wr=e,Wr}var Gr,ga;function Sf(){if(ga)return Gr;ga=1;var e=Array.prototype.slice,t=pa(),r=Object.keys,n=r?function(o){return r(o)}:xf(),i=Object.keys;return n.shim=function(){if(Object.keys){var o=function(){var s=Object.keys(arguments);return s&&s.length===arguments.length}(1,2);o||(Object.keys=function(f){return t(f)?i(e.call(f)):i(f)})}else Object.keys=n;return Object.keys||n},Gr=n,Gr}var Yr={exports:{}},Jr,va;function wa(){return va||(va=1,Jr=Object),Jr}var Xr,_a;function Af(){return _a||(_a=1,Xr=Error),Xr}var Qr,ba;function kf(){return ba||(ba=1,Qr=EvalError),Qr}var en,ma;function Rf(){return ma||(ma=1,en=RangeError),en}var tn,Ea;function Of(){return Ea||(Ea=1,tn=ReferenceError),tn}var rn,xa;function Sa(){return xa||(xa=1,rn=SyntaxError),rn}var nn,Aa;function ar(){return Aa||(Aa=1,nn=TypeError),nn}var an,ka;function Pf(){return ka||(ka=1,an=URIError),an}var on,Ra;function If(){return Ra||(Ra=1,on=Math.abs),on}var sn,Oa;function Tf(){return Oa||(Oa=1,sn=Math.floor),sn}var cn,Pa;function Df(){return Pa||(Pa=1,cn=Math.max),cn}var fn,Ia;function Cf(){return Ia||(Ia=1,fn=Math.min),fn}var ln,Ta;function jf(){return Ta||(Ta=1,ln=Math.pow),ln}var un,Da;function Ff(){return Da||(Da=1,un=Math.round),un}var hn,Ca;function Nf(){return Ca||(Ca=1,hn=Number.isNaN||function(t){return t!==t}),hn}var dn,ja;function Mf(){if(ja)return dn;ja=1;var e=Nf();return dn=function(r){return e(r)||r===0?r:r<0?-1:1},dn}var pn,Fa;function Lf(){return Fa||(Fa=1,pn=Object.getOwnPropertyDescriptor),pn}var yn,Na;function or(){if(Na)return yn;Na=1;var e=Lf();if(e)try{e([],"length")}catch{e=null}return yn=e,yn}var gn,Ma;function sr(){if(Ma)return gn;Ma=1;var e=Object.defineProperty||!1;if(e)try{e({},"a",{value:1})}catch{e=!1}return gn=e,gn}var vn,La;function $f(){return La||(La=1,vn=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;t[r]=i;for(var a in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var s=Object.getOwnPropertyDescriptor(t,r);if(s.value!==i||s.enumerable!==!0)return!1}return!0}),vn}var wn,$a;function Bf(){if($a)return wn;$a=1;var e=typeof Symbol<"u"&&Symbol,t=$f();return wn=function(){return typeof e!="function"||typeof Symbol!="function"||typeof e("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},wn}var _n,Ba;function Ua(){return Ba||(Ba=1,_n=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),_n}var bn,za;function Za(){if(za)return bn;za=1;var e=wa();return bn=e.getPrototypeOf||null,bn}var mn,qa;function Uf(){if(qa)return mn;qa=1;var e="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,r=Math.max,n="[object Function]",i=function(f,c){for(var l=[],d=0;d<f.length;d+=1)l[d]=f[d];for(var h=0;h<c.length;h+=1)l[h+f.length]=c[h];return l},a=function(f,c){for(var l=[],d=c,h=0;d<f.length;d+=1,h+=1)l[h]=f[d];return l},o=function(s,f){for(var c="",l=0;l<s.length;l+=1)c+=s[l],l+1<s.length&&(c+=f);return c};return mn=function(f){var c=this;if(typeof c!="function"||t.apply(c)!==n)throw new TypeError(e+c);for(var l=a(arguments,1),d,h=function(){if(this instanceof d){var _=c.apply(this,i(l,arguments));return Object(_)===_?_:this}return c.apply(f,i(l,arguments))},u=r(0,c.length-l.length),p=[],g=0;g<u;g++)p[g]="$"+g;if(d=Function("binder","return function ("+o(p,",")+"){ return binder.apply(this,arguments); }")(h),c.prototype){var w=function(){};w.prototype=c.prototype,d.prototype=new w,w.prototype=null}return d},mn}var En,Ha;function Pt(){if(Ha)return En;Ha=1;var e=Uf();return En=Function.prototype.bind||e,En}var xn,Ka;function Sn(){return Ka||(Ka=1,xn=Function.prototype.call),xn}var An,Va;function kn(){return Va||(Va=1,An=Function.prototype.apply),An}var Rn,Wa;function zf(){return Wa||(Wa=1,Rn=typeof Reflect<"u"&&Reflect&&Reflect.apply),Rn}var On,Ga;function Ya(){if(Ga)return On;Ga=1;var e=Pt(),t=kn(),r=Sn(),n=zf();return On=n||e.call(r,t),On}var Pn,Ja;function In(){if(Ja)return Pn;Ja=1;var e=Pt(),t=ar(),r=Sn(),n=Ya();return Pn=function(a){if(a.length<1||typeof a[0]!="function")throw new t("a function is required");return n(e,r,a)},Pn}var Tn,Xa;function Zf(){if(Xa)return Tn;Xa=1;var e=In(),t=or(),r;try{r=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var n=!!r&&t&&t(Object.prototype,"__proto__"),i=Object,a=i.getPrototypeOf;return Tn=n&&typeof n.get=="function"?e([n.get]):typeof a=="function"?function(s){return a(s==null?s:i(s))}:!1,Tn}var Dn,Qa;function qf(){if(Qa)return Dn;Qa=1;var e=Ua(),t=Za(),r=Zf();return Dn=e?function(i){return e(i)}:t?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return t(i)}:r?function(i){return r(i)}:null,Dn}var Cn,eo;function Hf(){if(eo)return Cn;eo=1;var e=Function.prototype.call,t=Object.prototype.hasOwnProperty,r=Pt();return Cn=r.call(e,t),Cn}var jn,to;function ro(){if(to)return jn;to=1;var e,t=wa(),r=Af(),n=kf(),i=Rf(),a=Of(),o=Sa(),s=ar(),f=Pf(),c=If(),l=Tf(),d=Df(),h=Cf(),u=jf(),p=Ff(),g=Mf(),w=Function,_=function(ue){try{return w('"use strict"; return ('+ue+").constructor;")()}catch{}},m=or(),x=sr(),v=function(){throw new s},A=m?function(){try{return arguments.callee,v}catch{try{return m(arguments,"callee").get}catch{return v}}}():v,O=Bf()(),b=qf(),S=Za(),P=Ua(),k=kn(),C=Sn(),q={},G=typeof Uint8Array>"u"||!b?e:b(Uint8Array),ie={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?e:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?e:ArrayBuffer,"%ArrayIteratorPrototype%":O&&b?b([][Symbol.iterator]()):e,"%AsyncFromSyncIteratorPrototype%":e,"%AsyncFunction%":q,"%AsyncGenerator%":q,"%AsyncGeneratorFunction%":q,"%AsyncIteratorPrototype%":q,"%Atomics%":typeof Atomics>"u"?e:Atomics,"%BigInt%":typeof BigInt>"u"?e:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?e:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?e:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?e:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":r,"%eval%":eval,"%EvalError%":n,"%Float16Array%":typeof Float16Array>"u"?e:Float16Array,"%Float32Array%":typeof Float32Array>"u"?e:Float32Array,"%Float64Array%":typeof Float64Array>"u"?e:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?e:FinalizationRegistry,"%Function%":w,"%GeneratorFunction%":q,"%Int8Array%":typeof Int8Array>"u"?e:Int8Array,"%Int16Array%":typeof Int16Array>"u"?e:Int16Array,"%Int32Array%":typeof Int32Array>"u"?e:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":O&&b?b(b([][Symbol.iterator]())):e,"%JSON%":typeof JSON=="object"?JSON:e,"%Map%":typeof Map>"u"?e:Map,"%MapIteratorPrototype%":typeof Map>"u"||!O||!b?e:b(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":t,"%Object.getOwnPropertyDescriptor%":m,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?e:Promise,"%Proxy%":typeof Proxy>"u"?e:Proxy,"%RangeError%":i,"%ReferenceError%":a,"%Reflect%":typeof Reflect>"u"?e:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?e:Set,"%SetIteratorPrototype%":typeof Set>"u"||!O||!b?e:b(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?e:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":O&&b?b(""[Symbol.iterator]()):e,"%Symbol%":O?Symbol:e,"%SyntaxError%":o,"%ThrowTypeError%":A,"%TypedArray%":G,"%TypeError%":s,"%Uint8Array%":typeof Uint8Array>"u"?e:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?e:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?e:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?e:Uint32Array,"%URIError%":f,"%WeakMap%":typeof WeakMap>"u"?e:WeakMap,"%WeakRef%":typeof WeakRef>"u"?e:WeakRef,"%WeakSet%":typeof WeakSet>"u"?e:WeakSet,"%Function.prototype.call%":C,"%Function.prototype.apply%":k,"%Object.defineProperty%":x,"%Object.getPrototypeOf%":S,"%Math.abs%":c,"%Math.floor%":l,"%Math.max%":d,"%Math.min%":h,"%Math.pow%":u,"%Math.round%":p,"%Math.sign%":g,"%Reflect.getPrototypeOf%":P};if(b)try{null.error}catch(ue){var Ze=b(b(ue));ie["%Error.prototype%"]=Ze}var J=function ue(N){var V;if(N==="%AsyncFunction%")V=_("async function () {}");else if(N==="%GeneratorFunction%")V=_("function* () {}");else if(N==="%AsyncGeneratorFunction%")V=_("async function* () {}");else if(N==="%AsyncGenerator%"){var $=ue("%AsyncGeneratorFunction%");$&&(V=$.prototype)}else if(N==="%AsyncIteratorPrototype%"){var Y=ue("%AsyncGenerator%");Y&&b&&(V=b(Y.prototype))}return ie[N]=V,V},le={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},qe=Pt(),He=Hf(),kt=qe.call(C,Array.prototype.concat),Dc=qe.call(k,Array.prototype.splice),$i=qe.call(C,String.prototype.replace),Gt=qe.call(C,String.prototype.slice),Cc=qe.call(C,RegExp.prototype.exec),jc=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Fc=/\\(\\)?/g,Nc=function(N){var V=Gt(N,0,1),$=Gt(N,-1);if(V==="%"&&$!=="%")throw new o("invalid intrinsic syntax, expected closing `%`");if($==="%"&&V!=="%")throw new o("invalid intrinsic syntax, expected opening `%`");var Y=[];return $i(N,jc,function(he,ht,X,Yt){Y[Y.length]=X?$i(Yt,Fc,"$1"):ht||he}),Y},Mc=function(N,V){var $=N,Y;if(He(le,$)&&(Y=le[$],$="%"+Y[0]+"%"),He(ie,$)){var he=ie[$];if(he===q&&(he=J($)),typeof he>"u"&&!V)throw new s("intrinsic "+N+" exists, but is not available. Please file an issue!");return{alias:Y,name:$,value:he}}throw new o("intrinsic "+N+" does not exist!")};return jn=function(N,V){if(typeof N!="string"||N.length===0)throw new s("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof V!="boolean")throw new s('"allowMissing" argument must be a boolean');if(Cc(/^%?[^%]*%?$/,N)===null)throw new o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var $=Nc(N),Y=$.length>0?$[0]:"",he=Mc("%"+Y+"%",V),ht=he.name,X=he.value,Yt=!1,Fr=he.alias;Fr&&(Y=Fr[0],Dc($,kt([0,1],Fr)));for(var Jt=1,Rt=!0;Jt<$.length;Jt+=1){var me=$[Jt],Xt=Gt(me,0,1),Qt=Gt(me,-1);if((Xt==='"'||Xt==="'"||Xt==="`"||Qt==='"'||Qt==="'"||Qt==="`")&&Xt!==Qt)throw new o("property names with quotes must have matching quotes");if((me==="constructor"||!Rt)&&(Yt=!0),Y+="."+me,ht="%"+Y+"%",He(ie,ht))X=ie[ht];else if(X!=null){if(!(me in X)){if(!V)throw new s("base intrinsic for "+N+" exists, but the property is not available.");return}if(m&&Jt+1>=$.length){var er=m(X,me);Rt=!!er,Rt&&"get"in er&&!("originalValue"in er.get)?X=er.get:X=X[me]}else Rt=He(X,me),X=X[me];Rt&&!Yt&&(ie[ht]=X)}}return X},jn}var Fn,no;function Kf(){if(no)return Fn;no=1;var e=sr(),t=Sa(),r=ar(),n=or();return Fn=function(a,o,s){if(!a||typeof a!="object"&&typeof a!="function")throw new r("`obj` must be an object or a function`");if(typeof o!="string"&&typeof o!="symbol")throw new r("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new r("`loose`, if provided, must be a boolean");var f=arguments.length>3?arguments[3]:null,c=arguments.length>4?arguments[4]:null,l=arguments.length>5?arguments[5]:null,d=arguments.length>6?arguments[6]:!1,h=!!n&&n(a,o);if(e)e(a,o,{configurable:l===null&&h?h.configurable:!l,enumerable:f===null&&h?h.enumerable:!f,value:s,writable:c===null&&h?h.writable:!c});else if(d||!f&&!c&&!l)a[o]=s;else throw new t("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Fn}var Nn,io;function Vf(){if(io)return Nn;io=1;var e=sr(),t=function(){return!!e};return t.hasArrayLengthDefineBug=function(){if(!e)return null;try{return e([],"length",{value:1}).length!==1}catch{return!0}},Nn=t,Nn}var Mn,ao;function Wf(){if(ao)return Mn;ao=1;var e=ro(),t=Kf(),r=Vf()(),n=or(),i=ar(),a=e("%Math.floor%");return Mn=function(s,f){if(typeof s!="function")throw new i("`fn` is not a function");if(typeof f!="number"||f<0||f>4294967295||a(f)!==f)throw new i("`length` must be a positive 32-bit integer");var c=arguments.length>2&&!!arguments[2],l=!0,d=!0;if("length"in s&&n){var h=n(s,"length");h&&!h.configurable&&(l=!1),h&&!h.writable&&(d=!1)}return(l||d||!c)&&(r?t(s,"length",f,!0,!0):t(s,"length",f)),s},Mn}var Ln,oo;function Gf(){if(oo)return Ln;oo=1;var e=Pt(),t=kn(),r=Ya();return Ln=function(){return r(e,t,arguments)},Ln}var so;function Yf(){return so||(so=1,function(e){var t=Wf(),r=sr(),n=In(),i=Gf();e.exports=function(o){var s=n(arguments),f=o.length-(arguments.length-1);return t(s,1+(f>0?f:0),!0)},r?r(e.exports,"apply",{value:i}):e.exports.apply=i}(Yr)),Yr.exports}var $n,co;function Jf(){if(co)return $n;co=1;var e=ro(),t=In(),r=t([e("%String.prototype.indexOf%")]);return $n=function(i,a){var o=e(i,!!a);return typeof o=="function"&&r(i,".prototype.")>-1?t([o]):o},$n}var Bn,fo;function Xf(){if(fo)return Bn;fo=1;var e=(typeof JSON<"u"?JSON:mf()).stringify,t=Ef(),r=Sf(),n=Yf(),i=Jf(),a=i("Array.prototype.join"),o=i("Array.prototype.indexOf"),s=i("Array.prototype.splice"),f=i("Array.prototype.sort"),c=function(h,u){for(var p="",g=0;g<h;g+=1)p+=u;return p},l=function(d,h,u){return u};return Bn=function(h){var u=arguments.length>1?arguments[1]:void 0,p=u&&u.space||"";typeof p=="number"&&(p=c(p," "));var g=!!u&&typeof u.cycles=="boolean"&&u.cycles,w=u&&u.replacer?n(u.replacer):l;if(u&&typeof u.collapseEmpty<"u"&&typeof u.collapseEmpty!="boolean")throw new TypeError("`collapseEmpty` must be a boolean, if provided");var _=!!u&&u.collapseEmpty,m=typeof u=="function"?u:u&&u.cmp,x=m&&function(A){var O=m.length>2&&function(S){return A[S]};return function(b,S){return m({key:b,value:A[b]},{key:S,value:A[S]},O?{__proto__:null,get:O}:void 0)}},v=[];return function A(O,b,S,P){var k=p?`
|
|
15
|
+
`+c(P,p):"",C=p?": ":":";if(S&&S.toJSON&&typeof S.toJSON=="function"&&(S=S.toJSON()),S=w(O,b,S),S!==void 0){if(typeof S!="object"||S===null)return e(S);var q=function(He,kt){return _&&He.length===0?kt:(kt==="[]"?"[":"{")+a(He,",")+k+(kt==="[]"?"]":"}")};if(t(S)){for(var J=[],G=0;G<S.length;G++){var ie=A(S,G,S[G],P+1)||e(null);J[J.length]=k+p+ie}return q(J,"[]")}if(o(v,S)!==-1){if(g)return e("__cycle__");throw new TypeError("Converting circular structure to JSON")}else v[v.length]=S;for(var Ze=f(r(S),x&&x(S)),J=[],G=0;G<Ze.length;G++){var b=Ze[G],le=A(S,b,S[b],P+1);if(le){var qe=e(b)+C+le;J[J.length]=k+p+qe}}return s(v,o(v,S),1),q(J,"{}")}}({"":h},"",h,0)},Bn}var Qf=Xf(),lo=wf(Qf);async function Un(e,t,r){if(!this.passphrase)return t.push({actual:e,type:"encryptionKeyMissing"}),e;try{return await Zr(String(e),this.passphrase)}catch(n){t.push({actual:e,type:"encryptionProblem",error:n})}return e}class uo extends Hc{constructor({options:t,passphrase:r,autoEncrypt:n=!0}={}){super(M.merge({},{useNewCustomCheckerFunction:!0,messages:{encryptionKeyMissing:"Missing configuration for secrets encryption.",encryptionProblem:"Problem encrypting secret. Actual: {actual}. Error: {error}"},defaults:{string:{trim:!0},object:{strict:"remove"}}},t)),this.passphrase=r,this.autoEncrypt=n,this.alias("secret",{type:"string",custom:this.autoEncrypt?Un:void 0,messages:{string:"The '{field}' field must be a string.",stringMin:"This secret '{field}' field length must be at least {expected} long."}}),this.alias("secretAny",{type:"any",custom:this.autoEncrypt?Un:void 0}),this.alias("secretNumber",{type:"number",custom:this.autoEncrypt?Un:void 0})}}const ho=new Proxy(uo,{instance:null,construct(e,t){return this.instance||(this.instance=new e(...t)),this.instance}}),po={trim:e=>e.trim(),encrypt:(e,{passphrase:t})=>Zr(e,t),decrypt:(e,{passphrase:t})=>sa(e,t),toString:e=>String(e),fromArray:(e,{separator:t})=>e==null||!Array.isArray(e)?e:e.length===0?"[]":e.map(n=>typeof n=="string"?n.replace(/\\/g,"\\\\").replace(new RegExp(`\\${t}`,"g"),`\\${t}`):String(n)).join(t),toArray:(e,{separator:t})=>{if(e==null)return e;if(e==="[]")return[];if(e==="")return[];const r=[];let n="",i=0;const a=String(e);for(;i<a.length;)a[i]==="\\"&&i+1<a.length?a[i+1]===t?(n+=t,i+=2):a[i+1]==="\\"?(n+="\\",i+=2):(n+=a[i],i++):a[i]===t?(r.push(n),n="",i++):(n+=a[i],i++);return r.push(n),r},toJSON:e=>JSON.stringify(e),fromJSON:e=>JSON.parse(e),toNumber:e=>M.isString(e)?e.includes(".")?parseFloat(e):parseInt(e):e,toBool:e=>[!0,1,"true","1","yes","y"].includes(e),fromBool:e=>[!0,1,"true","1","yes","y"].includes(e)?"1":"0"};class be{constructor(t){const{map:r,name:n,attributes:i,passphrase:a,version:o=1,options:s={}}=t;this.name=n,this.version=o,this.attributes=i||{},this.passphrase=a??"secret",this.options=M.merge({},this.defaultOptions(),s),this.allNestedObjectsOptional=this.options.allNestedObjectsOptional??!1;const f=this.preprocessAttributesForValidation(this.attributes);if(this.validator=new ho({autoEncrypt:!1}).compile(M.merge({$$async:!0},f)),this.options.generateAutoHooks&&this.generateAutoHooks(),!M.isEmpty(r))this.map=r,this.reversedMap=M.invert(r);else{const c=tr.flatten(this.attributes,{safe:!0}),l=Object.keys(c).filter(u=>!u.includes("$$")),d=this.extractObjectKeys(this.attributes),h=[...new Set([...l,...d])];this.reversedMap={...h},this.map=M.invert(this.reversedMap)}}defaultOptions(){return{autoEncrypt:!0,autoDecrypt:!0,arraySeparator:"|",generateAutoHooks:!0,hooks:{beforeMap:{},afterMap:{},beforeUnmap:{},afterUnmap:{}}}}addHook(t,r,n){this.options.hooks[t][r]||(this.options.hooks[t][r]=[]),this.options.hooks[t][r]=M.uniq([...this.options.hooks[t][r],n])}extractObjectKeys(t,r=""){const n=[];for(const[i,a]of Object.entries(t)){if(i.startsWith("$$"))continue;const o=r?`${r}.${i}`:i;typeof a=="object"&&a!==null&&!Array.isArray(a)&&(n.push(o),a.$$type==="object"&&n.push(...this.extractObjectKeys(a,o)))}return n}generateAutoHooks(){const t=tr.flatten(M.cloneDeep(this.attributes),{safe:!0});for(const[r,n]of Object.entries(t))n.includes("array")?(this.addHook("beforeMap",r,"fromArray"),this.addHook("afterUnmap",r,"toArray")):(n.includes("secret")&&(this.options.autoEncrypt&&this.addHook("beforeMap",r,"encrypt"),this.options.autoDecrypt&&this.addHook("afterUnmap",r,"decrypt")),n.includes("number")&&(this.addHook("beforeMap",r,"toString"),this.addHook("afterUnmap",r,"toNumber")),n.includes("boolean")&&(this.addHook("beforeMap",r,"fromBool"),this.addHook("afterUnmap",r,"toBool")))}static import(t){let{map:r,name:n,options:i,version:a,attributes:o}=M.isString(t)?JSON.parse(t):t;return o=be._importAttributes(o),new be({map:r,name:n,options:i,version:a,attributes:o})}static _importAttributes(t){if(typeof t=="string"){try{const r=JSON.parse(t);if(typeof r=="object"&&r!==null)return be._importAttributes(r)}catch{}return t}if(Array.isArray(t))return t.map(r=>be._importAttributes(r));if(typeof t=="object"&&t!==null){const r={};for(const[n,i]of Object.entries(t))r[n]=be._importAttributes(i);return r}return t}export(){return{version:this.version,name:this.name,options:this.options,attributes:this._exportAttributes(this.attributes),map:this.map}}_exportAttributes(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>this._exportAttributes(r));if(typeof t=="object"&&t!==null){const r={};for(const[n,i]of Object.entries(t))r[n]=this._exportAttributes(i);return r}return t}async applyHooksActions(t,r){for(const[n,i]of Object.entries(this.options.hooks[r]))for(const a of i){const o=M.get(t,n);o!==void 0&&typeof po[a]=="function"&&M.set(t,n,await po[a](o,{passphrase:this.passphrase,separator:this.options.arraySeparator}))}}async validate(t,{mutateOriginal:r=!1}={}){let n=r?t:M.cloneDeep(t);return await this.validator(n)}async mapper(t){const r=tr.flatten(M.cloneDeep(t),{safe:!0});await this.applyHooksActions(r,"beforeMap");const n={_v:this.version+""};for(const[i,a]of Object.entries(r))n[this.map[i]]=a;return await this.applyHooksActions(n,"afterMap"),n}async unmapper(t){const r=M.cloneDeep(t);delete r._v,await this.applyHooksActions(r,"beforeUnmap");const n={};for(const[i,a]of Object.entries(r))n[this.reversedMap[i]]=a;return await this.applyHooksActions(n,"afterUnmap"),tr.unflatten(n)}preprocessAttributesForValidation(t){const r={};for(const[n,i]of Object.entries(t))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){const a=i.$$type&&i.$$type.includes("required"),o=i.$$type&&i.$$type.includes("optional"),s={type:"object",properties:this.preprocessAttributesForValidation(i),strict:!1};a||(o||this.allNestedObjectsOptional)&&(s.optional=!0),r[n]=s}else r[n]=i;return r}}var dt=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},ge=[],ae=[],el=typeof Uint8Array<"u"?Uint8Array:Array,zn=!1;function yo(){zn=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t<r;++t)ge[t]=e[t],ae[e.charCodeAt(t)]=t;ae[45]=62,ae[95]=63}function tl(e){zn||yo();var t,r,n,i,a,o,s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a=e[s-2]==="="?2:e[s-1]==="="?1:0,o=new el(s*3/4-a),n=a>0?s-4:s;var f=0;for(t=0,r=0;t<n;t+=4,r+=3)i=ae[e.charCodeAt(t)]<<18|ae[e.charCodeAt(t+1)]<<12|ae[e.charCodeAt(t+2)]<<6|ae[e.charCodeAt(t+3)],o[f++]=i>>16&255,o[f++]=i>>8&255,o[f++]=i&255;return a===2?(i=ae[e.charCodeAt(t)]<<2|ae[e.charCodeAt(t+1)]>>4,o[f++]=i&255):a===1&&(i=ae[e.charCodeAt(t)]<<10|ae[e.charCodeAt(t+1)]<<4|ae[e.charCodeAt(t+2)]>>2,o[f++]=i>>8&255,o[f++]=i&255),o}function rl(e){return ge[e>>18&63]+ge[e>>12&63]+ge[e>>6&63]+ge[e&63]}function nl(e,t,r){for(var n,i=[],a=t;a<r;a+=3)n=(e[a]<<16)+(e[a+1]<<8)+e[a+2],i.push(rl(n));return i.join("")}function go(e){zn||yo();for(var t,r=e.length,n=r%3,i="",a=[],o=16383,s=0,f=r-n;s<f;s+=o)a.push(nl(e,s,s+o>f?f:s+o));return n===1?(t=e[r-1],i+=ge[t>>2],i+=ge[t<<4&63],i+="=="):n===2&&(t=(e[r-2]<<8)+e[r-1],i+=ge[t>>10],i+=ge[t>>4&63],i+=ge[t<<2&63],i+="="),a.push(i),a.join("")}function cr(e,t,r,n,i){var a,o,s=i*8-n-1,f=(1<<s)-1,c=f>>1,l=-7,d=r?i-1:0,h=r?-1:1,u=e[t+d];for(d+=h,a=u&(1<<-l)-1,u>>=-l,l+=s;l>0;a=a*256+e[t+d],d+=h,l-=8);for(o=a&(1<<-l)-1,a>>=-l,l+=n;l>0;o=o*256+e[t+d],d+=h,l-=8);if(a===0)a=1-c;else{if(a===f)return o?NaN:(u?-1:1)*(1/0);o=o+Math.pow(2,n),a=a-c}return(u?-1:1)*o*Math.pow(2,a-n)}function vo(e,t,r,n,i,a){var o,s,f,c=a*8-i-1,l=(1<<c)-1,d=l>>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,u=n?0:a-1,p=n?1:-1,g=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-o))<1&&(o--,f*=2),o+d>=1?t+=h/f:t+=h*Math.pow(2,1-d),t*f>=2&&(o++,f/=2),o+d>=l?(s=0,o=l):o+d>=1?(s=(t*f-1)*Math.pow(2,i),o=o+d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;e[r+u]=s&255,u+=p,s/=256,i-=8);for(o=o<<i|s,c+=i;c>0;e[r+u]=o&255,u+=p,o/=256,c-=8);e[r+u-p]|=g*128}var il={}.toString,wo=Array.isArray||function(e){return il.call(e)=="[object Array]"};/*!
|
|
16
16
|
* The buffer module from node.js, for the browser.
|
|
17
17
|
*
|
|
18
18
|
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
19
19
|
* @license MIT
|
|
20
|
-
*/var Yc=50;y.TYPED_ARRAY_SUPPORT=dt.TYPED_ARRAY_SUPPORT!==void 0?dt.TYPED_ARRAY_SUPPORT:!0,cr();function cr(){return y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function xe(e,t){if(cr()<t)throw new RangeError("Invalid typed array length");return y.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=y.prototype):(e===null&&(e=new y(t)),e.length=t),e}function y(e,t,r){if(!y.TYPED_ARRAY_SUPPORT&&!(this instanceof y))return new y(e,t,r);if(typeof e=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return Un(this,e)}return go(this,e,t,r)}y.poolSize=8192,y._augment=function(e){return e.__proto__=y.prototype,e};function go(e,t,r,n){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer?Qc(e,t,r,n):typeof t=="string"?Xc(e,t,r):el(e,t)}y.from=function(e,t,r){return go(null,e,t,r)},y.TYPED_ARRAY_SUPPORT&&(y.prototype.__proto__=Uint8Array.prototype,y.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&y[Symbol.species]);function vo(e){if(typeof e!="number")throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Jc(e,t,r,n){return vo(t),t<=0?xe(e,t):r!==void 0?typeof n=="string"?xe(e,t).fill(r,n):xe(e,t).fill(r):xe(e,t)}y.alloc=function(e,t,r){return Jc(null,e,t,r)};function Un(e,t){if(vo(t),e=xe(e,t<0?0:Zn(t)|0),!y.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}y.allocUnsafe=function(e){return Un(null,e)},y.allocUnsafeSlow=function(e){return Un(null,e)};function Xc(e,t,r){if((typeof r!="string"||r==="")&&(r="utf8"),!y.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=wo(t,r)|0;e=xe(e,n);var i=e.write(t,r);return i!==n&&(e=e.slice(0,i)),e}function zn(e,t){var r=t.length<0?0:Zn(t.length)|0;e=xe(e,r);for(var n=0;n<r;n+=1)e[n]=t[n]&255;return e}function Qc(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 r===void 0&&n===void 0?t=new Uint8Array(t):n===void 0?t=new Uint8Array(t,r):t=new Uint8Array(t,r,n),y.TYPED_ARRAY_SUPPORT?(e=t,e.__proto__=y.prototype):e=zn(e,t),e}function el(e,t){if(ge(t)){var r=Zn(t.length)|0;return e=xe(e,r),e.length===0||t.copy(e,0,0,r),e}if(t){if(typeof ArrayBuffer<"u"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||_l(t.length)?xe(e,0):zn(e,t);if(t.type==="Buffer"&&yo(t.data))return zn(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Zn(e){if(e>=cr())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+cr().toString(16)+" bytes");return e|0}y.isBuffer=bl;function ge(e){return!!(e!=null&&e._isBuffer)}y.compare=function(t,r){if(!ge(t)||!ge(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var n=t.length,i=r.length,a=0,o=Math.min(n,i);a<o;++a)if(t[a]!==r[a]){n=t[a],i=r[a];break}return n<i?-1:i<n?1:0},y.isEncoding=function(t){switch(String(t).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}},y.concat=function(t,r){if(!yo(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return y.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;var i=y.allocUnsafe(r),a=0;for(n=0;n<t.length;++n){var o=t[n];if(!ge(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,a),a+=o.length}return i};function wo(e,t){if(ge(e))return e.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;typeof e!="string"&&(e=""+e);var r=e.length;if(r===0)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 hr(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ro(e).length;default:if(n)return hr(e).length;t=(""+t).toLowerCase(),n=!0}}y.byteLength=wo;function tl(e,t,r){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return ul(this,t,r);case"utf8":case"utf-8":return xo(this,t,r);case"ascii":return cl(this,t,r);case"latin1":case"binary":return ll(this,t,r);case"base64":return sl(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hl(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}y.prototype._isBuffer=!0;function He(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}y.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)He(this,r,r+1);return this},y.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)He(this,r,r+3),He(this,r+1,r+2);return this},y.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)He(this,r,r+7),He(this,r+1,r+6),He(this,r+2,r+5),He(this,r+3,r+4);return this},y.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?xo(this,0,t):tl.apply(this,arguments)},y.prototype.equals=function(t){if(!ge(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:y.compare(this,t)===0},y.prototype.inspect=function(){var t="",r=Yc;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},y.prototype.compare=function(t,r,n,i,a){if(!ge(t))throw new TypeError("Argument must be a Buffer");if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),a===void 0&&(a=this.length),r<0||n>t.length||i<0||a>this.length)throw new RangeError("out of range index");if(i>=a&&r>=n)return 0;if(i>=a)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,a>>>=0,this===t)return 0;for(var o=a-i,s=n-r,c=Math.min(o,s),f=this.slice(i,a),l=t.slice(r,n),d=0;d<c;++d)if(f[d]!==l[d]){o=f[d],s=l[d];break}return o<s?-1:s<o?1:0};function _o(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(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)r=0;else return-1;if(typeof t=="string"&&(t=y.from(t,n)),ge(t))return t.length===0?-1:bo(e,t,r,n,i);if(typeof t=="number")return t=t&255,y.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):bo(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function bo(e,t,r,n,i){var a=1,o=e.length,s=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,r/=2}function c(u,p){return a===1?u[p]:u.readUInt16BE(p*a)}var f;if(i){var l=-1;for(f=r;f<o;f++)if(c(e,f)===c(t,l===-1?0:f-l)){if(l===-1&&(l=f),f-l+1===s)return l*a}else l!==-1&&(f-=f-l),l=-1}else for(r+s>o&&(r=o-s),f=r;f>=0;f--){for(var d=!0,h=0;h<s;h++)if(c(e,f+h)!==c(t,h)){d=!1;break}if(d)return f}return-1}y.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1},y.prototype.indexOf=function(t,r,n){return _o(this,t,r,n,!0)},y.prototype.lastIndexOf=function(t,r,n){return _o(this,t,r,n,!1)};function rl(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var a=t.length;if(a%2!==0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;o<n;++o){var s=parseInt(t.substr(o*2,2),16);if(isNaN(s))return o;e[r+o]=s}return o}function nl(e,t,r,n){return dr(hr(t,e.length-r),e,r,n)}function mo(e,t,r,n){return dr(vl(t),e,r,n)}function il(e,t,r,n){return mo(e,t,r,n)}function al(e,t,r,n){return dr(Ro(t),e,r,n)}function ol(e,t,r,n){return dr(wl(t,e.length-r),e,r,n)}y.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r|0,isFinite(n)?(n=n|0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var a=this.length-r;if((n===void 0||n>a)&&(n=a),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return rl(this,t,r,n);case"utf8":case"utf-8":return nl(this,t,r,n);case"ascii":return mo(this,t,r,n);case"latin1":case"binary":return il(this,t,r,n);case"base64":return al(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ol(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function sl(e,t,r){return t===0&&r===e.length?ho(e):ho(e.slice(t,r))}function xo(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var a=e[i],o=null,s=a>239?4:a>223?3:a>191?2:1;if(i+s<=r){var c,f,l,d;switch(s){case 1:a<128&&(o=a);break;case 2:c=e[i+1],(c&192)===128&&(d=(a&31)<<6|c&63,d>127&&(o=d));break;case 3:c=e[i+1],f=e[i+2],(c&192)===128&&(f&192)===128&&(d=(a&15)<<12|(c&63)<<6|f&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:c=e[i+1],f=e[i+2],l=e[i+3],(c&192)===128&&(f&192)===128&&(l&192)===128&&(d=(a&15)<<18|(c&63)<<12|(f&63)<<6|l&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=s}return fl(n)}var Eo=4096;function fl(e){var t=e.length;if(t<=Eo)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Eo));return r}function cl(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function ll(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 ul(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",a=t;a<r;++a)i+=gl(e[a]);return i}function hl(e,t,r){for(var n=e.slice(t,r),i="",a=0;a<n.length;a+=2)i+=String.fromCharCode(n[a]+n[a+1]*256);return i}y.prototype.slice=function(t,r){var n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);var i;if(y.TYPED_ARRAY_SUPPORT)i=this.subarray(t,r),i.__proto__=y.prototype;else{var a=r-t;i=new y(a,void 0);for(var o=0;o<a;++o)i[o]=this[o+t]}return i};function z(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")}y.prototype.readUIntLE=function(t,r,n){t=t|0,r=r|0,n||z(t,r,this.length);for(var i=this[t],a=1,o=0;++o<r&&(a*=256);)i+=this[t+o]*a;return i},y.prototype.readUIntBE=function(t,r,n){t=t|0,r=r|0,n||z(t,r,this.length);for(var i=this[t+--r],a=1;r>0&&(a*=256);)i+=this[t+--r]*a;return i},y.prototype.readUInt8=function(t,r){return r||z(t,1,this.length),this[t]},y.prototype.readUInt16LE=function(t,r){return r||z(t,2,this.length),this[t]|this[t+1]<<8},y.prototype.readUInt16BE=function(t,r){return r||z(t,2,this.length),this[t]<<8|this[t+1]},y.prototype.readUInt32LE=function(t,r){return r||z(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},y.prototype.readUInt32BE=function(t,r){return r||z(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},y.prototype.readIntLE=function(t,r,n){t=t|0,r=r|0,n||z(t,r,this.length);for(var i=this[t],a=1,o=0;++o<r&&(a*=256);)i+=this[t+o]*a;return a*=128,i>=a&&(i-=Math.pow(2,8*r)),i},y.prototype.readIntBE=function(t,r,n){t=t|0,r=r|0,n||z(t,r,this.length);for(var i=r,a=1,o=this[t+--i];i>0&&(a*=256);)o+=this[t+--i]*a;return a*=128,o>=a&&(o-=Math.pow(2,8*r)),o},y.prototype.readInt8=function(t,r){return r||z(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},y.prototype.readInt16LE=function(t,r){r||z(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n},y.prototype.readInt16BE=function(t,r){r||z(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n},y.prototype.readInt32LE=function(t,r){return r||z(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},y.prototype.readInt32BE=function(t,r){return r||z(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},y.prototype.readFloatLE=function(t,r){return r||z(t,4,this.length),fr(this,t,!0,23,4)},y.prototype.readFloatBE=function(t,r){return r||z(t,4,this.length),fr(this,t,!1,23,4)},y.prototype.readDoubleLE=function(t,r){return r||z(t,8,this.length),fr(this,t,!0,52,8)},y.prototype.readDoubleBE=function(t,r){return r||z(t,8,this.length),fr(this,t,!1,52,8)};function Q(e,t,r,n,i,a){if(!ge(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<a)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}y.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r|0,n=n|0,!i){var a=Math.pow(2,8*n)-1;Q(this,t,r,n,a,0)}var o=1,s=0;for(this[r]=t&255;++s<n&&(o*=256);)this[r+s]=t/o&255;return r+n},y.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r|0,n=n|0,!i){var a=Math.pow(2,8*n)-1;Q(this,t,r,n,a,0)}var o=n-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+n},y.prototype.writeUInt8=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,1,255,0),y.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=t&255,r+1};function lr(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,a=Math.min(e.length-r,2);i<a;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}y.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):lr(this,t,r,!0),r+2},y.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):lr(this,t,r,!1),r+2};function ur(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,a=Math.min(e.length-r,4);i<a;++i)e[r+i]=t>>>(n?i:3-i)*8&255}y.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255):ur(this,t,r,!0),r+4},y.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):ur(this,t,r,!1),r+4},y.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r|0,!i){var a=Math.pow(2,8*n-1);Q(this,t,r,n,a-1,-a)}var o=0,s=1,c=0;for(this[r]=t&255;++o<n&&(s*=256);)t<0&&c===0&&this[r+o-1]!==0&&(c=1),this[r+o]=(t/s>>0)-c&255;return r+n},y.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r|0,!i){var a=Math.pow(2,8*n-1);Q(this,t,r,n,a-1,-a)}var o=n-1,s=1,c=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&c===0&&this[r+o+1]!==0&&(c=1),this[r+o]=(t/s>>0)-c&255;return r+n},y.prototype.writeInt8=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,1,127,-128),y.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=t&255,r+1},y.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):lr(this,t,r,!0),r+2},y.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):lr(this,t,r,!1),r+2},y.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,4,2147483647,-2147483648),y.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):ur(this,t,r,!0),r+4},y.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):ur(this,t,r,!1),r+4};function So(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ao(e,t,r,n,i){return i||So(e,t,r,4),po(e,t,r,n,23,4),r+4}y.prototype.writeFloatLE=function(t,r,n){return Ao(this,t,r,!0,n)},y.prototype.writeFloatBE=function(t,r,n){return Ao(this,t,r,!1,n)};function ko(e,t,r,n,i){return i||So(e,t,r,8),po(e,t,r,n,52,8),r+8}y.prototype.writeDoubleLE=function(t,r,n){return ko(this,t,r,!0,n)},y.prototype.writeDoubleBE=function(t,r,n){return ko(this,t,r,!1,n)},y.prototype.copy=function(t,r,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);var a=i-n,o;if(this===t&&n<r&&r<i)for(o=a-1;o>=0;--o)t[o+r]=this[o+n];else if(a<1e3||!y.TYPED_ARRAY_SUPPORT)for(o=0;o<a;++o)t[o+r]=this[o+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+a),r);return a},y.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),t.length===1){var a=t.charCodeAt(0);a<256&&(t=a)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!y.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&255);if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);var o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{var s=ge(t)?t:hr(new y(t,i).toString()),c=s.length;for(o=0;o<n-r;++o)this[o+r]=s[o%c]}return this};var dl=/[^+\/0-9A-Za-z-_]/g;function pl(e){if(e=yl(e).replace(dl,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function yl(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function gl(e){return e<16?"0"+e.toString(16):e.toString(16)}function hr(e,t){t=t||1/0;for(var r,n=e.length,i=null,a=[],o=0;o<n;++o){if(r=e.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return a}function vl(e){for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function wl(e,t){for(var r,n,i,a=[],o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),n=r>>8,i=r%256,a.push(i),a.push(n);return a}function Ro(e){return Kc(pl(e))}function dr(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}function _l(e){return e!==e}function bl(e){return e!=null&&(!!e._isBuffer||Oo(e)||ml(e))}function Oo(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function ml(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&Oo(e.slice(0,0))}function To(){throw new Error("setTimeout has not been defined")}function Po(){throw new Error("clearTimeout has not been defined")}var Pe=To,Ie=Po;typeof dt.setTimeout=="function"&&(Pe=setTimeout),typeof dt.clearTimeout=="function"&&(Ie=clearTimeout);function Io(e){if(Pe===setTimeout)return setTimeout(e,0);if((Pe===To||!Pe)&&setTimeout)return Pe=setTimeout,setTimeout(e,0);try{return Pe(e,0)}catch{try{return Pe.call(null,e,0)}catch{return Pe.call(this,e,0)}}}function xl(e){if(Ie===clearTimeout)return clearTimeout(e);if((Ie===Po||!Ie)&&clearTimeout)return Ie=clearTimeout,clearTimeout(e);try{return Ie(e)}catch{try{return Ie.call(null,e)}catch{return Ie.call(this,e)}}}var Ee=[],pt=!1,Ke,pr=-1;function El(){!pt||!Ke||(pt=!1,Ke.length?Ee=Ke.concat(Ee):pr=-1,Ee.length&&Fo())}function Fo(){if(!pt){var e=Io(El);pt=!0;for(var t=Ee.length;t;){for(Ke=Ee,Ee=[];++pr<t;)Ke&&Ke[pr].run();pr=-1,t=Ee.length}Ke=null,pt=!1,xl(e)}}function te(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];Ee.push(new Co(e,t)),Ee.length===1&&!pt&&Io(Fo)}function Co(e,t){this.fun=e,this.array=t}Co.prototype.run=function(){this.fun.apply(null,this.array)};var Sl="browser",Al="browser",kl=!0,Rl={},Ol=[],Tl="",Pl={},Il={},Fl={};function We(){}var Cl=We,Dl=We,jl=We,Ml=We,Ll=We,Nl=We,Bl=We;function $l(e){throw new Error("process.binding is not supported")}function Ul(){return"/"}function zl(e){throw new Error("process.chdir is not supported")}function Zl(){return 0}var yt=dt.performance||{},ql=yt.now||yt.mozNow||yt.msNow||yt.oNow||yt.webkitNow||function(){return new Date().getTime()};function Hl(e){var t=ql.call(yt)*.001,r=Math.floor(t),n=Math.floor(t%1*1e9);return e&&(r=r-e[0],n=n-e[1],n<0&&(r--,n+=1e9)),[r,n]}var Kl=new Date;function Wl(){var e=new Date,t=e-Kl;return t/1e3}var Se={nextTick:te,title:Sl,browser:kl,env:Rl,argv:Ol,version:Tl,versions:Pl,on:Cl,addListener:Dl,once:jl,off:Ml,removeListener:Ll,removeAllListeners:Nl,emit:Bl,binding:$l,cwd:Ul,chdir:zl,umask:Zl,hrtime:Hl,platform:Al,release:Il,config:Fl,uptime:Wl},V;typeof Object.create=="function"?V=function(t,r){t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:V=function(t,r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t};var Vl=/%[sdj%]/g;function Gl(e){if(!Vn(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(Fe(arguments[r]));return t.join(" ")}for(var r=1,n=arguments,i=n.length,a=String(e).replace(Vl,function(s){if(s==="%%")return"%";if(r>=i)return s;switch(s){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch{return"[Circular]"}default:return s}}),o=n[r];r<i;o=n[++r])Wn(o)||!Pt(o)?a+=" "+o:a+=" "+Fe(o);return a}function Do(e,t){if(Ce(dt.process))return function(){return Do(e,t).apply(this,arguments)};if(Se.noDeprecation===!0)return e;var r=!1;function n(){if(!r){if(Se.throwDeprecation)throw new Error(t);Se.traceDeprecation?console.trace(t):console.error(t),r=!0}return e.apply(this,arguments)}return n}var yr={},qn;function Yl(e){if(Ce(qn)&&(qn=Se.env.NODE_DEBUG||""),e=e.toUpperCase(),!yr[e])if(new RegExp("\\b"+e+"\\b","i").test(qn)){var t=0;yr[e]=function(){var r=Gl.apply(null,arguments);console.error("%s %d: %s",e,t,r)}}else yr[e]=function(){};return yr[e]}function Fe(e,t){var r={seen:[],stylize:Xl};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),jo(t)?r.showHidden=t:t&&au(r,t),Ce(r.showHidden)&&(r.showHidden=!1),Ce(r.depth)&&(r.depth=2),Ce(r.colors)&&(r.colors=!1),Ce(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=Jl),gr(r,e,r.depth)}Fe.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},Fe.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function Jl(e,t){var r=Fe.styles[t];return r?"\x1B["+Fe.colors[r][0]+"m"+e+"\x1B["+Fe.colors[r][1]+"m":e}function Xl(e,t){return e}function Ql(e){var t={};return e.forEach(function(r,n){t[r]=!0}),t}function gr(e,t,r){if(e.customInspect&&t&&Jn(t.inspect)&&t.inspect!==Fe&&!(t.constructor&&t.constructor.prototype===t)){var n=t.inspect(r,e);return Vn(n)||(n=gr(e,n,r)),n}var i=eu(e,t);if(i)return i;var a=Object.keys(t),o=Ql(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),Yn(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return Hn(t);if(a.length===0){if(Jn(t)){var s=t.name?": "+t.name:"";return e.stylize("[Function"+s+"]","special")}if(Gn(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(Mo(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Yn(t))return Hn(t)}var c="",f=!1,l=["{","}"];if(nu(t)&&(f=!0,l=["[","]"]),Jn(t)){var d=t.name?": "+t.name:"";c=" [Function"+d+"]"}if(Gn(t)&&(c=" "+RegExp.prototype.toString.call(t)),Mo(t)&&(c=" "+Date.prototype.toUTCString.call(t)),Yn(t)&&(c=" "+Hn(t)),a.length===0&&(!f||t.length==0))return l[0]+c+l[1];if(r<0)return Gn(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var h;return f?h=tu(e,t,r,o,a):h=a.map(function(u){return Kn(e,t,r,o,u,f)}),e.seen.pop(),ru(h,c,l)}function eu(e,t){if(Ce(t))return e.stylize("undefined","undefined");if(Vn(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(iu(t))return e.stylize(""+t,"number");if(jo(t))return e.stylize(""+t,"boolean");if(Wn(t))return e.stylize("null","null")}function Hn(e){return"["+Error.prototype.toString.call(e)+"]"}function tu(e,t,r,n,i){for(var a=[],o=0,s=t.length;o<s;++o)Lo(t,String(o))?a.push(Kn(e,t,r,n,String(o),!0)):a.push("");return i.forEach(function(c){c.match(/^\d+$/)||a.push(Kn(e,t,r,n,c,!0))}),a}function Kn(e,t,r,n,i,a){var o,s,c;if(c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},c.get?c.set?s=e.stylize("[Getter/Setter]","special"):s=e.stylize("[Getter]","special"):c.set&&(s=e.stylize("[Setter]","special")),Lo(n,i)||(o="["+i+"]"),s||(e.seen.indexOf(c.value)<0?(Wn(r)?s=gr(e,c.value,null):s=gr(e,c.value,r-1),s.indexOf(`
|
|
20
|
+
*/var al=50;y.TYPED_ARRAY_SUPPORT=dt.TYPED_ARRAY_SUPPORT!==void 0?dt.TYPED_ARRAY_SUPPORT:!0,fr();function fr(){return y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function xe(e,t){if(fr()<t)throw new RangeError("Invalid typed array length");return y.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=y.prototype):(e===null&&(e=new y(t)),e.length=t),e}function y(e,t,r){if(!y.TYPED_ARRAY_SUPPORT&&!(this instanceof y))return new y(e,t,r);if(typeof e=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return Zn(this,e)}return _o(this,e,t,r)}y.poolSize=8192,y._augment=function(e){return e.__proto__=y.prototype,e};function _o(e,t,r,n){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer?cl(e,t,r,n):typeof t=="string"?sl(e,t,r):fl(e,t)}y.from=function(e,t,r){return _o(null,e,t,r)},y.TYPED_ARRAY_SUPPORT&&(y.prototype.__proto__=Uint8Array.prototype,y.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&y[Symbol.species]);function bo(e){if(typeof e!="number")throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function ol(e,t,r,n){return bo(t),t<=0?xe(e,t):r!==void 0?typeof n=="string"?xe(e,t).fill(r,n):xe(e,t).fill(r):xe(e,t)}y.alloc=function(e,t,r){return ol(null,e,t,r)};function Zn(e,t){if(bo(t),e=xe(e,t<0?0:Hn(t)|0),!y.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}y.allocUnsafe=function(e){return Zn(null,e)},y.allocUnsafeSlow=function(e){return Zn(null,e)};function sl(e,t,r){if((typeof r!="string"||r==="")&&(r="utf8"),!y.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=mo(t,r)|0;e=xe(e,n);var i=e.write(t,r);return i!==n&&(e=e.slice(0,i)),e}function qn(e,t){var r=t.length<0?0:Hn(t.length)|0;e=xe(e,r);for(var n=0;n<r;n+=1)e[n]=t[n]&255;return e}function cl(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 r===void 0&&n===void 0?t=new Uint8Array(t):n===void 0?t=new Uint8Array(t,r):t=new Uint8Array(t,r,n),y.TYPED_ARRAY_SUPPORT?(e=t,e.__proto__=y.prototype):e=qn(e,t),e}function fl(e,t){if(ve(t)){var r=Hn(t.length)|0;return e=xe(e,r),e.length===0||t.copy(e,0,0,r),e}if(t){if(typeof ArrayBuffer<"u"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||Ol(t.length)?xe(e,0):qn(e,t);if(t.type==="Buffer"&&wo(t.data))return qn(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Hn(e){if(e>=fr())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+fr().toString(16)+" bytes");return e|0}y.isBuffer=Pl;function ve(e){return!!(e!=null&&e._isBuffer)}y.compare=function(t,r){if(!ve(t)||!ve(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var n=t.length,i=r.length,a=0,o=Math.min(n,i);a<o;++a)if(t[a]!==r[a]){n=t[a],i=r[a];break}return n<i?-1:i<n?1:0},y.isEncoding=function(t){switch(String(t).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}},y.concat=function(t,r){if(!wo(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return y.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;var i=y.allocUnsafe(r),a=0;for(n=0;n<t.length;++n){var o=t[n];if(!ve(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,a),a+=o.length}return i};function mo(e,t){if(ve(e))return e.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;typeof e!="string"&&(e=""+e);var r=e.length;if(r===0)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 hr(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Io(e).length;default:if(n)return hr(e).length;t=(""+t).toLowerCase(),n=!0}}y.byteLength=mo;function ll(e,t,r){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return bl(this,t,r);case"utf8":case"utf-8":return Ao(this,t,r);case"ascii":return wl(this,t,r);case"latin1":case"binary":return _l(this,t,r);case"base64":return gl(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ml(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}y.prototype._isBuffer=!0;function Ke(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}y.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)Ke(this,r,r+1);return this},y.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)Ke(this,r,r+3),Ke(this,r+1,r+2);return this},y.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)Ke(this,r,r+7),Ke(this,r+1,r+6),Ke(this,r+2,r+5),Ke(this,r+3,r+4);return this},y.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?Ao(this,0,t):ll.apply(this,arguments)},y.prototype.equals=function(t){if(!ve(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:y.compare(this,t)===0},y.prototype.inspect=function(){var t="",r=al;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},y.prototype.compare=function(t,r,n,i,a){if(!ve(t))throw new TypeError("Argument must be a Buffer");if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),a===void 0&&(a=this.length),r<0||n>t.length||i<0||a>this.length)throw new RangeError("out of range index");if(i>=a&&r>=n)return 0;if(i>=a)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,a>>>=0,this===t)return 0;for(var o=a-i,s=n-r,f=Math.min(o,s),c=this.slice(i,a),l=t.slice(r,n),d=0;d<f;++d)if(c[d]!==l[d]){o=c[d],s=l[d];break}return o<s?-1:s<o?1:0};function Eo(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(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)r=0;else return-1;if(typeof t=="string"&&(t=y.from(t,n)),ve(t))return t.length===0?-1:xo(e,t,r,n,i);if(typeof t=="number")return t=t&255,y.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):xo(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function xo(e,t,r,n,i){var a=1,o=e.length,s=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,r/=2}function f(u,p){return a===1?u[p]:u.readUInt16BE(p*a)}var c;if(i){var l=-1;for(c=r;c<o;c++)if(f(e,c)===f(t,l===-1?0:c-l)){if(l===-1&&(l=c),c-l+1===s)return l*a}else l!==-1&&(c-=c-l),l=-1}else for(r+s>o&&(r=o-s),c=r;c>=0;c--){for(var d=!0,h=0;h<s;h++)if(f(e,c+h)!==f(t,h)){d=!1;break}if(d)return c}return-1}y.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1},y.prototype.indexOf=function(t,r,n){return Eo(this,t,r,n,!0)},y.prototype.lastIndexOf=function(t,r,n){return Eo(this,t,r,n,!1)};function ul(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var a=t.length;if(a%2!==0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;o<n;++o){var s=parseInt(t.substr(o*2,2),16);if(isNaN(s))return o;e[r+o]=s}return o}function hl(e,t,r,n){return dr(hr(t,e.length-r),e,r,n)}function So(e,t,r,n){return dr(kl(t),e,r,n)}function dl(e,t,r,n){return So(e,t,r,n)}function pl(e,t,r,n){return dr(Io(t),e,r,n)}function yl(e,t,r,n){return dr(Rl(t,e.length-r),e,r,n)}y.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r|0,isFinite(n)?(n=n|0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var a=this.length-r;if((n===void 0||n>a)&&(n=a),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return ul(this,t,r,n);case"utf8":case"utf-8":return hl(this,t,r,n);case"ascii":return So(this,t,r,n);case"latin1":case"binary":return dl(this,t,r,n);case"base64":return pl(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return yl(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function gl(e,t,r){return t===0&&r===e.length?go(e):go(e.slice(t,r))}function Ao(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var a=e[i],o=null,s=a>239?4:a>223?3:a>191?2:1;if(i+s<=r){var f,c,l,d;switch(s){case 1:a<128&&(o=a);break;case 2:f=e[i+1],(f&192)===128&&(d=(a&31)<<6|f&63,d>127&&(o=d));break;case 3:f=e[i+1],c=e[i+2],(f&192)===128&&(c&192)===128&&(d=(a&15)<<12|(f&63)<<6|c&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:f=e[i+1],c=e[i+2],l=e[i+3],(f&192)===128&&(c&192)===128&&(l&192)===128&&(d=(a&15)<<18|(f&63)<<12|(c&63)<<6|l&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=s}return vl(n)}var ko=4096;function vl(e){var t=e.length;if(t<=ko)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=ko));return r}function wl(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function _l(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 bl(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",a=t;a<r;++a)i+=Al(e[a]);return i}function ml(e,t,r){for(var n=e.slice(t,r),i="",a=0;a<n.length;a+=2)i+=String.fromCharCode(n[a]+n[a+1]*256);return i}y.prototype.slice=function(t,r){var n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);var i;if(y.TYPED_ARRAY_SUPPORT)i=this.subarray(t,r),i.__proto__=y.prototype;else{var a=r-t;i=new y(a,void 0);for(var o=0;o<a;++o)i[o]=this[o+t]}return i};function z(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")}y.prototype.readUIntLE=function(t,r,n){t=t|0,r=r|0,n||z(t,r,this.length);for(var i=this[t],a=1,o=0;++o<r&&(a*=256);)i+=this[t+o]*a;return i},y.prototype.readUIntBE=function(t,r,n){t=t|0,r=r|0,n||z(t,r,this.length);for(var i=this[t+--r],a=1;r>0&&(a*=256);)i+=this[t+--r]*a;return i},y.prototype.readUInt8=function(t,r){return r||z(t,1,this.length),this[t]},y.prototype.readUInt16LE=function(t,r){return r||z(t,2,this.length),this[t]|this[t+1]<<8},y.prototype.readUInt16BE=function(t,r){return r||z(t,2,this.length),this[t]<<8|this[t+1]},y.prototype.readUInt32LE=function(t,r){return r||z(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},y.prototype.readUInt32BE=function(t,r){return r||z(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},y.prototype.readIntLE=function(t,r,n){t=t|0,r=r|0,n||z(t,r,this.length);for(var i=this[t],a=1,o=0;++o<r&&(a*=256);)i+=this[t+o]*a;return a*=128,i>=a&&(i-=Math.pow(2,8*r)),i},y.prototype.readIntBE=function(t,r,n){t=t|0,r=r|0,n||z(t,r,this.length);for(var i=r,a=1,o=this[t+--i];i>0&&(a*=256);)o+=this[t+--i]*a;return a*=128,o>=a&&(o-=Math.pow(2,8*r)),o},y.prototype.readInt8=function(t,r){return r||z(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},y.prototype.readInt16LE=function(t,r){r||z(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n},y.prototype.readInt16BE=function(t,r){r||z(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n},y.prototype.readInt32LE=function(t,r){return r||z(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},y.prototype.readInt32BE=function(t,r){return r||z(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},y.prototype.readFloatLE=function(t,r){return r||z(t,4,this.length),cr(this,t,!0,23,4)},y.prototype.readFloatBE=function(t,r){return r||z(t,4,this.length),cr(this,t,!1,23,4)},y.prototype.readDoubleLE=function(t,r){return r||z(t,8,this.length),cr(this,t,!0,52,8)},y.prototype.readDoubleBE=function(t,r){return r||z(t,8,this.length),cr(this,t,!1,52,8)};function Q(e,t,r,n,i,a){if(!ve(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<a)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}y.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r|0,n=n|0,!i){var a=Math.pow(2,8*n)-1;Q(this,t,r,n,a,0)}var o=1,s=0;for(this[r]=t&255;++s<n&&(o*=256);)this[r+s]=t/o&255;return r+n},y.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r|0,n=n|0,!i){var a=Math.pow(2,8*n)-1;Q(this,t,r,n,a,0)}var o=n-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+n},y.prototype.writeUInt8=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,1,255,0),y.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=t&255,r+1};function lr(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,a=Math.min(e.length-r,2);i<a;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}y.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):lr(this,t,r,!0),r+2},y.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):lr(this,t,r,!1),r+2};function ur(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,a=Math.min(e.length-r,4);i<a;++i)e[r+i]=t>>>(n?i:3-i)*8&255}y.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255):ur(this,t,r,!0),r+4},y.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):ur(this,t,r,!1),r+4},y.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r|0,!i){var a=Math.pow(2,8*n-1);Q(this,t,r,n,a-1,-a)}var o=0,s=1,f=0;for(this[r]=t&255;++o<n&&(s*=256);)t<0&&f===0&&this[r+o-1]!==0&&(f=1),this[r+o]=(t/s>>0)-f&255;return r+n},y.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r|0,!i){var a=Math.pow(2,8*n-1);Q(this,t,r,n,a-1,-a)}var o=n-1,s=1,f=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&f===0&&this[r+o+1]!==0&&(f=1),this[r+o]=(t/s>>0)-f&255;return r+n},y.prototype.writeInt8=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,1,127,-128),y.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=t&255,r+1},y.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):lr(this,t,r,!0),r+2},y.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):lr(this,t,r,!1),r+2},y.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,4,2147483647,-2147483648),y.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):ur(this,t,r,!0),r+4},y.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r|0,n||Q(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):ur(this,t,r,!1),r+4};function Ro(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Oo(e,t,r,n,i){return i||Ro(e,t,r,4),vo(e,t,r,n,23,4),r+4}y.prototype.writeFloatLE=function(t,r,n){return Oo(this,t,r,!0,n)},y.prototype.writeFloatBE=function(t,r,n){return Oo(this,t,r,!1,n)};function Po(e,t,r,n,i){return i||Ro(e,t,r,8),vo(e,t,r,n,52,8),r+8}y.prototype.writeDoubleLE=function(t,r,n){return Po(this,t,r,!0,n)},y.prototype.writeDoubleBE=function(t,r,n){return Po(this,t,r,!1,n)},y.prototype.copy=function(t,r,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);var a=i-n,o;if(this===t&&n<r&&r<i)for(o=a-1;o>=0;--o)t[o+r]=this[o+n];else if(a<1e3||!y.TYPED_ARRAY_SUPPORT)for(o=0;o<a;++o)t[o+r]=this[o+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+a),r);return a},y.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),t.length===1){var a=t.charCodeAt(0);a<256&&(t=a)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!y.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&255);if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);var o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{var s=ve(t)?t:hr(new y(t,i).toString()),f=s.length;for(o=0;o<n-r;++o)this[o+r]=s[o%f]}return this};var El=/[^+\/0-9A-Za-z-_]/g;function xl(e){if(e=Sl(e).replace(El,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function Sl(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function Al(e){return e<16?"0"+e.toString(16):e.toString(16)}function hr(e,t){t=t||1/0;for(var r,n=e.length,i=null,a=[],o=0;o<n;++o){if(r=e.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return a}function kl(e){for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function Rl(e,t){for(var r,n,i,a=[],o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),n=r>>8,i=r%256,a.push(i),a.push(n);return a}function Io(e){return tl(xl(e))}function dr(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}function Ol(e){return e!==e}function Pl(e){return e!=null&&(!!e._isBuffer||To(e)||Il(e))}function To(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function Il(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&To(e.slice(0,0))}function Do(){throw new Error("setTimeout has not been defined")}function Co(){throw new Error("clearTimeout has not been defined")}var Te=Do,De=Co;typeof dt.setTimeout=="function"&&(Te=setTimeout),typeof dt.clearTimeout=="function"&&(De=clearTimeout);function jo(e){if(Te===setTimeout)return setTimeout(e,0);if((Te===Do||!Te)&&setTimeout)return Te=setTimeout,setTimeout(e,0);try{return Te(e,0)}catch{try{return Te.call(null,e,0)}catch{return Te.call(this,e,0)}}}function Tl(e){if(De===clearTimeout)return clearTimeout(e);if((De===Co||!De)&&clearTimeout)return De=clearTimeout,clearTimeout(e);try{return De(e)}catch{try{return De.call(null,e)}catch{return De.call(this,e)}}}var Se=[],pt=!1,Ve,pr=-1;function Dl(){!pt||!Ve||(pt=!1,Ve.length?Se=Ve.concat(Se):pr=-1,Se.length&&Fo())}function Fo(){if(!pt){var e=jo(Dl);pt=!0;for(var t=Se.length;t;){for(Ve=Se,Se=[];++pr<t;)Ve&&Ve[pr].run();pr=-1,t=Se.length}Ve=null,pt=!1,Tl(e)}}function re(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];Se.push(new No(e,t)),Se.length===1&&!pt&&jo(Fo)}function No(e,t){this.fun=e,this.array=t}No.prototype.run=function(){this.fun.apply(null,this.array)};var Cl="browser",jl="browser",Fl=!0,Nl={},Ml=[],Ll="",$l={},Bl={},Ul={};function We(){}var zl=We,Zl=We,ql=We,Hl=We,Kl=We,Vl=We,Wl=We;function Gl(e){throw new Error("process.binding is not supported")}function Yl(){return"/"}function Jl(e){throw new Error("process.chdir is not supported")}function Xl(){return 0}var yt=dt.performance||{},Ql=yt.now||yt.mozNow||yt.msNow||yt.oNow||yt.webkitNow||function(){return new Date().getTime()};function eu(e){var t=Ql.call(yt)*.001,r=Math.floor(t),n=Math.floor(t%1*1e9);return e&&(r=r-e[0],n=n-e[1],n<0&&(r--,n+=1e9)),[r,n]}var tu=new Date;function ru(){var e=new Date,t=e-tu;return t/1e3}var Ae={nextTick:re,title:Cl,browser:Fl,env:Nl,argv:Ml,version:Ll,versions:$l,on:zl,addListener:Zl,once:ql,off:Hl,removeListener:Kl,removeAllListeners:Vl,emit:Wl,binding:Gl,cwd:Yl,chdir:Jl,umask:Xl,hrtime:eu,platform:jl,release:Bl,config:Ul,uptime:ru},W;typeof Object.create=="function"?W=function(t,r){t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:W=function(t,r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t};var nu=/%[sdj%]/g;function iu(e){if(!Yn(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(Ce(arguments[r]));return t.join(" ")}for(var r=1,n=arguments,i=n.length,a=String(e).replace(nu,function(s){if(s==="%%")return"%";if(r>=i)return s;switch(s){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch{return"[Circular]"}default:return s}}),o=n[r];r<i;o=n[++r])Gn(o)||!It(o)?a+=" "+o:a+=" "+Ce(o);return a}function Mo(e,t){if(je(dt.process))return function(){return Mo(e,t).apply(this,arguments)};if(Ae.noDeprecation===!0)return e;var r=!1;function n(){if(!r){if(Ae.throwDeprecation)throw new Error(t);Ae.traceDeprecation?console.trace(t):console.error(t),r=!0}return e.apply(this,arguments)}return n}var yr={},Kn;function au(e){if(je(Kn)&&(Kn=Ae.env.NODE_DEBUG||""),e=e.toUpperCase(),!yr[e])if(new RegExp("\\b"+e+"\\b","i").test(Kn)){var t=0;yr[e]=function(){var r=iu.apply(null,arguments);console.error("%s %d: %s",e,t,r)}}else yr[e]=function(){};return yr[e]}function Ce(e,t){var r={seen:[],stylize:su};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),Lo(t)?r.showHidden=t:t&&pu(r,t),je(r.showHidden)&&(r.showHidden=!1),je(r.depth)&&(r.depth=2),je(r.colors)&&(r.colors=!1),je(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=ou),gr(r,e,r.depth)}Ce.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},Ce.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function ou(e,t){var r=Ce.styles[t];return r?"\x1B["+Ce.colors[r][0]+"m"+e+"\x1B["+Ce.colors[r][1]+"m":e}function su(e,t){return e}function cu(e){var t={};return e.forEach(function(r,n){t[r]=!0}),t}function gr(e,t,r){if(e.customInspect&&t&&Qn(t.inspect)&&t.inspect!==Ce&&!(t.constructor&&t.constructor.prototype===t)){var n=t.inspect(r,e);return Yn(n)||(n=gr(e,n,r)),n}var i=fu(e,t);if(i)return i;var a=Object.keys(t),o=cu(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),Xn(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return Vn(t);if(a.length===0){if(Qn(t)){var s=t.name?": "+t.name:"";return e.stylize("[Function"+s+"]","special")}if(Jn(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if($o(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Xn(t))return Vn(t)}var f="",c=!1,l=["{","}"];if(hu(t)&&(c=!0,l=["[","]"]),Qn(t)){var d=t.name?": "+t.name:"";f=" [Function"+d+"]"}if(Jn(t)&&(f=" "+RegExp.prototype.toString.call(t)),$o(t)&&(f=" "+Date.prototype.toUTCString.call(t)),Xn(t)&&(f=" "+Vn(t)),a.length===0&&(!c||t.length==0))return l[0]+f+l[1];if(r<0)return Jn(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var h;return c?h=lu(e,t,r,o,a):h=a.map(function(u){return Wn(e,t,r,o,u,c)}),e.seen.pop(),uu(h,f,l)}function fu(e,t){if(je(t))return e.stylize("undefined","undefined");if(Yn(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(du(t))return e.stylize(""+t,"number");if(Lo(t))return e.stylize(""+t,"boolean");if(Gn(t))return e.stylize("null","null")}function Vn(e){return"["+Error.prototype.toString.call(e)+"]"}function lu(e,t,r,n,i){for(var a=[],o=0,s=t.length;o<s;++o)Bo(t,String(o))?a.push(Wn(e,t,r,n,String(o),!0)):a.push("");return i.forEach(function(f){f.match(/^\d+$/)||a.push(Wn(e,t,r,n,f,!0))}),a}function Wn(e,t,r,n,i,a){var o,s,f;if(f=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},f.get?f.set?s=e.stylize("[Getter/Setter]","special"):s=e.stylize("[Getter]","special"):f.set&&(s=e.stylize("[Setter]","special")),Bo(n,i)||(o="["+i+"]"),s||(e.seen.indexOf(f.value)<0?(Gn(r)?s=gr(e,f.value,null):s=gr(e,f.value,r-1),s.indexOf(`
|
|
21
21
|
`)>-1&&(a?s=s.split(`
|
|
22
|
-
`).map(function(
|
|
22
|
+
`).map(function(c){return" "+c}).join(`
|
|
23
23
|
`).substr(2):s=`
|
|
24
24
|
`+s.split(`
|
|
25
|
-
`).map(function(
|
|
26
|
-
`))):s=e.stylize("[Circular]","special")),
|
|
25
|
+
`).map(function(c){return" "+c}).join(`
|
|
26
|
+
`))):s=e.stylize("[Circular]","special")),je(o)){if(a&&i.match(/^\d+$/))return s;o=JSON.stringify(""+i),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+s}function uu(e,t,r){var n=e.reduce(function(i,a){return a.indexOf(`
|
|
27
27
|
`)>=0,i+a.replace(/\u001b\[\d\d?m/g,"").length+1},0);return n>60?r[0]+(t===""?"":t+`
|
|
28
28
|
`)+" "+e.join(`,
|
|
29
|
-
`)+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function nu(e){return Array.isArray(e)}function jo(e){return typeof e=="boolean"}function Wn(e){return e===null}function iu(e){return typeof e=="number"}function Vn(e){return typeof e=="string"}function Ce(e){return e===void 0}function Gn(e){return Pt(e)&&Xn(e)==="[object RegExp]"}function Pt(e){return typeof e=="object"&&e!==null}function Mo(e){return Pt(e)&&Xn(e)==="[object Date]"}function Yn(e){return Pt(e)&&(Xn(e)==="[object Error]"||e instanceof Error)}function Jn(e){return typeof e=="function"}function Xn(e){return Object.prototype.toString.call(e)}function au(e,t){if(!t||!Pt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Lo(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ve(){this.head=null,this.tail=null,this.length=0}Ve.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},Ve.prototype.unshift=function(e){var t={data:e,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length},Ve.prototype.shift=function(){if(this.length!==0){var e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},Ve.prototype.clear=function(){this.head=this.tail=null,this.length=0},Ve.prototype.join=function(e){if(this.length===0)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},Ve.prototype.concat=function(e){if(this.length===0)return y.alloc(0);if(this.length===1)return this.head.data;for(var t=y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var ou=y.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function su(e){if(e&&!ou(e))throw new Error("Unknown encoding: "+e)}function It(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),su(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=cu;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=lu;break;default:this.write=fu;return}this.charBuffer=new y(6),this.charReceived=0,this.charLength=0}It.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";e=e.slice(r,e.length),t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var i=t.charCodeAt(t.length-1);if(i>=55296&&i<=56319){this.charLength+=this.surrogateSize,t="";continue}if(this.charReceived=this.charLength=0,e.length===0)return t;break}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived),t+=e.toString(this.encoding,0,n);var n=t.length-1,i=t.charCodeAt(n);if(i>=55296&&i<=56319){var a=this.surrogateSize;return this.charLength+=a,this.charReceived+=a,this.charBuffer.copy(this.charBuffer,a,0,a),e.copy(this.charBuffer,0,0,a),t.substring(0,n)}return t},It.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(t==1&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},It.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t};function fu(e){return e.toString(this.encoding)}function cu(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function lu(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}N.ReadableState=No;var F=Yl("stream");V(N,R);function uu(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function hu(e,t){return e.listeners(t).length}function No(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ae&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16*1024;this.highWaterMark=r||r===0?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new Ve,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new It(e.encoding),this.encoding=e.encoding)}function N(e){if(!(this instanceof N))return new N(e);this._readableState=new No(e,this),this.readable=!0,e&&typeof e.read=="function"&&(this._read=e.read),R.call(this)}N.prototype.push=function(e,t){var r=this._readableState;return!r.objectMode&&typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=y.from(e,t),t="")),Bo(this,r,e,t,!1)},N.prototype.unshift=function(e){var t=this._readableState;return Bo(this,t,e,"",!0)},N.prototype.isPaused=function(){return this._readableState.flowing===!1};function Bo(e,t,r,n,i){var a=yu(t,r);if(a)e.emit("error",a);else if(r===null)t.reading=!1,gu(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var o=new Error("stream.push() after EOF");e.emit("error",o)}else if(t.endEmitted&&i){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{var c;t.decoder&&!i&&!n&&(r=t.decoder.write(r),c=!t.objectMode&&r.length===0),i||(t.reading=!1),c||(t.flowing&&t.length===0&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&vr(e))),vu(e,t)}else i||(t.reading=!1);return du(t)}function du(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}N.prototype.setEncoding=function(e){return this._readableState.decoder=new It(e),this._readableState.encoding=e,this};var $o=8388608;function pu(e){return e>=$o?e=$o:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function Uo(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=pu(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}N.prototype.read=function(e){F("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return F("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?ei(this):vr(this),null;if(e=Uo(e,t),e===0&&t.ended)return t.length===0&&ei(this),null;var n=t.needReadable;F("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,F("length less than watermark",n)),t.ended||t.reading?(n=!1,F("reading or ended",n)):n&&(F("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=Uo(r,t)));var i;return e>0?i=Zo(e,t):i=null,i===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&ei(this)),i!==null&&this.emit("data",i),i};function yu(e,t){var r=null;return!y.isBuffer(t)&&typeof t!="string"&&t!==null&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function gu(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,vr(e)}}function vr(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(F("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?te(zo,e):zo(e))}function zo(e){F("emit readable"),e.emit("readable"),Qn(e)}function vu(e,t){t.readingMore||(t.readingMore=!0,te(wu,e,t))}function wu(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(F("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}N.prototype._read=function(e){this.emit("error",new Error("not implemented"))},N.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,F("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||t.end!==!1,a=i?s:l;n.endEmitted?te(a):r.once("end",a),e.on("unpipe",o);function o(_){F("onunpipe"),_===r&&l()}function s(){F("onend"),e.end()}var c=_u(r);e.on("drain",c);var f=!1;function l(){F("cleanup"),e.removeListener("close",p),e.removeListener("finish",g),e.removeListener("drain",c),e.removeListener("error",u),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",l),r.removeListener("data",h),f=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}var d=!1;r.on("data",h);function h(_){F("ondata"),d=!1;var x=e.write(_);x===!1&&!d&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&qo(n.pipes,e)!==-1)&&!f&&(F("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,d=!0),r.pause())}function u(_){F("onerror",_),w(),e.removeListener("error",u),hu(e,"error")===0&&e.emit("error",_)}uu(e,"error",u);function p(){e.removeListener("finish",g),w()}e.once("close",p);function g(){F("onfinish"),e.removeListener("close",p),w()}e.once("finish",g);function w(){F("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(F("pipe resume"),r.resume()),e};function _u(e){return function(){var t=e._readableState;F("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&e.listeners("data").length&&(t.flowing=!0,Qn(e))}}N.prototype.unpipe=function(e){var t=this._readableState;if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<n;i++)r[i].emit("unpipe",this);return this}var a=qo(t.pipes,e);return a===-1?this:(t.pipes.splice(a,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},N.prototype.on=function(e,t){var r=R.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var n=this._readableState;!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&vr(this):te(bu,this))}return r},N.prototype.addListener=N.prototype.on;function bu(e){F("readable nexttick read 0"),e.read(0)}N.prototype.resume=function(){var e=this._readableState;return e.flowing||(F("resume"),e.flowing=!0,mu(this,e)),this};function mu(e,t){t.resumeScheduled||(t.resumeScheduled=!0,te(xu,e,t))}function xu(e,t){t.reading||(F("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),Qn(e),t.flowing&&!t.reading&&e.read(0)}N.prototype.pause=function(){return F("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(F("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function Qn(e){var t=e._readableState;for(F("flow",t.flowing);t.flowing&&e.read()!==null;);}N.prototype.wrap=function(e){var t=this._readableState,r=!1,n=this;e.on("end",function(){if(F("wrapped end"),t.decoder&&!t.ended){var o=t.decoder.end();o&&o.length&&n.push(o)}n.push(null)}),e.on("data",function(o){if(F("wrapped data"),t.decoder&&(o=t.decoder.write(o)),!(t.objectMode&&o==null)&&!(!t.objectMode&&(!o||!o.length))){var s=n.push(o);s||(r=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=function(o){return function(){return e[o].apply(e,arguments)}}(i));var a=["error","close","destroy","pause","resume"];return Ru(a,function(o){e.on(o,n.emit.bind(n,o))}),n._read=function(o){F("wrapped _read",o),r&&(r=!1,e.resume())},n},N._fromList=Zo;function Zo(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.head.data:r=t.buffer.concat(t.length),t.buffer.clear()):r=Eu(e,t.buffer,t.decoder),r}function Eu(e,t,r){var n;return e<t.head.data.length?(n=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?n=t.shift():n=r?Su(e,t):Au(e,t),n}function Su(e,t){var r=t.head,n=1,i=r.data;for(e-=i.length;r=r.next;){var a=r.data,o=e>a.length?a.length:e;if(o===a.length?i+=a:i+=a.slice(0,e),e-=o,e===0){o===a.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=a.slice(o));break}++n}return t.length-=n,i}function Au(e,t){var r=y.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var a=n.data,o=e>a.length?a.length:e;if(a.copy(r,r.length-e,0,o),e-=o,e===0){o===a.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=a.slice(o));break}++i}return t.length-=i,r}function ei(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,te(ku,t,e))}function ku(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ru(e,t){for(var r=0,n=e.length;r<n;r++)t(e[r],r)}function qo(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}H.WritableState=ti,V(H,R);function Ou(){}function Tu(e,t,r){this.chunk=e,this.encoding=t,this.callback=r,this.next=null}function ti(e,t){Object.defineProperty(this,"buffer",{get:Do(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),e=e||{},this.objectMode=!!e.objectMode,t instanceof ae&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16*1024;this.highWaterMark=r||r===0?r:n,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var i=e.decodeStrings===!1;this.decodeStrings=!i,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){Mu(t,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Yo(this)}ti.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};function H(e){if(!(this instanceof H)&&!(this instanceof ae))return new H(e);this._writableState=new ti(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev)),R.call(this)}H.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function Pu(e,t){var r=new Error("write after end");e.emit("error",r),te(t,r)}function Iu(e,t,r,n){var i=!0,a=!1;return r===null?a=new TypeError("May not write null values to stream"):!y.isBuffer(r)&&typeof r!="string"&&r!==void 0&&!t.objectMode&&(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),te(n,a),i=!1),i}H.prototype.write=function(e,t,r){var n=this._writableState,i=!1;return typeof t=="function"&&(r=t,t=null),y.isBuffer(e)?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=Ou),n.ended?Pu(this,r):Iu(this,n,e,r)&&(n.pendingcb++,i=Cu(this,n,e,t,r)),i},H.prototype.cork=function(){var e=this._writableState;e.corked++},H.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.bufferedRequest&&Ko(this,e))},H.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function Fu(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=y.from(t,r)),t}function Cu(e,t,r,n,i){r=Fu(t,r,n),y.isBuffer(r)&&(n="buffer");var a=t.objectMode?1:r.length;t.length+=a;var o=t.length<t.highWaterMark;if(o||(t.needDrain=!0),t.writing||t.corked){var s=t.lastBufferedRequest;t.lastBufferedRequest=new Tu(r,n,i),s?s.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else ri(e,t,!1,a,r,n,i);return o}function ri(e,t,r,n,i,a,o){t.writelen=n,t.writecb=o,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,a,t.onwrite),t.sync=!1}function Du(e,t,r,n,i){--t.pendingcb,r?te(i,n):i(n),e._writableState.errorEmitted=!0,e.emit("error",n)}function ju(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function Mu(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(ju(r),t)Du(e,r,n,t,i);else{var a=Wo(r);!a&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&Ko(e,r),n?te(Ho,e,r,a,i):Ho(e,r,a,i)}}function Ho(e,t,r,n){r||Lu(e,t),t.pendingcb--,n(),Go(e,t)}function Lu(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function Ko(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),a=t.corkedRequestsFree;a.entry=r;for(var o=0;r;)i[o]=r,r=r.next,o+=1;ri(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new Yo(t)}else{for(;r;){var s=r.chunk,c=r.encoding,f=r.callback,l=t.objectMode?1:s.length;if(ri(e,t,!1,l,s,c,f),r=r.next,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=r,t.bufferProcessing=!1}H.prototype._write=function(e,t,r){r(new Error("not implemented"))},H.prototype._writev=null,H.prototype.end=function(e,t,r){var n=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),!n.ending&&!n.finished&&Nu(this,n,r)};function Wo(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function Vo(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function Go(e,t){var r=Wo(t);return r&&(t.pendingcb===0?(Vo(e,t),t.finished=!0,e.emit("finish")):Vo(e,t)),r}function Nu(e,t,r){t.ending=!0,Go(e,t),r&&(t.finished?te(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function Yo(e){var t=this;this.next=null,this.entry=null,this.finish=function(r){var n=t.entry;for(t.entry=null;n;){var i=n.callback;e.pendingcb--,i(r),n=n.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}V(ae,N);for(var Jo=Object.keys(H.prototype),ni=0;ni<Jo.length;ni++){var ii=Jo[ni];ae.prototype[ii]||(ae.prototype[ii]=H.prototype[ii])}function ae(e){if(!(this instanceof ae))return new ae(e);N.call(this,e),H.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",Bu)}function Bu(){this.allowHalfOpen||this._writableState.ended||te($u,this)}function $u(e){e.end()}V(re,ae);function Uu(e){this.afterTransform=function(t,r){return zu(e,t,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function zu(e,t,r){var n=e._transformState;n.transforming=!1;var i=n.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));n.writechunk=null,n.writecb=null,r!=null&&e.push(r),i(t);var a=e._readableState;a.reading=!1,(a.needReadable||a.length<a.highWaterMark)&&e._read(a.highWaterMark)}function re(e){if(!(this instanceof re))return new re(e);ae.call(this,e),this._transformState=new Uu(this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.once("prefinish",function(){typeof this._flush=="function"?this._flush(function(r){Xo(t,r)}):Xo(t)})}re.prototype.push=function(e,t){return this._transformState.needTransform=!1,ae.prototype.push.call(this,e,t)},re.prototype._transform=function(e,t,r){throw new Error("Not implemented")},re.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},re.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};function Xo(e,t){if(t)return e.emit("error",t);var r=e._writableState,n=e._transformState;if(r.length)throw new Error("Calling transform done when ws.length != 0");if(n.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}V(Ft,re);function Ft(e){if(!(this instanceof Ft))return new Ft(e);re.call(this,e)}Ft.prototype._transform=function(e,t,r){r(null,e)},V(Ae,R),Ae.Readable=N,Ae.Writable=H,Ae.Duplex=ae,Ae.Transform=re,Ae.PassThrough=Ft,Ae.Stream=Ae;function Ae(){R.call(this)}Ae.prototype.pipe=function(e,t){var r=this;function n(l){e.writable&&e.write(l)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}e.on("drain",i),!e._isStdio&&(!t||t.end!==!1)&&(r.on("end",o),r.on("close",s));var a=!1;function o(){a||(a=!0,e.end())}function s(){a||(a=!0,typeof e.destroy=="function"&&e.destroy())}function c(l){if(f(),R.listenerCount(this,"error")===0)throw l}r.on("error",c),e.on("error",c);function f(){r.removeListener("data",n),e.removeListener("drain",i),r.removeListener("end",o),r.removeListener("close",s),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),e.removeListener("close",f)}return r.on("end",f),r.on("close",f),e.on("close",f),e.emit("pipe",r),e};class Qo extends R{constructor({resource:t}){super(),this.resource=t,this.client=t.client,this.stream=new qf.ReadableStream({highWaterMark:this.client.parallelism*3,start:this._start.bind(this),pull:this._pull.bind(this),cancel:this._cancel.bind(this)})}build(){return this.stream.getReader()}async _start(t){this.controller=t,this.continuationToken=null,this.closeNextIteration=!1}async _pull(t){if(this.closeNextIteration){t.close();return}const r=await this.client.listObjects({prefix:`resource=${this.resource.name}`,continuationToken:this.continuationToken}),n=r?.Contents.map(i=>i.Key).map(i=>i.replace(this.client.config.keyPrefix,"")).map(i=>i.startsWith("/")?i.replace("/",""):i).map(i=>i.replace(`resource=${this.resource.name}/id=`,""));this.continuationToken=r.NextContinuationToken,this.enqueue(n),r.IsTruncated||(this.closeNextIteration=!0)}enqueue(t){t.forEach(r=>{this.controller.enqueue(r),this.emit("id",r)})}_cancel(t){console.warn("Stream cancelled",t)}}class es extends Qo{enqueue(t){this.controller.enqueue(t),this.emit("page",t)}}class ts extends R{constructor({resource:t,batchSize:r=10,concurrency:n=5}){if(super(),!t)throw new Error("Resource is required for ResourceReader");this.resource=t,this.client=t.client,this.batchSize=r,this.concurrency=n,this.input=new es({resource:this.resource}),this.transform=new re({objectMode:!0,transform:this._transform.bind(this)}),this.input.on("data",i=>{this.transform.write(i)}),this.input.on("end",()=>{this.transform.end()}),this.input.on("error",i=>{this.emit("error",i)}),this.transform.on("data",i=>{this.emit("data",i)}),this.transform.on("end",()=>{this.emit("end")}),this.transform.on("error",i=>{this.emit("error",i)})}build(){return this}async _transform(t,r,n){try{await he.PromisePool.for(t).withConcurrency(this.concurrency).handleError(async(i,a)=>{this.emit("error",i,a)}).process(async i=>{const a=await this.resource.get(i);return this.push(a),a}),n()}catch(i){n(i)}}resume(){this.input.resume()}}class rs extends R{constructor({resource:t,batchSize:r=10,concurrency:n=5}){super(),this.resource=t,this.client=t.client,this.batchSize=r,this.concurrency=n,this.buffer=[],this.writing=!1,this.writable=new H({objectMode:!0,write:this._write.bind(this)}),this.writable.on("finish",()=>{this.emit("finish")}),this.writable.on("error",i=>{this.emit("error",i)})}build(){return this}write(t){return this.buffer.push(t),this._maybeWrite().catch(r=>{this.emit("error",r)}),!0}end(){this.ended=!0,this._maybeWrite().catch(t=>{this.emit("error",t)})}async _maybeWrite(){if(!this.writing&&!(this.buffer.length===0&&!this.ended)){for(this.writing=!0;this.buffer.length>0;){const t=this.buffer.splice(0,this.batchSize);try{await he.PromisePool.for(t).withConcurrency(this.concurrency).handleError(async(r,n)=>{this.emit("error",r,n)}).process(async r=>{await this.resource.insert(r)})}catch(r){this.emit("error",r)}}this.writing=!1,this.ended&&this.writable.emit("finish")}}async _write(t,r,n){n()}}function gt(e){return new Promise((t,r)=>{const n=[];e.on("data",i=>n.push(i)),e.on("error",r),e.on("end",()=>t(Buffer.concat(n).toString("utf-8")))})}function vt(e){typeof e!="string"&&(e=String(e));let t=0;for(let r=0;r<e.length;r++){const n=e.codePointAt(r);n<=127?t+=1:n<=2047?t+=2:n<=65535?t+=3:n<=1114111&&(t+=4,n>65535&&r++)}return t}function Zu(e){let t=0;for(const r of Object.keys(e))r!=="_v"&&(t+=vt(r));return t}function ns(e){return e==null?"":typeof e=="boolean"?e?"1":"0":typeof e=="number"?String(e):typeof e=="string"?e:Array.isArray(e)?e.length===0?"[]":e.map(t=>String(t)).join("|"):typeof e=="object"?JSON.stringify(e):String(e)}function ai(e){const t={};for(const[r,n]of Object.entries(e)){const i=ns(n),a=vt(i);t[r]=a}return t}function Ge(e){const t=ai(e),r=Object.values(t).reduce((i,a)=>i+a,0),n=Zu(e);return r+n}const $=2048;async function qu({resource:e,data:t,mappedData:r}){const n=Ge(r);if(n>$)throw new Error(`S3 metadata size exceeds 2KB limit. Current size: ${n} bytes, limit: ${$} bytes`);return{mappedData:r,body:""}}async function Hu({resource:e,id:t,data:r,mappedData:n}){const i=Ge(n);if(i>$)throw new Error(`S3 metadata size exceeds 2KB limit. Current size: ${i} bytes, limit: ${$} bytes`);return{mappedData:n,body:""}}async function Ku({resource:e,id:t,data:r,mappedData:n}){const i=Ge(n);if(i>$)throw new Error(`S3 metadata size exceeds 2KB limit. Current size: ${i} bytes, limit: ${$} bytes`);return{mappedData:n,body:""}}async function Wu({resource:e,metadata:t,body:r}){return{metadata:t,body:r}}var Vu=Object.freeze({__proto__:null,S3_METADATA_LIMIT_BYTES:$,handleGet:Wu,handleInsert:qu,handleUpdate:Hu,handleUpsert:Ku});async function Gu({resource:e,data:t,mappedData:r}){const n=Ge(r);return n>$&&e.emit("exceedsLimit",{operation:"insert",totalSize:n,limit:$,excess:n-$,data:t}),{mappedData:r,body:""}}async function Yu({resource:e,id:t,data:r,mappedData:n}){const i=Ge(n);return i>$&&e.emit("exceedsLimit",{operation:"update",id:t,totalSize:i,limit:$,excess:i-$,data:r}),{mappedData:n,body:""}}async function Ju({resource:e,id:t,data:r,mappedData:n}){const i=Ge(n);return i>$&&e.emit("exceedsLimit",{operation:"upsert",id:t,totalSize:i,limit:$,excess:i-$,data:r}),{mappedData:n,body:""}}async function Xu({resource:e,metadata:t,body:r}){return{metadata:t,body:r}}var Qu=Object.freeze({__proto__:null,handleGet:Xu,handleInsert:Gu,handleUpdate:Yu,handleUpsert:Ju});const is="...",as=vt(is);async function eh({resource:e,data:t,mappedData:r}){return oi({resource:e,data:t,mappedData:r})}async function th({resource:e,id:t,data:r,mappedData:n}){return oi({resource:e,data:r,mappedData:n})}async function rh({resource:e,id:t,data:r,mappedData:n}){return oi({resource:e,data:r,mappedData:n})}async function nh({resource:e,metadata:t,body:r}){return{metadata:t,body:r}}function oi({resource:e,data:t,mappedData:r}){const n=ai(r),i=Object.entries(n).sort(([,s],[,c])=>s-c),a={};let o=0;for(const[s,c]of i){const f=$-o;if(c<=f)a[s]=r[s],o+=c;else if(f>as){const l=f-as,d=ns(r[s]);let h="",u=0;for(let p=0;p<d.length;p++){const g=d[p],w=vt(g);if(u+w<=l)h+=g,u+=w;else break}a[s]=h+is,o=$;break}else break}return{mappedData:a,body:""}}var ih=Object.freeze({__proto__:null,handleGet:nh,handleInsert:eh,handleUpdate:th,handleUpsert:rh});const wr="$overflow",si="true",ah=vt(wr)+vt(si);async function oh({resource:e,data:t,mappedData:r}){return fi({resource:e,data:t,mappedData:r})}async function sh({resource:e,id:t,data:r,mappedData:n}){return fi({resource:e,data:r,mappedData:n})}async function fh({resource:e,id:t,data:r,mappedData:n}){return fi({resource:e,data:r,mappedData:n})}async function ch({resource:e,metadata:t,body:r}){if(t[wr]===si)try{const n=r?JSON.parse(r):{},i={...t};return delete i[wr],{metadata:{...i,...n},body:""}}catch{return{metadata:t,body:r}}return{metadata:t,body:r}}function fi({resource:e,data:t,mappedData:r}){if(Ge(r)<=$)return{mappedData:r,body:""};const i=$-ah,a=ai(r),o=Object.entries(a).sort(([,d],[,h])=>d-h),s={},c={};let f=0;for(const[d,h]of o)f+h<=i?(s[d]=r[d],f+=h):c[d]=r[d];s[wr]=si;const l=Object.keys(c).length>0?JSON.stringify(c):"";return{mappedData:s,body:l}}var lh=Object.freeze({__proto__:null,handleGet:ch,handleInsert:oh,handleUpdate:sh,handleUpsert:fh});const os={"user-management":Qu,"enforce-limits":Vu,"data-truncate":ih,"body-overflow":lh};function Ye(e){const t=os[e];if(!t)throw new Error(`Unknown behavior: ${e}. Available behaviors: ${Object.keys(os).join(", ")}`);return t}const uh="user-management";class ci extends R{constructor({name:t,client:r,version:n="1",options:i={},attributes:a={},parallelism:o=10,passphrase:s="secret",observers:c=[],behavior:f=uh}){if(super(),this.name=t,this.client=r,this.version=n,this.behavior=f,this.observers=c,this.parallelism=o,this.passphrase=s??"secret",this.options={cache:!1,autoDecrypt:!0,timestamps:!1,partitions:{},paranoid:!0,allNestedObjectsOptional:i.allNestedObjectsOptional??!1,...i},this.hooks={preInsert:[],afterInsert:[],preUpdate:[],afterUpdate:[],preDelete:[],afterDelete:[]},this.attributes=a||{},i.timestamps&&(this.attributes.createdAt="string|optional",this.attributes.updatedAt="string|optional",this.options.partitions.byCreatedDate||(this.options.partitions.byCreatedDate={fields:{createdAt:"date|maxlength:10"}}),this.options.partitions.byUpdatedDate||(this.options.partitions.byUpdatedDate={fields:{updatedAt:"date|maxlength:10"}})),this.schema=new _e({name:t,attributes:this.attributes,passphrase:s,version:this.version,options:{...this.options,allNestedObjectsOptional:this.options.allNestedObjectsOptional??!1}}),this.validatePartitions(),this.setupPartitionHooks(),i.hooks){for(const[l,d]of Object.entries(i.hooks))if(Array.isArray(d)&&this.hooks[l])for(const h of d)this.hooks[l].push(h.bind(this))}}export(){const t=this.schema.export();return t.behavior=this.behavior,t}updateAttributes(t){const r=this.attributes;return this.attributes=t,this.options.timestamps&&(t.createdAt="string|optional",t.updatedAt="string|optional",this.options.partitions.byCreatedDate||(this.options.partitions.byCreatedDate={fields:{createdAt:"date|maxlength:10"}}),this.options.partitions.byUpdatedDate||(this.options.partitions.byUpdatedDate={fields:{updatedAt:"date|maxlength:10"}})),this.schema=new _e({name:this.name,attributes:t,passphrase:this.passphrase,version:this.version,options:this.options}),this.validatePartitions(),this.setupPartitionHooks(),{oldAttributes:r,newAttributes:t}}addHook(t,r){this.hooks[t]&&this.hooks[t].push(r.bind(this))}async executeHooks(t,r){if(!this.hooks[t])return r;let n=r;for(const i of this.hooks[t])n=await i(n);return n}setupPartitionHooks(){const t=this.options.partitions;!t||Object.keys(t).length===0||(this.addHook("afterInsert",async r=>(await this.createPartitionReferences(r),r)),this.addHook("afterDelete",async r=>(await this.deletePartitionReferences(r),r)))}async validate(t){const r={original:L.cloneDeep(t),isValid:!1,errors:[]},n=await this.schema.validate(t,{mutateOriginal:!0});return n===!0?r.isValid=!0:r.errors=n,r.data=t,r}validatePartitions(){const t=this.options.partitions;if(!t||Object.keys(t).length===0)return;const r=Object.keys(this.attributes||{});for(const[n,i]of Object.entries(t))if(i.fields){for(const a of Object.keys(i.fields))if(!this.fieldExistsInAttributes(a))throw new Error(`Partition '${n}' uses field '${a}' which does not exist in resource version '${this.version}'. Available fields: ${r.join(", ")}. This version of resource does not have support for this partition.`)}}fieldExistsInAttributes(t){if(!t.includes("."))return Object.keys(this.attributes||{}).includes(t);const r=t.split(".");let n=this.attributes||{};for(const i of r){if(!n||typeof n!="object"||!(i in n))return!1;n=n[i]}return!0}applyPartitionRule(t,r){if(t==null)return t;let n=t;if(typeof r=="string"&&r.includes("maxlength:")){const i=r.match(/maxlength:(\d+)/);if(i){const a=parseInt(i[1]);typeof n=="string"&&n.length>a&&(n=n.substring(0,a))}}if(r.includes("date")){if(n instanceof Date)n=n.toISOString().split("T")[0];else if(typeof n=="string")try{if(n.includes("T")&&n.includes("Z"))n=n.split("T")[0];else{const i=new Date(n);isNaN(i.getTime())||(n=i.toISOString().split("T")[0])}}catch{}}return n}getResourceKey(t){return me(`resource=${this.name}`,`v=${this.version}`,`id=${t}`)}getPartitionKey({partitionName:t,id:r,data:n}){const i=this.options.partitions[t];if(!i)throw new Error(`Partition '${t}' not found`);const a=[],o=Object.entries(i.fields).sort(([s],[c])=>s.localeCompare(c));for(const[s,c]of o){const f=this.getNestedFieldValue(n,s),l=this.applyPartitionRule(f,c);if(l==null)return null;a.push(`${s}=${l}`)}return a.length===0?null:me(`resource=${this.name}`,`partition=${t}`,...a,`id=${r}`)}getNestedFieldValue(t,r){if(!r.includes("."))return t[r];const n=r.split(".");let i=t;for(const a of n){if(!i||typeof i!="object"||!(a in i))return;i=i[a]}return i}async insert({id:t,...r}){this.options.timestamps&&(r.createdAt=new Date().toISOString(),r.updatedAt=new Date().toISOString());const n=await this.executeHooks("preInsert",r),{errors:i,isValid:a,data:o}=await this.validate(n);if(!a)throw new rr({bucket:this.client.config.bucket,resourceName:this.name,attributes:n,validation:i});!t&&t!==0&&(t=Zi());const s=await this.schema.mapper(o),c=Ye(this.behavior),{mappedData:f,body:l}=await c.handleInsert({resource:this,data:o,mappedData:s}),d=this.getResourceKey(t);await this.client.putObject({metadata:f,key:d,body:l});const h=L.merge({id:t},o);return await this.executeHooks("afterInsert",h),this.emit("insert",h),h}async get(t){const r=this.getResourceKey(t);try{const n=await this.client.headObject(r),i=this.extractVersionFromKey(r)||this.version;let o=await(await this.getSchemaForVersion(i)).unmapper(n.Metadata);const s=Ye(this.behavior);let c="";if(n.ContentLength>0)try{const d=await this.client.getObject(r);c=await gt(d.Body)}catch(d){console.warn(`Failed to read body for resource ${t}:`,d.message),c=""}const{metadata:f}=await s.handleGet({resource:this,metadata:o,body:c});let l=f;return l.id=t,l._contentLength=n.ContentLength,l._lastModified=n.LastModified,l._hasContent=n.ContentLength>0,l._mimeType=n.ContentType||null,n.VersionId&&(l._versionId=n.VersionId),n.Expiration&&(l._expiresAt=n.Expiration),l._definitionHash=this.getDefinitionHash(),this.emit("get",l),l}catch(n){if(n.message.includes("Cipher job failed")||n.message.includes("OperationError")||n.originalError?.message?.includes("Cipher job failed"))try{console.warn(`Decryption failed for resource ${t}, attempting to get raw metadata`);const a=await this.client.headObject(r),o=this.extractVersionFromKey(r)||this.version;let c=await new _e({name:this.name,attributes:this.attributes,passphrase:this.passphrase,version:o,options:{...this.options,autoDecrypt:!1,autoEncrypt:!1}}).unmapper(a.Metadata);const f=Ye(this.behavior);let l="";if(a.ContentLength>0)try{const u=await this.client.getObject(r);l=await gt(u.Body)}catch(u){console.warn(`Failed to read body for resource ${t}:`,u.message),l=""}const{metadata:d}=await f.handleGet({resource:this,metadata:c,body:l});let h=d;return h.id=t,h._contentLength=a.ContentLength,h._lastModified=a.LastModified,h._hasContent=a.ContentLength>0,h._mimeType=a.ContentType||null,h._version=o,h._decryptionFailed=!0,a.VersionId&&(h._versionId=a.VersionId),a.Expiration&&(h._expiresAt=a.Expiration),h._definitionHash=this.getDefinitionHash(),this.emit("get",h),h}catch(a){console.error(`Fallback attempt also failed for resource ${t}:`,a.message)}const i=new Error(`Failed to get resource with id '${t}': ${n.message}`);throw i.originalError=n,i.resourceId=t,i.resourceKey=r,i}}async exists(t){try{const r=this.getResourceKey(t);return await this.client.headObject(r),!0}catch{return!1}}async update(t,r){const n=await this.get(t);this.options.timestamps&&(r.updatedAt=new Date().toISOString());const i=await this.executeHooks("preUpdate",r),a=L.merge(n,i);delete a.id;const{isValid:o,errors:s,data:c}=await this.validate(a);if(!o)throw new rr({bucket:this.client.bucket,resourceName:this.name,attributes:i,validation:s});const f=await this.schema.mapper(c),l=Ye(this.behavior),{mappedData:d,body:h}=await l.handleUpdate({resource:this,id:t,data:c,mappedData:f}),u=this.getResourceKey(t);let p,g=h;if(h===""&&this.behavior!=="body-overflow")try{const w=await this.client.getObject(u);if(w.ContentLength>0){const _=Buffer.from(await w.Body.transformToByteArray()),x=_.toString();try{JSON.parse(x)}catch{g=_,p=w.ContentType}}}catch{}return await this.client.putObject({key:u,body:g,contentType:p,metadata:d}),c.id=t,await this.executeHooks("afterUpdate",c),await this.updatePartitionReferences(c),this.emit("update",i,c),c}async delete(t){let r;try{r=await this.get(t)}catch{r={id:t}}await this.executeHooks("preDelete",r);const n=this.getResourceKey(t),i=await this.client.deleteObject(n);return await this.executeHooks("afterDelete",r),this.emit("delete",t),i}async upsert({id:t,...r}){return await this.exists(t)?this.update(t,r):this.insert({id:t,...r})}async count({partition:t=null,partitionValues:r={}}={}){let n;if(t&&Object.keys(r).length>0){const a=this.options.partitions[t];if(!a)throw new Error(`Partition '${t}' not found`);const o=[],s=Object.entries(a.fields).sort(([c],[f])=>c.localeCompare(f));for(const[c,f]of s){const l=r[c];if(l!=null){const d=this.applyPartitionRule(l,f);o.push(`${c}=${d}`)}}o.length>0?n=`resource=${this.name}/partition=${t}/${o.join("/")}`:n=`resource=${this.name}/partition=${t}`}else n=`resource=${this.name}/v=${this.version}`;const i=await this.client.count({prefix:n});return this.emit("count",i),i}async insertMany(t){const{results:r}=await he.PromisePool.for(t).withConcurrency(this.parallelism).handleError(async(n,i)=>{this.emit("error",n,i),this.observers.map(a=>a.emit("error",this.name,n,i))}).process(async n=>await this.insert(n));return this.emit("insertMany",t.length),r}async deleteMany(t){const r=L.chunk(t.map(i=>this.getResourceKey(i)),1e3),{results:n}=await he.PromisePool.for(r).withConcurrency(this.parallelism).handleError(async(i,a)=>{this.emit("error",i,a),this.observers.map(o=>o.emit("error",this.name,i,a))}).process(async i=>{const a=await this.client.deleteObjects(i);return i.forEach(o=>{const c=o.split("/").find(l=>l.startsWith("id=")),f=c?c.replace("id=",""):null;f&&(this.emit("deleted",f),this.observers.map(l=>l.emit("deleted",this.name,f)))}),a});return this.emit("deleteMany",t.length),n}async deleteAll(){if(this.options.paranoid!==!1)throw new Error(`deleteAll() is a dangerous operation and requires paranoid: false option. Current paranoid setting: ${this.options.paranoid}`);const t=`resource=${this.name}/v=${this.version}`,r=await this.client.deleteAll({prefix:t});return this.emit("deleteAll",{version:this.version,prefix:t,deletedCount:r}),{deletedCount:r,version:this.version}}async deleteAllData(){if(this.options.paranoid!==!1)throw new Error(`deleteAllData() is a dangerous operation and requires paranoid: false option. Current paranoid setting: ${this.options.paranoid}`);const t=`resource=${this.name}`,r=await this.client.deleteAll({prefix:t});return this.emit("deleteAllData",{resource:this.name,prefix:t,deletedCount:r}),{deletedCount:r,resource:this.name}}async listIds({partition:t=null,partitionValues:r={},limit:n,offset:i=0}={}){let a;if(t&&Object.keys(r).length>0){const c=this.options.partitions[t];if(!c)throw new Error(`Partition '${t}' not found`);const f=[],l=Object.entries(c.fields).sort(([d],[h])=>d.localeCompare(h));for(const[d,h]of l){const u=r[d];if(u!=null){const p=this.applyPartitionRule(u,h);f.push(`${d}=${p}`)}}f.length>0?a=`resource=${this.name}/partition=${t}/${f.join("/")}`:a=`resource=${this.name}/partition=${t}`}else a=`resource=${this.name}/v=${this.version}`;const s=(await this.client.getKeysPage({prefix:a,offset:i,amount:n||1e3})).map(c=>{const l=c.split("/").find(d=>d.startsWith("id="));return l?l.replace("id=",""):null}).filter(Boolean);return this.emit("listIds",s.length),s}async list({partition:t=null,partitionValues:r={},limit:n,offset:i=0}={}){if(!t){let w=(await this.listIds({partition:t,partitionValues:r})).slice(i);n&&(w=w.slice(0,n));const{results:_,errors:x}=await he.PromisePool.for(w).withConcurrency(this.parallelism).handleError(async(v,S)=>(console.warn(`Failed to get resource ${S}:`,v.message),null)).process(async v=>{try{return await this.get(v)}catch(S){if(S.message.includes("Cipher job failed")||S.message.includes("OperationError"))return console.warn(`Decryption failed for ${v}, returning basic info`),{id:v,_decryptionFailed:!0,_error:S.message};throw S}}),A=_.filter(v=>v!==null);return this.emit("list",{partition:t,partitionValues:r,count:A.length,errors:x.length}),A}const a=this.options.partitions[t];if(!a)throw new Error(`Partition '${t}' not found`);const o=[],s=Object.entries(a.fields).sort(([g],[w])=>g.localeCompare(w));for(const[g,w]of s){const _=r[g];if(_!=null){const x=this.applyPartitionRule(_,w);o.push(`${g}=${x}`)}}let c;o.length>0?c=`resource=${this.name}/partition=${t}/${o.join("/")}`:c=`resource=${this.name}/partition=${t}`;let d=(await this.client.getAllKeys({prefix:c})).map(g=>{const _=g.split("/").find(x=>x.startsWith("id="));return _?_.replace("id=",""):null}).filter(Boolean).slice(i);n&&(d=d.slice(0,n));const{results:h,errors:u}=await he.PromisePool.for(d).withConcurrency(this.parallelism).handleError(async(g,w)=>(console.warn(`Failed to get partition resource ${w}:`,g.message),null)).process(async g=>{try{return await this.getFromPartition({id:g,partitionName:t,partitionValues:r})}catch(w){if(w.message.includes("Cipher job failed")||w.message.includes("OperationError"))return console.warn(`Decryption failed for partition resource ${g}, returning basic info`),{id:g,_partition:t,_partitionValues:r,_decryptionFailed:!0,_error:w.message};throw w}}),p=h.filter(g=>g!==null);return this.emit("list",{partition:t,partitionValues:r,count:p.length,errors:u.length}),p}async getMany(t){const{results:r,errors:n}=await he.PromisePool.for(t).withConcurrency(this.client.parallelism).handleError(async(i,a)=>(console.warn(`Failed to get resource ${a}:`,i.message),{id:a,_error:i.message,_decryptionFailed:i.message.includes("Cipher job failed")||i.message.includes("OperationError")})).process(async i=>{this.emit("id",i);try{const a=await this.get(i);return this.emit("data",a),a}catch(a){if(a.message.includes("Cipher job failed")||a.message.includes("OperationError"))return console.warn(`Decryption failed for ${i}, returning basic info`),{id:i,_decryptionFailed:!0,_error:a.message};throw a}});return this.emit("getMany",t.length),r}async getAll(){let t=await this.listIds();if(t.length===0)return[];const{results:r,errors:n}=await he.PromisePool.for(t).withConcurrency(this.client.parallelism).handleError(async(i,a)=>(console.warn(`Failed to get resource ${a}:`,i.message),{id:a,_error:i.message,_decryptionFailed:i.message.includes("Cipher job failed")||i.message.includes("OperationError")})).process(async i=>{try{return await this.get(i)}catch(a){if(a.message.includes("Cipher job failed")||a.message.includes("OperationError"))return console.warn(`Decryption failed for ${i}, returning basic info`),{id:i,_decryptionFailed:!0,_error:a.message};throw a}});return this.emit("getAll",r.length),r}async page({offset:t=0,size:r=100,partition:n=null,partitionValues:i={},skipCount:a=!1}={}){let o=null,s=null;a||(o=await this.count({partition:n,partitionValues:i}),s=Math.ceil(o/r));const c=Math.floor(t/r),f=await this.list({partition:n,partitionValues:i,limit:r,offset:t}),l={items:f,totalItems:o,page:c,pageSize:r,totalPages:s,_debug:{requestedSize:r,requestedOffset:t,actualItemsReturned:f.length,skipCount:a,hasTotalItems:o!==null}};return this.emit("page",l),l}readable(){return new ts({resource:this}).build()}writable(){return new rs({resource:this}).build()}async setContent({id:t,buffer:r,contentType:n="application/octet-stream"}){const i=await this.get(t);if(!i)throw new Error(`Resource with id '${t}' not found`);const a={...i,_hasContent:!0,_contentLength:r.length,_mimeType:n};return await this.client.putObject({key:this.getResourceKey(t),metadata:await this.schema.mapper(a),body:r,contentType:n}),this.emit("setContent",{id:t,contentType:n,contentLength:r.length}),a}async content(t){const r=this.getResourceKey(t);try{const n=await this.client.getObject(r),i=Buffer.from(await n.Body.transformToByteArray()),a=n.ContentType||null;return this.emit("content",t,i.length,a),{buffer:i,contentType:a}}catch(n){if(n.name==="NoSuchKey")return{buffer:null,contentType:null};throw n}}async hasContent(t){const r=this.getResourceKey(t);try{return(await this.client.headObject(r)).ContentLength>0}catch{return!1}}async deleteContent(t){const r=this.getResourceKey(t),i=(await this.client.headObject(r)).Metadata||{},a=await this.client.putObject({key:r,body:"",metadata:i});return this.emit("deleteContent",t),a}getDefinitionHash(){const r={...this.schema.export().attributes};this.options.timestamps&&(delete r.createdAt,delete r.updatedAt);const n=so(r);return`sha256:${Bi.createHash("sha256").update(n).digest("hex")}`}extractVersionFromKey(t){const n=t.split("/").find(i=>i.startsWith("v="));return n?n.replace("v=",""):null}async getSchemaForVersion(t){if(t===this.version)return this.schema;try{return new _e({name:this.name,attributes:this.attributes,passphrase:this.passphrase,version:t,options:{...this.options,autoDecrypt:!0,autoEncrypt:!0}})}catch(r){return console.warn(`Failed to create compatible schema for version ${t}, using current schema:`,r.message),this.schema}}async createPartitionReferences(t){const r=this.options.partitions;if(!(!r||Object.keys(r).length===0))for(const[n,i]of Object.entries(r)){const a=this.getPartitionKey({partitionName:n,id:t.id,data:t});if(a){const o=await this.schema.mapper(t),s=Ye(this.behavior),{mappedData:c,body:f}=await s.handleInsert({resource:this,data:t,mappedData:o}),l={...c,_version:this.version};await this.client.putObject({key:a,metadata:l,body:f})}}}async deletePartitionReferences(t){const r=this.options.partitions;if(!r||Object.keys(r).length===0)return;const n=[];for(const[i,a]of Object.entries(r)){const o=this.getPartitionKey({partitionName:i,id:t.id,data:t});o&&n.push(o)}if(n.length>0)try{await this.client.deleteObjects(n)}catch(i){console.warn("Some partition objects could not be deleted:",i.message)}}async query(t={},{limit:r=100,offset:n=0,partition:i=null,partitionValues:a={}}={}){if(Object.keys(t).length===0)return await this.list({partition:i,partitionValues:a,limit:r,offset:n});const o=[];let s=n;const c=Math.min(r,50);for(;o.length<r;){const f=await this.list({partition:i,partitionValues:a,limit:c,offset:s});if(f.length===0)break;const l=f.filter(d=>Object.entries(t).every(([h,u])=>d[h]===u));if(o.push(...l),s+=c,f.length<c)break}return o.slice(0,r)}async updatePartitionReferences(t){const r=this.options.partitions;if(!(!r||Object.keys(r).length===0))for(const[n,i]of Object.entries(r)){const a=this.getPartitionKey({partitionName:n,id:t.id,data:t});if(a){const o=await this.schema.mapper(t),s=Ye(this.behavior),{mappedData:c,body:f}=await s.handleUpdate({resource:this,id:t.id,data:t,mappedData:o}),l={...c,_version:this.version};try{await this.client.putObject({key:a,metadata:l,body:f})}catch(d){console.warn(`Partition object could not be updated for ${n}:`,d.message)}}}}async getFromPartition({id:t,partitionName:r,partitionValues:n={}}){const i=this.options.partitions[r];if(!i)throw new Error(`Partition '${r}' not found`);const a=[],o=Object.entries(i.fields).sort(([w],[_])=>w.localeCompare(_));for(const[w,_]of o){const x=n[w];if(x!=null){const A=this.applyPartitionRule(x,_);a.push(`${w}=${A}`)}}if(a.length===0)throw new Error(`No partition values provided for partition '${r}'`);const s=me(`resource=${this.name}`,`partition=${r}`,...a,`id=${t}`),c=await this.client.headObject(s),f=c.Metadata?._version||this.version;let d=await(await this.getSchemaForVersion(f)).unmapper(c.Metadata);const h=Ye(this.behavior);let u="";if(c.ContentLength>0)try{const w=await this.client.getObject(s);u=await gt(w.Body)}catch{u=""}const{metadata:p}=await h.handleGet({resource:this,metadata:d,body:u});let g=p;return g.id=t,g._contentLength=c.ContentLength,g._lastModified=c.LastModified,g._hasContent=c.ContentLength>0,g._mimeType=c.ContentType||null,g._partition=r,g._partitionValues=n,c.VersionId&&(g._versionId=c.VersionId),c.Expiration&&(g._expiresAt=c.Expiration),g._definitionHash=this.getDefinitionHash(),this.emit("getFromPartition",g),g}}class ss extends R{constructor(t){super(),this.version="1",this.s3dbVersion=(()=>{try{return"4.1.9"}catch{return"latest"}})(),this.resources={},this.savedMetadata=null,this.options=t,this.verbose=t.verbose||!1,this.parallelism=parseInt(t.parallelism+"")||10,this.plugins=t.plugins||[],this.cache=t.cache,this.passphrase=t.passphrase||"secret",this.client=t.client||new ra({verbose:this.verbose,parallelism:this.parallelism,connectionString:t.connectionString}),this.bucket=this.client.bucket,this.keyPrefix=this.client.keyPrefix}async connect(){await this.startPlugins();let t=null;if(await this.client.exists("s3db.json")){const n=await this.client.getObject("s3db.json");t=JSON.parse(await gt(n?.Body))}else t=this.blankMetadataStructure(),await this.uploadMetadataFile();this.savedMetadata=t;const r=this.detectDefinitionChanges(t);for(const[n,i]of Object.entries(t.resources||{})){const a=i.currentVersion||"v0",o=i.versions?.[a];o&&(this.resources[n]=new ci({name:n,client:this.client,version:a,options:{...o.options,partitions:i.partitions||o.options?.partitions||{}},attributes:o.attributes,behavior:o.behavior||"user-management",parallelism:this.parallelism,passphrase:this.passphrase,observers:[this]}))}r.length>0&&this.emit("resourceDefinitionsChanged",{changes:r,metadata:this.savedMetadata}),this.emit("connected",new Date)}detectDefinitionChanges(t){const r=[];for(const[n,i]of Object.entries(this.resources)){const a=this.generateDefinitionHash(i.export()),o=t.resources?.[n];if(!o)r.push({type:"new",resourceName:n,currentHash:a,savedHash:null});else{const s=o.currentVersion||"v0",f=o.versions?.[s]?.hash;f!==a&&r.push({type:"changed",resourceName:n,currentHash:a,savedHash:f,fromVersion:s,toVersion:this.getNextVersion(o.versions)})}}for(const[n,i]of Object.entries(t.resources||{}))if(!this.resources[n]){const a=i.currentVersion||"v0",o=i.versions?.[a];r.push({type:"deleted",resourceName:n,currentHash:null,savedHash:o?.hash,deletedVersion:a})}return r}generateDefinitionHash(t,r=void 0){const i={...t.attributes};t.options?.timestamps&&(delete i.createdAt,delete i.updatedAt);const a={attributes:i,behavior:r||t.behavior||"user-management"},o=so(a);return`sha256:${Bi.createHash("sha256").update(o).digest("hex")}`}getNextVersion(t={}){const r=Object.keys(t).filter(i=>i.startsWith("v")).map(i=>parseInt(i.substring(1))).filter(i=>!isNaN(i));return`v${(r.length>0?Math.max(...r):-1)+1}`}async startPlugins(){const t=this;if(!L.isEmpty(this.plugins)){const r=this.plugins.map(a=>L.isFunction(a)?new a(this):a),n=r.map(async a=>{a.beforeSetup&&await a.beforeSetup(),await a.setup(t),a.afterSetup&&await a.afterSetup()});await Promise.all(n);const i=r.map(async a=>{a.beforeStart&&await a.beforeStart(),await a.start(),a.afterStart&&await a.afterStart()});await Promise.all(i)}}async uploadMetadataFile(){const t={version:this.version,s3dbVersion:this.s3dbVersion,lastUpdated:new Date().toISOString(),resources:{}};Object.entries(this.resources).forEach(([r,n])=>{const i=n.export(),a=this.generateDefinitionHash(i),o=this.savedMetadata?.resources?.[r],s=o?.currentVersion||"v0",c=o?.versions?.[s];let f,l;!c||c.hash!==a?(f=this.getNextVersion(o?.versions),l=!0):(f=s,l=!1),t.resources[r]={currentVersion:f,partitions:i.options?.partitions||{},versions:{...o?.versions,[f]:{hash:a,attributes:i.attributes,options:i.options,behavior:i.behavior||"user-management",createdAt:l?new Date().toISOString():c?.createdAt}}},n.version!==f&&(n.version=f,n.emit("versionUpdated",{oldVersion:s,newVersion:f}))}),await this.client.putObject({key:"s3db.json",body:JSON.stringify(t,null,2),contentType:"application/json"}),this.savedMetadata=t,this.emit("metadataUploaded",t)}blankMetadataStructure(){return{version:"1",s3dbVersion:this.s3dbVersion,resources:{}}}resourceExists(t){return!!this.resources[t]}resourceExistsWithSameHash({name:t,attributes:r,options:n={},behavior:i="user-management"}){if(!this.resources[t])return{exists:!1,sameHash:!1,hash:null};const a=new ci({name:t,attributes:r,behavior:i,observers:[],client:this.client,version:"temp",options:{cache:this.cache,...n}}),o=this.generateDefinitionHash(a.export(),i),s=this.generateDefinitionHash(this.resources[t].export(),this.resources[t].behavior);return{exists:!0,sameHash:o===s,hash:o,existingHash:s}}async createResourceIfNotExists({name:t,attributes:r,options:n={},behavior:i="user-management"}){const a=!!this.resources[t],o=this.resourceExistsWithSameHash({name:t,attributes:r,options:n,behavior:i});return o.exists&&o.sameHash?{resource:this.resources[t],created:!1,reason:"Resource already exists with same definition hash"}:{resource:await this.createResource({name:t,attributes:r,options:n,behavior:i}),created:!a,reason:a?"Resource updated with new definition":"New resource created"}}async createResource({name:t,attributes:r,options:n={},behavior:i="user-management"}){if(this.resources[t]){const c=this.resources[t];Object.assign(c.options,{cache:this.cache,...n}),i&&(c.behavior=i),c.updateAttributes(r);const f=this.generateDefinitionHash(c.export(),c.behavior),l=this.savedMetadata?.resources?.[t],d=l?.currentVersion||"v0",h=l?.versions?.[d];return(!h||h.hash!==f)&&await this.uploadMetadataFile(),this.emit("s3db.resourceUpdated",t),c}const o=this.savedMetadata?.resources?.[t]?.currentVersion||"v0",s=new ci({name:t,attributes:r,behavior:i,observers:[this],client:this.client,version:o,options:{cache:this.cache,...n}});return this.resources[t]=s,await this.uploadMetadataFile(),this.emit("s3db.resourceCreated",t),s}resource(t){return this.resources[t]?this.resources[t]:Promise.reject(`resource ${t} does not exist`)}async listResources(){return Object.keys(this.resources).map(t=>({name:t}))}async getResource(t){if(!this.resources[t])throw new Error(`Resource not found: ${t}`);return this.resources[t]}get config(){return{version:this.version,s3dbVersion:this.s3dbVersion,bucket:this.bucket,keyPrefix:this.keyPrefix,parallelism:this.parallelism,verbose:this.verbose}}isConnected(){return!!this.savedMetadata}}class hh extends ss{}class li extends R{constructor(t={}){super(),this.config=t}async _set(t,r){}async _get(t){}async _del(t){}async _clear(t){}validateKey(t){if(t==null||typeof t!="string"||!t)throw new Error("Invalid key")}async set(t,r){return this.validateKey(t),await this._set(t,r),this.emit("set",r),r}async get(t){this.validateKey(t);const r=await this._get(t);return this.emit("get",r),r}async del(t){this.validateKey(t);const r=await this._del(t);return this.emit("delete",r),r}async delete(t){return this.del(t)}async clear(){const t=await this._clear();return this.emit("clear",t),t}}class dh extends li{constructor(t={}){super(t),this.cache={},this.meta={},this.maxSize=t.maxSize||0,this.ttl=t.ttl||0}async _set(t,r){if(this.maxSize>0&&Object.keys(this.cache).length>=this.maxSize){const n=Object.entries(this.meta).sort((i,a)=>i[1].ts-a[1].ts)[0]?.[0];n&&(delete this.cache[n],delete this.meta[n])}return this.cache[t]=r,this.meta[t]={ts:Date.now()},r}async _get(t){if(!Object.prototype.hasOwnProperty.call(this.cache,t))return null;if(this.ttl>0){const r=Date.now(),n=this.meta[t];if(n&&r-n.ts>this.ttl*1e3)return delete this.cache[t],delete this.meta[t],null}return this.cache[t]}async _del(t){return delete this.cache[t],delete this.meta[t],!0}async _clear(){return this.cache={},this.meta={},!0}async size(){return Object.keys(this.cache).length}async keys(){return Object.keys(this.cache)}}var fs={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function ph(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function ke(e,t,r,n,i){if(t.subarray&&e.subarray){e.set(t.subarray(r,r+n),i);return}for(var a=0;a<n;a++)e[i+a]=t[r+a]}var _r=Uint8Array,oe=Uint16Array,br=Int32Array,yh=4,cs=0,ls=1,gh=2;function wt(e){for(var t=e.length;--t>=0;)e[t]=0}var vh=0,us=1,wh=2,_h=3,bh=258,ui=29,Ct=256,Dt=Ct+1+ui,_t=30,hi=19,hs=2*Dt+1,Je=15,di=16,mh=7,pi=256,ds=16,ps=17,ys=18,yi=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],mr=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],xh=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],gs=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Eh=512,Re=new Array((Dt+2)*2);wt(Re);var jt=new Array(_t*2);wt(jt);var Mt=new Array(Eh);wt(Mt);var Lt=new Array(bh-_h+1);wt(Lt);var gi=new Array(ui);wt(gi);var xr=new Array(_t);wt(xr);function vi(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}var vs,ws,_s;function wi(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function bs(e){return e<256?Mt[e]:Mt[256+(e>>>7)]}function Nt(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function ee(e,t,r){e.bi_valid>di-r?(e.bi_buf|=t<<e.bi_valid&65535,Nt(e,e.bi_buf),e.bi_buf=t>>di-e.bi_valid,e.bi_valid+=r-di):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function ve(e,t,r){ee(e,r[t*2],r[t*2+1])}function ms(e,t){var r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1}function Sh(e){e.bi_valid===16?(Nt(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function Ah(e,t){var r=t.dyn_tree,n=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length,f,l,d,h,u,p,g=0;for(h=0;h<=Je;h++)e.bl_count[h]=0;for(r[e.heap[e.heap_max]*2+1]=0,f=e.heap_max+1;f<hs;f++)l=e.heap[f],h=r[r[l*2+1]*2+1]+1,h>c&&(h=c,g++),r[l*2+1]=h,!(l>n)&&(e.bl_count[h]++,u=0,l>=s&&(u=o[l-s]),p=r[l*2],e.opt_len+=p*(h+u),a&&(e.static_len+=p*(i[l*2+1]+u)));if(g!==0){do{for(h=c-1;e.bl_count[h]===0;)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[c]--,g-=2}while(g>0);for(h=c;h!==0;h--)for(l=e.bl_count[h];l!==0;)d=e.heap[--f],!(d>n)&&(r[d*2+1]!==h&&(e.opt_len+=(h-r[d*2+1])*r[d*2],r[d*2+1]=h),l--)}}function xs(e,t,r){var n=new Array(Je+1),i=0,a,o;for(a=1;a<=Je;a++)n[a]=i=i+r[a-1]<<1;for(o=0;o<=t;o++){var s=e[o*2+1];s!==0&&(e[o*2]=ms(n[s]++,s))}}function kh(){var e,t,r,n,i,a=new Array(Je+1);for(r=0,n=0;n<ui-1;n++)for(gi[n]=r,e=0;e<1<<yi[n];e++)Lt[r++]=n;for(Lt[r-1]=n,i=0,n=0;n<16;n++)for(xr[n]=i,e=0;e<1<<mr[n];e++)Mt[i++]=n;for(i>>=7;n<_t;n++)for(xr[n]=i<<7,e=0;e<1<<mr[n]-7;e++)Mt[256+i++]=n;for(t=0;t<=Je;t++)a[t]=0;for(e=0;e<=143;)Re[e*2+1]=8,e++,a[8]++;for(;e<=255;)Re[e*2+1]=9,e++,a[9]++;for(;e<=279;)Re[e*2+1]=7,e++,a[7]++;for(;e<=287;)Re[e*2+1]=8,e++,a[8]++;for(xs(Re,Dt+1,a),e=0;e<_t;e++)jt[e*2+1]=5,jt[e*2]=ms(e,5);vs=new vi(Re,yi,Ct+1,Dt,Je),ws=new vi(jt,mr,0,_t,Je),_s=new vi(new Array(0),xh,0,hi,mh)}function Es(e){var t;for(t=0;t<Dt;t++)e.dyn_ltree[t*2]=0;for(t=0;t<_t;t++)e.dyn_dtree[t*2]=0;for(t=0;t<hi;t++)e.bl_tree[t*2]=0;e.dyn_ltree[pi*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function Ss(e){e.bi_valid>8?Nt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Rh(e,t,r,n){Ss(e),Nt(e,r),Nt(e,~r),ke(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}function As(e,t,r,n){var i=t*2,a=r*2;return e[i]<e[a]||e[i]===e[a]&&n[t]<=n[r]}function _i(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&As(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!As(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function ks(e,t,r){var n,i,a=0,o,s;if(e.last_lit!==0)do n=e.pending_buf[e.d_buf+a*2]<<8|e.pending_buf[e.d_buf+a*2+1],i=e.pending_buf[e.l_buf+a],a++,n===0?ve(e,i,t):(o=Lt[i],ve(e,o+Ct+1,t),s=yi[o],s!==0&&(i-=gi[o],ee(e,i,s)),n--,o=bs(n),ve(e,o,r),s=mr[o],s!==0&&(n-=xr[o],ee(e,n,s)));while(a<e.last_lit);ve(e,pi,t)}function bi(e,t){var r=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems,o,s,c=-1,f;for(e.heap_len=0,e.heap_max=hs,o=0;o<a;o++)r[o*2]!==0?(e.heap[++e.heap_len]=c=o,e.depth[o]=0):r[o*2+1]=0;for(;e.heap_len<2;)f=e.heap[++e.heap_len]=c<2?++c:0,r[f*2]=1,e.depth[f]=0,e.opt_len--,i&&(e.static_len-=n[f*2+1]);for(t.max_code=c,o=e.heap_len>>1;o>=1;o--)_i(e,r,o);f=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],_i(e,r,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,r[f*2]=r[o*2]+r[s*2],e.depth[f]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,r[o*2+1]=r[s*2+1]=f,e.heap[1]=f++,_i(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Ah(e,t),xs(r,c,e.bl_count)}function Rs(e,t,r){var n,i=-1,a,o=t[0*2+1],s=0,c=7,f=4;for(o===0&&(c=138,f=3),t[(r+1)*2+1]=65535,n=0;n<=r;n++)a=o,o=t[(n+1)*2+1],!(++s<c&&a===o)&&(s<f?e.bl_tree[a*2]+=s:a!==0?(a!==i&&e.bl_tree[a*2]++,e.bl_tree[ds*2]++):s<=10?e.bl_tree[ps*2]++:e.bl_tree[ys*2]++,s=0,i=a,o===0?(c=138,f=3):a===o?(c=6,f=3):(c=7,f=4))}function Os(e,t,r){var n,i=-1,a,o=t[0*2+1],s=0,c=7,f=4;for(o===0&&(c=138,f=3),n=0;n<=r;n++)if(a=o,o=t[(n+1)*2+1],!(++s<c&&a===o)){if(s<f)do ve(e,a,e.bl_tree);while(--s!==0);else a!==0?(a!==i&&(ve(e,a,e.bl_tree),s--),ve(e,ds,e.bl_tree),ee(e,s-3,2)):s<=10?(ve(e,ps,e.bl_tree),ee(e,s-3,3)):(ve(e,ys,e.bl_tree),ee(e,s-11,7));s=0,i=a,o===0?(c=138,f=3):a===o?(c=6,f=3):(c=7,f=4)}}function Oh(e){var t;for(Rs(e,e.dyn_ltree,e.l_desc.max_code),Rs(e,e.dyn_dtree,e.d_desc.max_code),bi(e,e.bl_desc),t=hi-1;t>=3&&e.bl_tree[gs[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function Th(e,t,r,n){var i;for(ee(e,t-257,5),ee(e,r-1,5),ee(e,n-4,4),i=0;i<n;i++)ee(e,e.bl_tree[gs[i]*2+1],3);Os(e,e.dyn_ltree,t-1),Os(e,e.dyn_dtree,r-1)}function Ph(e){var t=4093624447,r;for(r=0;r<=31;r++,t>>>=1)if(t&1&&e.dyn_ltree[r*2]!==0)return cs;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return ls;for(r=32;r<Ct;r++)if(e.dyn_ltree[r*2]!==0)return ls;return cs}var Ts=!1;function Ih(e){Ts||(kh(),Ts=!0),e.l_desc=new wi(e.dyn_ltree,vs),e.d_desc=new wi(e.dyn_dtree,ws),e.bl_desc=new wi(e.bl_tree,_s),e.bi_buf=0,e.bi_valid=0,Es(e)}function Ps(e,t,r,n){ee(e,(vh<<1)+(n?1:0),3),Rh(e,t,r)}function Fh(e){ee(e,us<<1,3),ve(e,pi,Re),Sh(e)}function Ch(e,t,r,n){var i,a,o=0;e.level>0?(e.strm.data_type===gh&&(e.strm.data_type=Ph(e)),bi(e,e.l_desc),bi(e,e.d_desc),o=Oh(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i&&(i=a)):i=a=r+5,r+4<=i&&t!==-1?Ps(e,t,r,n):e.strategy===yh||a===i?(ee(e,(us<<1)+(n?1:0),3),ks(e,Re,jt)):(ee(e,(wh<<1)+(n?1:0),3),Th(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),ks(e,e.dyn_ltree,e.dyn_dtree)),Es(e),n&&Ss(e)}function De(e,t,r){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=r&255,e.last_lit++,t===0?e.dyn_ltree[r*2]++:(e.matches++,t--,e.dyn_ltree[(Lt[r]+Ct+1)*2]++,e.dyn_dtree[bs(t)*2]++),e.last_lit===e.lit_bufsize-1}function mi(e,t,r,n){for(var i=e&65535|0,a=e>>>16&65535|0,o=0;r!==0;){o=r>2e3?2e3:r,r-=o;do i=i+t[n++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0}function Dh(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t}var jh=Dh();function Z(e,t,r,n){var i=jh,a=n+r;e^=-1;for(var o=n;o<a;o++)e=e>>>8^i[(e^t[o])&255];return e^-1}var Xe=0,Mh=1,Lh=3,je=4,Is=5,Me=0,Fs=1,Le=-2,Nh=-3,xi=-5,Bh=-1,$h=1,Er=2,Uh=3,zh=4,Zh=2,Ei=8,qh=9,Hh=29,Kh=256,Si=Kh+1+Hh,Wh=30,Vh=19,Gh=2*Si+1,Yh=15,I=3,Ne=258,se=Ne+I+1,Jh=32,Ai=42,ki=69,Sr=73,Ar=91,kr=103,Qe=113,Bt=666,U=1,$t=2,et=3,bt=4,Xh=3;function Be(e,t){return e.msg=fs[t],t}function Cs(e){return(e<<1)-(e>4?9:0)}function tt(e){for(var t=e.length;--t>=0;)e[t]=0}function $e(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(ke(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,t.pending===0&&(t.pending_out=0))}function K(e,t){Ch(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,$e(e.strm)}function P(e,t){e.pending_buf[e.pending++]=t}function Ut(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function Qh(e,t,r,n){var i=e.avail_in;return i>n&&(i=n),i===0?0:(e.avail_in-=i,ke(t,e.input,e.next_in,i,r),e.state.wrap===1?e.adler=mi(e.adler,t,i,r):e.state.wrap===2&&(e.adler=Z(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)}function Ds(e,t){var r=e.max_chain_length,n=e.strstart,i,a,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-se?e.strstart-(e.w_size-se):0,f=e.window,l=e.w_mask,d=e.prev,h=e.strstart+Ne,u=f[n+o-1],p=f[n+o];e.prev_length>=e.good_match&&(r>>=2),s>e.lookahead&&(s=e.lookahead);do if(i=t,!(f[i+o]!==p||f[i+o-1]!==u||f[i]!==f[n]||f[++i]!==f[n+1])){n+=2,i++;do;while(f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&n<h);if(a=Ne-(h-n),n=h-Ne,a>o){if(e.match_start=t,o=a,a>=s)break;u=f[n+o-1],p=f[n+o]}}while((t=d[t&l])>c&&--r!==0);return o<=e.lookahead?o:e.lookahead}function zt(e){var t=e.w_size,r,n,i,a,o;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-se)){ke(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,n=e.hash_size,r=n;do i=e.head[--r],e.head[r]=i>=t?i-t:0;while(--n);n=t,r=n;do i=e.prev[--r],e.prev[r]=i>=t?i-t:0;while(--n);a+=t}if(e.strm.avail_in===0)break;if(n=Qh(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=n,e.lookahead+e.insert>=I)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+I-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<I)););}while(e.lookahead<se&&e.strm.avail_in!==0)}function ed(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(zt(e),e.lookahead===0&&t===Xe)return U;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((e.strstart===0||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,K(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-se&&(K(e,!1),e.strm.avail_out===0))return U}return e.insert=0,t===je?(K(e,!0),e.strm.avail_out===0?et:bt):(e.strstart>e.block_start&&(K(e,!1),e.strm.avail_out===0),U)}function Ri(e,t){for(var r,n;;){if(e.lookahead<se){if(zt(e),e.lookahead<se&&t===Xe)return U;if(e.lookahead===0)break}if(r=0,e.lookahead>=I&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+I-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),r!==0&&e.strstart-r<=e.w_size-se&&(e.match_length=Ds(e,r)),e.match_length>=I)if(n=De(e,e.strstart-e.match_start,e.match_length-I),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=I){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+I-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=De(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(K(e,!1),e.strm.avail_out===0))return U}return e.insert=e.strstart<I-1?e.strstart:I-1,t===je?(K(e,!0),e.strm.avail_out===0?et:bt):e.last_lit&&(K(e,!1),e.strm.avail_out===0)?U:$t}function mt(e,t){for(var r,n,i;;){if(e.lookahead<se){if(zt(e),e.lookahead<se&&t===Xe)return U;if(e.lookahead===0)break}if(r=0,e.lookahead>=I&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+I-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=I-1,r!==0&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-se&&(e.match_length=Ds(e,r),e.match_length<=5&&(e.strategy===$h||e.match_length===I&&e.strstart-e.match_start>4096)&&(e.match_length=I-1)),e.prev_length>=I&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-I,n=De(e,e.strstart-1-e.prev_match,e.prev_length-I),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+I-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=I-1,e.strstart++,n&&(K(e,!1),e.strm.avail_out===0))return U}else if(e.match_available){if(n=De(e,0,e.window[e.strstart-1]),n&&K(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return U}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=De(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<I-1?e.strstart:I-1,t===je?(K(e,!0),e.strm.avail_out===0?et:bt):e.last_lit&&(K(e,!1),e.strm.avail_out===0)?U:$t}function td(e,t){for(var r,n,i,a,o=e.window;;){if(e.lookahead<=Ne){if(zt(e),e.lookahead<=Ne&&t===Xe)return U;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=I&&e.strstart>0&&(i=e.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){a=e.strstart+Ne;do;while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<a);e.match_length=Ne-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=I?(r=De(e,1,e.match_length-I),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=De(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(K(e,!1),e.strm.avail_out===0))return U}return e.insert=0,t===je?(K(e,!0),e.strm.avail_out===0?et:bt):e.last_lit&&(K(e,!1),e.strm.avail_out===0)?U:$t}function rd(e,t){for(var r;;){if(e.lookahead===0&&(zt(e),e.lookahead===0)){if(t===Xe)return U;break}if(e.match_length=0,r=De(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(K(e,!1),e.strm.avail_out===0))return U}return e.insert=0,t===je?(K(e,!0),e.strm.avail_out===0?et:bt):e.last_lit&&(K(e,!1),e.strm.avail_out===0)?U:$t}function we(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}var xt;xt=[new we(0,0,0,0,ed),new we(4,4,8,4,Ri),new we(4,5,16,8,Ri),new we(4,6,32,32,Ri),new we(4,4,16,16,mt),new we(8,16,32,32,mt),new we(8,16,128,128,mt),new we(8,32,128,256,mt),new we(32,128,258,1024,mt),new we(32,258,258,4096,mt)];function nd(e){e.window_size=2*e.w_size,tt(e.head),e.max_lazy_match=xt[e.level].max_lazy,e.good_match=xt[e.level].good_length,e.nice_match=xt[e.level].nice_length,e.max_chain_length=xt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=I-1,e.match_available=0,e.ins_h=0}function id(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Ei,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new oe(Gh*2),this.dyn_dtree=new oe((2*Wh+1)*2),this.bl_tree=new oe((2*Vh+1)*2),tt(this.dyn_ltree),tt(this.dyn_dtree),tt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new oe(Yh+1),this.heap=new oe(2*Si+1),tt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new oe(2*Si+1),tt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function ad(e){var t;return!e||!e.state?Be(e,Le):(e.total_in=e.total_out=0,e.data_type=Zh,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?Ai:Qe,e.adler=t.wrap===2?0:1,t.last_flush=Xe,Ih(t),Me)}function js(e){var t=ad(e);return t===Me&&nd(e.state),t}function od(e,t,r,n,i,a){if(!e)return Le;var o=1;if(t===Bh&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>qh||r!==Ei||n<8||n>15||t<0||t>9||a<0||a>zh)return Be(e,Le);n===8&&(n=9);var s=new id;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+I-1)/I),s.window=new _r(s.w_size*2),s.head=new oe(s.hash_size),s.prev=new oe(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new _r(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=a,s.method=r,js(e)}function sd(e,t){var r,n,i,a;if(!e||!e.state||t>Is||t<0)return e?Be(e,Le):Le;if(n=e.state,!e.output||!e.input&&e.avail_in!==0||n.status===Bt&&t!==je)return Be(e,e.avail_out===0?xi:Le);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===Ai)if(n.wrap===2)e.adler=0,P(n,31),P(n,139),P(n,8),n.gzhead?(P(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),P(n,n.gzhead.time&255),P(n,n.gzhead.time>>8&255),P(n,n.gzhead.time>>16&255),P(n,n.gzhead.time>>24&255),P(n,n.level===9?2:n.strategy>=Er||n.level<2?4:0),P(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(P(n,n.gzhead.extra.length&255),P(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Z(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=ki):(P(n,0),P(n,0),P(n,0),P(n,0),P(n,0),P(n,n.level===9?2:n.strategy>=Er||n.level<2?4:0),P(n,Xh),n.status=Qe);else{var o=Ei+(n.w_bits-8<<4)<<8,s=-1;n.strategy>=Er||n.level<2?s=0:n.level<6?s=1:n.level===6?s=2:s=3,o|=s<<6,n.strstart!==0&&(o|=Jh),o+=31-o%31,n.status=Qe,Ut(n,o),n.strstart!==0&&(Ut(n,e.adler>>>16),Ut(n,e.adler&65535)),e.adler=1}if(n.status===ki)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(n.gzhead.extra.length&65535)&&!(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),$e(e),i=n.pending,n.pending===n.pending_buf_size));)P(n,n.gzhead.extra[n.gzindex]&255),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=Sr)}else n.status=Sr;if(n.status===Sr)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),$e(e),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}n.gzindex<n.gzhead.name.length?a=n.gzhead.name.charCodeAt(n.gzindex++)&255:a=0,P(n,a)}while(a!==0);n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),a===0&&(n.gzindex=0,n.status=Ar)}else n.status=Ar;if(n.status===Ar)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),$e(e),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}n.gzindex<n.gzhead.comment.length?a=n.gzhead.comment.charCodeAt(n.gzindex++)&255:a=0,P(n,a)}while(a!==0);n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),a===0&&(n.status=kr)}else n.status=kr;if(n.status===kr&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&$e(e),n.pending+2<=n.pending_buf_size&&(P(n,e.adler&255),P(n,e.adler>>8&255),e.adler=0,n.status=Qe)):n.status=Qe),n.pending!==0){if($e(e),e.avail_out===0)return n.last_flush=-1,Me}else if(e.avail_in===0&&Cs(t)<=Cs(r)&&t!==je)return Be(e,xi);if(n.status===Bt&&e.avail_in!==0)return Be(e,xi);if(e.avail_in!==0||n.lookahead!==0||t!==Xe&&n.status!==Bt){var c=n.strategy===Er?rd(n,t):n.strategy===Uh?td(n,t):xt[n.level].func(n,t);if((c===et||c===bt)&&(n.status=Bt),c===U||c===et)return e.avail_out===0&&(n.last_flush=-1),Me;if(c===$t&&(t===Mh?Fh(n):t!==Is&&(Ps(n,0,0,!1),t===Lh&&(tt(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),$e(e),e.avail_out===0))return n.last_flush=-1,Me}return t!==je?Me:n.wrap<=0?Fs:(n.wrap===2?(P(n,e.adler&255),P(n,e.adler>>8&255),P(n,e.adler>>16&255),P(n,e.adler>>24&255),P(n,e.total_in&255),P(n,e.total_in>>8&255),P(n,e.total_in>>16&255),P(n,e.total_in>>24&255)):(Ut(n,e.adler>>>16),Ut(n,e.adler&65535)),$e(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?Me:Fs)}function fd(e){var t;return!e||!e.state?Le:(t=e.state.status,t!==Ai&&t!==ki&&t!==Sr&&t!==Ar&&t!==kr&&t!==Qe&&t!==Bt?Be(e,Le):(e.state=null,t===Qe?Be(e,Nh):Me))}var Rr=30,cd=12;function ld(e,t){var r,n,i,a,o,s,c,f,l,d,h,u,p,g,w,_,x,A,v,S,T,b,E,O,k;r=e.state,n=e.next_in,O=e.input,i=n+(e.avail_in-5),a=e.next_out,k=e.output,o=a-(t-e.avail_out),s=a+(e.avail_out-257),c=r.dmax,f=r.wsize,l=r.whave,d=r.wnext,h=r.window,u=r.hold,p=r.bits,g=r.lencode,w=r.distcode,_=(1<<r.lenbits)-1,x=(1<<r.distbits)-1;e:do{p<15&&(u+=O[n++]<<p,p+=8,u+=O[n++]<<p,p+=8),A=g[u&_];t:for(;;){if(v=A>>>24,u>>>=v,p-=v,v=A>>>16&255,v===0)k[a++]=A&65535;else if(v&16){S=A&65535,v&=15,v&&(p<v&&(u+=O[n++]<<p,p+=8),S+=u&(1<<v)-1,u>>>=v,p-=v),p<15&&(u+=O[n++]<<p,p+=8,u+=O[n++]<<p,p+=8),A=w[u&x];r:for(;;){if(v=A>>>24,u>>>=v,p-=v,v=A>>>16&255,v&16){if(T=A&65535,v&=15,p<v&&(u+=O[n++]<<p,p+=8,p<v&&(u+=O[n++]<<p,p+=8)),T+=u&(1<<v)-1,T>c){e.msg="invalid distance too far back",r.mode=Rr;break e}if(u>>>=v,p-=v,v=a-o,T>v){if(v=T-v,v>l&&r.sane){e.msg="invalid distance too far back",r.mode=Rr;break e}if(b=0,E=h,d===0){if(b+=f-v,v<S){S-=v;do k[a++]=h[b++];while(--v);b=a-T,E=k}}else if(d<v){if(b+=f+d-v,v-=d,v<S){S-=v;do k[a++]=h[b++];while(--v);if(b=0,d<S){v=d,S-=v;do k[a++]=h[b++];while(--v);b=a-T,E=k}}}else if(b+=d-v,v<S){S-=v;do k[a++]=h[b++];while(--v);b=a-T,E=k}for(;S>2;)k[a++]=E[b++],k[a++]=E[b++],k[a++]=E[b++],S-=3;S&&(k[a++]=E[b++],S>1&&(k[a++]=E[b++]))}else{b=a-T;do k[a++]=k[b++],k[a++]=k[b++],k[a++]=k[b++],S-=3;while(S>2);S&&(k[a++]=k[b++],S>1&&(k[a++]=k[b++]))}}else if((v&64)===0){A=w[(A&65535)+(u&(1<<v)-1)];continue r}else{e.msg="invalid distance code",r.mode=Rr;break e}break}}else if((v&64)===0){A=g[(A&65535)+(u&(1<<v)-1)];continue t}else if(v&32){r.mode=cd;break e}else{e.msg="invalid literal/length code",r.mode=Rr;break e}break}}while(n<i&&a<s);S=p>>3,n-=S,p-=S<<3,u&=(1<<p)-1,e.next_in=n,e.next_out=a,e.avail_in=n<i?5+(i-n):5-(n-i),e.avail_out=a<s?257+(s-a):257-(a-s),r.hold=u,r.bits=p}var Et=15,Ms=852,Ls=592,Ns=0,Oi=1,Bs=2,ud=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],hd=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],dd=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],pd=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];function Zt(e,t,r,n,i,a,o,s){var c=s.bits,f=0,l=0,d=0,h=0,u=0,p=0,g=0,w=0,_=0,x=0,A,v,S,T,b,E=null,O=0,k,C=new oe(Et+1),q=new oe(Et+1),G=null,ne=0,ze,J,ce;for(f=0;f<=Et;f++)C[f]=0;for(l=0;l<n;l++)C[t[r+l]]++;for(u=c,h=Et;h>=1&&C[h]===0;h--);if(u>h&&(u=h),h===0)return i[a++]=1<<24|64<<16|0,i[a++]=1<<24|64<<16|0,s.bits=1,0;for(d=1;d<h&&C[d]===0;d++);for(u<d&&(u=d),w=1,f=1;f<=Et;f++)if(w<<=1,w-=C[f],w<0)return-1;if(w>0&&(e===Ns||h!==1))return-1;for(q[1]=0,f=1;f<Et;f++)q[f+1]=q[f]+C[f];for(l=0;l<n;l++)t[r+l]!==0&&(o[q[t[r+l]]++]=l);if(e===Ns?(E=G=o,k=19):e===Oi?(E=ud,O-=257,G=hd,ne-=257,k=256):(E=dd,G=pd,k=-1),x=0,l=0,f=d,b=a,p=u,g=0,S=-1,_=1<<u,T=_-1,e===Oi&&_>Ms||e===Bs&&_>Ls)return 1;for(;;){ze=f-g,o[l]<k?(J=0,ce=o[l]):o[l]>k?(J=G[ne+o[l]],ce=E[O+o[l]]):(J=96,ce=0),A=1<<f-g,v=1<<p,d=v;do v-=A,i[b+(x>>g)+v]=ze<<24|J<<16|ce|0;while(v!==0);for(A=1<<f-1;x&A;)A>>=1;if(A!==0?(x&=A-1,x+=A):x=0,l++,--C[f]===0){if(f===h)break;f=t[r+o[l]]}if(f>u&&(x&T)!==S){for(g===0&&(g=u),b+=d,p=f-g,w=1<<p;p+g<h&&(w-=C[p+g],!(w<=0));)p++,w<<=1;if(_+=1<<p,e===Oi&&_>Ms||e===Bs&&_>Ls)return 1;S=x&T,i[S]=u<<24|p<<16|b-a|0}}return x!==0&&(i[b+x]=f-g<<24|64<<16|0),s.bits=u,0}var yd=0,$s=1,Us=2,zs=4,gd=5,Or=6,qt=0,vd=1,wd=2,Ue=-2,_d=-3,bd=-4,md=-5,Zs=8,qs=1,Hs=2,Ks=3,Ws=4,Vs=5,Gs=6,Ys=7,Js=8,Xs=9,Qs=10,ef=11,Oe=12,Ti=13,tf=14,Pi=15,rf=16,nf=17,af=18,of=19,Tr=20,Pr=21,sf=22,ff=23,cf=24,lf=25,uf=26,Ii=27,hf=28,df=29,D=30,xd=31,Ed=32,Sd=852,Ad=592;function pf(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function kd(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new oe(320),this.work=new oe(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Rd(e){var t;return!e||!e.state?Ue:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=qs,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new br(Sd),t.distcode=t.distdyn=new br(Ad),t.sane=1,t.back=-1,qt)}function yf(e){var t;return!e||!e.state?Ue:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,Rd(e))}function Od(e,t){var r,n;return!e||!e.state||(n=e.state,t<0?(r=0,t=-t):(r=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?Ue:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,yf(e))}function Td(e,t){var r,n;return e?(n=new kd,e.state=n,n.window=null,r=Od(e,t),r!==qt&&(e.state=null),r):Ue}var gf=!0,Fi,Ci;function Pd(e){if(gf){var t;for(Fi=new br(512),Ci=new br(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Zt($s,e.lens,0,288,Fi,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Zt(Us,e.lens,0,32,Ci,0,e.work,{bits:5}),gf=!1}e.lencode=Fi,e.lenbits=9,e.distcode=Ci,e.distbits=5}function Id(e,t,r,n){var i,a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new _r(a.wsize)),n>=a.wsize?(ke(a.window,t,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>n&&(i=n),ke(a.window,t,r-n,i,a.wnext),n-=i,n?(ke(a.window,t,r-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0}function Fd(e,t){var r,n,i,a,o,s,c,f,l,d,h,u,p,g,w=0,_,x,A,v,S,T,b,E,O=new _r(4),k,C,q=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return Ue;r=e.state,r.mode===Oe&&(r.mode=Ti),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,f=r.hold,l=r.bits,d=s,h=c,E=qt;e:for(;;)switch(r.mode){case qs:if(r.wrap===0){r.mode=Ti;break}for(;l<16;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if(r.wrap&2&&f===35615){r.check=0,O[0]=f&255,O[1]=f>>>8&255,r.check=Z(r.check,O,2,0),f=0,l=0,r.mode=Hs;break}if(r.flags=0,r.head&&(r.head.done=!1),!(r.wrap&1)||(((f&255)<<8)+(f>>8))%31){e.msg="incorrect header check",r.mode=D;break}if((f&15)!==Zs){e.msg="unknown compression method",r.mode=D;break}if(f>>>=4,l-=4,b=(f&15)+8,r.wbits===0)r.wbits=b;else if(b>r.wbits){e.msg="invalid window size",r.mode=D;break}r.dmax=1<<b,e.adler=r.check=1,r.mode=f&512?Qs:Oe,f=0,l=0;break;case Hs:for(;l<16;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if(r.flags=f,(r.flags&255)!==Zs){e.msg="unknown compression method",r.mode=D;break}if(r.flags&57344){e.msg="unknown header flags set",r.mode=D;break}r.head&&(r.head.text=f>>8&1),r.flags&512&&(O[0]=f&255,O[1]=f>>>8&255,r.check=Z(r.check,O,2,0)),f=0,l=0,r.mode=Ks;case Ks:for(;l<32;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}r.head&&(r.head.time=f),r.flags&512&&(O[0]=f&255,O[1]=f>>>8&255,O[2]=f>>>16&255,O[3]=f>>>24&255,r.check=Z(r.check,O,4,0)),f=0,l=0,r.mode=Ws;case Ws:for(;l<16;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}r.head&&(r.head.xflags=f&255,r.head.os=f>>8),r.flags&512&&(O[0]=f&255,O[1]=f>>>8&255,r.check=Z(r.check,O,2,0)),f=0,l=0,r.mode=Vs;case Vs:if(r.flags&1024){for(;l<16;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}r.length=f,r.head&&(r.head.extra_len=f),r.flags&512&&(O[0]=f&255,O[1]=f>>>8&255,r.check=Z(r.check,O,2,0)),f=0,l=0}else r.head&&(r.head.extra=null);r.mode=Gs;case Gs:if(r.flags&1024&&(u=r.length,u>s&&(u=s),u&&(r.head&&(b=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),ke(r.head.extra,n,a,u,b)),r.flags&512&&(r.check=Z(r.check,n,u,a)),s-=u,a+=u,r.length-=u),r.length))break e;r.length=0,r.mode=Ys;case Ys:if(r.flags&2048){if(s===0)break e;u=0;do b=n[a+u++],r.head&&b&&r.length<65536&&(r.head.name+=String.fromCharCode(b));while(b&&u<s);if(r.flags&512&&(r.check=Z(r.check,n,u,a)),s-=u,a+=u,b)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=Js;case Js:if(r.flags&4096){if(s===0)break e;u=0;do b=n[a+u++],r.head&&b&&r.length<65536&&(r.head.comment+=String.fromCharCode(b));while(b&&u<s);if(r.flags&512&&(r.check=Z(r.check,n,u,a)),s-=u,a+=u,b)break e}else r.head&&(r.head.comment=null);r.mode=Xs;case Xs:if(r.flags&512){for(;l<16;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if(f!==(r.check&65535)){e.msg="header crc mismatch",r.mode=D;break}f=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=Oe;break;case Qs:for(;l<32;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}e.adler=r.check=pf(f),f=0,l=0,r.mode=ef;case ef:if(r.havedict===0)return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,r.hold=f,r.bits=l,wd;e.adler=r.check=1,r.mode=Oe;case Oe:if(t===gd||t===Or)break e;case Ti:if(r.last){f>>>=l&7,l-=l&7,r.mode=Ii;break}for(;l<3;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}switch(r.last=f&1,f>>>=1,l-=1,f&3){case 0:r.mode=tf;break;case 1:if(Pd(r),r.mode=Tr,t===Or){f>>>=2,l-=2;break e}break;case 2:r.mode=nf;break;case 3:e.msg="invalid block type",r.mode=D}f>>>=2,l-=2;break;case tf:for(f>>>=l&7,l-=l&7;l<32;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if((f&65535)!==(f>>>16^65535)){e.msg="invalid stored block lengths",r.mode=D;break}if(r.length=f&65535,f=0,l=0,r.mode=Pi,t===Or)break e;case Pi:r.mode=rf;case rf:if(u=r.length,u){if(u>s&&(u=s),u>c&&(u=c),u===0)break e;ke(i,n,a,u,o),s-=u,a+=u,c-=u,o+=u,r.length-=u;break}r.mode=Oe;break;case nf:for(;l<14;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if(r.nlen=(f&31)+257,f>>>=5,l-=5,r.ndist=(f&31)+1,f>>>=5,l-=5,r.ncode=(f&15)+4,f>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=D;break}r.have=0,r.mode=af;case af:for(;r.have<r.ncode;){for(;l<3;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}r.lens[q[r.have++]]=f&7,f>>>=3,l-=3}for(;r.have<19;)r.lens[q[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,k={bits:r.lenbits},E=Zt(yd,r.lens,0,19,r.lencode,0,r.work,k),r.lenbits=k.bits,E){e.msg="invalid code lengths set",r.mode=D;break}r.have=0,r.mode=of;case of:for(;r.have<r.nlen+r.ndist;){for(;w=r.lencode[f&(1<<r.lenbits)-1],_=w>>>24,x=w>>>16&255,A=w&65535,!(_<=l);){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if(A<16)f>>>=_,l-=_,r.lens[r.have++]=A;else{if(A===16){for(C=_+2;l<C;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if(f>>>=_,l-=_,r.have===0){e.msg="invalid bit length repeat",r.mode=D;break}b=r.lens[r.have-1],u=3+(f&3),f>>>=2,l-=2}else if(A===17){for(C=_+3;l<C;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}f>>>=_,l-=_,b=0,u=3+(f&7),f>>>=3,l-=3}else{for(C=_+7;l<C;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}f>>>=_,l-=_,b=0,u=11+(f&127),f>>>=7,l-=7}if(r.have+u>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=D;break}for(;u--;)r.lens[r.have++]=b}}if(r.mode===D)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=D;break}if(r.lenbits=9,k={bits:r.lenbits},E=Zt($s,r.lens,0,r.nlen,r.lencode,0,r.work,k),r.lenbits=k.bits,E){e.msg="invalid literal/lengths set",r.mode=D;break}if(r.distbits=6,r.distcode=r.distdyn,k={bits:r.distbits},E=Zt(Us,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,k),r.distbits=k.bits,E){e.msg="invalid distances set",r.mode=D;break}if(r.mode=Tr,t===Or)break e;case Tr:r.mode=Pr;case Pr:if(s>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,r.hold=f,r.bits=l,ld(e,h),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,f=r.hold,l=r.bits,r.mode===Oe&&(r.back=-1);break}for(r.back=0;w=r.lencode[f&(1<<r.lenbits)-1],_=w>>>24,x=w>>>16&255,A=w&65535,!(_<=l);){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if(x&&(x&240)===0){for(v=_,S=x,T=A;w=r.lencode[T+((f&(1<<v+S)-1)>>v)],_=w>>>24,x=w>>>16&255,A=w&65535,!(v+_<=l);){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}f>>>=v,l-=v,r.back+=v}if(f>>>=_,l-=_,r.back+=_,r.length=A,x===0){r.mode=uf;break}if(x&32){r.back=-1,r.mode=Oe;break}if(x&64){e.msg="invalid literal/length code",r.mode=D;break}r.extra=x&15,r.mode=sf;case sf:if(r.extra){for(C=r.extra;l<C;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}r.length+=f&(1<<r.extra)-1,f>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=ff;case ff:for(;w=r.distcode[f&(1<<r.distbits)-1],_=w>>>24,x=w>>>16&255,A=w&65535,!(_<=l);){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if((x&240)===0){for(v=_,S=x,T=A;w=r.distcode[T+((f&(1<<v+S)-1)>>v)],_=w>>>24,x=w>>>16&255,A=w&65535,!(v+_<=l);){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}f>>>=v,l-=v,r.back+=v}if(f>>>=_,l-=_,r.back+=_,x&64){e.msg="invalid distance code",r.mode=D;break}r.offset=A,r.extra=x&15,r.mode=cf;case cf:if(r.extra){for(C=r.extra;l<C;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}r.offset+=f&(1<<r.extra)-1,f>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=D;break}r.mode=lf;case lf:if(c===0)break e;if(u=h-c,r.offset>u){if(u=r.offset-u,u>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=D;break}u>r.wnext?(u-=r.wnext,p=r.wsize-u):p=r.wnext-u,u>r.length&&(u=r.length),g=r.window}else g=i,p=o-r.offset,u=r.length;u>c&&(u=c),c-=u,r.length-=u;do i[o++]=g[p++];while(--u);r.length===0&&(r.mode=Pr);break;case uf:if(c===0)break e;i[o++]=r.length,c--,r.mode=Pr;break;case Ii:if(r.wrap){for(;l<32;){if(s===0)break e;s--,f|=n[a++]<<l,l+=8}if(h-=c,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=r.flags?Z(r.check,i,h,o-h):mi(r.check,i,h,o-h)),h=c,(r.flags?f:pf(f))!==r.check){e.msg="incorrect data check",r.mode=D;break}f=0,l=0}r.mode=hf;case hf:if(r.wrap&&r.flags){for(;l<32;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if(f!==(r.total&4294967295)){e.msg="incorrect length check",r.mode=D;break}f=0,l=0}r.mode=df;case df:E=vd;break e;case D:E=_d;break e;case xd:return bd;case Ed:default:return Ue}return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,r.hold=f,r.bits=l,(r.wsize||h!==e.avail_out&&r.mode<D&&(r.mode<Ii||t!==zs))&&Id(e,e.output,e.next_out,h-e.avail_out),d-=e.avail_in,h-=e.avail_out,e.total_in+=d,e.total_out+=h,r.total+=h,r.wrap&&h&&(e.adler=r.check=r.flags?Z(r.check,i,h,e.next_out-h):mi(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===Oe?128:0)+(r.mode===Tr||r.mode===Pi?256:0),(d===0&&h===0||t===zs)&&E===qt&&(E=md),E}function Cd(e){if(!e||!e.state)return Ue;var t=e.state;return t.window&&(t.window=null),e.state=null,qt}var Di=0,St=1,Ir=2,Ht=3,Fr=4,At=5,Kt=6,Wt=7,vf=0,wf=1,_f=2,bf=3,ji=4,mf=5,Dd=6,Cr=0,xf=1,Ef=2,jd=-1,Md=-2,Ld=-3,Sf=-5,Nd=0,Bd=1,$d=9,Ud=-1,zd=1,Zd=2,qd=3,Hd=4,Kd=0,Wd=0,Vd=1,Gd=2,Af=8;function fe(e){if(e<St||e>Wt)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}fe.prototype.init=function(e,t,r,n,i){this.windowBits=e,this.level=t,this.memLevel=r,this.strategy=n,(this.mode===Ht||this.mode===Fr)&&(this.windowBits+=16),this.mode===Wt&&(this.windowBits+=32),(this.mode===At||this.mode===Kt)&&(this.windowBits=-this.windowBits),this.strm=new ph;var a;switch(this.mode){case St:case Ht:case At:a=od(this.strm,this.level,Af,this.windowBits,this.memLevel,this.strategy);break;case Ir:case Fr:case Kt:case Wt:a=Td(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}if(a!==Cr){this._error(a);return}this.write_in_progress=!1,this.init_done=!0},fe.prototype.params=function(){throw new Error("deflateParams Not supported")},fe.prototype._writeCheck=function(){if(!this.init_done)throw new Error("write before init");if(this.mode===Di)throw new Error("already finalized");if(this.write_in_progress)throw new Error("write already in progress");if(this.pending_close)throw new Error("close is pending")},fe.prototype.write=function(e,t,r,n,i,a,o){this._writeCheck(),this.write_in_progress=!0;var s=this;return Se.nextTick(function(){s.write_in_progress=!1;var c=s._write(e,t,r,n,i,a,o);s.callback(c[0],c[1]),s.pending_close&&s.close()}),this};function Yd(e,t){for(var r=0;r<e.length;r++)this[t+r]=e[r]}fe.prototype.writeSync=function(e,t,r,n,i,a,o){return this._writeCheck(),this._write(e,t,r,n,i,a,o)},fe.prototype._write=function(e,t,r,n,i,a,o){if(this.write_in_progress=!0,e!==vf&&e!==wf&&e!==_f&&e!==bf&&e!==ji&&e!==mf)throw new Error("Invalid flush value");t==null&&(t=new y(0),n=0,r=0),i._set?i.set=i._set:i.set=Yd;var s=this.strm;s.avail_in=n,s.input=t,s.next_in=r,s.avail_out=o,s.output=i,s.next_out=a;var c;switch(this.mode){case St:case Ht:case At:c=sd(s,e);break;case Wt:case Ir:case Fr:case Kt:c=Fd(s,e);break;default:throw new Error("Unknown mode "+this.mode)}return this._checkError(c,s,e)||this._error(c),this.write_in_progress=!1,[s.avail_in,s.avail_out]},fe.prototype._checkError=function(e,t,r){switch(e){case Cr:case Sf:if(t.avail_out!==0&&r===ji)return!1;break;case xf:break;case Ef:return!1;default:return!1}return!0},fe.prototype.close=function(){if(this.write_in_progress){this.pending_close=!0;return}this.pending_close=!1,this.mode===St||this.mode===Ht||this.mode===At?fd(this.strm):Cd(this.strm),this.mode=Di};var Dr;fe.prototype.reset=function(){switch(this.mode){case St:case At:Dr=js(this.strm);break;case Ir:case Kt:Dr=yf(this.strm);break}Dr!==Cr&&this._error(Dr)},fe.prototype._error=function(e){this.onerror(fs[e]+": "+this.strm.msg,e),this.write_in_progress=!1,this.pending_close&&this.close()};var kf=Object.freeze({__proto__:null,DEFLATE:St,DEFLATERAW:At,GUNZIP:Fr,GZIP:Ht,INFLATE:Ir,INFLATERAW:Kt,NONE:Di,UNZIP:Wt,Z_BEST_COMPRESSION:$d,Z_BEST_SPEED:Bd,Z_BINARY:Wd,Z_BLOCK:mf,Z_BUF_ERROR:Sf,Z_DATA_ERROR:Ld,Z_DEFAULT_COMPRESSION:Ud,Z_DEFAULT_STRATEGY:Kd,Z_DEFLATED:Af,Z_ERRNO:jd,Z_FILTERED:zd,Z_FINISH:ji,Z_FIXED:Hd,Z_FULL_FLUSH:bf,Z_HUFFMAN_ONLY:Zd,Z_NEED_DICT:Ef,Z_NO_COMPRESSION:Nd,Z_NO_FLUSH:vf,Z_OK:Cr,Z_PARTIAL_FLUSH:wf,Z_RLE:qd,Z_STREAM_END:xf,Z_STREAM_ERROR:Md,Z_SYNC_FLUSH:_f,Z_TEXT:Vd,Z_TREES:Dd,Z_UNKNOWN:Gd,Zlib:fe});function Jd(e,t){if(!e)throw new Error(t)}var m={};Object.keys(kf).forEach(function(e){m[e]=kf[e]}),m.Z_MIN_WINDOWBITS=8,m.Z_MAX_WINDOWBITS=15,m.Z_DEFAULT_WINDOWBITS=15,m.Z_MIN_CHUNK=64,m.Z_MAX_CHUNK=1/0,m.Z_DEFAULT_CHUNK=16*1024,m.Z_MIN_MEMLEVEL=1,m.Z_MAX_MEMLEVEL=9,m.Z_DEFAULT_MEMLEVEL=8,m.Z_MIN_LEVEL=-1,m.Z_MAX_LEVEL=9,m.Z_DEFAULT_LEVEL=m.Z_DEFAULT_COMPRESSION;var Vt={Z_OK:m.Z_OK,Z_STREAM_END:m.Z_STREAM_END,Z_NEED_DICT:m.Z_NEED_DICT,Z_ERRNO:m.Z_ERRNO,Z_STREAM_ERROR:m.Z_STREAM_ERROR,Z_DATA_ERROR:m.Z_DATA_ERROR,Z_MEM_ERROR:m.Z_MEM_ERROR,Z_BUF_ERROR:m.Z_BUF_ERROR,Z_VERSION_ERROR:m.Z_VERSION_ERROR};Object.keys(Vt).forEach(function(e){Vt[Vt[e]]=e});function Xd(e){return new it(e)}function Qd(e){return new at(e)}function ep(e){return new ft(e)}function tp(e){return new ct(e)}function rp(e){return new ot(e)}function np(e){return new st(e)}function ip(e){return new lt(e)}function ap(e,t,r){return typeof t=="function"&&(r=t,t={}),rt(new it(t),e,r)}function op(e,t){return nt(new it(t),e)}function sp(e,t,r){return typeof t=="function"&&(r=t,t={}),rt(new ot(t),e,r)}function fp(e,t){return nt(new ot(t),e)}function cp(e,t,r){return typeof t=="function"&&(r=t,t={}),rt(new ft(t),e,r)}function lp(e,t){return nt(new ft(t),e)}function up(e,t,r){return typeof t=="function"&&(r=t,t={}),rt(new lt(t),e,r)}function hp(e,t){return nt(new lt(t),e)}function dp(e,t,r){return typeof t=="function"&&(r=t,t={}),rt(new at(t),e,r)}function pp(e,t){return nt(new at(t),e)}function yp(e,t,r){return typeof t=="function"&&(r=t,t={}),rt(new st(t),e,r)}function gp(e,t){return nt(new st(t),e)}function vp(e,t,r){return typeof t=="function"&&(r=t,t={}),rt(new ct(t),e,r)}function wp(e,t){return nt(new ct(t),e)}function rt(e,t,r){var n=[],i=0;e.on("error",o),e.on("end",s),e.end(t),a();function a(){for(var c;(c=e.read())!==null;)n.push(c),i+=c.length;e.once("readable",a)}function o(c){e.removeListener("end",s),e.removeListener("readable",a),r(c)}function s(){var c=y.concat(n,i);n=[],r(null,c),e.close()}}function nt(e,t){if(typeof t=="string"&&(t=new y(t)),!y.isBuffer(t))throw new TypeError("Not a string or buffer");var r=m.Z_FINISH;return e._processChunk(t,r)}function it(e){if(!(this instanceof it))return new it(e);j.call(this,e,m.DEFLATE)}function at(e){if(!(this instanceof at))return new at(e);j.call(this,e,m.INFLATE)}function ot(e){if(!(this instanceof ot))return new ot(e);j.call(this,e,m.GZIP)}function st(e){if(!(this instanceof st))return new st(e);j.call(this,e,m.GUNZIP)}function ft(e){if(!(this instanceof ft))return new ft(e);j.call(this,e,m.DEFLATERAW)}function ct(e){if(!(this instanceof ct))return new ct(e);j.call(this,e,m.INFLATERAW)}function lt(e){if(!(this instanceof lt))return new lt(e);j.call(this,e,m.UNZIP)}function j(e,t){if(this._opts=e=e||{},this._chunkSize=e.chunkSize||m.Z_DEFAULT_CHUNK,re.call(this,e),e.flush&&e.flush!==m.Z_NO_FLUSH&&e.flush!==m.Z_PARTIAL_FLUSH&&e.flush!==m.Z_SYNC_FLUSH&&e.flush!==m.Z_FULL_FLUSH&&e.flush!==m.Z_FINISH&&e.flush!==m.Z_BLOCK)throw new Error("Invalid flush flag: "+e.flush);if(this._flushFlag=e.flush||m.Z_NO_FLUSH,e.chunkSize&&(e.chunkSize<m.Z_MIN_CHUNK||e.chunkSize>m.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBits<m.Z_MIN_WINDOWBITS||e.windowBits>m.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.level<m.Z_MIN_LEVEL||e.level>m.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevel<m.Z_MIN_MEMLEVEL||e.memLevel>m.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=m.Z_FILTERED&&e.strategy!=m.Z_HUFFMAN_ONLY&&e.strategy!=m.Z_RLE&&e.strategy!=m.Z_FIXED&&e.strategy!=m.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!y.isBuffer(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new m.Zlib(t);var r=this;this._hadError=!1,this._binding.onerror=function(a,o){r._binding=null,r._hadError=!0;var s=new Error(a);s.errno=o,s.code=Vt[o],r.emit("error",s)};var n=m.Z_DEFAULT_COMPRESSION;typeof e.level=="number"&&(n=e.level);var i=m.Z_DEFAULT_STRATEGY;typeof e.strategy=="number"&&(i=e.strategy),this._binding.init(e.windowBits||m.Z_DEFAULT_WINDOWBITS,n,e.memLevel||m.Z_DEFAULT_MEMLEVEL,i,e.dictionary),this._buffer=new y(this._chunkSize),this._offset=0,this._closed=!1,this._level=n,this._strategy=i,this.once("end",this.close)}V(j,re),j.prototype.params=function(e,t,r){if(e<m.Z_MIN_LEVEL||e>m.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(t!=m.Z_FILTERED&&t!=m.Z_HUFFMAN_ONLY&&t!=m.Z_RLE&&t!=m.Z_FIXED&&t!=m.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+t);if(this._level!==e||this._strategy!==t){var n=this;this.flush(m.Z_SYNC_FLUSH,function(){n._binding.params(e,t),n._hadError||(n._level=e,n._strategy=t,r&&r())})}else Se.nextTick(r)},j.prototype.reset=function(){return this._binding.reset()},j.prototype._flush=function(e){this._transform(new y(0),"",e)},j.prototype.flush=function(e,t){var r=this._writableState;if((typeof e=="function"||e===void 0&&!t)&&(t=e,e=m.Z_FULL_FLUSH),r.ended)t&&Se.nextTick(t);else if(r.ending)t&&this.once("end",t);else if(r.needDrain){var n=this;this.once("drain",function(){n.flush(t)})}else this._flushFlag=e,this.write(new y(0),"",t)},j.prototype.close=function(e){if(e&&Se.nextTick(e),!this._closed){this._closed=!0,this._binding.close();var t=this;Se.nextTick(function(){t.emit("close")})}},j.prototype._transform=function(e,t,r){var n,i=this._writableState,a=i.ending||i.ended,o=a&&(!e||i.length===e.length);if(!e===null&&!y.isBuffer(e))return r(new Error("invalid input"));o?n=m.Z_FINISH:(n=this._flushFlag,e.length>=i.length&&(this._flushFlag=this._opts.flush||m.Z_NO_FLUSH)),this._processChunk(e,n,r)},j.prototype._processChunk=function(e,t,r){var n=e&&e.length,i=this._chunkSize-this._offset,a=0,o=this,s=typeof r=="function";if(!s){var c=[],f=0,l;this.on("error",function(g){l=g});do var d=this._binding.writeSync(t,e,a,n,this._buffer,this._offset,i);while(!this._hadError&&p(d[0],d[1]));if(this._hadError)throw l;var h=y.concat(c,f);return this.close(),h}var u=this._binding.write(t,e,a,n,this._buffer,this._offset,i);u.buffer=e,u.callback=p;function p(g,w){if(!o._hadError){var _=i-w;if(Jd(_>=0,"have should not go down"),_>0){var x=o._buffer.slice(o._offset,o._offset+_);o._offset+=_,s?o.push(x):(c.push(x),f+=x.length)}if((w===0||o._offset>=o._chunkSize)&&(i=o._chunkSize,o._offset=0,o._buffer=new y(o._chunkSize)),w===0){if(a+=n-g,n=g,!s)return!0;var A=o._binding.write(t,e,a,n,o._buffer,o._offset,o._chunkSize);A.callback=p,A.buffer=e;return}if(!s)return!1;r()}}},V(it,j),V(at,j),V(ot,j),V(st,j),V(ft,j),V(ct,j),V(lt,j);var Rf={codes:Vt,createDeflate:Xd,createInflate:Qd,createDeflateRaw:ep,createInflateRaw:tp,createGzip:rp,createGunzip:np,createUnzip:ip,deflate:ap,deflateSync:op,gzip:sp,gzipSync:fp,deflateRaw:cp,deflateRawSync:lp,unzip:up,unzipSync:hp,inflate:dp,inflateSync:pp,gunzip:yp,gunzipSync:gp,inflateRaw:vp,inflateRawSync:wp,Deflate:it,Inflate:at,Gzip:ot,Gunzip:st,DeflateRaw:ft,InflateRaw:ct,Unzip:lt,Zlib:j};class Of extends li{constructor({client:t,keyPrefix:r="cache",ttl:n=0,prefix:i=void 0}){super({client:t,keyPrefix:r,ttl:n,prefix:i}),this.client=t,this.keyPrefix=r,this.config.ttl=n,this.config.client=t,this.config.prefix=i!==void 0?i:r+(r.endsWith("/")?"":"/")}async _set(t,r){let n=JSON.stringify(r);const i=n.length;return n=Rf.gzipSync(n).toString("base64"),this.client.putObject({key:me(this.keyPrefix,t),body:n,contentEncoding:"gzip",contentType:"application/gzip",metadata:{compressor:"zlib",compressed:"true","client-id":this.client.id,"length-serialized":String(i),"length-compressed":String(n.length),"compression-gain":(n.length/i).toFixed(2)}})}async _get(t){try{const{Body:r}=await this.client.getObject(me(this.keyPrefix,t));let n=await gt(r);return n=Buffer.from(n,"base64"),n=Rf.unzipSync(n).toString(),JSON.parse(n)}catch(r){if(r.name==="NoSuchKey"||r.name==="NotFound")return null;throw r}}async _del(t){return await this.client.deleteObject(me(this.keyPrefix,t)),!0}async _clear(){const t=await this.client.getAllKeys({prefix:this.keyPrefix});for(const r of t)await this.client.deleteObject(r)}async size(){return(await this.keys()).length}async keys(){const t=await this.client.getAllKeys({prefix:this.keyPrefix}),r=this.keyPrefix.endsWith("/")?this.keyPrefix:this.keyPrefix+"/";return t.map(n=>n.startsWith(r)?n.slice(r.length):n)}}class Tf extends R{async setup(t){}async start(){}async stop(){}beforeSetup(){this.emit("plugin.beforeSetup",new Date)}afterSetup(){this.emit("plugin.afterSetup",new Date)}beforeStart(){this.emit("plugin.beforeStart",new Date)}afterStart(){this.emit("plugin.afterStart",new Date)}beforeStop(){this.emit("plugin.beforeStop",new Date)}afterStop(){this.emit("plugin.afterStop",new Date)}}const _p={setup(e){},start(){},stop(){}},bp={async setup(e){this.client=e.client,this.map={PutObjectCommand:"put",GetObjectCommand:"get",HeadObjectCommand:"get",DeleteObjectCommand:"delete",DeleteObjectsCommand:"delete",ListObjectsV2Command:"list"},this.costs={total:0,prices:{put:.005/1e3,copy:.005/1e3,list:.005/1e3,post:.005/1e3,get:4e-4/1e3,select:4e-4/1e3,delete:4e-4/1e3},requests:{total:0,put:0,post:0,copy:0,list:0,get:0,select:0,delete:0},events:{total:0,PutObjectCommand:0,GetObjectCommand:0,HeadObjectCommand:0,DeleteObjectCommand:0,DeleteObjectsCommand:0,ListObjectsV2Command:0}},this.client.costs=JSON.parse(JSON.stringify(this.costs))},async start(){this.client.on("command.response",e=>this.addRequest(e,this.map[e]))},addRequest(e,t){this.costs.events[e]++,this.costs.events.total++,this.costs.requests.total++,this.costs.requests[t]++,this.costs.total+=this.costs.prices[t],this.client.costs.events[e]++,this.client.costs.events.total++,this.client.costs.requests.total++,this.client.costs.requests[t]++,this.client.costs.total+=this.client.costs.prices[t]}};class mp extends Tf{constructor(t={}){super(),this.driver=t.driver}async setup(t){this.database=t,this.driver||(this.driver=new Of({keyPrefix:"cache",client:t.client})),this.installDatabaseProxy();for(const r of Object.values(t.resources))this.installResourcesProxies(r)}async start(){}async stop(){}installDatabaseProxy(){const t=this.installResourcesProxies.bind(this);this.database._createResource=this.database.createResource,this.database.createResource=async function(...r){const n=await this._createResource(...r);return t(n),n}}installResourcesProxies(t){t.cache=this.driver;let r=`resource=${t.name}`;this.driver.keyPrefix&&(this.driver.keyPrefix=me(this.driver.keyPrefix,r)),t.cacheKeyFor=async function({params:n={},action:i="list"}){let a=Object.keys(n).sort().map(o=>`${o}:${n[o]}`).join("|")||"empty";return a=await na(a),a=me(r,`action=${i}`,`${a}.json.gz`),a},t._count=t.count,t._listIds=t.listIds,t._getMany=t.getMany,t._getAll=t.getAll,t._page=t.page,t.count=async function(){const n=await this.cacheKeyFor({action:"count"});try{const a=await this.cache.get(n);if(a)return a}catch(a){if(a.name!=="NoSuchKey")throw a}const i=await t._count();return await this.cache.set(n,i),i},t.listIds=async function(){const n=await this.cacheKeyFor({action:"listIds"});try{const a=await this.cache.get(n);if(a)return a}catch(a){if(a.name!=="NoSuchKey")throw a}const i=await t._listIds();return await this.cache.set(n,i),i},t.getMany=async function(n){const i=await this.cacheKeyFor({action:"getMany",params:{ids:n}});try{const o=await this.cache.get(i);if(o)return o}catch(o){if(o.name!=="NoSuchKey")throw o}const a=await t._getMany(n);return await this.cache.set(i,a),a},t.getAll=async function(){const n=await this.cacheKeyFor({action:"getAll"});try{const a=await this.cache.get(n);if(a)return a}catch(a){if(a.name!=="NoSuchKey")throw a}const i=await t._getAll();return await this.cache.set(n,i),i},t.page=async function({offset:n,size:i}){const a=await this.cacheKeyFor({action:"page",params:{offset:n,size:i}});try{const s=await this.cache.get(a);if(s)return s}catch(s){if(s.name!=="NoSuchKey")throw s}const o=await t._page({offset:n,size:i});return await this.cache.set(a,o),o},t._insert=t.insert,t._update=t.update,t._delete=t.delete,t._deleteMany=t.deleteMany,t.insert=async function(...n){const i=await t._insert(...n);return await this.cache.clear(r),i},t.update=async function(...n){const i=await t._update(...n);return await this.cache.clear(r),i},t.delete=async function(...n){const i=await t._delete(...n);return await this.cache.clear(r),i},t.deleteMany=async function(...n){const i=await t._deleteMany(...n);return await this.cache.clear(r),i}}}exports.BaseError=ht,exports.Cache=li,exports.CachePlugin=mp,exports.Client=ra,exports.ConnectionString=ta,exports.CostsPlugin=bp,exports.Database=ss,exports.ErrorMap=Xi,exports.InvalidResourceItem=rr,exports.MemoryCache=dh,exports.MissingMetadata=Yi,exports.NoSuchBucket=Vi,exports.NoSuchKey=$r,exports.NotFound=Gi,exports.Plugin=Tf,exports.PluginObject=_p,exports.ResourceIdsPageReader=es,exports.ResourceIdsReader=Qo,exports.ResourceReader=ts,exports.ResourceWriter=rs,exports.S3Cache=Of,exports.S3_DEFAULT_ENDPOINT=ea,exports.S3_DEFAULT_REGION=Qi,exports.S3db=hh,exports.UnknownError=Ji,exports.Validator=fo,exports.ValidatorManager=co,exports.decrypt=ia,exports.encrypt=Ur,exports.sha256=na,exports.streamToString=gt;
|
|
29
|
+
`)+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function hu(e){return Array.isArray(e)}function Lo(e){return typeof e=="boolean"}function Gn(e){return e===null}function du(e){return typeof e=="number"}function Yn(e){return typeof e=="string"}function je(e){return e===void 0}function Jn(e){return It(e)&&ei(e)==="[object RegExp]"}function It(e){return typeof e=="object"&&e!==null}function $o(e){return It(e)&&ei(e)==="[object Date]"}function Xn(e){return It(e)&&(ei(e)==="[object Error]"||e instanceof Error)}function Qn(e){return typeof e=="function"}function ei(e){return Object.prototype.toString.call(e)}function pu(e,t){if(!t||!It(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Bo(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ge(){this.head=null,this.tail=null,this.length=0}Ge.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},Ge.prototype.unshift=function(e){var t={data:e,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length},Ge.prototype.shift=function(){if(this.length!==0){var e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},Ge.prototype.clear=function(){this.head=this.tail=null,this.length=0},Ge.prototype.join=function(e){if(this.length===0)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},Ge.prototype.concat=function(e){if(this.length===0)return y.alloc(0);if(this.length===1)return this.head.data;for(var t=y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var yu=y.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function gu(e){if(e&&!yu(e))throw new Error("Unknown encoding: "+e)}function Tt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),gu(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=wu;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=_u;break;default:this.write=vu;return}this.charBuffer=new y(6),this.charReceived=0,this.charLength=0}Tt.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";e=e.slice(r,e.length),t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var i=t.charCodeAt(t.length-1);if(i>=55296&&i<=56319){this.charLength+=this.surrogateSize,t="";continue}if(this.charReceived=this.charLength=0,e.length===0)return t;break}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived),t+=e.toString(this.encoding,0,n);var n=t.length-1,i=t.charCodeAt(n);if(i>=55296&&i<=56319){var a=this.surrogateSize;return this.charLength+=a,this.charReceived+=a,this.charBuffer.copy(this.charBuffer,a,0,a),e.copy(this.charBuffer,0,0,a),t.substring(0,n)}return t},Tt.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(t==1&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},Tt.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t};function vu(e){return e.toString(this.encoding)}function wu(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function _u(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}L.ReadableState=Uo;var D=au("stream");W(L,R);function bu(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function mu(e,t){return e.listeners(t).length}function Uo(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof oe&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16*1024;this.highWaterMark=r||r===0?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new Ge,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new Tt(e.encoding),this.encoding=e.encoding)}function L(e){if(!(this instanceof L))return new L(e);this._readableState=new Uo(e,this),this.readable=!0,e&&typeof e.read=="function"&&(this._read=e.read),R.call(this)}L.prototype.push=function(e,t){var r=this._readableState;return!r.objectMode&&typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=y.from(e,t),t="")),zo(this,r,e,t,!1)},L.prototype.unshift=function(e){var t=this._readableState;return zo(this,t,e,"",!0)},L.prototype.isPaused=function(){return this._readableState.flowing===!1};function zo(e,t,r,n,i){var a=Su(t,r);if(a)e.emit("error",a);else if(r===null)t.reading=!1,Au(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var o=new Error("stream.push() after EOF");e.emit("error",o)}else if(t.endEmitted&&i){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{var f;t.decoder&&!i&&!n&&(r=t.decoder.write(r),f=!t.objectMode&&r.length===0),i||(t.reading=!1),f||(t.flowing&&t.length===0&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&vr(e))),ku(e,t)}else i||(t.reading=!1);return Eu(t)}function Eu(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}L.prototype.setEncoding=function(e){return this._readableState.decoder=new Tt(e),this._readableState.encoding=e,this};var Zo=8388608;function xu(e){return e>=Zo?e=Zo:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function qo(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=xu(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}L.prototype.read=function(e){D("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return D("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?ri(this):vr(this),null;if(e=qo(e,t),e===0&&t.ended)return t.length===0&&ri(this),null;var n=t.needReadable;D("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,D("length less than watermark",n)),t.ended||t.reading?(n=!1,D("reading or ended",n)):n&&(D("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=qo(r,t)));var i;return e>0?i=Ko(e,t):i=null,i===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&ri(this)),i!==null&&this.emit("data",i),i};function Su(e,t){var r=null;return!y.isBuffer(t)&&typeof t!="string"&&t!==null&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function Au(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,vr(e)}}function vr(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(D("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?re(Ho,e):Ho(e))}function Ho(e){D("emit readable"),e.emit("readable"),ti(e)}function ku(e,t){t.readingMore||(t.readingMore=!0,re(Ru,e,t))}function Ru(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(D("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}L.prototype._read=function(e){this.emit("error",new Error("not implemented"))},L.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,D("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||t.end!==!1,a=i?s:l;n.endEmitted?re(a):r.once("end",a),e.on("unpipe",o);function o(_){D("onunpipe"),_===r&&l()}function s(){D("onend"),e.end()}var f=Ou(r);e.on("drain",f);var c=!1;function l(){D("cleanup"),e.removeListener("close",p),e.removeListener("finish",g),e.removeListener("drain",f),e.removeListener("error",u),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",l),r.removeListener("data",h),c=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&f()}var d=!1;r.on("data",h);function h(_){D("ondata"),d=!1;var m=e.write(_);m===!1&&!d&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&Vo(n.pipes,e)!==-1)&&!c&&(D("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,d=!0),r.pause())}function u(_){D("onerror",_),w(),e.removeListener("error",u),mu(e,"error")===0&&e.emit("error",_)}bu(e,"error",u);function p(){e.removeListener("finish",g),w()}e.once("close",p);function g(){D("onfinish"),e.removeListener("close",p),w()}e.once("finish",g);function w(){D("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(D("pipe resume"),r.resume()),e};function Ou(e){return function(){var t=e._readableState;D("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&e.listeners("data").length&&(t.flowing=!0,ti(e))}}L.prototype.unpipe=function(e){var t=this._readableState;if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<n;i++)r[i].emit("unpipe",this);return this}var a=Vo(t.pipes,e);return a===-1?this:(t.pipes.splice(a,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},L.prototype.on=function(e,t){var r=R.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var n=this._readableState;!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&vr(this):re(Pu,this))}return r},L.prototype.addListener=L.prototype.on;function Pu(e){D("readable nexttick read 0"),e.read(0)}L.prototype.resume=function(){var e=this._readableState;return e.flowing||(D("resume"),e.flowing=!0,Iu(this,e)),this};function Iu(e,t){t.resumeScheduled||(t.resumeScheduled=!0,re(Tu,e,t))}function Tu(e,t){t.reading||(D("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),ti(e),t.flowing&&!t.reading&&e.read(0)}L.prototype.pause=function(){return D("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(D("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function ti(e){var t=e._readableState;for(D("flow",t.flowing);t.flowing&&e.read()!==null;);}L.prototype.wrap=function(e){var t=this._readableState,r=!1,n=this;e.on("end",function(){if(D("wrapped end"),t.decoder&&!t.ended){var o=t.decoder.end();o&&o.length&&n.push(o)}n.push(null)}),e.on("data",function(o){if(D("wrapped data"),t.decoder&&(o=t.decoder.write(o)),!(t.objectMode&&o==null)&&!(!t.objectMode&&(!o||!o.length))){var s=n.push(o);s||(r=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=function(o){return function(){return e[o].apply(e,arguments)}}(i));var a=["error","close","destroy","pause","resume"];return Nu(a,function(o){e.on(o,n.emit.bind(n,o))}),n._read=function(o){D("wrapped _read",o),r&&(r=!1,e.resume())},n},L._fromList=Ko;function Ko(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.head.data:r=t.buffer.concat(t.length),t.buffer.clear()):r=Du(e,t.buffer,t.decoder),r}function Du(e,t,r){var n;return e<t.head.data.length?(n=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?n=t.shift():n=r?Cu(e,t):ju(e,t),n}function Cu(e,t){var r=t.head,n=1,i=r.data;for(e-=i.length;r=r.next;){var a=r.data,o=e>a.length?a.length:e;if(o===a.length?i+=a:i+=a.slice(0,e),e-=o,e===0){o===a.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=a.slice(o));break}++n}return t.length-=n,i}function ju(e,t){var r=y.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var a=n.data,o=e>a.length?a.length:e;if(a.copy(r,r.length-e,0,o),e-=o,e===0){o===a.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=a.slice(o));break}++i}return t.length-=i,r}function ri(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,re(Fu,t,e))}function Fu(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Nu(e,t){for(var r=0,n=e.length;r<n;r++)t(e[r],r)}function Vo(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}H.WritableState=ni,W(H,R);function Mu(){}function Lu(e,t,r){this.chunk=e,this.encoding=t,this.callback=r,this.next=null}function ni(e,t){Object.defineProperty(this,"buffer",{get:Mo(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),e=e||{},this.objectMode=!!e.objectMode,t instanceof oe&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16*1024;this.highWaterMark=r||r===0?r:n,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var i=e.decodeStrings===!1;this.decodeStrings=!i,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){Hu(t,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Qo(this)}ni.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};function H(e){if(!(this instanceof H)&&!(this instanceof oe))return new H(e);this._writableState=new ni(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev)),R.call(this)}H.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function $u(e,t){var r=new Error("write after end");e.emit("error",r),re(t,r)}function Bu(e,t,r,n){var i=!0,a=!1;return r===null?a=new TypeError("May not write null values to stream"):!y.isBuffer(r)&&typeof r!="string"&&r!==void 0&&!t.objectMode&&(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),re(n,a),i=!1),i}H.prototype.write=function(e,t,r){var n=this._writableState,i=!1;return typeof t=="function"&&(r=t,t=null),y.isBuffer(e)?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=Mu),n.ended?$u(this,r):Bu(this,n,e,r)&&(n.pendingcb++,i=zu(this,n,e,t,r)),i},H.prototype.cork=function(){var e=this._writableState;e.corked++},H.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.bufferedRequest&&Go(this,e))},H.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function Uu(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=y.from(t,r)),t}function zu(e,t,r,n,i){r=Uu(t,r,n),y.isBuffer(r)&&(n="buffer");var a=t.objectMode?1:r.length;t.length+=a;var o=t.length<t.highWaterMark;if(o||(t.needDrain=!0),t.writing||t.corked){var s=t.lastBufferedRequest;t.lastBufferedRequest=new Lu(r,n,i),s?s.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else ii(e,t,!1,a,r,n,i);return o}function ii(e,t,r,n,i,a,o){t.writelen=n,t.writecb=o,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,a,t.onwrite),t.sync=!1}function Zu(e,t,r,n,i){--t.pendingcb,r?re(i,n):i(n),e._writableState.errorEmitted=!0,e.emit("error",n)}function qu(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function Hu(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(qu(r),t)Zu(e,r,n,t,i);else{var a=Yo(r);!a&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&Go(e,r),n?re(Wo,e,r,a,i):Wo(e,r,a,i)}}function Wo(e,t,r,n){r||Ku(e,t),t.pendingcb--,n(),Xo(e,t)}function Ku(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function Go(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),a=t.corkedRequestsFree;a.entry=r;for(var o=0;r;)i[o]=r,r=r.next,o+=1;ii(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new Qo(t)}else{for(;r;){var s=r.chunk,f=r.encoding,c=r.callback,l=t.objectMode?1:s.length;if(ii(e,t,!1,l,s,f,c),r=r.next,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=r,t.bufferProcessing=!1}H.prototype._write=function(e,t,r){r(new Error("not implemented"))},H.prototype._writev=null,H.prototype.end=function(e,t,r){var n=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),!n.ending&&!n.finished&&Vu(this,n,r)};function Yo(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function Jo(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function Xo(e,t){var r=Yo(t);return r&&(t.pendingcb===0?(Jo(e,t),t.finished=!0,e.emit("finish")):Jo(e,t)),r}function Vu(e,t,r){t.ending=!0,Xo(e,t),r&&(t.finished?re(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function Qo(e){var t=this;this.next=null,this.entry=null,this.finish=function(r){var n=t.entry;for(t.entry=null;n;){var i=n.callback;e.pendingcb--,i(r),n=n.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}W(oe,L);for(var es=Object.keys(H.prototype),ai=0;ai<es.length;ai++){var oi=es[ai];oe.prototype[oi]||(oe.prototype[oi]=H.prototype[oi])}function oe(e){if(!(this instanceof oe))return new oe(e);L.call(this,e),H.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",Wu)}function Wu(){this.allowHalfOpen||this._writableState.ended||re(Gu,this)}function Gu(e){e.end()}W(ne,oe);function Yu(e){this.afterTransform=function(t,r){return Ju(e,t,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function Ju(e,t,r){var n=e._transformState;n.transforming=!1;var i=n.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));n.writechunk=null,n.writecb=null,r!=null&&e.push(r),i(t);var a=e._readableState;a.reading=!1,(a.needReadable||a.length<a.highWaterMark)&&e._read(a.highWaterMark)}function ne(e){if(!(this instanceof ne))return new ne(e);oe.call(this,e),this._transformState=new Yu(this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.once("prefinish",function(){typeof this._flush=="function"?this._flush(function(r){ts(t,r)}):ts(t)})}ne.prototype.push=function(e,t){return this._transformState.needTransform=!1,oe.prototype.push.call(this,e,t)},ne.prototype._transform=function(e,t,r){throw new Error("Not implemented")},ne.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},ne.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};function ts(e,t){if(t)return e.emit("error",t);var r=e._writableState,n=e._transformState;if(r.length)throw new Error("Calling transform done when ws.length != 0");if(n.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}W(Dt,ne);function Dt(e){if(!(this instanceof Dt))return new Dt(e);ne.call(this,e)}Dt.prototype._transform=function(e,t,r){r(null,e)},W(ke,R),ke.Readable=L,ke.Writable=H,ke.Duplex=oe,ke.Transform=ne,ke.PassThrough=Dt,ke.Stream=ke;function ke(){R.call(this)}ke.prototype.pipe=function(e,t){var r=this;function n(l){e.writable&&e.write(l)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}e.on("drain",i),!e._isStdio&&(!t||t.end!==!1)&&(r.on("end",o),r.on("close",s));var a=!1;function o(){a||(a=!0,e.end())}function s(){a||(a=!0,typeof e.destroy=="function"&&e.destroy())}function f(l){if(c(),R.listenerCount(this,"error")===0)throw l}r.on("error",f),e.on("error",f);function c(){r.removeListener("data",n),e.removeListener("drain",i),r.removeListener("end",o),r.removeListener("close",s),r.removeListener("error",f),e.removeListener("error",f),r.removeListener("end",c),r.removeListener("close",c),e.removeListener("close",c)}return r.on("end",c),r.on("close",c),e.on("close",c),e.emit("pipe",r),e};class rs extends R{constructor({resource:t}){super(),this.resource=t,this.client=t.client,this.stream=new Kc.ReadableStream({highWaterMark:this.client.parallelism*3,start:this._start.bind(this),pull:this._pull.bind(this),cancel:this._cancel.bind(this)})}build(){return this.stream.getReader()}async _start(t){this.controller=t,this.continuationToken=null,this.closeNextIteration=!1}async _pull(t){if(this.closeNextIteration){t.close();return}const r=await this.client.listObjects({prefix:`resource=${this.resource.name}`,continuationToken:this.continuationToken}),n=r?.Contents.map(i=>i.Key).map(i=>i.replace(this.client.config.keyPrefix,"")).map(i=>i.startsWith("/")?i.replace("/",""):i).map(i=>i.replace(`resource=${this.resource.name}/id=`,""));this.continuationToken=r.NextContinuationToken,this.enqueue(n),r.IsTruncated||(this.closeNextIteration=!0)}enqueue(t){t.forEach(r=>{this.controller.enqueue(r),this.emit("id",r)})}_cancel(t){console.warn("Stream cancelled",t)}}class ns extends rs{enqueue(t){this.controller.enqueue(t),this.emit("page",t)}}class is extends R{constructor({resource:t,batchSize:r=10,concurrency:n=5}){if(super(),!t)throw new Error("Resource is required for ResourceReader");this.resource=t,this.client=t.client,this.batchSize=r,this.concurrency=n,this.input=new ns({resource:this.resource}),this.transform=new ne({objectMode:!0,transform:this._transform.bind(this)}),this.input.on("data",i=>{this.transform.write(i)}),this.input.on("end",()=>{this.transform.end()}),this.input.on("error",i=>{this.emit("error",i)}),this.transform.on("data",i=>{this.emit("data",i)}),this.transform.on("end",()=>{this.emit("end")}),this.transform.on("error",i=>{this.emit("error",i)})}build(){return this}async _transform(t,r,n){try{await de.PromisePool.for(t).withConcurrency(this.concurrency).handleError(async(i,a)=>{this.emit("error",i,a)}).process(async i=>{const a=await this.resource.get(i);return this.push(a),a}),n()}catch(i){n(i)}}resume(){this.input.resume()}}class as extends R{constructor({resource:t,batchSize:r=10,concurrency:n=5}){super(),this.resource=t,this.client=t.client,this.batchSize=r,this.concurrency=n,this.buffer=[],this.writing=!1,this.writable=new H({objectMode:!0,write:this._write.bind(this)}),this.writable.on("finish",()=>{this.emit("finish")}),this.writable.on("error",i=>{this.emit("error",i)})}build(){return this}write(t){return this.buffer.push(t),this._maybeWrite().catch(r=>{this.emit("error",r)}),!0}end(){this.ended=!0,this._maybeWrite().catch(t=>{this.emit("error",t)})}async _maybeWrite(){if(!this.writing&&!(this.buffer.length===0&&!this.ended)){for(this.writing=!0;this.buffer.length>0;){const t=this.buffer.splice(0,this.batchSize);try{await de.PromisePool.for(t).withConcurrency(this.concurrency).handleError(async(r,n)=>{this.emit("error",r,n)}).process(async r=>{await this.resource.insert(r)})}catch(r){this.emit("error",r)}}this.writing=!1,this.ended&&this.writable.emit("finish")}}async _write(t,r,n){n()}}function gt(e){return new Promise((t,r)=>{const n=[];e.on("data",i=>n.push(i)),e.on("error",r),e.on("end",()=>t(Buffer.concat(n).toString("utf-8")))})}function vt(e){typeof e!="string"&&(e=String(e));let t=0;for(let r=0;r<e.length;r++){const n=e.codePointAt(r);n<=127?t+=1:n<=2047?t+=2:n<=65535?t+=3:n<=1114111&&(t+=4,n>65535&&r++)}return t}function Xu(e){let t=0;for(const r of Object.keys(e))r!=="_v"&&(t+=vt(r));return t}function os(e){return e==null?"":typeof e=="boolean"?e?"1":"0":typeof e=="number"?String(e):typeof e=="string"?e:Array.isArray(e)?e.length===0?"[]":e.map(t=>String(t)).join("|"):typeof e=="object"?JSON.stringify(e):String(e)}function si(e){const t={};for(const[r,n]of Object.entries(e)){const i=os(n),a=vt(i);t[r]=a}return t}function Ye(e){const t=si(e),r=Object.values(t).reduce((i,a)=>i+a,0),n=Xu(e);return r+n}const B=2048;async function Qu({resource:e,data:t,mappedData:r}){const n=Ye(r);if(n>B)throw new Error(`S3 metadata size exceeds 2KB limit. Current size: ${n} bytes, limit: ${B} bytes`);return{mappedData:r,body:""}}async function eh({resource:e,id:t,data:r,mappedData:n}){const i=Ye(n);if(i>B)throw new Error(`S3 metadata size exceeds 2KB limit. Current size: ${i} bytes, limit: ${B} bytes`);return{mappedData:n,body:""}}async function th({resource:e,id:t,data:r,mappedData:n}){const i=Ye(n);if(i>B)throw new Error(`S3 metadata size exceeds 2KB limit. Current size: ${i} bytes, limit: ${B} bytes`);return{mappedData:n,body:""}}async function rh({resource:e,metadata:t,body:r}){return{metadata:t,body:r}}var nh=Object.freeze({__proto__:null,S3_METADATA_LIMIT_BYTES:B,handleGet:rh,handleInsert:Qu,handleUpdate:eh,handleUpsert:th});async function ih({resource:e,data:t,mappedData:r}){const n=Ye(r);return n>B&&e.emit("exceedsLimit",{operation:"insert",totalSize:n,limit:B,excess:n-B,data:t}),{mappedData:r,body:""}}async function ah({resource:e,id:t,data:r,mappedData:n}){const i=Ye(n);return i>B&&e.emit("exceedsLimit",{operation:"update",id:t,totalSize:i,limit:B,excess:i-B,data:r}),{mappedData:n,body:""}}async function oh({resource:e,id:t,data:r,mappedData:n}){const i=Ye(n);return i>B&&e.emit("exceedsLimit",{operation:"upsert",id:t,totalSize:i,limit:B,excess:i-B,data:r}),{mappedData:n,body:""}}async function sh({resource:e,metadata:t,body:r}){return{metadata:t,body:r}}var ch=Object.freeze({__proto__:null,handleGet:sh,handleInsert:ih,handleUpdate:ah,handleUpsert:oh});const ss="...",cs=vt(ss);async function fh({resource:e,data:t,mappedData:r}){return ci({resource:e,data:t,mappedData:r})}async function lh({resource:e,id:t,data:r,mappedData:n}){return ci({resource:e,data:r,mappedData:n})}async function uh({resource:e,id:t,data:r,mappedData:n}){return ci({resource:e,data:r,mappedData:n})}async function hh({resource:e,metadata:t,body:r}){return{metadata:t,body:r}}function ci({resource:e,data:t,mappedData:r}){const n=si(r),i=Object.entries(n).sort(([,s],[,f])=>s-f),a={};let o=0;for(const[s,f]of i){const c=B-o;if(f<=c)a[s]=r[s],o+=f;else if(c>cs){const l=c-cs,d=os(r[s]);let h="",u=0;for(let p=0;p<d.length;p++){const g=d[p],w=vt(g);if(u+w<=l)h+=g,u+=w;else break}a[s]=h+ss,o=B;break}else break}return{mappedData:a,body:""}}var dh=Object.freeze({__proto__:null,handleGet:hh,handleInsert:fh,handleUpdate:lh,handleUpsert:uh});const wr="$overflow",fi="true",ph=vt(wr)+vt(fi);async function yh({resource:e,data:t,mappedData:r}){return li({resource:e,data:t,mappedData:r})}async function gh({resource:e,id:t,data:r,mappedData:n}){return li({resource:e,data:r,mappedData:n})}async function vh({resource:e,id:t,data:r,mappedData:n}){return li({resource:e,data:r,mappedData:n})}async function wh({resource:e,metadata:t,body:r}){if(t[wr]===fi)try{const n=r?JSON.parse(r):{},i={...t};return delete i[wr],{metadata:{...i,...n},body:""}}catch{return{metadata:t,body:r}}return{metadata:t,body:r}}function li({resource:e,data:t,mappedData:r}){if(Ye(r)<=B)return{mappedData:r,body:""};const i=B-ph,a=si(r),o=Object.entries(a).sort(([,d],[,h])=>d-h),s={},f={};let c=0;for(const[d,h]of o)c+h<=i?(s[d]=r[d],c+=h):f[d]=r[d];s[wr]=fi;const l=Object.keys(f).length>0?JSON.stringify(f):"";return{mappedData:s,body:l}}var _h=Object.freeze({__proto__:null,handleGet:wh,handleInsert:yh,handleUpdate:gh,handleUpsert:vh});const fs={"user-management":ch,"enforce-limits":nh,"data-truncate":dh,"body-overflow":_h};function Je(e){const t=fs[e];if(!t)throw new Error(`Unknown behavior: ${e}. Available behaviors: ${Object.keys(fs).join(", ")}`);return t}const bh="user-management";class ui extends R{constructor(t){super();const r=mh(t);if(!r.isValid)throw new Error(`Invalid Resource configuration:
|
|
30
|
+
${r.errors.join(`
|
|
31
|
+
`)}`);const{name:n,client:i,version:a="1",attributes:o={},behavior:s=bh,passphrase:f="secret",parallelism:c=10,observers:l=[],cache:d=!1,autoDecrypt:h=!0,timestamps:u=!1,partitions:p={},paranoid:g=!0,allNestedObjectsOptional:w=!0,hooks:_={},options:m={}}=t,x={cache:typeof m.cache=="boolean"?m.cache:d,autoDecrypt:typeof m.autoDecrypt=="boolean"?m.autoDecrypt:h,timestamps:typeof m.timestamps=="boolean"?m.timestamps:u,paranoid:typeof m.paranoid=="boolean"?m.paranoid:g,allNestedObjectsOptional:typeof m.allNestedObjectsOptional=="boolean"?m.allNestedObjectsOptional:w,partitions:m.partitions||p||{}};if(this.name=n,this.client=i,this.version=a,this.behavior=s,this.observers=l,this.parallelism=c,this.passphrase=f??"secret",this.config={cache:x.cache,hooks:_,paranoid:x.paranoid,timestamps:x.timestamps,partitions:x.partitions,autoDecrypt:x.autoDecrypt,allNestedObjectsOptional:x.allNestedObjectsOptional},this.hooks={preInsert:[],afterInsert:[],preUpdate:[],afterUpdate:[],preDelete:[],afterDelete:[]},this.attributes=o||{},this.config.timestamps&&(this.attributes.createdAt="string|optional",this.attributes.updatedAt="string|optional",this.config.partitions||(this.config.partitions={}),this.config.partitions.byCreatedDate||(this.config.partitions.byCreatedDate={fields:{createdAt:"date|maxlength:10"}}),this.config.partitions.byUpdatedDate||(this.config.partitions.byUpdatedDate={fields:{updatedAt:"date|maxlength:10"}})),this.schema=new be({name:n,attributes:this.attributes,passphrase:f,version:this.version,options:{autoDecrypt:this.config.autoDecrypt,allNestedObjectsOptional:this.config.allNestedObjectsOptional}}),this.setupPartitionHooks(),this.validatePartitions(),_){for(const[v,A]of Object.entries(_))if(Array.isArray(A)&&this.hooks[v])for(const O of A)typeof O=="function"&&this.hooks[v].push(O.bind(this))}}get options(){return{timestamps:this.config.timestamps,partitions:this.config.partitions||{},cache:this.config.cache,autoDecrypt:this.config.autoDecrypt,paranoid:this.config.paranoid,allNestedObjectsOptional:this.config.allNestedObjectsOptional}}export(){const t=this.schema.export();return t.behavior=this.behavior,t.timestamps=this.config.timestamps,t.partitions=this.config.partitions||{},t.paranoid=this.config.paranoid,t.allNestedObjectsOptional=this.config.allNestedObjectsOptional,t.autoDecrypt=this.config.autoDecrypt,t.cache=this.config.cache,t.hooks=this.hooks,t}updateAttributes(t){const r=this.attributes;return this.attributes=t,this.config.timestamps&&(t.createdAt="string|optional",t.updatedAt="string|optional",this.config.partitions||(this.config.partitions={}),this.config.partitions.byCreatedDate||(this.config.partitions.byCreatedDate={fields:{createdAt:"date|maxlength:10"}}),this.config.partitions.byUpdatedDate||(this.config.partitions.byUpdatedDate={fields:{updatedAt:"date|maxlength:10"}})),this.schema=new be({name:this.name,attributes:t,passphrase:this.passphrase,version:this.version,options:{autoDecrypt:this.config.autoDecrypt,allNestedObjectsOptional:this.config.allNestedObjectsOptional}}),this.setupPartitionHooks(),this.validatePartitions(),{oldAttributes:r,newAttributes:t}}addHook(t,r){this.hooks[t]&&this.hooks[t].push(r.bind(this))}async executeHooks(t,r){if(!this.hooks[t])return r;let n=r;for(const i of this.hooks[t])n=await i(n);return n}setupPartitionHooks(){if(!this.config.partitions)return;const t=this.config.partitions;Object.keys(t).length!==0&&(this.hooks.afterInsert||(this.hooks.afterInsert=[]),this.hooks.afterInsert.push(async r=>(await this.createPartitionReferences(r),r)),this.hooks.afterDelete||(this.hooks.afterDelete=[]),this.hooks.afterDelete.push(async r=>(await this.deletePartitionReferences(r),r)))}async validate(t){const r={original:M.cloneDeep(t),isValid:!1,errors:[]},n=await this.schema.validate(t,{mutateOriginal:!0});return n===!0?r.isValid=!0:r.errors=n,r.data=t,r}validatePartitions(){if(!this.config.partitions)return;const t=this.config.partitions;if(Object.keys(t).length===0)return;const r=Object.keys(this.attributes||{});for(const[n,i]of Object.entries(t))if(i.fields){for(const a of Object.keys(i.fields))if(!this.fieldExistsInAttributes(a))throw new Error(`Partition '${n}' uses field '${a}' which does not exist in resource version '${this.version}'. Available fields: ${r.join(", ")}. This version of resource does not have support for this partition.`)}}fieldExistsInAttributes(t){if(!t.includes("."))return Object.keys(this.attributes||{}).includes(t);const r=t.split(".");let n=this.attributes||{};for(const i of r){if(!n||typeof n!="object"||!(i in n))return!1;n=n[i]}return!0}applyPartitionRule(t,r){if(t==null)return t;let n=t;if(typeof r=="string"&&r.includes("maxlength:")){const i=r.match(/maxlength:(\d+)/);if(i){const a=parseInt(i[1]);typeof n=="string"&&n.length>a&&(n=n.substring(0,a))}}if(r.includes("date")){if(n instanceof Date)n=n.toISOString().split("T")[0];else if(typeof n=="string")try{if(n.includes("T")&&n.includes("Z"))n=n.split("T")[0];else{const i=new Date(n);isNaN(i.getTime())||(n=i.toISOString().split("T")[0])}}catch{}}return n}getResourceKey(t){return Ee(`resource=${this.name}`,`v=${this.version}`,`id=${t}`)}getPartitionKey({partitionName:t,id:r,data:n}){if(!this.config.partitions||!this.config.partitions[t])throw new Error(`Partition '${t}' not found`);const i=this.config.partitions[t],a=[],o=Object.entries(i.fields).sort(([s],[f])=>s.localeCompare(f));for(const[s,f]of o){const c=this.getNestedFieldValue(n,s),l=this.applyPartitionRule(c,f);if(l==null)return null;a.push(`${s}=${l}`)}return a.length===0?null:Ee(`resource=${this.name}`,`partition=${t}`,...a,`id=${r}`)}getNestedFieldValue(t,r){if(!r.includes("."))return t[r];const n=r.split(".");let i=t;for(const a of n){if(!i||typeof i!="object"||!(a in i))return;i=i[a]}return i}async insert({id:t,...r}){this.options.timestamps&&(r.createdAt=new Date().toISOString(),r.updatedAt=new Date().toISOString());const n=await this.executeHooks("preInsert",r),{errors:i,isValid:a,data:o}=await this.validate(n);if(!a)throw new rr({bucket:this.client.config.bucket,resourceName:this.name,attributes:n,validation:i});!t&&t!==0&&(t=Hi());const s=await this.schema.mapper(o),f=Je(this.behavior),{mappedData:c,body:l}=await f.handleInsert({resource:this,data:o,mappedData:s}),d=this.getResourceKey(t);await this.client.putObject({metadata:c,key:d,body:l});const h=M.merge({id:t},o);return await this.executeHooks("afterInsert",h),this.emit("insert",h),h}async get(t){const r=this.getResourceKey(t);try{const n=await this.client.headObject(r),i=this.extractVersionFromKey(r)||this.version;let o=await(await this.getSchemaForVersion(i)).unmapper(n.Metadata);const s=Je(this.behavior);let f="";if(n.ContentLength>0)try{const d=await this.client.getObject(r);f=await gt(d.Body)}catch(d){console.warn(`Failed to read body for resource ${t}:`,d.message),f=""}const{metadata:c}=await s.handleGet({resource:this,metadata:o,body:f});let l=c;return l.id=t,l._contentLength=n.ContentLength,l._lastModified=n.LastModified,l._hasContent=n.ContentLength>0,l._mimeType=n.ContentType||null,n.VersionId&&(l._versionId=n.VersionId),n.Expiration&&(l._expiresAt=n.Expiration),l._definitionHash=this.getDefinitionHash(),this.emit("get",l),l}catch(n){if(n.message.includes("Cipher job failed")||n.message.includes("OperationError")||n.originalError?.message?.includes("Cipher job failed"))try{console.warn(`Decryption failed for resource ${t}, attempting to get raw metadata`);const a=await this.client.headObject(r),o=this.extractVersionFromKey(r)||this.version;let f=await new be({name:this.name,attributes:this.attributes,passphrase:this.passphrase,version:o,options:{...this.config,autoDecrypt:!1,autoEncrypt:!1}}).unmapper(a.Metadata);const c=Je(this.behavior);let l="";if(a.ContentLength>0)try{const u=await this.client.getObject(r);l=await gt(u.Body)}catch(u){console.warn(`Failed to read body for resource ${t}:`,u.message),l=""}const{metadata:d}=await c.handleGet({resource:this,metadata:f,body:l});let h=d;return h.id=t,h._contentLength=a.ContentLength,h._lastModified=a.LastModified,h._hasContent=a.ContentLength>0,h._mimeType=a.ContentType||null,h._version=o,h._decryptionFailed=!0,a.VersionId&&(h._versionId=a.VersionId),a.Expiration&&(h._expiresAt=a.Expiration),h._definitionHash=this.getDefinitionHash(),this.emit("get",h),h}catch(a){console.error(`Fallback attempt also failed for resource ${t}:`,a.message)}const i=new Error(`Failed to get resource with id '${t}': ${n.message}`);throw i.originalError=n,i.resourceId=t,i.resourceKey=r,i}}async exists(t){try{const r=this.getResourceKey(t);return await this.client.headObject(r),!0}catch{return!1}}async update(t,r){const n=await this.get(t);this.config.timestamps&&(r.updatedAt=new Date().toISOString());const i=await this.executeHooks("preUpdate",r),a=M.merge(n,i);delete a.id;const{isValid:o,errors:s,data:f}=await this.validate(a);if(!o)throw new rr({bucket:this.client.bucket,resourceName:this.name,attributes:i,validation:s});const c=await this.schema.mapper(f),l=Je(this.behavior),{mappedData:d,body:h}=await l.handleUpdate({resource:this,id:t,data:f,mappedData:c}),u=this.getResourceKey(t);let p,g=h;if(h===""&&this.behavior!=="body-overflow")try{const w=await this.client.getObject(u);if(w.ContentLength>0){const _=Buffer.from(await w.Body.transformToByteArray()),m=_.toString();try{JSON.parse(m)}catch{g=_,p=w.ContentType}}}catch{}return await this.client.putObject({key:u,body:g,contentType:p,metadata:d}),f.id=t,await this.executeHooks("afterUpdate",f),await this.updatePartitionReferences(f),this.emit("update",i,f),f}async delete(t){let r;try{r=await this.get(t)}catch{r={id:t}}await this.executeHooks("preDelete",r);const n=this.getResourceKey(t),i=await this.client.deleteObject(n);return await this.executeHooks("afterDelete",r),this.emit("delete",t),i}async upsert({id:t,...r}){return await this.exists(t)?this.update(t,r):this.insert({id:t,...r})}async count({partition:t=null,partitionValues:r={}}={}){let n;if(t&&Object.keys(r).length>0){const a=this.config.partitions[t];if(!a)throw new Error(`Partition '${t}' not found`);const o=[],s=Object.entries(a.fields).sort(([f],[c])=>f.localeCompare(c));for(const[f,c]of s){const l=r[f];if(l!=null){const d=this.applyPartitionRule(l,c);o.push(`${f}=${d}`)}}o.length>0?n=`resource=${this.name}/partition=${t}/${o.join("/")}`:n=`resource=${this.name}/partition=${t}`}else n=`resource=${this.name}/v=${this.version}`;const i=await this.client.count({prefix:n});return this.emit("count",i),i}async insertMany(t){const{results:r}=await de.PromisePool.for(t).withConcurrency(this.parallelism).handleError(async(n,i)=>{this.emit("error",n,i),this.observers.map(a=>a.emit("error",this.name,n,i))}).process(async n=>await this.insert(n));return this.emit("insertMany",t.length),r}async deleteMany(t){const r=M.chunk(t.map(i=>this.getResourceKey(i)),1e3),{results:n}=await de.PromisePool.for(r).withConcurrency(this.parallelism).handleError(async(i,a)=>{this.emit("error",i,a),this.observers.map(o=>o.emit("error",this.name,i,a))}).process(async i=>{const a=await this.client.deleteObjects(i);return i.forEach(o=>{const f=o.split("/").find(l=>l.startsWith("id=")),c=f?f.replace("id=",""):null;c&&(this.emit("deleted",c),this.observers.map(l=>l.emit("deleted",this.name,c)))}),a});return this.emit("deleteMany",t.length),n}async deleteAll(){if(this.config.paranoid!==!1)throw new Error(`deleteAll() is a dangerous operation and requires paranoid: false option. Current paranoid setting: ${this.config.paranoid}`);const t=`resource=${this.name}/v=${this.version}`,r=await this.client.deleteAll({prefix:t});return this.emit("deleteAll",{version:this.version,prefix:t,deletedCount:r}),{deletedCount:r,version:this.version}}async deleteAllData(){if(this.config.paranoid!==!1)throw new Error(`deleteAllData() is a dangerous operation and requires paranoid: false option. Current paranoid setting: ${this.config.paranoid}`);const t=`resource=${this.name}`,r=await this.client.deleteAll({prefix:t});return this.emit("deleteAllData",{resource:this.name,prefix:t,deletedCount:r}),{deletedCount:r,resource:this.name}}async listIds({partition:t=null,partitionValues:r={},limit:n,offset:i=0}={}){let a;if(t&&Object.keys(r).length>0){if(!this.config.partitions||!this.config.partitions[t])throw new Error(`Partition '${t}' not found`);const f=this.config.partitions[t],c=[],l=Object.entries(f.fields).sort(([d],[h])=>d.localeCompare(h));for(const[d,h]of l){const u=r[d];if(u!=null){const p=this.applyPartitionRule(u,h);c.push(`${d}=${p}`)}}c.length>0?a=`resource=${this.name}/partition=${t}/${c.join("/")}`:a=`resource=${this.name}/partition=${t}`}else a=`resource=${this.name}/v=${this.version}`;const s=(await this.client.getKeysPage({prefix:a,offset:i,amount:n||1e3})).map(f=>{const l=f.split("/").find(d=>d.startsWith("id="));return l?l.replace("id=",""):null}).filter(Boolean);return this.emit("listIds",s.length),s}async list({partition:t=null,partitionValues:r={},limit:n,offset:i=0}={}){if(!t){let w=(await this.listIds({partition:t,partitionValues:r})).slice(i);n&&(w=w.slice(0,n));const{results:_,errors:m}=await de.PromisePool.for(w).withConcurrency(this.parallelism).handleError(async(v,A)=>(console.warn(`Failed to get resource ${A}:`,v.message),null)).process(async v=>{try{return await this.get(v)}catch(A){if(A.message.includes("Cipher job failed")||A.message.includes("OperationError"))return console.warn(`Decryption failed for ${v}, returning basic info`),{id:v,_decryptionFailed:!0,_error:A.message};throw A}}),x=_.filter(v=>v!==null);return this.emit("list",{partition:t,partitionValues:r,count:x.length,errors:m.length}),x}if(!this.config.partitions||!this.config.partitions[t])throw new Error(`Partition '${t}' not found`);const a=this.config.partitions[t],o=[],s=Object.entries(a.fields).sort(([g],[w])=>g.localeCompare(w));for(const[g,w]of s){const _=r[g];if(_!=null){const m=this.applyPartitionRule(_,w);o.push(`${g}=${m}`)}}let f;o.length>0?f=`resource=${this.name}/partition=${t}/${o.join("/")}`:f=`resource=${this.name}/partition=${t}`;let d=(await this.client.getAllKeys({prefix:f})).map(g=>{const _=g.split("/").find(m=>m.startsWith("id="));return _?_.replace("id=",""):null}).filter(Boolean).slice(i);n&&(d=d.slice(0,n));const{results:h,errors:u}=await de.PromisePool.for(d).withConcurrency(this.parallelism).handleError(async(g,w)=>(console.warn(`Failed to get partition resource ${w}:`,g.message),null)).process(async g=>{try{return await this.getFromPartition({id:g,partitionName:t,partitionValues:r})}catch(w){if(w.message.includes("Cipher job failed")||w.message.includes("OperationError"))return console.warn(`Decryption failed for partition resource ${g}, returning basic info`),{id:g,_partition:t,_partitionValues:r,_decryptionFailed:!0,_error:w.message};throw w}}),p=h.filter(g=>g!==null);return this.emit("list",{partition:t,partitionValues:r,count:p.length,errors:u.length}),p}async getMany(t){const{results:r,errors:n}=await de.PromisePool.for(t).withConcurrency(this.client.parallelism).handleError(async(i,a)=>(console.warn(`Failed to get resource ${a}:`,i.message),{id:a,_error:i.message,_decryptionFailed:i.message.includes("Cipher job failed")||i.message.includes("OperationError")})).process(async i=>{this.emit("id",i);try{const a=await this.get(i);return this.emit("data",a),a}catch(a){if(a.message.includes("Cipher job failed")||a.message.includes("OperationError"))return console.warn(`Decryption failed for ${i}, returning basic info`),{id:i,_decryptionFailed:!0,_error:a.message};throw a}});return this.emit("getMany",t.length),r}async getAll(){let t=await this.listIds();if(t.length===0)return[];const{results:r,errors:n}=await de.PromisePool.for(t).withConcurrency(this.client.parallelism).handleError(async(i,a)=>(console.warn(`Failed to get resource ${a}:`,i.message),{id:a,_error:i.message,_decryptionFailed:i.message.includes("Cipher job failed")||i.message.includes("OperationError")})).process(async i=>{try{return await this.get(i)}catch(a){if(a.message.includes("Cipher job failed")||a.message.includes("OperationError"))return console.warn(`Decryption failed for ${i}, returning basic info`),{id:i,_decryptionFailed:!0,_error:a.message};throw a}});return this.emit("getAll",r.length),r}async page({offset:t=0,size:r=100,partition:n=null,partitionValues:i={},skipCount:a=!1}={}){let o=null,s=null;a||(o=await this.count({partition:n,partitionValues:i}),s=Math.ceil(o/r));const f=Math.floor(t/r),c=await this.list({partition:n,partitionValues:i,limit:r,offset:t}),l={items:c,totalItems:o,page:f,pageSize:r,totalPages:s,_debug:{requestedSize:r,requestedOffset:t,actualItemsReturned:c.length,skipCount:a,hasTotalItems:o!==null}};return this.emit("page",l),l}readable(){return new is({resource:this}).build()}writable(){return new as({resource:this}).build()}async setContent({id:t,buffer:r,contentType:n="application/octet-stream"}){const i=await this.get(t);if(!i)throw new Error(`Resource with id '${t}' not found`);const a={...i,_hasContent:!0,_contentLength:r.length,_mimeType:n};return await this.client.putObject({key:this.getResourceKey(t),metadata:await this.schema.mapper(a),body:r,contentType:n}),this.emit("setContent",{id:t,contentType:n,contentLength:r.length}),a}async content(t){const r=this.getResourceKey(t);try{const n=await this.client.getObject(r),i=Buffer.from(await n.Body.transformToByteArray()),a=n.ContentType||null;return this.emit("content",t,i.length,a),{buffer:i,contentType:a}}catch(n){if(n.name==="NoSuchKey")return{buffer:null,contentType:null};throw n}}async hasContent(t){const r=this.getResourceKey(t);try{return(await this.client.headObject(r)).ContentLength>0}catch{return!1}}async deleteContent(t){const r=this.getResourceKey(t),i=(await this.client.headObject(r)).Metadata||{},a=await this.client.putObject({key:r,body:"",metadata:i});return this.emit("deleteContent",t),a}getDefinitionHash(){const t={attributes:this.attributes,behavior:this.behavior},r=lo(t);return`sha256:${Ui.createHash("sha256").update(r).digest("hex")}`}extractVersionFromKey(t){const n=t.split("/").find(i=>i.startsWith("v="));return n?n.replace("v=",""):null}async getSchemaForVersion(t){if(t===this.version)return this.schema;try{return new be({name:this.name,attributes:this.attributes,passphrase:this.passphrase,version:t,options:{...this.config,autoDecrypt:!0,autoEncrypt:!0}})}catch(r){return console.warn(`Failed to create compatible schema for version ${t}, using current schema:`,r.message),this.schema}}async createPartitionReferences(t){const r=this.config.partitions;if(!(!r||Object.keys(r).length===0))for(const[n,i]of Object.entries(r)){const a=this.getPartitionKey({partitionName:n,id:t.id,data:t});if(a){const o=await this.schema.mapper(t),s=Je(this.behavior),{mappedData:f,body:c}=await s.handleInsert({resource:this,data:t,mappedData:o}),l={...f,_version:this.version};await this.client.putObject({key:a,metadata:l,body:c})}}}async deletePartitionReferences(t){const r=this.config.partitions;if(!r||Object.keys(r).length===0)return;const n=[];for(const[i,a]of Object.entries(r)){const o=this.getPartitionKey({partitionName:i,id:t.id,data:t});o&&n.push(o)}if(n.length>0)try{await this.client.deleteObjects(n)}catch(i){console.warn("Some partition objects could not be deleted:",i.message)}}async query(t={},{limit:r=100,offset:n=0,partition:i=null,partitionValues:a={}}={}){if(Object.keys(t).length===0)return await this.list({partition:i,partitionValues:a,limit:r,offset:n});const o=[];let s=n;const f=Math.min(r,50);for(;o.length<r;){const c=await this.list({partition:i,partitionValues:a,limit:f,offset:s});if(c.length===0)break;const l=c.filter(d=>Object.entries(t).every(([h,u])=>d[h]===u));if(o.push(...l),s+=f,c.length<f)break}return o.slice(0,r)}async updatePartitionReferences(t){const r=this.config.partitions;if(!(!r||Object.keys(r).length===0))for(const[n,i]of Object.entries(r)){const a=this.getPartitionKey({partitionName:n,id:t.id,data:t});if(a){const o=await this.schema.mapper(t),s=Je(this.behavior),{mappedData:f,body:c}=await s.handleUpdate({resource:this,id:t.id,data:t,mappedData:o}),l={...f,_version:this.version};try{await this.client.putObject({key:a,metadata:l,body:c})}catch(d){console.warn(`Partition object could not be updated for ${n}:`,d.message)}}}}async getFromPartition({id:t,partitionName:r,partitionValues:n={}}){if(!this.config.partitions||!this.config.partitions[r])throw new Error(`Partition '${r}' not found`);const i=this.config.partitions[r],a=[],o=Object.entries(i.fields).sort(([w],[_])=>w.localeCompare(_));for(const[w,_]of o){const m=n[w];if(m!=null){const x=this.applyPartitionRule(m,_);a.push(`${w}=${x}`)}}if(a.length===0)throw new Error(`No partition values provided for partition '${r}'`);const s=Ee(`resource=${this.name}`,`partition=${r}`,...a,`id=${t}`),f=await this.client.headObject(s),c=f.Metadata?._version||this.version;let d=await(await this.getSchemaForVersion(c)).unmapper(f.Metadata);const h=Je(this.behavior);let u="";if(f.ContentLength>0)try{const w=await this.client.getObject(s);u=await gt(w.Body)}catch{u=""}const{metadata:p}=await h.handleGet({resource:this,metadata:d,body:u});let g=p;return g.id=t,g._contentLength=f.ContentLength,g._lastModified=f.LastModified,g._hasContent=f.ContentLength>0,g._mimeType=f.ContentType||null,g._partition=r,g._partitionValues=n,f.VersionId&&(g._versionId=f.VersionId),f.Expiration&&(g._expiresAt=f.Expiration),g._definitionHash=this.getDefinitionHash(),this.emit("getFromPartition",g),g}}function mh(e){const t=[];e.name?typeof e.name!="string"?t.push("Resource 'name' must be a string"):e.name.trim()===""&&t.push("Resource 'name' cannot be empty"):t.push("Resource 'name' is required"),e.client||t.push("S3 'client' is required"),e.attributes?typeof e.attributes!="object"||Array.isArray(e.attributes)?t.push("Resource 'attributes' must be an object"):Object.keys(e.attributes).length===0&&t.push("Resource 'attributes' cannot be empty"):t.push("Resource 'attributes' are required"),e.version!==void 0&&typeof e.version!="string"&&t.push("Resource 'version' must be a string"),e.behavior!==void 0&&typeof e.behavior!="string"&&t.push("Resource 'behavior' must be a string"),e.passphrase!==void 0&&typeof e.passphrase!="string"&&t.push("Resource 'passphrase' must be a string"),e.parallelism!==void 0&&(typeof e.parallelism!="number"||!Number.isInteger(e.parallelism)?t.push("Resource 'parallelism' must be an integer"):e.parallelism<1&&t.push("Resource 'parallelism' must be greater than 0")),e.observers!==void 0&&!Array.isArray(e.observers)&&t.push("Resource 'observers' must be an array");const r=["cache","autoDecrypt","timestamps","paranoid","allNestedObjectsOptional"];for(const n of r)e[n]!==void 0&&typeof e[n]!="boolean"&&t.push(`Resource '${n}' must be a boolean`);if(e.partitions!==void 0)if(typeof e.partitions!="object"||Array.isArray(e.partitions))t.push("Resource 'partitions' must be an object");else for(const[n,i]of Object.entries(e.partitions))if(typeof i!="object"||Array.isArray(i))t.push(`Partition '${n}' must be an object`);else if(!i.fields)t.push(`Partition '${n}' must have a 'fields' property`);else if(typeof i.fields!="object"||Array.isArray(i.fields))t.push(`Partition '${n}.fields' must be an object`);else for(const[a,o]of Object.entries(i.fields))typeof o!="string"&&t.push(`Partition '${n}.fields.${a}' must be a string`);if(e.hooks!==void 0)if(typeof e.hooks!="object"||Array.isArray(e.hooks))t.push("Resource 'hooks' must be an object");else{const n=["preInsert","afterInsert","preUpdate","afterUpdate","preDelete","afterDelete"];for(const[i,a]of Object.entries(e.hooks))if(!n.includes(i))t.push(`Invalid hook event '${i}'. Valid events: ${n.join(", ")}`);else if(!Array.isArray(a))t.push(`Resource 'hooks.${i}' must be an array`);else for(let o=0;o<a.length;o++){const s=a[o];if(typeof s!="function"){if(typeof s=="string")continue;continue}}}return{isValid:t.length===0,errors:t}}class ls extends R{constructor(t){super(),this.version="1",this.s3dbVersion=(()=>{try{return"4.1.12"}catch{return"latest"}})(),this.resources={},this.savedMetadata=null,this.options=t,this.verbose=t.verbose||!1,this.parallelism=parseInt(t.parallelism+"")||10,this.plugins=t.plugins||[],this.cache=t.cache,this.passphrase=t.passphrase||"secret";let r=t.connectionString;!r&&(t.bucket||t.accessKeyId||t.secretAccessKey)&&(r=zr.buildFromParams({bucket:t.bucket,region:t.region,accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,endpoint:t.endpoint,forcePathStyle:t.forcePathStyle})),this.client=t.client||new aa({verbose:this.verbose,parallelism:this.parallelism,connectionString:r}),this.bucket=this.client.bucket,this.keyPrefix=this.client.keyPrefix}async connect(){await this.startPlugins();let t=null;if(await this.client.exists("s3db.json")){const n=await this.client.getObject("s3db.json");t=JSON.parse(await gt(n?.Body))}else t=this.blankMetadataStructure(),await this.uploadMetadataFile();this.savedMetadata=t;const r=this.detectDefinitionChanges(t);for(const[n,i]of Object.entries(t.resources||{})){const a=i.currentVersion||"v0",o=i.versions?.[a];o&&(this.resources[n]=new ui({name:n,client:this.client,version:a,attributes:o.attributes,behavior:o.behavior||"user-management",parallelism:this.parallelism,passphrase:this.passphrase,observers:[this],cache:this.cache,timestamps:o.options?.timestamps||!1,partitions:i.partitions||o.options?.partitions||{},paranoid:o.options?.paranoid!==!1,allNestedObjectsOptional:o.options?.allNestedObjectsOptional||!1,autoDecrypt:o.options?.autoDecrypt!==!1,hooks:o.options?.hooks||{}}))}r.length>0&&this.emit("resourceDefinitionsChanged",{changes:r,metadata:this.savedMetadata}),this.emit("connected",new Date)}detectDefinitionChanges(t){const r=[];for(const[n,i]of Object.entries(this.resources)){const a=this.generateDefinitionHash(i.export()),o=t.resources?.[n];if(!o)r.push({type:"new",resourceName:n,currentHash:a,savedHash:null});else{const s=o.currentVersion||"v0",c=o.versions?.[s]?.hash;c!==a&&r.push({type:"changed",resourceName:n,currentHash:a,savedHash:c,fromVersion:s,toVersion:this.getNextVersion(o.versions)})}}for(const[n,i]of Object.entries(t.resources||{}))if(!this.resources[n]){const a=i.currentVersion||"v0",o=i.versions?.[a];r.push({type:"deleted",resourceName:n,currentHash:null,savedHash:o?.hash,deletedVersion:a})}return r}generateDefinitionHash(t,r=void 0){const i={...t.attributes};t.timestamps&&(delete i.createdAt,delete i.updatedAt);const a={attributes:i,behavior:r||t.behavior||"user-management"},o=lo(a);return`sha256:${Ui.createHash("sha256").update(o).digest("hex")}`}getNextVersion(t={}){const r=Object.keys(t).filter(i=>i.startsWith("v")).map(i=>parseInt(i.substring(1))).filter(i=>!isNaN(i));return`v${(r.length>0?Math.max(...r):-1)+1}`}async startPlugins(){const t=this;if(!M.isEmpty(this.plugins)){const r=this.plugins.map(a=>M.isFunction(a)?new a(this):a),n=r.map(async a=>{a.beforeSetup&&await a.beforeSetup(),await a.setup(t),a.afterSetup&&await a.afterSetup()});await Promise.all(n);const i=r.map(async a=>{a.beforeStart&&await a.beforeStart(),await a.start(),a.afterStart&&await a.afterStart()});await Promise.all(i)}}async uploadMetadataFile(){const t={version:this.version,s3dbVersion:this.s3dbVersion,lastUpdated:new Date().toISOString(),resources:{}};Object.entries(this.resources).forEach(([r,n])=>{const i=n.export(),a=this.generateDefinitionHash(i),o=this.savedMetadata?.resources?.[r],s=o?.currentVersion||"v0",f=o?.versions?.[s];let c,l;!f||f.hash!==a?(c=this.getNextVersion(o?.versions),l=!0):(c=s,l=!1),t.resources[r]={currentVersion:c,partitions:n.config.partitions||{},versions:{...o?.versions,[c]:{hash:a,attributes:i.attributes,options:{timestamps:n.config.timestamps,partitions:n.config.partitions,paranoid:n.config.paranoid,allNestedObjectsOptional:n.config.allNestedObjectsOptional,autoDecrypt:n.config.autoDecrypt,cache:n.config.cache,hooks:i.hooks||{}},behavior:i.behavior||"user-management",createdAt:l?new Date().toISOString():f?.createdAt}}},n.version!==c&&(n.version=c,n.emit("versionUpdated",{oldVersion:s,newVersion:c}))}),await this.client.putObject({key:"s3db.json",body:JSON.stringify(t,null,2),contentType:"application/json"}),this.savedMetadata=t,this.emit("metadataUploaded",t)}blankMetadataStructure(){return{version:"1",s3dbVersion:this.s3dbVersion,resources:{}}}resourceExists(t){return!!this.resources[t]}resourceExistsWithSameHash({name:t,attributes:r,options:n={},behavior:i="user-management"}){if(!this.resources[t])return{exists:!1,sameHash:!1,hash:null};const a=new ui({name:t,attributes:r,behavior:i,observers:[],client:this.client,version:"temp",passphrase:this.passphrase,cache:this.cache,...n}),o=this.generateDefinitionHash(a.export(),i),s=this.generateDefinitionHash(this.resources[t].export(),this.resources[t].behavior);return{exists:!0,sameHash:o===s,hash:o,existingHash:s}}async createResourceIfNotExists({name:t,attributes:r,options:n={},behavior:i="user-management"}){const a=!!this.resources[t],o=this.resourceExistsWithSameHash({name:t,attributes:r,options:n,behavior:i});return o.exists&&o.sameHash?{resource:this.resources[t],created:!1,reason:"Resource already exists with same definition hash"}:{resource:await this.createResource({name:t,attributes:r,options:n,behavior:i}),created:!a,reason:a?"Resource updated with new definition":"New resource created"}}async createResource({name:t,attributes:r,options:n={},behavior:i="user-management"}){if(this.resources[t]){const f=this.resources[t];Object.assign(f.config,{cache:this.cache,...n}),i&&(f.behavior=i),f.updateAttributes(r);const c=this.generateDefinitionHash(f.export(),f.behavior),l=this.savedMetadata?.resources?.[t],d=l?.currentVersion||"v0",h=l?.versions?.[d];return(!h||h.hash!==c)&&await this.uploadMetadataFile(),this.emit("s3db.resourceUpdated",t),f}const o=this.savedMetadata?.resources?.[t]?.currentVersion||"v0",s=new ui({name:t,attributes:r,behavior:i,observers:[this],client:this.client,version:o,passphrase:this.passphrase,cache:this.cache,...n});return this.resources[t]=s,await this.uploadMetadataFile(),this.emit("s3db.resourceCreated",t),s}resource(t){return this.resources[t]?this.resources[t]:Promise.reject(`resource ${t} does not exist`)}async listResources(){return Object.keys(this.resources).map(t=>({name:t}))}async getResource(t){if(!this.resources[t])throw new Error(`Resource not found: ${t}`);return this.resources[t]}get config(){return{version:this.version,s3dbVersion:this.s3dbVersion,bucket:this.bucket,keyPrefix:this.keyPrefix,parallelism:this.parallelism,verbose:this.verbose}}isConnected(){return!!this.savedMetadata}}class hi extends ls{}class di extends R{constructor(t={}){super(),this.config=t}async _set(t,r){}async _get(t){}async _del(t){}async _clear(t){}validateKey(t){if(t==null||typeof t!="string"||!t)throw new Error("Invalid key")}async set(t,r){return this.validateKey(t),await this._set(t,r),this.emit("set",r),r}async get(t){this.validateKey(t);const r=await this._get(t);return this.emit("get",r),r}async del(t){this.validateKey(t);const r=await this._del(t);return this.emit("delete",r),r}async delete(t){return this.del(t)}async clear(){const t=await this._clear();return this.emit("clear",t),t}}class Eh extends di{constructor(t={}){super(t),this.cache={},this.meta={},this.maxSize=t.maxSize||0,this.ttl=t.ttl||0}async _set(t,r){if(this.maxSize>0&&Object.keys(this.cache).length>=this.maxSize){const n=Object.entries(this.meta).sort((i,a)=>i[1].ts-a[1].ts)[0]?.[0];n&&(delete this.cache[n],delete this.meta[n])}return this.cache[t]=r,this.meta[t]={ts:Date.now()},r}async _get(t){if(!Object.prototype.hasOwnProperty.call(this.cache,t))return null;if(this.ttl>0){const r=Date.now(),n=this.meta[t];if(n&&r-n.ts>this.ttl*1e3)return delete this.cache[t],delete this.meta[t],null}return this.cache[t]}async _del(t){return delete this.cache[t],delete this.meta[t],!0}async _clear(){return this.cache={},this.meta={},!0}async size(){return Object.keys(this.cache).length}async keys(){return Object.keys(this.cache)}}var us={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function xh(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function Re(e,t,r,n,i){if(t.subarray&&e.subarray){e.set(t.subarray(r,r+n),i);return}for(var a=0;a<n;a++)e[i+a]=t[r+a]}var _r=Uint8Array,se=Uint16Array,br=Int32Array,Sh=4,hs=0,ds=1,Ah=2;function wt(e){for(var t=e.length;--t>=0;)e[t]=0}var kh=0,ps=1,Rh=2,Oh=3,Ph=258,pi=29,Ct=256,jt=Ct+1+pi,_t=30,yi=19,ys=2*jt+1,Xe=15,gi=16,Ih=7,vi=256,gs=16,vs=17,ws=18,wi=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],mr=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Th=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],_s=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Dh=512,Oe=new Array((jt+2)*2);wt(Oe);var Ft=new Array(_t*2);wt(Ft);var Nt=new Array(Dh);wt(Nt);var Mt=new Array(Ph-Oh+1);wt(Mt);var _i=new Array(pi);wt(_i);var Er=new Array(_t);wt(Er);function bi(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}var bs,ms,Es;function mi(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function xs(e){return e<256?Nt[e]:Nt[256+(e>>>7)]}function Lt(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function ee(e,t,r){e.bi_valid>gi-r?(e.bi_buf|=t<<e.bi_valid&65535,Lt(e,e.bi_buf),e.bi_buf=t>>gi-e.bi_valid,e.bi_valid+=r-gi):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function we(e,t,r){ee(e,r[t*2],r[t*2+1])}function Ss(e,t){var r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1}function Ch(e){e.bi_valid===16?(Lt(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function jh(e,t){var r=t.dyn_tree,n=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,f=t.stat_desc.max_length,c,l,d,h,u,p,g=0;for(h=0;h<=Xe;h++)e.bl_count[h]=0;for(r[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;c<ys;c++)l=e.heap[c],h=r[r[l*2+1]*2+1]+1,h>f&&(h=f,g++),r[l*2+1]=h,!(l>n)&&(e.bl_count[h]++,u=0,l>=s&&(u=o[l-s]),p=r[l*2],e.opt_len+=p*(h+u),a&&(e.static_len+=p*(i[l*2+1]+u)));if(g!==0){do{for(h=f-1;e.bl_count[h]===0;)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[f]--,g-=2}while(g>0);for(h=f;h!==0;h--)for(l=e.bl_count[h];l!==0;)d=e.heap[--c],!(d>n)&&(r[d*2+1]!==h&&(e.opt_len+=(h-r[d*2+1])*r[d*2],r[d*2+1]=h),l--)}}function As(e,t,r){var n=new Array(Xe+1),i=0,a,o;for(a=1;a<=Xe;a++)n[a]=i=i+r[a-1]<<1;for(o=0;o<=t;o++){var s=e[o*2+1];s!==0&&(e[o*2]=Ss(n[s]++,s))}}function Fh(){var e,t,r,n,i,a=new Array(Xe+1);for(r=0,n=0;n<pi-1;n++)for(_i[n]=r,e=0;e<1<<wi[n];e++)Mt[r++]=n;for(Mt[r-1]=n,i=0,n=0;n<16;n++)for(Er[n]=i,e=0;e<1<<mr[n];e++)Nt[i++]=n;for(i>>=7;n<_t;n++)for(Er[n]=i<<7,e=0;e<1<<mr[n]-7;e++)Nt[256+i++]=n;for(t=0;t<=Xe;t++)a[t]=0;for(e=0;e<=143;)Oe[e*2+1]=8,e++,a[8]++;for(;e<=255;)Oe[e*2+1]=9,e++,a[9]++;for(;e<=279;)Oe[e*2+1]=7,e++,a[7]++;for(;e<=287;)Oe[e*2+1]=8,e++,a[8]++;for(As(Oe,jt+1,a),e=0;e<_t;e++)Ft[e*2+1]=5,Ft[e*2]=Ss(e,5);bs=new bi(Oe,wi,Ct+1,jt,Xe),ms=new bi(Ft,mr,0,_t,Xe),Es=new bi(new Array(0),Th,0,yi,Ih)}function ks(e){var t;for(t=0;t<jt;t++)e.dyn_ltree[t*2]=0;for(t=0;t<_t;t++)e.dyn_dtree[t*2]=0;for(t=0;t<yi;t++)e.bl_tree[t*2]=0;e.dyn_ltree[vi*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function Rs(e){e.bi_valid>8?Lt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Nh(e,t,r,n){Rs(e),Lt(e,r),Lt(e,~r),Re(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}function Os(e,t,r,n){var i=t*2,a=r*2;return e[i]<e[a]||e[i]===e[a]&&n[t]<=n[r]}function Ei(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&Os(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!Os(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function Ps(e,t,r){var n,i,a=0,o,s;if(e.last_lit!==0)do n=e.pending_buf[e.d_buf+a*2]<<8|e.pending_buf[e.d_buf+a*2+1],i=e.pending_buf[e.l_buf+a],a++,n===0?we(e,i,t):(o=Mt[i],we(e,o+Ct+1,t),s=wi[o],s!==0&&(i-=_i[o],ee(e,i,s)),n--,o=xs(n),we(e,o,r),s=mr[o],s!==0&&(n-=Er[o],ee(e,n,s)));while(a<e.last_lit);we(e,vi,t)}function xi(e,t){var r=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems,o,s,f=-1,c;for(e.heap_len=0,e.heap_max=ys,o=0;o<a;o++)r[o*2]!==0?(e.heap[++e.heap_len]=f=o,e.depth[o]=0):r[o*2+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=f<2?++f:0,r[c*2]=1,e.depth[c]=0,e.opt_len--,i&&(e.static_len-=n[c*2+1]);for(t.max_code=f,o=e.heap_len>>1;o>=1;o--)Ei(e,r,o);c=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ei(e,r,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,r[c*2]=r[o*2]+r[s*2],e.depth[c]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,r[o*2+1]=r[s*2+1]=c,e.heap[1]=c++,Ei(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],jh(e,t),As(r,f,e.bl_count)}function Is(e,t,r){var n,i=-1,a,o=t[0*2+1],s=0,f=7,c=4;for(o===0&&(f=138,c=3),t[(r+1)*2+1]=65535,n=0;n<=r;n++)a=o,o=t[(n+1)*2+1],!(++s<f&&a===o)&&(s<c?e.bl_tree[a*2]+=s:a!==0?(a!==i&&e.bl_tree[a*2]++,e.bl_tree[gs*2]++):s<=10?e.bl_tree[vs*2]++:e.bl_tree[ws*2]++,s=0,i=a,o===0?(f=138,c=3):a===o?(f=6,c=3):(f=7,c=4))}function Ts(e,t,r){var n,i=-1,a,o=t[0*2+1],s=0,f=7,c=4;for(o===0&&(f=138,c=3),n=0;n<=r;n++)if(a=o,o=t[(n+1)*2+1],!(++s<f&&a===o)){if(s<c)do we(e,a,e.bl_tree);while(--s!==0);else a!==0?(a!==i&&(we(e,a,e.bl_tree),s--),we(e,gs,e.bl_tree),ee(e,s-3,2)):s<=10?(we(e,vs,e.bl_tree),ee(e,s-3,3)):(we(e,ws,e.bl_tree),ee(e,s-11,7));s=0,i=a,o===0?(f=138,c=3):a===o?(f=6,c=3):(f=7,c=4)}}function Mh(e){var t;for(Is(e,e.dyn_ltree,e.l_desc.max_code),Is(e,e.dyn_dtree,e.d_desc.max_code),xi(e,e.bl_desc),t=yi-1;t>=3&&e.bl_tree[_s[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function Lh(e,t,r,n){var i;for(ee(e,t-257,5),ee(e,r-1,5),ee(e,n-4,4),i=0;i<n;i++)ee(e,e.bl_tree[_s[i]*2+1],3);Ts(e,e.dyn_ltree,t-1),Ts(e,e.dyn_dtree,r-1)}function $h(e){var t=4093624447,r;for(r=0;r<=31;r++,t>>>=1)if(t&1&&e.dyn_ltree[r*2]!==0)return hs;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return ds;for(r=32;r<Ct;r++)if(e.dyn_ltree[r*2]!==0)return ds;return hs}var Ds=!1;function Bh(e){Ds||(Fh(),Ds=!0),e.l_desc=new mi(e.dyn_ltree,bs),e.d_desc=new mi(e.dyn_dtree,ms),e.bl_desc=new mi(e.bl_tree,Es),e.bi_buf=0,e.bi_valid=0,ks(e)}function Cs(e,t,r,n){ee(e,(kh<<1)+(n?1:0),3),Nh(e,t,r)}function Uh(e){ee(e,ps<<1,3),we(e,vi,Oe),Ch(e)}function zh(e,t,r,n){var i,a,o=0;e.level>0?(e.strm.data_type===Ah&&(e.strm.data_type=$h(e)),xi(e,e.l_desc),xi(e,e.d_desc),o=Mh(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i&&(i=a)):i=a=r+5,r+4<=i&&t!==-1?Cs(e,t,r,n):e.strategy===Sh||a===i?(ee(e,(ps<<1)+(n?1:0),3),Ps(e,Oe,Ft)):(ee(e,(Rh<<1)+(n?1:0),3),Lh(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),Ps(e,e.dyn_ltree,e.dyn_dtree)),ks(e),n&&Rs(e)}function Fe(e,t,r){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=r&255,e.last_lit++,t===0?e.dyn_ltree[r*2]++:(e.matches++,t--,e.dyn_ltree[(Mt[r]+Ct+1)*2]++,e.dyn_dtree[xs(t)*2]++),e.last_lit===e.lit_bufsize-1}function Si(e,t,r,n){for(var i=e&65535|0,a=e>>>16&65535|0,o=0;r!==0;){o=r>2e3?2e3:r,r-=o;do i=i+t[n++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0}function Zh(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t}var qh=Zh();function Z(e,t,r,n){var i=qh,a=n+r;e^=-1;for(var o=n;o<a;o++)e=e>>>8^i[(e^t[o])&255];return e^-1}var Qe=0,Hh=1,Kh=3,Ne=4,js=5,Me=0,Fs=1,Le=-2,Vh=-3,Ai=-5,Wh=-1,Gh=1,xr=2,Yh=3,Jh=4,Xh=2,ki=8,Qh=9,ed=29,td=256,Ri=td+1+ed,rd=30,nd=19,id=2*Ri+1,ad=15,T=3,$e=258,ce=$e+T+1,od=32,Oi=42,Pi=69,Sr=73,Ar=91,kr=103,et=113,$t=666,U=1,Bt=2,tt=3,bt=4,sd=3;function Be(e,t){return e.msg=us[t],t}function Ns(e){return(e<<1)-(e>4?9:0)}function rt(e){for(var t=e.length;--t>=0;)e[t]=0}function Ue(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(Re(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,t.pending===0&&(t.pending_out=0))}function K(e,t){zh(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Ue(e.strm)}function I(e,t){e.pending_buf[e.pending++]=t}function Ut(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function cd(e,t,r,n){var i=e.avail_in;return i>n&&(i=n),i===0?0:(e.avail_in-=i,Re(t,e.input,e.next_in,i,r),e.state.wrap===1?e.adler=Si(e.adler,t,i,r):e.state.wrap===2&&(e.adler=Z(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)}function Ms(e,t){var r=e.max_chain_length,n=e.strstart,i,a,o=e.prev_length,s=e.nice_match,f=e.strstart>e.w_size-ce?e.strstart-(e.w_size-ce):0,c=e.window,l=e.w_mask,d=e.prev,h=e.strstart+$e,u=c[n+o-1],p=c[n+o];e.prev_length>=e.good_match&&(r>>=2),s>e.lookahead&&(s=e.lookahead);do if(i=t,!(c[i+o]!==p||c[i+o-1]!==u||c[i]!==c[n]||c[++i]!==c[n+1])){n+=2,i++;do;while(c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&n<h);if(a=$e-(h-n),n=h-$e,a>o){if(e.match_start=t,o=a,a>=s)break;u=c[n+o-1],p=c[n+o]}}while((t=d[t&l])>f&&--r!==0);return o<=e.lookahead?o:e.lookahead}function zt(e){var t=e.w_size,r,n,i,a,o;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-ce)){Re(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,n=e.hash_size,r=n;do i=e.head[--r],e.head[r]=i>=t?i-t:0;while(--n);n=t,r=n;do i=e.prev[--r],e.prev[r]=i>=t?i-t:0;while(--n);a+=t}if(e.strm.avail_in===0)break;if(n=cd(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=n,e.lookahead+e.insert>=T)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+T-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<T)););}while(e.lookahead<ce&&e.strm.avail_in!==0)}function fd(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(zt(e),e.lookahead===0&&t===Qe)return U;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((e.strstart===0||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,K(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-ce&&(K(e,!1),e.strm.avail_out===0))return U}return e.insert=0,t===Ne?(K(e,!0),e.strm.avail_out===0?tt:bt):(e.strstart>e.block_start&&(K(e,!1),e.strm.avail_out===0),U)}function Ii(e,t){for(var r,n;;){if(e.lookahead<ce){if(zt(e),e.lookahead<ce&&t===Qe)return U;if(e.lookahead===0)break}if(r=0,e.lookahead>=T&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+T-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),r!==0&&e.strstart-r<=e.w_size-ce&&(e.match_length=Ms(e,r)),e.match_length>=T)if(n=Fe(e,e.strstart-e.match_start,e.match_length-T),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=T){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+T-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=Fe(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(K(e,!1),e.strm.avail_out===0))return U}return e.insert=e.strstart<T-1?e.strstart:T-1,t===Ne?(K(e,!0),e.strm.avail_out===0?tt:bt):e.last_lit&&(K(e,!1),e.strm.avail_out===0)?U:Bt}function mt(e,t){for(var r,n,i;;){if(e.lookahead<ce){if(zt(e),e.lookahead<ce&&t===Qe)return U;if(e.lookahead===0)break}if(r=0,e.lookahead>=T&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+T-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=T-1,r!==0&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-ce&&(e.match_length=Ms(e,r),e.match_length<=5&&(e.strategy===Gh||e.match_length===T&&e.strstart-e.match_start>4096)&&(e.match_length=T-1)),e.prev_length>=T&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-T,n=Fe(e,e.strstart-1-e.prev_match,e.prev_length-T),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+T-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=T-1,e.strstart++,n&&(K(e,!1),e.strm.avail_out===0))return U}else if(e.match_available){if(n=Fe(e,0,e.window[e.strstart-1]),n&&K(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return U}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Fe(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<T-1?e.strstart:T-1,t===Ne?(K(e,!0),e.strm.avail_out===0?tt:bt):e.last_lit&&(K(e,!1),e.strm.avail_out===0)?U:Bt}function ld(e,t){for(var r,n,i,a,o=e.window;;){if(e.lookahead<=$e){if(zt(e),e.lookahead<=$e&&t===Qe)return U;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=T&&e.strstart>0&&(i=e.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){a=e.strstart+$e;do;while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<a);e.match_length=$e-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=T?(r=Fe(e,1,e.match_length-T),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Fe(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(K(e,!1),e.strm.avail_out===0))return U}return e.insert=0,t===Ne?(K(e,!0),e.strm.avail_out===0?tt:bt):e.last_lit&&(K(e,!1),e.strm.avail_out===0)?U:Bt}function ud(e,t){for(var r;;){if(e.lookahead===0&&(zt(e),e.lookahead===0)){if(t===Qe)return U;break}if(e.match_length=0,r=Fe(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(K(e,!1),e.strm.avail_out===0))return U}return e.insert=0,t===Ne?(K(e,!0),e.strm.avail_out===0?tt:bt):e.last_lit&&(K(e,!1),e.strm.avail_out===0)?U:Bt}function _e(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}var Et;Et=[new _e(0,0,0,0,fd),new _e(4,4,8,4,Ii),new _e(4,5,16,8,Ii),new _e(4,6,32,32,Ii),new _e(4,4,16,16,mt),new _e(8,16,32,32,mt),new _e(8,16,128,128,mt),new _e(8,32,128,256,mt),new _e(32,128,258,1024,mt),new _e(32,258,258,4096,mt)];function hd(e){e.window_size=2*e.w_size,rt(e.head),e.max_lazy_match=Et[e.level].max_lazy,e.good_match=Et[e.level].good_length,e.nice_match=Et[e.level].nice_length,e.max_chain_length=Et[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=T-1,e.match_available=0,e.ins_h=0}function dd(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ki,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new se(id*2),this.dyn_dtree=new se((2*rd+1)*2),this.bl_tree=new se((2*nd+1)*2),rt(this.dyn_ltree),rt(this.dyn_dtree),rt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new se(ad+1),this.heap=new se(2*Ri+1),rt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new se(2*Ri+1),rt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function pd(e){var t;return!e||!e.state?Be(e,Le):(e.total_in=e.total_out=0,e.data_type=Xh,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?Oi:et,e.adler=t.wrap===2?0:1,t.last_flush=Qe,Bh(t),Me)}function Ls(e){var t=pd(e);return t===Me&&hd(e.state),t}function yd(e,t,r,n,i,a){if(!e)return Le;var o=1;if(t===Wh&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>Qh||r!==ki||n<8||n>15||t<0||t>9||a<0||a>Jh)return Be(e,Le);n===8&&(n=9);var s=new dd;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+T-1)/T),s.window=new _r(s.w_size*2),s.head=new se(s.hash_size),s.prev=new se(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new _r(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=a,s.method=r,Ls(e)}function gd(e,t){var r,n,i,a;if(!e||!e.state||t>js||t<0)return e?Be(e,Le):Le;if(n=e.state,!e.output||!e.input&&e.avail_in!==0||n.status===$t&&t!==Ne)return Be(e,e.avail_out===0?Ai:Le);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===Oi)if(n.wrap===2)e.adler=0,I(n,31),I(n,139),I(n,8),n.gzhead?(I(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),I(n,n.gzhead.time&255),I(n,n.gzhead.time>>8&255),I(n,n.gzhead.time>>16&255),I(n,n.gzhead.time>>24&255),I(n,n.level===9?2:n.strategy>=xr||n.level<2?4:0),I(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(I(n,n.gzhead.extra.length&255),I(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Z(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=Pi):(I(n,0),I(n,0),I(n,0),I(n,0),I(n,0),I(n,n.level===9?2:n.strategy>=xr||n.level<2?4:0),I(n,sd),n.status=et);else{var o=ki+(n.w_bits-8<<4)<<8,s=-1;n.strategy>=xr||n.level<2?s=0:n.level<6?s=1:n.level===6?s=2:s=3,o|=s<<6,n.strstart!==0&&(o|=od),o+=31-o%31,n.status=et,Ut(n,o),n.strstart!==0&&(Ut(n,e.adler>>>16),Ut(n,e.adler&65535)),e.adler=1}if(n.status===Pi)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(n.gzhead.extra.length&65535)&&!(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),Ue(e),i=n.pending,n.pending===n.pending_buf_size));)I(n,n.gzhead.extra[n.gzindex]&255),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=Sr)}else n.status=Sr;if(n.status===Sr)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),Ue(e),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}n.gzindex<n.gzhead.name.length?a=n.gzhead.name.charCodeAt(n.gzindex++)&255:a=0,I(n,a)}while(a!==0);n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),a===0&&(n.gzindex=0,n.status=Ar)}else n.status=Ar;if(n.status===Ar)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),Ue(e),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}n.gzindex<n.gzhead.comment.length?a=n.gzhead.comment.charCodeAt(n.gzindex++)&255:a=0,I(n,a)}while(a!==0);n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),a===0&&(n.status=kr)}else n.status=kr;if(n.status===kr&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&Ue(e),n.pending+2<=n.pending_buf_size&&(I(n,e.adler&255),I(n,e.adler>>8&255),e.adler=0,n.status=et)):n.status=et),n.pending!==0){if(Ue(e),e.avail_out===0)return n.last_flush=-1,Me}else if(e.avail_in===0&&Ns(t)<=Ns(r)&&t!==Ne)return Be(e,Ai);if(n.status===$t&&e.avail_in!==0)return Be(e,Ai);if(e.avail_in!==0||n.lookahead!==0||t!==Qe&&n.status!==$t){var f=n.strategy===xr?ud(n,t):n.strategy===Yh?ld(n,t):Et[n.level].func(n,t);if((f===tt||f===bt)&&(n.status=$t),f===U||f===tt)return e.avail_out===0&&(n.last_flush=-1),Me;if(f===Bt&&(t===Hh?Uh(n):t!==js&&(Cs(n,0,0,!1),t===Kh&&(rt(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),Ue(e),e.avail_out===0))return n.last_flush=-1,Me}return t!==Ne?Me:n.wrap<=0?Fs:(n.wrap===2?(I(n,e.adler&255),I(n,e.adler>>8&255),I(n,e.adler>>16&255),I(n,e.adler>>24&255),I(n,e.total_in&255),I(n,e.total_in>>8&255),I(n,e.total_in>>16&255),I(n,e.total_in>>24&255)):(Ut(n,e.adler>>>16),Ut(n,e.adler&65535)),Ue(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?Me:Fs)}function vd(e){var t;return!e||!e.state?Le:(t=e.state.status,t!==Oi&&t!==Pi&&t!==Sr&&t!==Ar&&t!==kr&&t!==et&&t!==$t?Be(e,Le):(e.state=null,t===et?Be(e,Vh):Me))}var Rr=30,wd=12;function _d(e,t){var r,n,i,a,o,s,f,c,l,d,h,u,p,g,w,_,m,x,v,A,O,b,S,P,k;r=e.state,n=e.next_in,P=e.input,i=n+(e.avail_in-5),a=e.next_out,k=e.output,o=a-(t-e.avail_out),s=a+(e.avail_out-257),f=r.dmax,c=r.wsize,l=r.whave,d=r.wnext,h=r.window,u=r.hold,p=r.bits,g=r.lencode,w=r.distcode,_=(1<<r.lenbits)-1,m=(1<<r.distbits)-1;e:do{p<15&&(u+=P[n++]<<p,p+=8,u+=P[n++]<<p,p+=8),x=g[u&_];t:for(;;){if(v=x>>>24,u>>>=v,p-=v,v=x>>>16&255,v===0)k[a++]=x&65535;else if(v&16){A=x&65535,v&=15,v&&(p<v&&(u+=P[n++]<<p,p+=8),A+=u&(1<<v)-1,u>>>=v,p-=v),p<15&&(u+=P[n++]<<p,p+=8,u+=P[n++]<<p,p+=8),x=w[u&m];r:for(;;){if(v=x>>>24,u>>>=v,p-=v,v=x>>>16&255,v&16){if(O=x&65535,v&=15,p<v&&(u+=P[n++]<<p,p+=8,p<v&&(u+=P[n++]<<p,p+=8)),O+=u&(1<<v)-1,O>f){e.msg="invalid distance too far back",r.mode=Rr;break e}if(u>>>=v,p-=v,v=a-o,O>v){if(v=O-v,v>l&&r.sane){e.msg="invalid distance too far back",r.mode=Rr;break e}if(b=0,S=h,d===0){if(b+=c-v,v<A){A-=v;do k[a++]=h[b++];while(--v);b=a-O,S=k}}else if(d<v){if(b+=c+d-v,v-=d,v<A){A-=v;do k[a++]=h[b++];while(--v);if(b=0,d<A){v=d,A-=v;do k[a++]=h[b++];while(--v);b=a-O,S=k}}}else if(b+=d-v,v<A){A-=v;do k[a++]=h[b++];while(--v);b=a-O,S=k}for(;A>2;)k[a++]=S[b++],k[a++]=S[b++],k[a++]=S[b++],A-=3;A&&(k[a++]=S[b++],A>1&&(k[a++]=S[b++]))}else{b=a-O;do k[a++]=k[b++],k[a++]=k[b++],k[a++]=k[b++],A-=3;while(A>2);A&&(k[a++]=k[b++],A>1&&(k[a++]=k[b++]))}}else if((v&64)===0){x=w[(x&65535)+(u&(1<<v)-1)];continue r}else{e.msg="invalid distance code",r.mode=Rr;break e}break}}else if((v&64)===0){x=g[(x&65535)+(u&(1<<v)-1)];continue t}else if(v&32){r.mode=wd;break e}else{e.msg="invalid literal/length code",r.mode=Rr;break e}break}}while(n<i&&a<s);A=p>>3,n-=A,p-=A<<3,u&=(1<<p)-1,e.next_in=n,e.next_out=a,e.avail_in=n<i?5+(i-n):5-(n-i),e.avail_out=a<s?257+(s-a):257-(a-s),r.hold=u,r.bits=p}var xt=15,$s=852,Bs=592,Us=0,Ti=1,zs=2,bd=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],md=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],Ed=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],xd=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];function Zt(e,t,r,n,i,a,o,s){var f=s.bits,c=0,l=0,d=0,h=0,u=0,p=0,g=0,w=0,_=0,m=0,x,v,A,O,b,S=null,P=0,k,C=new se(xt+1),q=new se(xt+1),G=null,ie=0,Ze,J,le;for(c=0;c<=xt;c++)C[c]=0;for(l=0;l<n;l++)C[t[r+l]]++;for(u=f,h=xt;h>=1&&C[h]===0;h--);if(u>h&&(u=h),h===0)return i[a++]=1<<24|64<<16|0,i[a++]=1<<24|64<<16|0,s.bits=1,0;for(d=1;d<h&&C[d]===0;d++);for(u<d&&(u=d),w=1,c=1;c<=xt;c++)if(w<<=1,w-=C[c],w<0)return-1;if(w>0&&(e===Us||h!==1))return-1;for(q[1]=0,c=1;c<xt;c++)q[c+1]=q[c]+C[c];for(l=0;l<n;l++)t[r+l]!==0&&(o[q[t[r+l]]++]=l);if(e===Us?(S=G=o,k=19):e===Ti?(S=bd,P-=257,G=md,ie-=257,k=256):(S=Ed,G=xd,k=-1),m=0,l=0,c=d,b=a,p=u,g=0,A=-1,_=1<<u,O=_-1,e===Ti&&_>$s||e===zs&&_>Bs)return 1;for(;;){Ze=c-g,o[l]<k?(J=0,le=o[l]):o[l]>k?(J=G[ie+o[l]],le=S[P+o[l]]):(J=96,le=0),x=1<<c-g,v=1<<p,d=v;do v-=x,i[b+(m>>g)+v]=Ze<<24|J<<16|le|0;while(v!==0);for(x=1<<c-1;m&x;)x>>=1;if(x!==0?(m&=x-1,m+=x):m=0,l++,--C[c]===0){if(c===h)break;c=t[r+o[l]]}if(c>u&&(m&O)!==A){for(g===0&&(g=u),b+=d,p=c-g,w=1<<p;p+g<h&&(w-=C[p+g],!(w<=0));)p++,w<<=1;if(_+=1<<p,e===Ti&&_>$s||e===zs&&_>Bs)return 1;A=m&O,i[A]=u<<24|p<<16|b-a|0}}return m!==0&&(i[b+m]=c-g<<24|64<<16|0),s.bits=u,0}var Sd=0,Zs=1,qs=2,Hs=4,Ad=5,Or=6,qt=0,kd=1,Rd=2,ze=-2,Od=-3,Pd=-4,Id=-5,Ks=8,Vs=1,Ws=2,Gs=3,Ys=4,Js=5,Xs=6,Qs=7,ec=8,tc=9,rc=10,nc=11,Pe=12,Di=13,ic=14,Ci=15,ac=16,oc=17,sc=18,cc=19,Pr=20,Ir=21,fc=22,lc=23,uc=24,hc=25,dc=26,ji=27,pc=28,yc=29,j=30,Td=31,Dd=32,Cd=852,jd=592;function gc(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function Fd(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new se(320),this.work=new se(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Nd(e){var t;return!e||!e.state?ze:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=Vs,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new br(Cd),t.distcode=t.distdyn=new br(jd),t.sane=1,t.back=-1,qt)}function vc(e){var t;return!e||!e.state?ze:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,Nd(e))}function Md(e,t){var r,n;return!e||!e.state||(n=e.state,t<0?(r=0,t=-t):(r=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?ze:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,vc(e))}function Ld(e,t){var r,n;return e?(n=new Fd,e.state=n,n.window=null,r=Md(e,t),r!==qt&&(e.state=null),r):ze}var wc=!0,Fi,Ni;function $d(e){if(wc){var t;for(Fi=new br(512),Ni=new br(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Zt(Zs,e.lens,0,288,Fi,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Zt(qs,e.lens,0,32,Ni,0,e.work,{bits:5}),wc=!1}e.lencode=Fi,e.lenbits=9,e.distcode=Ni,e.distbits=5}function Bd(e,t,r,n){var i,a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new _r(a.wsize)),n>=a.wsize?(Re(a.window,t,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>n&&(i=n),Re(a.window,t,r-n,i,a.wnext),n-=i,n?(Re(a.window,t,r-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0}function Ud(e,t){var r,n,i,a,o,s,f,c,l,d,h,u,p,g,w=0,_,m,x,v,A,O,b,S,P=new _r(4),k,C,q=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return ze;r=e.state,r.mode===Pe&&(r.mode=Di),o=e.next_out,i=e.output,f=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,c=r.hold,l=r.bits,d=s,h=f,S=qt;e:for(;;)switch(r.mode){case Vs:if(r.wrap===0){r.mode=Di;break}for(;l<16;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}if(r.wrap&2&&c===35615){r.check=0,P[0]=c&255,P[1]=c>>>8&255,r.check=Z(r.check,P,2,0),c=0,l=0,r.mode=Ws;break}if(r.flags=0,r.head&&(r.head.done=!1),!(r.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",r.mode=j;break}if((c&15)!==Ks){e.msg="unknown compression method",r.mode=j;break}if(c>>>=4,l-=4,b=(c&15)+8,r.wbits===0)r.wbits=b;else if(b>r.wbits){e.msg="invalid window size",r.mode=j;break}r.dmax=1<<b,e.adler=r.check=1,r.mode=c&512?rc:Pe,c=0,l=0;break;case Ws:for(;l<16;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}if(r.flags=c,(r.flags&255)!==Ks){e.msg="unknown compression method",r.mode=j;break}if(r.flags&57344){e.msg="unknown header flags set",r.mode=j;break}r.head&&(r.head.text=c>>8&1),r.flags&512&&(P[0]=c&255,P[1]=c>>>8&255,r.check=Z(r.check,P,2,0)),c=0,l=0,r.mode=Gs;case Gs:for(;l<32;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}r.head&&(r.head.time=c),r.flags&512&&(P[0]=c&255,P[1]=c>>>8&255,P[2]=c>>>16&255,P[3]=c>>>24&255,r.check=Z(r.check,P,4,0)),c=0,l=0,r.mode=Ys;case Ys:for(;l<16;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}r.head&&(r.head.xflags=c&255,r.head.os=c>>8),r.flags&512&&(P[0]=c&255,P[1]=c>>>8&255,r.check=Z(r.check,P,2,0)),c=0,l=0,r.mode=Js;case Js:if(r.flags&1024){for(;l<16;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}r.length=c,r.head&&(r.head.extra_len=c),r.flags&512&&(P[0]=c&255,P[1]=c>>>8&255,r.check=Z(r.check,P,2,0)),c=0,l=0}else r.head&&(r.head.extra=null);r.mode=Xs;case Xs:if(r.flags&1024&&(u=r.length,u>s&&(u=s),u&&(r.head&&(b=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),Re(r.head.extra,n,a,u,b)),r.flags&512&&(r.check=Z(r.check,n,u,a)),s-=u,a+=u,r.length-=u),r.length))break e;r.length=0,r.mode=Qs;case Qs:if(r.flags&2048){if(s===0)break e;u=0;do b=n[a+u++],r.head&&b&&r.length<65536&&(r.head.name+=String.fromCharCode(b));while(b&&u<s);if(r.flags&512&&(r.check=Z(r.check,n,u,a)),s-=u,a+=u,b)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=ec;case ec:if(r.flags&4096){if(s===0)break e;u=0;do b=n[a+u++],r.head&&b&&r.length<65536&&(r.head.comment+=String.fromCharCode(b));while(b&&u<s);if(r.flags&512&&(r.check=Z(r.check,n,u,a)),s-=u,a+=u,b)break e}else r.head&&(r.head.comment=null);r.mode=tc;case tc:if(r.flags&512){for(;l<16;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}if(c!==(r.check&65535)){e.msg="header crc mismatch",r.mode=j;break}c=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=Pe;break;case rc:for(;l<32;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}e.adler=r.check=gc(c),c=0,l=0,r.mode=nc;case nc:if(r.havedict===0)return e.next_out=o,e.avail_out=f,e.next_in=a,e.avail_in=s,r.hold=c,r.bits=l,Rd;e.adler=r.check=1,r.mode=Pe;case Pe:if(t===Ad||t===Or)break e;case Di:if(r.last){c>>>=l&7,l-=l&7,r.mode=ji;break}for(;l<3;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}switch(r.last=c&1,c>>>=1,l-=1,c&3){case 0:r.mode=ic;break;case 1:if($d(r),r.mode=Pr,t===Or){c>>>=2,l-=2;break e}break;case 2:r.mode=oc;break;case 3:e.msg="invalid block type",r.mode=j}c>>>=2,l-=2;break;case ic:for(c>>>=l&7,l-=l&7;l<32;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}if((c&65535)!==(c>>>16^65535)){e.msg="invalid stored block lengths",r.mode=j;break}if(r.length=c&65535,c=0,l=0,r.mode=Ci,t===Or)break e;case Ci:r.mode=ac;case ac:if(u=r.length,u){if(u>s&&(u=s),u>f&&(u=f),u===0)break e;Re(i,n,a,u,o),s-=u,a+=u,f-=u,o+=u,r.length-=u;break}r.mode=Pe;break;case oc:for(;l<14;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}if(r.nlen=(c&31)+257,c>>>=5,l-=5,r.ndist=(c&31)+1,c>>>=5,l-=5,r.ncode=(c&15)+4,c>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=j;break}r.have=0,r.mode=sc;case sc:for(;r.have<r.ncode;){for(;l<3;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}r.lens[q[r.have++]]=c&7,c>>>=3,l-=3}for(;r.have<19;)r.lens[q[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,k={bits:r.lenbits},S=Zt(Sd,r.lens,0,19,r.lencode,0,r.work,k),r.lenbits=k.bits,S){e.msg="invalid code lengths set",r.mode=j;break}r.have=0,r.mode=cc;case cc:for(;r.have<r.nlen+r.ndist;){for(;w=r.lencode[c&(1<<r.lenbits)-1],_=w>>>24,m=w>>>16&255,x=w&65535,!(_<=l);){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}if(x<16)c>>>=_,l-=_,r.lens[r.have++]=x;else{if(x===16){for(C=_+2;l<C;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}if(c>>>=_,l-=_,r.have===0){e.msg="invalid bit length repeat",r.mode=j;break}b=r.lens[r.have-1],u=3+(c&3),c>>>=2,l-=2}else if(x===17){for(C=_+3;l<C;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}c>>>=_,l-=_,b=0,u=3+(c&7),c>>>=3,l-=3}else{for(C=_+7;l<C;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}c>>>=_,l-=_,b=0,u=11+(c&127),c>>>=7,l-=7}if(r.have+u>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=j;break}for(;u--;)r.lens[r.have++]=b}}if(r.mode===j)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=j;break}if(r.lenbits=9,k={bits:r.lenbits},S=Zt(Zs,r.lens,0,r.nlen,r.lencode,0,r.work,k),r.lenbits=k.bits,S){e.msg="invalid literal/lengths set",r.mode=j;break}if(r.distbits=6,r.distcode=r.distdyn,k={bits:r.distbits},S=Zt(qs,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,k),r.distbits=k.bits,S){e.msg="invalid distances set",r.mode=j;break}if(r.mode=Pr,t===Or)break e;case Pr:r.mode=Ir;case Ir:if(s>=6&&f>=258){e.next_out=o,e.avail_out=f,e.next_in=a,e.avail_in=s,r.hold=c,r.bits=l,_d(e,h),o=e.next_out,i=e.output,f=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,c=r.hold,l=r.bits,r.mode===Pe&&(r.back=-1);break}for(r.back=0;w=r.lencode[c&(1<<r.lenbits)-1],_=w>>>24,m=w>>>16&255,x=w&65535,!(_<=l);){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}if(m&&(m&240)===0){for(v=_,A=m,O=x;w=r.lencode[O+((c&(1<<v+A)-1)>>v)],_=w>>>24,m=w>>>16&255,x=w&65535,!(v+_<=l);){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}c>>>=v,l-=v,r.back+=v}if(c>>>=_,l-=_,r.back+=_,r.length=x,m===0){r.mode=dc;break}if(m&32){r.back=-1,r.mode=Pe;break}if(m&64){e.msg="invalid literal/length code",r.mode=j;break}r.extra=m&15,r.mode=fc;case fc:if(r.extra){for(C=r.extra;l<C;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=lc;case lc:for(;w=r.distcode[c&(1<<r.distbits)-1],_=w>>>24,m=w>>>16&255,x=w&65535,!(_<=l);){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}if((m&240)===0){for(v=_,A=m,O=x;w=r.distcode[O+((c&(1<<v+A)-1)>>v)],_=w>>>24,m=w>>>16&255,x=w&65535,!(v+_<=l);){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}c>>>=v,l-=v,r.back+=v}if(c>>>=_,l-=_,r.back+=_,m&64){e.msg="invalid distance code",r.mode=j;break}r.offset=x,r.extra=m&15,r.mode=uc;case uc:if(r.extra){for(C=r.extra;l<C;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=j;break}r.mode=hc;case hc:if(f===0)break e;if(u=h-f,r.offset>u){if(u=r.offset-u,u>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=j;break}u>r.wnext?(u-=r.wnext,p=r.wsize-u):p=r.wnext-u,u>r.length&&(u=r.length),g=r.window}else g=i,p=o-r.offset,u=r.length;u>f&&(u=f),f-=u,r.length-=u;do i[o++]=g[p++];while(--u);r.length===0&&(r.mode=Ir);break;case dc:if(f===0)break e;i[o++]=r.length,f--,r.mode=Ir;break;case ji:if(r.wrap){for(;l<32;){if(s===0)break e;s--,c|=n[a++]<<l,l+=8}if(h-=f,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=r.flags?Z(r.check,i,h,o-h):Si(r.check,i,h,o-h)),h=f,(r.flags?c:gc(c))!==r.check){e.msg="incorrect data check",r.mode=j;break}c=0,l=0}r.mode=pc;case pc:if(r.wrap&&r.flags){for(;l<32;){if(s===0)break e;s--,c+=n[a++]<<l,l+=8}if(c!==(r.total&4294967295)){e.msg="incorrect length check",r.mode=j;break}c=0,l=0}r.mode=yc;case yc:S=kd;break e;case j:S=Od;break e;case Td:return Pd;case Dd:default:return ze}return e.next_out=o,e.avail_out=f,e.next_in=a,e.avail_in=s,r.hold=c,r.bits=l,(r.wsize||h!==e.avail_out&&r.mode<j&&(r.mode<ji||t!==Hs))&&Bd(e,e.output,e.next_out,h-e.avail_out),d-=e.avail_in,h-=e.avail_out,e.total_in+=d,e.total_out+=h,r.total+=h,r.wrap&&h&&(e.adler=r.check=r.flags?Z(r.check,i,h,e.next_out-h):Si(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===Pe?128:0)+(r.mode===Pr||r.mode===Ci?256:0),(d===0&&h===0||t===Hs)&&S===qt&&(S=Id),S}function zd(e){if(!e||!e.state)return ze;var t=e.state;return t.window&&(t.window=null),e.state=null,qt}var Mi=0,St=1,Tr=2,Ht=3,Dr=4,At=5,Kt=6,Vt=7,_c=0,bc=1,mc=2,Ec=3,Li=4,xc=5,Zd=6,Cr=0,Sc=1,Ac=2,qd=-1,Hd=-2,Kd=-3,kc=-5,Vd=0,Wd=1,Gd=9,Yd=-1,Jd=1,Xd=2,Qd=3,ep=4,tp=0,rp=0,np=1,ip=2,Rc=8;function fe(e){if(e<St||e>Vt)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}fe.prototype.init=function(e,t,r,n,i){this.windowBits=e,this.level=t,this.memLevel=r,this.strategy=n,(this.mode===Ht||this.mode===Dr)&&(this.windowBits+=16),this.mode===Vt&&(this.windowBits+=32),(this.mode===At||this.mode===Kt)&&(this.windowBits=-this.windowBits),this.strm=new xh;var a;switch(this.mode){case St:case Ht:case At:a=yd(this.strm,this.level,Rc,this.windowBits,this.memLevel,this.strategy);break;case Tr:case Dr:case Kt:case Vt:a=Ld(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}if(a!==Cr){this._error(a);return}this.write_in_progress=!1,this.init_done=!0},fe.prototype.params=function(){throw new Error("deflateParams Not supported")},fe.prototype._writeCheck=function(){if(!this.init_done)throw new Error("write before init");if(this.mode===Mi)throw new Error("already finalized");if(this.write_in_progress)throw new Error("write already in progress");if(this.pending_close)throw new Error("close is pending")},fe.prototype.write=function(e,t,r,n,i,a,o){this._writeCheck(),this.write_in_progress=!0;var s=this;return Ae.nextTick(function(){s.write_in_progress=!1;var f=s._write(e,t,r,n,i,a,o);s.callback(f[0],f[1]),s.pending_close&&s.close()}),this};function ap(e,t){for(var r=0;r<e.length;r++)this[t+r]=e[r]}fe.prototype.writeSync=function(e,t,r,n,i,a,o){return this._writeCheck(),this._write(e,t,r,n,i,a,o)},fe.prototype._write=function(e,t,r,n,i,a,o){if(this.write_in_progress=!0,e!==_c&&e!==bc&&e!==mc&&e!==Ec&&e!==Li&&e!==xc)throw new Error("Invalid flush value");t==null&&(t=new y(0),n=0,r=0),i._set?i.set=i._set:i.set=ap;var s=this.strm;s.avail_in=n,s.input=t,s.next_in=r,s.avail_out=o,s.output=i,s.next_out=a;var f;switch(this.mode){case St:case Ht:case At:f=gd(s,e);break;case Vt:case Tr:case Dr:case Kt:f=Ud(s,e);break;default:throw new Error("Unknown mode "+this.mode)}return this._checkError(f,s,e)||this._error(f),this.write_in_progress=!1,[s.avail_in,s.avail_out]},fe.prototype._checkError=function(e,t,r){switch(e){case Cr:case kc:if(t.avail_out!==0&&r===Li)return!1;break;case Sc:break;case Ac:return!1;default:return!1}return!0},fe.prototype.close=function(){if(this.write_in_progress){this.pending_close=!0;return}this.pending_close=!1,this.mode===St||this.mode===Ht||this.mode===At?vd(this.strm):zd(this.strm),this.mode=Mi};var jr;fe.prototype.reset=function(){switch(this.mode){case St:case At:jr=Ls(this.strm);break;case Tr:case Kt:jr=vc(this.strm);break}jr!==Cr&&this._error(jr)},fe.prototype._error=function(e){this.onerror(us[e]+": "+this.strm.msg,e),this.write_in_progress=!1,this.pending_close&&this.close()};var Oc=Object.freeze({__proto__:null,DEFLATE:St,DEFLATERAW:At,GUNZIP:Dr,GZIP:Ht,INFLATE:Tr,INFLATERAW:Kt,NONE:Mi,UNZIP:Vt,Z_BEST_COMPRESSION:Gd,Z_BEST_SPEED:Wd,Z_BINARY:rp,Z_BLOCK:xc,Z_BUF_ERROR:kc,Z_DATA_ERROR:Kd,Z_DEFAULT_COMPRESSION:Yd,Z_DEFAULT_STRATEGY:tp,Z_DEFLATED:Rc,Z_ERRNO:qd,Z_FILTERED:Jd,Z_FINISH:Li,Z_FIXED:ep,Z_FULL_FLUSH:Ec,Z_HUFFMAN_ONLY:Xd,Z_NEED_DICT:Ac,Z_NO_COMPRESSION:Vd,Z_NO_FLUSH:_c,Z_OK:Cr,Z_PARTIAL_FLUSH:bc,Z_RLE:Qd,Z_STREAM_END:Sc,Z_STREAM_ERROR:Hd,Z_SYNC_FLUSH:mc,Z_TEXT:np,Z_TREES:Zd,Z_UNKNOWN:ip,Zlib:fe});function op(e,t){if(!e)throw new Error(t)}var E={};Object.keys(Oc).forEach(function(e){E[e]=Oc[e]}),E.Z_MIN_WINDOWBITS=8,E.Z_MAX_WINDOWBITS=15,E.Z_DEFAULT_WINDOWBITS=15,E.Z_MIN_CHUNK=64,E.Z_MAX_CHUNK=1/0,E.Z_DEFAULT_CHUNK=16*1024,E.Z_MIN_MEMLEVEL=1,E.Z_MAX_MEMLEVEL=9,E.Z_DEFAULT_MEMLEVEL=8,E.Z_MIN_LEVEL=-1,E.Z_MAX_LEVEL=9,E.Z_DEFAULT_LEVEL=E.Z_DEFAULT_COMPRESSION;var Wt={Z_OK:E.Z_OK,Z_STREAM_END:E.Z_STREAM_END,Z_NEED_DICT:E.Z_NEED_DICT,Z_ERRNO:E.Z_ERRNO,Z_STREAM_ERROR:E.Z_STREAM_ERROR,Z_DATA_ERROR:E.Z_DATA_ERROR,Z_MEM_ERROR:E.Z_MEM_ERROR,Z_BUF_ERROR:E.Z_BUF_ERROR,Z_VERSION_ERROR:E.Z_VERSION_ERROR};Object.keys(Wt).forEach(function(e){Wt[Wt[e]]=e});function sp(e){return new at(e)}function cp(e){return new ot(e)}function fp(e){return new ft(e)}function lp(e){return new lt(e)}function up(e){return new st(e)}function hp(e){return new ct(e)}function dp(e){return new ut(e)}function pp(e,t,r){return typeof t=="function"&&(r=t,t={}),nt(new at(t),e,r)}function yp(e,t){return it(new at(t),e)}function gp(e,t,r){return typeof t=="function"&&(r=t,t={}),nt(new st(t),e,r)}function vp(e,t){return it(new st(t),e)}function wp(e,t,r){return typeof t=="function"&&(r=t,t={}),nt(new ft(t),e,r)}function _p(e,t){return it(new ft(t),e)}function bp(e,t,r){return typeof t=="function"&&(r=t,t={}),nt(new ut(t),e,r)}function mp(e,t){return it(new ut(t),e)}function Ep(e,t,r){return typeof t=="function"&&(r=t,t={}),nt(new ot(t),e,r)}function xp(e,t){return it(new ot(t),e)}function Sp(e,t,r){return typeof t=="function"&&(r=t,t={}),nt(new ct(t),e,r)}function Ap(e,t){return it(new ct(t),e)}function kp(e,t,r){return typeof t=="function"&&(r=t,t={}),nt(new lt(t),e,r)}function Rp(e,t){return it(new lt(t),e)}function nt(e,t,r){var n=[],i=0;e.on("error",o),e.on("end",s),e.end(t),a();function a(){for(var f;(f=e.read())!==null;)n.push(f),i+=f.length;e.once("readable",a)}function o(f){e.removeListener("end",s),e.removeListener("readable",a),r(f)}function s(){var f=y.concat(n,i);n=[],r(null,f),e.close()}}function it(e,t){if(typeof t=="string"&&(t=new y(t)),!y.isBuffer(t))throw new TypeError("Not a string or buffer");var r=E.Z_FINISH;return e._processChunk(t,r)}function at(e){if(!(this instanceof at))return new at(e);F.call(this,e,E.DEFLATE)}function ot(e){if(!(this instanceof ot))return new ot(e);F.call(this,e,E.INFLATE)}function st(e){if(!(this instanceof st))return new st(e);F.call(this,e,E.GZIP)}function ct(e){if(!(this instanceof ct))return new ct(e);F.call(this,e,E.GUNZIP)}function ft(e){if(!(this instanceof ft))return new ft(e);F.call(this,e,E.DEFLATERAW)}function lt(e){if(!(this instanceof lt))return new lt(e);F.call(this,e,E.INFLATERAW)}function ut(e){if(!(this instanceof ut))return new ut(e);F.call(this,e,E.UNZIP)}function F(e,t){if(this._opts=e=e||{},this._chunkSize=e.chunkSize||E.Z_DEFAULT_CHUNK,ne.call(this,e),e.flush&&e.flush!==E.Z_NO_FLUSH&&e.flush!==E.Z_PARTIAL_FLUSH&&e.flush!==E.Z_SYNC_FLUSH&&e.flush!==E.Z_FULL_FLUSH&&e.flush!==E.Z_FINISH&&e.flush!==E.Z_BLOCK)throw new Error("Invalid flush flag: "+e.flush);if(this._flushFlag=e.flush||E.Z_NO_FLUSH,e.chunkSize&&(e.chunkSize<E.Z_MIN_CHUNK||e.chunkSize>E.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBits<E.Z_MIN_WINDOWBITS||e.windowBits>E.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.level<E.Z_MIN_LEVEL||e.level>E.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevel<E.Z_MIN_MEMLEVEL||e.memLevel>E.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=E.Z_FILTERED&&e.strategy!=E.Z_HUFFMAN_ONLY&&e.strategy!=E.Z_RLE&&e.strategy!=E.Z_FIXED&&e.strategy!=E.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!y.isBuffer(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new E.Zlib(t);var r=this;this._hadError=!1,this._binding.onerror=function(a,o){r._binding=null,r._hadError=!0;var s=new Error(a);s.errno=o,s.code=Wt[o],r.emit("error",s)};var n=E.Z_DEFAULT_COMPRESSION;typeof e.level=="number"&&(n=e.level);var i=E.Z_DEFAULT_STRATEGY;typeof e.strategy=="number"&&(i=e.strategy),this._binding.init(e.windowBits||E.Z_DEFAULT_WINDOWBITS,n,e.memLevel||E.Z_DEFAULT_MEMLEVEL,i,e.dictionary),this._buffer=new y(this._chunkSize),this._offset=0,this._closed=!1,this._level=n,this._strategy=i,this.once("end",this.close)}W(F,ne),F.prototype.params=function(e,t,r){if(e<E.Z_MIN_LEVEL||e>E.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(t!=E.Z_FILTERED&&t!=E.Z_HUFFMAN_ONLY&&t!=E.Z_RLE&&t!=E.Z_FIXED&&t!=E.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+t);if(this._level!==e||this._strategy!==t){var n=this;this.flush(E.Z_SYNC_FLUSH,function(){n._binding.params(e,t),n._hadError||(n._level=e,n._strategy=t,r&&r())})}else Ae.nextTick(r)},F.prototype.reset=function(){return this._binding.reset()},F.prototype._flush=function(e){this._transform(new y(0),"",e)},F.prototype.flush=function(e,t){var r=this._writableState;if((typeof e=="function"||e===void 0&&!t)&&(t=e,e=E.Z_FULL_FLUSH),r.ended)t&&Ae.nextTick(t);else if(r.ending)t&&this.once("end",t);else if(r.needDrain){var n=this;this.once("drain",function(){n.flush(t)})}else this._flushFlag=e,this.write(new y(0),"",t)},F.prototype.close=function(e){if(e&&Ae.nextTick(e),!this._closed){this._closed=!0,this._binding.close();var t=this;Ae.nextTick(function(){t.emit("close")})}},F.prototype._transform=function(e,t,r){var n,i=this._writableState,a=i.ending||i.ended,o=a&&(!e||i.length===e.length);if(!e===null&&!y.isBuffer(e))return r(new Error("invalid input"));o?n=E.Z_FINISH:(n=this._flushFlag,e.length>=i.length&&(this._flushFlag=this._opts.flush||E.Z_NO_FLUSH)),this._processChunk(e,n,r)},F.prototype._processChunk=function(e,t,r){var n=e&&e.length,i=this._chunkSize-this._offset,a=0,o=this,s=typeof r=="function";if(!s){var f=[],c=0,l;this.on("error",function(g){l=g});do var d=this._binding.writeSync(t,e,a,n,this._buffer,this._offset,i);while(!this._hadError&&p(d[0],d[1]));if(this._hadError)throw l;var h=y.concat(f,c);return this.close(),h}var u=this._binding.write(t,e,a,n,this._buffer,this._offset,i);u.buffer=e,u.callback=p;function p(g,w){if(!o._hadError){var _=i-w;if(op(_>=0,"have should not go down"),_>0){var m=o._buffer.slice(o._offset,o._offset+_);o._offset+=_,s?o.push(m):(f.push(m),c+=m.length)}if((w===0||o._offset>=o._chunkSize)&&(i=o._chunkSize,o._offset=0,o._buffer=new y(o._chunkSize)),w===0){if(a+=n-g,n=g,!s)return!0;var x=o._binding.write(t,e,a,n,o._buffer,o._offset,o._chunkSize);x.callback=p,x.buffer=e;return}if(!s)return!1;r()}}},W(at,F),W(ot,F),W(st,F),W(ct,F),W(ft,F),W(lt,F),W(ut,F);var Pc={codes:Wt,createDeflate:sp,createInflate:cp,createDeflateRaw:fp,createInflateRaw:lp,createGzip:up,createGunzip:hp,createUnzip:dp,deflate:pp,deflateSync:yp,gzip:gp,gzipSync:vp,deflateRaw:wp,deflateRawSync:_p,unzip:bp,unzipSync:mp,inflate:Ep,inflateSync:xp,gunzip:Sp,gunzipSync:Ap,inflateRaw:kp,inflateRawSync:Rp,Deflate:at,Inflate:ot,Gzip:st,Gunzip:ct,DeflateRaw:ft,InflateRaw:lt,Unzip:ut,Zlib:F};class Ic extends di{constructor({client:t,keyPrefix:r="cache",ttl:n=0,prefix:i=void 0}){super({client:t,keyPrefix:r,ttl:n,prefix:i}),this.client=t,this.keyPrefix=r,this.config.ttl=n,this.config.client=t,this.config.prefix=i!==void 0?i:r+(r.endsWith("/")?"":"/")}async _set(t,r){let n=JSON.stringify(r);const i=n.length;return n=Pc.gzipSync(n).toString("base64"),this.client.putObject({key:Ee(this.keyPrefix,t),body:n,contentEncoding:"gzip",contentType:"application/gzip",metadata:{compressor:"zlib",compressed:"true","client-id":this.client.id,"length-serialized":String(i),"length-compressed":String(n.length),"compression-gain":(n.length/i).toFixed(2)}})}async _get(t){try{const{Body:r}=await this.client.getObject(Ee(this.keyPrefix,t));let n=await gt(r);return n=Buffer.from(n,"base64"),n=Pc.unzipSync(n).toString(),JSON.parse(n)}catch(r){if(r.name==="NoSuchKey"||r.name==="NotFound")return null;throw r}}async _del(t){return await this.client.deleteObject(Ee(this.keyPrefix,t)),!0}async _clear(){const t=await this.client.getAllKeys({prefix:this.keyPrefix});for(const r of t)await this.client.deleteObject(r)}async size(){return(await this.keys()).length}async keys(){const t=await this.client.getAllKeys({prefix:this.keyPrefix}),r=this.keyPrefix.endsWith("/")?this.keyPrefix:this.keyPrefix+"/";return t.map(n=>n.startsWith(r)?n.slice(r.length):n)}}class Tc extends R{async setup(t){}async start(){}async stop(){}beforeSetup(){this.emit("plugin.beforeSetup",new Date)}afterSetup(){this.emit("plugin.afterSetup",new Date)}beforeStart(){this.emit("plugin.beforeStart",new Date)}afterStart(){this.emit("plugin.afterStart",new Date)}beforeStop(){this.emit("plugin.beforeStop",new Date)}afterStop(){this.emit("plugin.afterStop",new Date)}}const Op={setup(e){},start(){},stop(){}},Pp={async setup(e){this.client=e.client,this.map={PutObjectCommand:"put",GetObjectCommand:"get",HeadObjectCommand:"get",DeleteObjectCommand:"delete",DeleteObjectsCommand:"delete",ListObjectsV2Command:"list"},this.costs={total:0,prices:{put:.005/1e3,copy:.005/1e3,list:.005/1e3,post:.005/1e3,get:4e-4/1e3,select:4e-4/1e3,delete:4e-4/1e3},requests:{total:0,put:0,post:0,copy:0,list:0,get:0,select:0,delete:0},events:{total:0,PutObjectCommand:0,GetObjectCommand:0,HeadObjectCommand:0,DeleteObjectCommand:0,DeleteObjectsCommand:0,ListObjectsV2Command:0}},this.client.costs=JSON.parse(JSON.stringify(this.costs))},async start(){this.client.on("command.response",e=>this.addRequest(e,this.map[e]))},addRequest(e,t){this.costs.events[e]++,this.costs.events.total++,this.costs.requests.total++,this.costs.requests[t]++,this.costs.total+=this.costs.prices[t],this.client.costs.events[e]++,this.client.costs.events.total++,this.client.costs.requests.total++,this.client.costs.requests[t]++,this.client.costs.total+=this.client.costs.prices[t]}};class Ip extends Tc{constructor(t={}){super(),this.driver=t.driver}async setup(t){this.database=t,this.driver||(this.driver=new Ic({keyPrefix:"cache",client:t.client})),this.installDatabaseProxy();for(const r of Object.values(t.resources))this.installResourcesProxies(r)}async start(){}async stop(){}installDatabaseProxy(){const t=this.installResourcesProxies.bind(this);this.database._createResource=this.database.createResource,this.database.createResource=async function(...r){const n=await this._createResource(...r);return t(n),n}}installResourcesProxies(t){t.cache=this.driver;let r=`resource=${t.name}`;this.driver.keyPrefix&&(this.driver.keyPrefix=Ee(this.driver.keyPrefix,r)),t.cacheKeyFor=async function({params:n={},action:i="list"}){let a=Object.keys(n).sort().map(o=>`${o}:${n[o]}`).join("|")||"empty";return a=await oa(a),a=Ee(r,`action=${i}`,`${a}.json.gz`),a},t._count=t.count,t._listIds=t.listIds,t._getMany=t.getMany,t._getAll=t.getAll,t._page=t.page,t.count=async function(){const n=await this.cacheKeyFor({action:"count"});try{const a=await this.cache.get(n);if(a)return a}catch(a){if(a.name!=="NoSuchKey")throw a}const i=await t._count();return await this.cache.set(n,i),i},t.listIds=async function(){const n=await this.cacheKeyFor({action:"listIds"});try{const a=await this.cache.get(n);if(a)return a}catch(a){if(a.name!=="NoSuchKey")throw a}const i=await t._listIds();return await this.cache.set(n,i),i},t.getMany=async function(n){const i=await this.cacheKeyFor({action:"getMany",params:{ids:n}});try{const o=await this.cache.get(i);if(o)return o}catch(o){if(o.name!=="NoSuchKey")throw o}const a=await t._getMany(n);return await this.cache.set(i,a),a},t.getAll=async function(){const n=await this.cacheKeyFor({action:"getAll"});try{const a=await this.cache.get(n);if(a)return a}catch(a){if(a.name!=="NoSuchKey")throw a}const i=await t._getAll();return await this.cache.set(n,i),i},t.page=async function({offset:n,size:i}){const a=await this.cacheKeyFor({action:"page",params:{offset:n,size:i}});try{const s=await this.cache.get(a);if(s)return s}catch(s){if(s.name!=="NoSuchKey")throw s}const o=await t._page({offset:n,size:i});return await this.cache.set(a,o),o},t._insert=t.insert,t._update=t.update,t._delete=t.delete,t._deleteMany=t.deleteMany,t.insert=async function(...n){const i=await t._insert(...n);return await this.cache.clear(r),i},t.update=async function(...n){const i=await t._update(...n);return await this.cache.clear(r),i},t.delete=async function(...n){const i=await t._delete(...n);return await this.cache.clear(r),i},t.deleteMany=async function(...n){const i=await t._deleteMany(...n);return await this.cache.clear(r),i}}}exports.AuthenticationError=df,exports.BaseError=Yi,exports.Cache=di,exports.CachePlugin=Ip,exports.Client=aa,exports.ConnectionString=zr,exports.CostsPlugin=Pp,exports.Database=ls,exports.DatabaseError=uf,exports.EncryptionError=yf,exports.ErrorMap=ra,exports.InvalidResourceItem=rr,exports.MemoryCache=Eh,exports.MissingMetadata=ea,exports.NoSuchBucket=Xi,exports.NoSuchKey=Ur,exports.NotFound=Qi,exports.PermissionError=pf,exports.Plugin=Tc,exports.PluginObject=Op,exports.ResourceIdsPageReader=ns,exports.ResourceIdsReader=rs,exports.ResourceNotFound=Ji,exports.ResourceNotFoundError=Ji,exports.ResourceReader=is,exports.ResourceWriter=as,exports.S3Cache=Ic,exports.S3DB=hi,exports.S3DBError=te,exports.S3_DEFAULT_ENDPOINT=ia,exports.S3_DEFAULT_REGION=na,exports.S3db=hi,exports.S3dbError=te,exports.UnknownError=ta,exports.ValidationError=hf,exports.Validator=uo,exports.ValidatorManager=ho,exports.decrypt=sa,exports.default=hi,exports.encrypt=Zr,exports.sha256=oa,exports.streamToString=gt;
|